Search in sources :

Example 1 with BaseDtoUserInfoEnrichedAdapter

use of com.ctrip.framework.apollo.portal.enricher.adapter.BaseDtoUserInfoEnrichedAdapter in project apollo by ctripcorp.

the class NamespaceService method transformNamespace2BO.

private NamespaceBO transformNamespace2BO(Env env, NamespaceDTO namespace) {
    NamespaceBO namespaceBO = new NamespaceBO();
    namespaceBO.setBaseInfo(namespace);
    String appId = namespace.getAppId();
    String clusterName = namespace.getClusterName();
    String namespaceName = namespace.getNamespaceName();
    fillAppNamespaceProperties(namespaceBO);
    List<ItemBO> itemBOs = new LinkedList<>();
    namespaceBO.setItems(itemBOs);
    // latest Release
    ReleaseDTO latestRelease;
    Map<String, String> releaseItems = new HashMap<>();
    Map<String, ItemDTO> deletedItemDTOs = new HashMap<>();
    latestRelease = releaseService.loadLatestRelease(appId, env, clusterName, namespaceName);
    if (latestRelease != null) {
        releaseItems = GSON.fromJson(latestRelease.getConfigurations(), GsonType.CONFIG);
    }
    // not Release config items
    List<ItemDTO> items = itemService.findItems(appId, env, clusterName, namespaceName);
    additionalUserInfoEnrichService.enrichAdditionalUserInfo(items, BaseDtoUserInfoEnrichedAdapter::new);
    int modifiedItemCnt = 0;
    for (ItemDTO itemDTO : items) {
        ItemBO itemBO = transformItem2BO(itemDTO, releaseItems);
        if (itemBO.isModified()) {
            modifiedItemCnt++;
        }
        itemBOs.add(itemBO);
    }
    // deleted items
    itemService.findDeletedItems(appId, env, clusterName, namespaceName).forEach(item -> {
        deletedItemDTOs.put(item.getKey(), item);
    });
    List<ItemBO> deletedItems = parseDeletedItems(items, releaseItems, deletedItemDTOs);
    itemBOs.addAll(deletedItems);
    modifiedItemCnt += deletedItems.size();
    namespaceBO.setItemModifiedCnt(modifiedItemCnt);
    return namespaceBO;
}
Also used : BaseDtoUserInfoEnrichedAdapter(com.ctrip.framework.apollo.portal.enricher.adapter.BaseDtoUserInfoEnrichedAdapter) ItemBO(com.ctrip.framework.apollo.portal.entity.bo.ItemBO) NamespaceBO(com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList) ItemDTO(com.ctrip.framework.apollo.common.dto.ItemDTO) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO)

Example 2 with BaseDtoUserInfoEnrichedAdapter

use of com.ctrip.framework.apollo.portal.enricher.adapter.BaseDtoUserInfoEnrichedAdapter in project apollo by ctripcorp.

the class ReleaseHistoryService method transformReleaseHistoryDTO2BO.

private List<ReleaseHistoryBO> transformReleaseHistoryDTO2BO(List<ReleaseHistoryDTO> source, List<ReleaseDTO> releases) {
    if (CollectionUtils.isEmpty(source)) {
        return Collections.emptyList();
    }
    this.additionalUserInfoEnrichService.enrichAdditionalUserInfo(source, BaseDtoUserInfoEnrichedAdapter::new);
    Map<Long, ReleaseDTO> releasesMap = BeanUtils.mapByKey("id", releases);
    List<ReleaseHistoryBO> bos = new ArrayList<>(source.size());
    for (ReleaseHistoryDTO dto : source) {
        ReleaseDTO release = releasesMap.get(dto.getReleaseId());
        bos.add(transformReleaseHistoryDTO2BO(dto, release));
    }
    return bos;
}
Also used : BaseDtoUserInfoEnrichedAdapter(com.ctrip.framework.apollo.portal.enricher.adapter.BaseDtoUserInfoEnrichedAdapter) ReleaseHistoryDTO(com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO) ReleaseHistoryBO(com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO) ArrayList(java.util.ArrayList) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO)

Aggregations

ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)2 BaseDtoUserInfoEnrichedAdapter (com.ctrip.framework.apollo.portal.enricher.adapter.BaseDtoUserInfoEnrichedAdapter)2 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)1 ReleaseHistoryDTO (com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO)1 ItemBO (com.ctrip.framework.apollo.portal.entity.bo.ItemBO)1 NamespaceBO (com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO)1 ReleaseHistoryBO (com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1