Search in sources :

Example 1 with NewVersionListElement

use of org.eclipse.winery.repository.rest.resources.apiData.NewVersionListElement in project winery by eclipse.

the class TopologyTemplateResource method getNewVersionList.

@GET
@Path("newversions")
@Produces(MediaType.APPLICATION_JSON)
public List<NewVersionListElement> getNewVersionList() {
    IRepository repository = RepositoryFactory.getRepository();
    Map<QName, TNodeType> nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);
    Map<QName, List<WineryVersion>> versionElements = new HashMap<>();
    for (TNodeTemplate node : this.topologyTemplate.getNodeTemplates()) {
        if (nodeTypes.containsKey(node.getType())) {
            NodeTypeId nodeTypeId = new NodeTypeId(node.getType());
            if (!versionElements.containsKey(nodeTypeId.getQName())) {
                List<WineryVersion> versionList = WineryVersionUtils.getAllVersionsOfOneDefinition(nodeTypeId, repository).stream().filter(wineryVersion -> {
                    QName qName = VersionSupport.getDefinitionInTheGivenVersion(nodeTypeId, wineryVersion).getQName();
                    NamespaceProperties namespaceProperties = repository.getNamespaceManager().getNamespaceProperties(qName.getNamespaceURI());
                    return !(namespaceProperties.isGeneratedNamespace() || ModelUtilities.isFeatureType(qName, nodeTypes));
                }).collect(Collectors.toList());
                versionElements.put(nodeTypeId.getQName(), versionList);
            }
        }
    }
    return versionElements.entrySet().stream().map(qNameListEntry -> new NewVersionListElement(qNameListEntry.getKey(), qNameListEntry.getValue())).collect(Collectors.toList());
}
Also used : UpdateInfo(org.eclipse.winery.repository.rest.resources.apiData.UpdateInfo) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) NamespaceProperties(org.eclipse.winery.repository.backend.filebased.NamespaceProperties) AvailableFeaturesApiData(org.eclipse.winery.repository.rest.resources.apiData.AvailableFeaturesApiData) EncodingUtil(org.eclipse.winery.model.ids.EncodingUtil) WineryVersion(org.eclipse.winery.common.version.WineryVersion) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) InvalidParameterException(java.security.InvalidParameterException) Consumes(javax.ws.rs.Consumes) SolutionStrategy(org.eclipse.winery.model.adaptation.problemsolving.SolutionStrategy) VersionSupport(org.eclipse.winery.model.version.VersionSupport) Map(java.util.Map) PlacementUtils(org.eclipse.winery.model.adaptation.placement.PlacementUtils) URI(java.net.URI) TEntityType(org.eclipse.winery.model.tosca.TEntityType) WineryVersionUtils(org.eclipse.winery.repository.backend.WineryVersionUtils) Context(javax.ws.rs.core.Context) SolutionInputData(org.eclipse.winery.model.adaptation.problemsolving.SolutionInputData) TopologyAndErrorList(org.eclipse.winery.model.adaptation.enhance.TopologyAndErrorList) Allocation(org.eclipse.winery.repository.targetallocation.Allocation) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) RepositoryFactory(org.eclipse.winery.repository.backend.RepositoryFactory) CompositionData(org.eclipse.winery.repository.rest.resources._support.dataadapter.composeadapter.CompositionData) NewVersionListElement(org.eclipse.winery.repository.rest.resources.apiData.NewVersionListElement) Objects(java.util.Objects) List(java.util.List) PropertyDefinitionKV(org.eclipse.winery.model.tosca.extensions.kvproperties.PropertyDefinitionKV) Response(javax.ws.rs.core.Response) IRepository(org.eclipse.winery.repository.backend.IRepository) Optional(java.util.Optional) RestUtils(org.eclipse.winery.repository.rest.RestUtils) UriInfo(javax.ws.rs.core.UriInfo) QName(javax.xml.namespace.QName) AllocationRequest(org.eclipse.winery.repository.targetallocation.util.AllocationRequest) AbstractComponentInstanceResourceContainingATopology(org.eclipse.winery.repository.rest.resources._support.AbstractComponentInstanceResourceContainingATopology) GET(javax.ws.rs.GET) Splitting(org.eclipse.winery.repository.splitting.Splitting) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) HashMap(java.util.HashMap) EnhancementUtils(org.eclipse.winery.model.adaptation.enhance.EnhancementUtils) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BackendUtils(org.eclipse.winery.repository.backend.BackendUtils) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) POST(javax.ws.rs.POST) Logger(org.slf4j.Logger) Environments(org.eclipse.winery.common.configuration.Environments) HasTags(org.eclipse.winery.model.tosca.HasTags) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) DeploymentTechnologyDescriptor(org.eclipse.winery.model.tosca.DeploymentTechnologyDescriptor) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) PropertyDiffList(org.eclipse.winery.repository.rest.resources.apiData.PropertyDiffList) PUT(javax.ws.rs.PUT) ModelUtilities(org.eclipse.winery.model.tosca.utils.ModelUtilities) Collections(java.util.Collections) SolutionFactory(org.eclipse.winery.model.adaptation.problemsolving.SolutionFactory) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) QName(javax.xml.namespace.QName) TNodeType(org.eclipse.winery.model.tosca.TNodeType) NewVersionListElement(org.eclipse.winery.repository.rest.resources.apiData.NewVersionListElement) NamespaceProperties(org.eclipse.winery.repository.backend.filebased.NamespaceProperties) TopologyAndErrorList(org.eclipse.winery.model.adaptation.enhance.TopologyAndErrorList) List(java.util.List) ArrayList(java.util.ArrayList) PropertyDiffList(org.eclipse.winery.repository.rest.resources.apiData.PropertyDiffList) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) IRepository(org.eclipse.winery.repository.backend.IRepository) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 IOException (java.io.IOException)1 URI (java.net.URI)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1