Search in sources :

Example 1 with StackDetailsJson

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

the class ImagesToImagesResponseJsonConverter method getDefaultStackInfos.

private List<StackDetailsJson> getDefaultStackInfos(Iterable<? extends StackInfo> defaultStackInfos) {
    List<StackDetailsJson> result = new ArrayList<>();
    for (StackInfo info : defaultStackInfos) {
        StackDetailsJson json = new StackDetailsJson();
        StackRepoDetailsJson repoJson = new StackRepoDetailsJson();
        Map<String, String> stackRepo = info.getRepo().getStack();
        if (stackRepo != null) {
            repoJson.setStack(stackRepo);
        }
        Map<String, String> utilRepo = info.getRepo().getUtil();
        if (utilRepo != null) {
            repoJson.setUtil(utilRepo);
        }
        Map<String, String> knoxRepo = info.getRepo().getKnox();
        if (knoxRepo != null) {
            repoJson.setKnox(knoxRepo);
        }
        json.setRepo(repoJson);
        json.setVersion(info.getVersion());
        result.add(json);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson) StackInfo(com.sequenceiq.cloudbreak.cloud.model.component.StackInfo) StackRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackRepoDetailsJson)

Example 2 with StackDetailsJson

use of com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson 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 3 with StackDetailsJson

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

the class ImagesToImagesResponseJsonConverter method convertStackDetailsToJson.

private StackDetailsJson convertStackDetailsToJson(StackDetails stackDetails) {
    StackDetailsJson json = new StackDetailsJson();
    json.setVersion(stackDetails.getVersion());
    json.setRepo(convertStackRepoDetailsToJson(stackDetails.getRepo()));
    return json;
}
Also used : StackDetailsJson(com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson)

Aggregations

StackDetailsJson (com.sequenceiq.cloudbreak.api.model.imagecatalog.StackDetailsJson)3 StackRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.imagecatalog.StackRepoDetailsJson)2 StackInfo (com.sequenceiq.cloudbreak.cloud.model.component.StackInfo)2 ArrayList (java.util.ArrayList)2 BaseImageResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.BaseImageResponse)1 ImageResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.ImageResponse)1 ImagesResponse (com.sequenceiq.cloudbreak.api.model.imagecatalog.ImagesResponse)1 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)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 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