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());
}
Aggregations