Search in sources :

Example 1 with TTag

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);
}
Also used : TTag(org.eclipse.winery.model.tosca.TTag) CreateFromArtifactApiData(org.eclipse.winery.repository.rest.resources._support.CreateFromArtifactApiData) QName(javax.xml.namespace.QName) AbstractComponentInstanceResource(org.eclipse.winery.repository.rest.resources._support.AbstractComponentInstanceResource)

Example 2 with TTag

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;
}
Also used : TTag(org.eclipse.winery.model.tosca.TTag) AbstractComponentInstanceResource(org.eclipse.winery.repository.rest.resources._support.AbstractComponentInstanceResource) TTags(org.eclipse.winery.model.tosca.TTags) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId)

Aggregations

TTag (org.eclipse.winery.model.tosca.TTag)2 AbstractComponentInstanceResource (org.eclipse.winery.repository.rest.resources._support.AbstractComponentInstanceResource)2 QName (javax.xml.namespace.QName)1 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)1 TTags (org.eclipse.winery.model.tosca.TTags)1 CreateFromArtifactApiData (org.eclipse.winery.repository.rest.resources._support.CreateFromArtifactApiData)1