Search in sources :

Example 1 with HasTags

use of org.eclipse.winery.model.tosca.HasTags in project winery by eclipse.

the class TopologyTemplateResource method getAvailableFeatures.

@GET
@Path("availablefeatures")
@Produces(MediaType.APPLICATION_JSON)
public ArrayList<AvailableFeaturesApiData> getAvailableFeatures() {
    ArrayList<AvailableFeaturesApiData> apiData = new ArrayList<>();
    List<DeploymentTechnologyDescriptor> deploymentTechnologies = Collections.emptyList();
    if (this.parent.getElement() instanceof HasTags && ((HasTags) this.parent.getElement()).getTags() != null) {
        ObjectMapper objectMapper = new ObjectMapper();
        deploymentTechnologies = ModelUtilities.extractDeploymentTechnologiesFromTags(((HasTags) this.parent.getElement()).getTags(), objectMapper);
    }
    EnhancementUtils.getAvailableFeaturesForTopology(this.topologyTemplate, deploymentTechnologies).forEach((nodeTemplateId, featuresMap) -> {
        ArrayList<AvailableFeaturesApiData.Features> features = new ArrayList<>();
        featuresMap.forEach((featureType, featureName) -> features.add(new AvailableFeaturesApiData.Features(featureType, featureName)));
        apiData.add(new AvailableFeaturesApiData(nodeTemplateId, features));
    });
    return apiData;
}
Also used : AvailableFeaturesApiData(org.eclipse.winery.repository.rest.resources.apiData.AvailableFeaturesApiData) HasTags(org.eclipse.winery.model.tosca.HasTags) DeploymentTechnologyDescriptor(org.eclipse.winery.model.tosca.DeploymentTechnologyDescriptor) ArrayList(java.util.ArrayList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DeploymentTechnologyDescriptor (org.eclipse.winery.model.tosca.DeploymentTechnologyDescriptor)1 HasTags (org.eclipse.winery.model.tosca.HasTags)1 AvailableFeaturesApiData (org.eclipse.winery.repository.rest.resources.apiData.AvailableFeaturesApiData)1