use of org.eclipse.winery.model.tosca.TTag 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);
}
use of org.eclipse.winery.model.tosca.TTag in project winery by eclipse.
the class ServiceTemplatesResource method getXaaSPackageTemplates.
private Collection<ServiceTemplateId> getXaaSPackageTemplates() {
Collection<AbstractComponentInstanceResource> templates = this.getAll();
Collection<ServiceTemplateId> xaasPackages = new ArrayList<ServiceTemplateId>();
for (AbstractComponentInstanceResource resource : templates) {
if (resource instanceof ServiceTemplateResource) {
ServiceTemplateResource stRes = (ServiceTemplateResource) resource;
TTags tags = stRes.getServiceTemplate().getTags();
if (tags == null) {
continue;
}
int check = 0;
for (TTag tag : tags.getTag()) {
switch(tag.getName()) {
case "xaasPackageNode":
case "xaasPackageArtifactType":
case "xaasPackageDeploymentArtifact":
check++;
break;
default:
break;
}
}
if (check == 3) {
xaasPackages.add((ServiceTemplateId) stRes.getId());
}
}
}
return xaasPackages;
}
Aggregations