use of org.eclipse.winery.repository.rest.resources._support.CreateFromArtifactApiData in project winery by eclipse.
the class ServiceTemplatesResource method getCreateFromArtifactData.
@GET
@Path("createfromartifact")
@Produces(MediaType.APPLICATION_JSON)
public CreateFromArtifactApiData getCreateFromArtifactData() {
Set<QName> artifactTypes = new HashSet<QName>();
Set<QName> infrastructureNodeTypes = new HashSet<QName>();
Collection<AbstractComponentInstanceResource> templates = this.getAll();
for (AbstractComponentInstanceResource resource : templates) {
if (resource instanceof ServiceTemplateResource) {
ServiceTemplateResource stRes = (ServiceTemplateResource) resource;
if (stRes.getServiceTemplate().getTags() != null) {
int check = 0;
QName artifactType = null;
for (TTag tag : stRes.getServiceTemplate().getTags().getTag()) {
switch(tag.getName()) {
case "xaasPackageNode":
check++;
break;
case "xaasPackageArtifactType":
check++;
artifactType = QName.valueOf(tag.getValue());
break;
case "xaasPackageDeploymentArtifact":
check++;
break;
case "xaasPackageInfrastructure":
// optional tag, hence no check++
infrastructureNodeTypes.add(QName.valueOf(tag.getValue()));
default:
break;
}
}
if (check == 3) {
artifactTypes.add(artifactType);
}
}
}
}
return new CreateFromArtifactApiData(artifactTypes, infrastructureNodeTypes);
}
Aggregations