Search in sources :

Example 1 with ReleaseBO

use of com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO in project apollo by ctripcorp.

the class ReleaseService method findAllReleases.

public List<ReleaseBO> findAllReleases(String appId, Env env, String clusterName, String namespaceName, int page, int size) {
    List<ReleaseDTO> releaseDTOs = releaseAPI.findAllReleases(appId, env, clusterName, namespaceName, page, size);
    if (CollectionUtils.isEmpty(releaseDTOs)) {
        return Collections.emptyList();
    }
    List<ReleaseBO> releases = new LinkedList<>();
    for (ReleaseDTO releaseDTO : releaseDTOs) {
        ReleaseBO release = new ReleaseBO();
        release.setBaseInfo(releaseDTO);
        Set<KVEntity> kvEntities = new LinkedHashSet<>();
        Map<String, String> configurations = gson.fromJson(releaseDTO.getConfigurations(), GsonType.CONFIG);
        Set<Map.Entry<String, String>> entries = configurations.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            kvEntities.add(new KVEntity(entry.getKey(), entry.getValue()));
        }
        release.setItems(kvEntities);
        // 为了减少数据量
        releaseDTO.setConfigurations("");
        releases.add(release);
    }
    return releases;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) LinkedList(java.util.LinkedList) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO) KVEntity(com.ctrip.framework.apollo.portal.entity.bo.KVEntity) ReleaseBO(com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)1 KVEntity (com.ctrip.framework.apollo.portal.entity.bo.KVEntity)1 ReleaseBO (com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1