Search in sources :

Example 1 with ArtifactTypeId

use of org.eclipse.winery.common.ids.definitions.ArtifactTypeId in project winery by eclipse.

the class BackendUtils method createWrapperDefinitionsAndInitialEmptyElement.

public static Definitions createWrapperDefinitionsAndInitialEmptyElement(IRepository repository, DefinitionsChildId id) {
    final Definitions definitions = createWrapperDefinitions(id);
    HasIdInIdOrNameField element;
    if (id instanceof RelationshipTypeImplementationId) {
        element = new TRelationshipTypeImplementation();
    } else if (id instanceof NodeTypeImplementationId) {
        element = new TNodeTypeImplementation();
    } else if (id instanceof RequirementTypeId) {
        element = new TRequirementType();
    } else if (id instanceof NodeTypeId) {
        element = new TNodeType();
    } else if (id instanceof RelationshipTypeId) {
        element = new TRelationshipType();
    } else if (id instanceof CapabilityTypeId) {
        element = new TCapabilityType();
    } else if (id instanceof ArtifactTypeId) {
        element = new TArtifactType();
    } else if (id instanceof PolicyTypeId) {
        element = new TPolicyType();
    } else if (id instanceof PolicyTemplateId) {
        element = new TPolicyTemplate();
    } else if (id instanceof ServiceTemplateId) {
        element = new TServiceTemplate();
    } else if (id instanceof ArtifactTemplateId) {
        element = new TArtifactTemplate();
    } else if (id instanceof XSDImportId) {
        // TImport has no id; thus directly generating it without setting an id
        TImport tImport = new TImport();
        definitions.setElement(tImport);
        return definitions;
    } else {
        throw new IllegalStateException("Unhandled id branch. Could happen for XSDImportId");
    }
    copyIdToFields(element, id);
    definitions.setElement((TExtensibleElements) element);
    return definitions;
}
Also used : ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TImport(org.eclipse.winery.model.tosca.TImport) TCapabilityType(org.eclipse.winery.model.tosca.TCapabilityType) TRequirementType(org.eclipse.winery.model.tosca.TRequirementType) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) HasIdInIdOrNameField(org.eclipse.winery.model.tosca.HasIdInIdOrNameField) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) TPolicyType(org.eclipse.winery.model.tosca.TPolicyType) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) NodeTypeImplementationId(org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId) XSDImportId(org.eclipse.winery.common.ids.definitions.imports.XSDImportId) RelationshipTypeId(org.eclipse.winery.common.ids.definitions.RelationshipTypeId) CapabilityTypeId(org.eclipse.winery.common.ids.definitions.CapabilityTypeId) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) Definitions(org.eclipse.winery.model.tosca.Definitions) RelationshipTypeImplementationId(org.eclipse.winery.common.ids.definitions.RelationshipTypeImplementationId) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TPolicyTemplate(org.eclipse.winery.model.tosca.TPolicyTemplate) PolicyTypeId(org.eclipse.winery.common.ids.definitions.PolicyTypeId) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) RequirementTypeId(org.eclipse.winery.common.ids.definitions.RequirementTypeId) PolicyTemplateId(org.eclipse.winery.common.ids.definitions.PolicyTemplateId) NodeTypeId(org.eclipse.winery.common.ids.definitions.NodeTypeId)

Example 2 with ArtifactTypeId

use of org.eclipse.winery.common.ids.definitions.ArtifactTypeId in project winery by eclipse.

the class IGenericRepository method getReferencedDefinitionsChildIds.

default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(ComplianceRuleId id) {
    // We have to use a HashSet to ensure that no duplicate ids are added
    // E.g., there may be multiple relationship templates having the same type
    Collection<DefinitionsChildId> ids = new HashSet<>();
    TComplianceRule complianceRule = this.getElement(id);
    // TODO extend to required Structure
    if (complianceRule.getIdentifier() != null) {
        for (TEntityTemplate entityTemplate : complianceRule.getIdentifier().getNodeTemplateOrRelationshipTemplate()) {
            QName qname = entityTemplate.getType();
            if (entityTemplate instanceof TNodeTemplate) {
                ids.add(new NodeTypeId(qname));
                TNodeTemplate n = (TNodeTemplate) entityTemplate;
                // crawl through deployment artifacts
                TDeploymentArtifacts deploymentArtifacts = n.getDeploymentArtifacts();
                if (deploymentArtifacts != null) {
                    List<TDeploymentArtifact> das = deploymentArtifacts.getDeploymentArtifact();
                    for (TDeploymentArtifact da : das) {
                        ids.add(new ArtifactTypeId(da.getArtifactType()));
                        if ((qname = da.getArtifactRef()) != null) {
                            ids.add(new ArtifactTemplateId(qname));
                        }
                    }
                }
                // crawl through reqs/caps
                TNodeTemplate.Requirements requirements = n.getRequirements();
                if (requirements != null) {
                    for (TRequirement req : requirements.getRequirement()) {
                        QName type = req.getType();
                        RequirementTypeId rtId = new RequirementTypeId(type);
                        ids.add(rtId);
                    }
                }
                TNodeTemplate.Capabilities capabilities = n.getCapabilities();
                if (capabilities != null) {
                    for (TCapability cap : capabilities.getCapability()) {
                        QName type = cap.getType();
                        CapabilityTypeId ctId = new CapabilityTypeId(type);
                        ids.add(ctId);
                    }
                }
                // crawl through policies
                org.eclipse.winery.model.tosca.TNodeTemplate.Policies policies = n.getPolicies();
                if (policies != null) {
                    for (TPolicy pol : policies.getPolicy()) {
                        QName type = pol.getPolicyType();
                        PolicyTypeId ctId = new PolicyTypeId(type);
                        ids.add(ctId);
                    }
                }
            } else {
                assert (entityTemplate instanceof TRelationshipTemplate);
                ids.add(new RelationshipTypeId(qname));
            }
        }
    }
    return ids;
}
Also used : DefinitionsChildId(org.eclipse.winery.common.ids.definitions.DefinitionsChildId) ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) TRequirement(org.eclipse.winery.model.tosca.TRequirement) TComplianceRule(org.eclipse.winery.model.tosca.TComplianceRule) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) HashSet(java.util.HashSet) RelationshipTypeId(org.eclipse.winery.common.ids.definitions.RelationshipTypeId) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) CapabilityTypeId(org.eclipse.winery.common.ids.definitions.CapabilityTypeId) QName(javax.xml.namespace.QName) TCapability(org.eclipse.winery.model.tosca.TCapability) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) PolicyTypeId(org.eclipse.winery.common.ids.definitions.PolicyTypeId) RequirementTypeId(org.eclipse.winery.common.ids.definitions.RequirementTypeId) TPolicy(org.eclipse.winery.model.tosca.TPolicy) NodeTypeId(org.eclipse.winery.common.ids.definitions.NodeTypeId)

Example 3 with ArtifactTypeId

use of org.eclipse.winery.common.ids.definitions.ArtifactTypeId in project winery by eclipse.

the class IGenericRepository method getReferencedDefinitionsChildIds.

default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(NodeTypeImplementationId id) {
    // We have to use a HashSet to ensure that no duplicate ids are added
    // There may be multiple DAs/IAs referencing the same type
    Collection<DefinitionsChildId> ids = new HashSet<>();
    final TNodeTypeImplementation element = this.getElement(id);
    // DAs
    TDeploymentArtifacts deploymentArtifacts = element.getDeploymentArtifacts();
    if (deploymentArtifacts != null) {
        for (TDeploymentArtifact da : deploymentArtifacts.getDeploymentArtifact()) {
            QName qname;
            if ((qname = da.getArtifactRef()) != null) {
                ids.add(new ArtifactTemplateId(qname));
            }
            ids.add(new ArtifactTypeId(da.getArtifactType()));
        }
    }
    // IAs
    return this.getReferencedTOSCAComponentImplementationArtifactIds(ids, element.getImplementationArtifacts(), id);
}
Also used : TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) DefinitionsChildId(org.eclipse.winery.common.ids.definitions.DefinitionsChildId) ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId) HashSet(java.util.HashSet)

Example 4 with ArtifactTypeId

use of org.eclipse.winery.common.ids.definitions.ArtifactTypeId in project winery by eclipse.

the class DASpecification method getArtifactTypeOfDA.

public static TArtifactType getArtifactTypeOfDA(TDeploymentArtifact deploymentArtifact) {
    QName DAArtifactTypeQName = deploymentArtifact.getArtifactType();
    ArtifactTypeId artifactTypeId = new ArtifactTypeId(DAArtifactTypeQName);
    TArtifactType artifactType = RepositoryFactory.getRepository().getElement(artifactTypeId);
    return artifactType;
}
Also used : ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName)

Example 5 with ArtifactTypeId

use of org.eclipse.winery.common.ids.definitions.ArtifactTypeId in project winery by eclipse.

the class GenericArtifactsResource method getAllArtifactTypes.

/**
 * Required for artifacts.jsp
 *
 * @return list of known artifact types.
 */
public List<QName> getAllArtifactTypes() {
    SortedSet<ArtifactTypeId> allArtifactTypes = RepositoryFactory.getRepository().getAllDefinitionsChildIds(ArtifactTypeId.class);
    List<QName> res = new ArrayList<>(allArtifactTypes.size());
    for (ArtifactTypeId id : allArtifactTypes) {
        res.add(id.getQName());
    }
    return res;
}
Also used : ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName)

Aggregations

ArtifactTypeId (org.eclipse.winery.common.ids.definitions.ArtifactTypeId)12 QName (javax.xml.namespace.QName)10 ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)6 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)4 HashSet (java.util.HashSet)3 CapabilityTypeId (org.eclipse.winery.common.ids.definitions.CapabilityTypeId)3 NodeTypeId (org.eclipse.winery.common.ids.definitions.NodeTypeId)3 PolicyTypeId (org.eclipse.winery.common.ids.definitions.PolicyTypeId)3 RelationshipTypeId (org.eclipse.winery.common.ids.definitions.RelationshipTypeId)3 RequirementTypeId (org.eclipse.winery.common.ids.definitions.RequirementTypeId)3 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)3 TDeploymentArtifacts (org.eclipse.winery.model.tosca.TDeploymentArtifacts)3 ArrayList (java.util.ArrayList)2 PolicyTemplateId (org.eclipse.winery.common.ids.definitions.PolicyTemplateId)2 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)2 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)2 TCapability (org.eclipse.winery.model.tosca.TCapability)2 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)2 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)2 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)2