Search in sources :

Example 1 with DeploymentSourceType

use of alien4cloud.model.deployment.DeploymentSourceType in project alien4cloud by alien4cloud.

the class DeploymentController method buildDeploymentsDTOS.

private List<DeploymentDTO> buildDeploymentsDTOS(boolean includeSourceSummary, Deployment... deployments) {
    List<DeploymentDTO> dtos = Lists.newArrayList();
    if (ArrayUtils.isEmpty(deployments)) {
        return dtos;
    }
    Map<String, ? extends IDeploymentSource> sources = Maps.newHashMap();
    // get the app summaries if true
    if (includeSourceSummary) {
        DeploymentSourceType sourceType = deployments[0].getSourceType();
        String[] sourceIds = getSourceIdsFromDeployments(deployments);
        if (sourceIds[0] != null) {
            // can have no application deployed
            switch(sourceType) {
                case APPLICATION:
                    Map<String, ? extends IDeploymentSource> appSources = applicationService.findByIdsIfAuthorized(FetchContext.SUMMARY, sourceIds);
                    if (appSources != null) {
                        sources = appSources;
                    }
            }
        }
    }
    Map<String, Location> locationsSummariesMap = getRelatedLocationsSummaries(deployments);
    for (Object object : deployments) {
        Deployment deployment = (Deployment) object;
        IDeploymentSource source = sources.get(deployment.getSourceId());
        if (source == null) {
            source = new DeploymentSourceDTO(deployment.getSourceId(), deployment.getSourceName());
        }
        List<Location> locationsSummaries = getLocations(deployment.getLocationIds(), locationsSummariesMap);
        DeploymentDTO dto = new DeploymentDTO(deployment, source, locationsSummaries);
        dtos.add(dto);
    }
    return dtos;
}
Also used : Deployment(alien4cloud.model.deployment.Deployment) DeploymentSourceType(alien4cloud.model.deployment.DeploymentSourceType) IDeploymentSource(alien4cloud.model.deployment.IDeploymentSource) Location(alien4cloud.model.orchestrators.locations.Location)

Aggregations

Deployment (alien4cloud.model.deployment.Deployment)1 DeploymentSourceType (alien4cloud.model.deployment.DeploymentSourceType)1 IDeploymentSource (alien4cloud.model.deployment.IDeploymentSource)1 Location (alien4cloud.model.orchestrators.locations.Location)1