Search in sources :

Example 1 with DiskResponse

use of com.sequenceiq.cloudbreak.api.model.DiskResponse in project cloudbreak by hortonworks.

the class PlatformRecommendationToPlatformRecommendationResponseConverter method convert.

@Override
public RecommendationResponse convert(PlatformRecommendation source) {
    Map<String, VmTypeJson> result = new HashMap<>();
    source.getRecommendations().forEach((hostGroupName, vm) -> result.put(hostGroupName, getConversionService().convert(vm, VmTypeJson.class)));
    Set<VmTypeJson> vmTypes = source.getVirtualMachines().stream().map(vmType -> getConversionService().convert(vmType, VmTypeJson.class)).collect(Collectors.toSet());
    Set<DiskResponse> diskResponses = new HashSet<>();
    for (Entry<DiskType, DisplayName> diskTypeDisplayName : source.getDiskTypes().displayNames().entrySet()) {
        for (Entry<String, VolumeParameterType> volumeParameterType : source.getDiskTypes().diskMapping().entrySet()) {
            if (diskTypeDisplayName.getKey().value().equals(volumeParameterType.getKey())) {
                DiskResponse diskResponse = new DiskResponse(diskTypeDisplayName.getKey().value(), volumeParameterType.getValue().name(), diskTypeDisplayName.getValue().value());
                diskResponses.add(diskResponse);
            }
        }
    }
    return new RecommendationResponse(result, vmTypes, diskResponses);
}
Also used : DisplayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName) PlatformRecommendation(com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) Set(java.util.Set) HashMap(java.util.HashMap) RecommendationResponse(com.sequenceiq.cloudbreak.api.model.RecommendationResponse) Collectors(java.util.stream.Collectors) DiskResponse(com.sequenceiq.cloudbreak.api.model.DiskResponse) HashSet(java.util.HashSet) Component(org.springframework.stereotype.Component) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) Map(java.util.Map) Entry(java.util.Map.Entry) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) HashMap(java.util.HashMap) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) RecommendationResponse(com.sequenceiq.cloudbreak.api.model.RecommendationResponse) DiskResponse(com.sequenceiq.cloudbreak.api.model.DiskResponse) DisplayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName) HashSet(java.util.HashSet)

Aggregations

DiskResponse (com.sequenceiq.cloudbreak.api.model.DiskResponse)1 RecommendationResponse (com.sequenceiq.cloudbreak.api.model.RecommendationResponse)1 VmTypeJson (com.sequenceiq.cloudbreak.api.model.VmTypeJson)1 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)1 DisplayName (com.sequenceiq.cloudbreak.cloud.model.DisplayName)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 VolumeParameterType (com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Component (org.springframework.stereotype.Component)1