Search in sources :

Example 1 with ReleaseHistoryDTO

use of com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO in project apollo by ctripcorp.

the class ReleaseHistoryController method transformReleaseHistory2DTO.

private ReleaseHistoryDTO transformReleaseHistory2DTO(ReleaseHistory releaseHistory) {
    ReleaseHistoryDTO dto = new ReleaseHistoryDTO();
    BeanUtils.copyProperties(releaseHistory, dto, "operationContext");
    dto.setOperationContext(gson.fromJson(releaseHistory.getOperationContext(), configurationTypeReference));
    return dto;
}
Also used : ReleaseHistoryDTO(com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO)

Example 2 with ReleaseHistoryDTO

use of com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO in project apollo by ctripcorp.

the class ReleaseHistoryService method findLatestByPreviousReleaseIdAndOperation.

public ReleaseHistoryBO findLatestByPreviousReleaseIdAndOperation(Env env, long previousReleaseId, int operation) {
    PageDTO<ReleaseHistoryDTO> pageDTO = releaseHistoryAPI.findByPreviousReleaseIdAndOperation(env, previousReleaseId, operation, 0, 1);
    if (pageDTO != null && pageDTO.hasContent()) {
        ReleaseHistoryDTO releaseHistory = pageDTO.getContent().get(0);
        ReleaseDTO release = releaseService.findReleaseById(env, releaseHistory.getReleaseId());
        return transformReleaseHistoryDTO2BO(releaseHistory, release);
    }
    return null;
}
Also used : ReleaseHistoryDTO(com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO)

Example 3 with ReleaseHistoryDTO

use of com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO in project apollo by ctripcorp.

the class ReleaseHistoryService method transformReleaseHistoryDTO2BO.

private List<ReleaseHistoryBO> transformReleaseHistoryDTO2BO(List<ReleaseHistoryDTO> source, List<ReleaseDTO> releases) {
    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 : 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)

Example 4 with ReleaseHistoryDTO

use of com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO in project apollo by ctripcorp.

the class ReleaseHistoryService method findNamespaceReleaseHistory.

public List<ReleaseHistoryBO> findNamespaceReleaseHistory(String appId, Env env, String clusterName, String namespaceName, int page, int size) {
    PageDTO<ReleaseHistoryDTO> result = releaseHistoryAPI.findReleaseHistoriesByNamespace(appId, env, clusterName, namespaceName, page, size);
    if (result == null || !result.hasContent()) {
        return Collections.emptyList();
    }
    List<ReleaseHistoryDTO> content = result.getContent();
    Set<Long> releaseIds = new HashSet<>();
    for (ReleaseHistoryDTO releaseHistoryDTO : content) {
        long releaseId = releaseHistoryDTO.getReleaseId();
        if (releaseId != 0) {
            releaseIds.add(releaseId);
        }
    }
    List<ReleaseDTO> releases = releaseService.findReleaseByIds(env, releaseIds);
    return transformReleaseHistoryDTO2BO(content, releases);
}
Also used : ReleaseHistoryDTO(com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO) HashSet(java.util.HashSet)

Example 5 with ReleaseHistoryDTO

use of com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO in project apollo by ctripcorp.

the class ReleaseHistoryService method findLatestByReleaseIdAndOperation.

public ReleaseHistoryBO findLatestByReleaseIdAndOperation(Env env, long releaseId, int operation) {
    PageDTO<ReleaseHistoryDTO> pageDTO = releaseHistoryAPI.findByReleaseIdAndOperation(env, releaseId, operation, 0, 1);
    if (pageDTO != null && pageDTO.hasContent()) {
        ReleaseHistoryDTO releaseHistory = pageDTO.getContent().get(0);
        ReleaseDTO release = releaseService.findReleaseById(env, releaseHistory.getReleaseId());
        return transformReleaseHistoryDTO2BO(releaseHistory, release);
    }
    return null;
}
Also used : ReleaseHistoryDTO(com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO) ReleaseDTO(com.ctrip.framework.apollo.common.dto.ReleaseDTO)

Aggregations

ReleaseHistoryDTO (com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO)6 ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)4 ArrayList (java.util.ArrayList)2 ReleaseHistory (com.ctrip.framework.apollo.biz.entity.ReleaseHistory)1 PageDTO (com.ctrip.framework.apollo.common.dto.PageDTO)1 ReleaseHistoryBO (com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO)1 HashSet (java.util.HashSet)1