Search in sources :

Example 1 with BaseImageResponse

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

the class ImagesToImagesResponseJsonConverter method getBaseImageResponses.

private List<BaseImageResponse> getBaseImageResponses(Images source) {
    List<StackDetailsJson> defaultHdpStacks = getDefaultStackInfos(defaultHDPEntries.getEntries().values());
    List<StackDetailsJson> defaultHdfStacks = getDefaultStackInfos(defaultHDFEntries.getEntries().values());
    List<BaseImageResponse> baseImages = source.getBaseImages().stream().filter(i -> defaultAmbariRepoService.getDefault(i.getOsType()) != null).map(i -> {
        BaseImageResponse imgJson = new BaseImageResponse();
        copyImageFieldsToJson(i, imgJson);
        imgJson.setHdpStacks(defaultHdpStacks);
        imgJson.setHdfStacks(defaultHdfStacks);
        imgJson.setVersion(defaultAmbariRepoService.getVersion());
        AmbariRepo ambariRepo = defaultAmbariRepoService.getDefault(i.getOsType());
        Map<String, String> repoJson = new HashMap<>();
        repoJson.put("baseurl", ambariRepo.getBaseUrl());
        repoJson.put("gpgkey", ambariRepo.getGpgKeyUrl());
        imgJson.setRepo(repoJson);
        return imgJson;
    }).collect(Collectors.toList());
    return baseImages;
}
Also used : AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) DefaultHDFEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDFEntries) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackRepoDetails) HashMap(java.util.HashMap) StackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackDetails) Collectors(java.util.stream.Collectors) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ImagesResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImagesResponse) List(java.util.List) Component(org.springframework.stereotype.Component) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) StackRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackRepoDetailsJson) DefaultHDPEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDPEntries) ImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImageResponse) Map(java.util.Map) Images(com.sequenceiq.cloudbreak.cloud.model.catalog.Images) StackInfo(com.sequenceiq.cloudbreak.cloud.model.component.StackInfo) DefaultAmbariRepoService(com.sequenceiq.cloudbreak.service.DefaultAmbariRepoService) StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with BaseImageResponse

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

the class ImagesToImagesResponseJsonConverter method convert.

@Override
public ImagesResponse convert(Images source) {
    ImagesResponse res = new ImagesResponse();
    List<BaseImageResponse> baseImages = getBaseImageResponses(source);
    res.setBaseImages(baseImages);
    List<ImageResponse> hdpImages = new ArrayList<>();
    for (Image hdpImg : source.getHdpImages()) {
        ImageResponse hdpImgJson = new ImageResponse();
        copyImageFieldsToJson(hdpImg, hdpImgJson);
        hdpImgJson.setStackDetails(convertStackDetailsToJson(hdpImg.getStackDetails()));
        hdpImages.add(hdpImgJson);
    }
    res.setHdpImages(hdpImages);
    List<ImageResponse> hdfImages = new ArrayList<>();
    for (Image hdfImg : source.getHdfImages()) {
        ImageResponse hdfImgJson = new ImageResponse();
        copyImageFieldsToJson(hdfImg, hdfImgJson);
        hdfImgJson.setStackDetails(convertStackDetailsToJson(hdfImg.getStackDetails()));
        hdfImages.add(hdfImgJson);
    }
    res.setHdfImages(hdfImages);
    return res;
}
Also used : ArrayList(java.util.ArrayList) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) ImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImageResponse) BaseImageResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) ImagesResponse(com.sequenceiq.cloudbreak.api.model.imagecatalog.ImagesResponse)

Aggregations

BaseImageResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse)2 ImageResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.ImageResponse)2 ImagesResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.ImagesResponse)2 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)2 ArrayList (java.util.ArrayList)2 StackDetailsJson (com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson)1 StackRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.imagecatalog.StackRepoDetailsJson)1 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)1 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)1 StackDetails (com.sequenceiq.cloudbreak.cloud.model.catalog.StackDetails)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.catalog.StackRepoDetails)1 DefaultHDFEntries (com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDFEntries)1 DefaultHDPEntries (com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDPEntries)1 StackInfo (com.sequenceiq.cloudbreak.cloud.model.component.StackInfo)1 DefaultAmbariRepoService (com.sequenceiq.cloudbreak.service.DefaultAmbariRepoService)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1