Search in sources :

Example 6 with ArtifactTypeId

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

the class ArtifactTypesResource method getArtifactTypeForExtension.

/**
 * Returns the first matching ArtifactTypeResource for the given file
 * extension. Returns null if no such ArtifactType can be found
 * <p>
 * The case of the extension is ignored.
 * <p>
 * This is more a DAO method
 */
public ArtifactTypeResource getArtifactTypeForExtension(String extension) {
    SortedSet<ArtifactTypeId> allArtifactTypeIds = RepositoryFactory.getRepository().getAllDefinitionsChildIds(ArtifactTypeId.class);
    ArtifactTypeResource res = null;
    for (ArtifactTypeId id : allArtifactTypeIds) {
        ArtifactTypeResource r = new ArtifactTypeResource(id);
        if (extension.equalsIgnoreCase(r.getAssociatedFileExtension())) {
            res = r;
            break;
        }
    }
    return res;
}
Also used : ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId)

Example 7 with ArtifactTypeId

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

the class DASpecificationTest method getArtifactTypeOfDA.

@Test
public void getArtifactTypeOfDA() throws Exception {
    setRevisionTo("af529e513388dc9358a8f700757d8dc59aba3a55");
    ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
    TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
    TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
    TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().get(0);
    QName artifactTypeQName = deploymentArtifact.getArtifactType();
    ArtifactTypeId artifactTypeId = new ArtifactTypeId(artifactTypeQName);
    TArtifactType artifactType = this.repository.getElement(artifactTypeId);
    assertEquals(artifactType.getTargetNamespace(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().get(0)).getTargetNamespace());
    assertEquals(artifactType.getName(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().getDeploymentArtifact().get(0)).getName());
}
Also used : ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) Test(org.junit.Test)

Example 8 with ArtifactTypeId

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

the class IGenericRepository method getReferencedTOSCAComponentImplementationArtifactIds.

/**
 * Helper method
 *
 * @param ids                     the list of ids to add the new ids to
 * @param implementationArtifacts the implementation artifacts belonging to the given id
 * @param id                      the id to handle
 */
default Collection<DefinitionsChildId> getReferencedTOSCAComponentImplementationArtifactIds(Collection<DefinitionsChildId> ids, TImplementationArtifacts implementationArtifacts, DefinitionsChildId id) {
    if (implementationArtifacts != null) {
        for (TImplementationArtifact ia : implementationArtifacts.getImplementationArtifact()) {
            QName qname;
            if ((qname = ia.getArtifactRef()) != null) {
                ids.add(new ArtifactTemplateId(qname));
            }
            ids.add(new ArtifactTypeId(ia.getArtifactType()));
        }
    }
    return ids;
}
Also used : TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName) ArtifactTemplateId(org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)

Example 9 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(ServiceTemplateId 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<>();
    TServiceTemplate serviceTemplate = this.getElement(id);
    // add included things to export queue
    TBoundaryDefinitions boundaryDefs;
    if ((boundaryDefs = serviceTemplate.getBoundaryDefinitions()) != null) {
        TBoundaryDefinitions.Policies policies = boundaryDefs.getPolicies();
        if (policies != null) {
            for (TPolicy policy : policies.getPolicy()) {
                PolicyTypeId policyTypeId = new PolicyTypeId(policy.getPolicyType());
                ids.add(policyTypeId);
                PolicyTemplateId policyTemplateId = new PolicyTemplateId(policy.getPolicyRef());
                ids.add(policyTemplateId);
            }
        }
    // reqs and caps don't have to be exported here as they are references to existing reqs/caps (of nested node templates)
    }
    if (serviceTemplate.getTopologyTemplate() != null) {
        for (TEntityTemplate entityTemplate : serviceTemplate.getTopologyTemplate().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);
                        QName template = pol.getPolicyRef();
                        if (template != null) {
                            PolicyTemplateId policyTemplateId = new PolicyTemplateId(template);
                            ids.add(policyTemplateId);
                        }
                    }
                }
            } 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) 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) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) 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) TBoundaryDefinitions(org.eclipse.winery.model.tosca.TBoundaryDefinitions) 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) PolicyTemplateId(org.eclipse.winery.common.ids.definitions.PolicyTemplateId) NodeTypeId(org.eclipse.winery.common.ids.definitions.NodeTypeId)

Example 10 with ArtifactTypeId

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

the class IGenericRepository method getReferencedDefinitionsChildIds.

/**
 * Determines the referenced definition children Ids. Does NOT return the included files.
 *
 * @return a collection of referenced definition child Ids
 */
default Collection<DefinitionsChildId> getReferencedDefinitionsChildIds(ArtifactTemplateId id) throws RepositoryCorruptException {
    Collection<DefinitionsChildId> ids = new ArrayList<>();
    final TArtifactTemplate artifactTemplate = this.getElement(id);
    // "Export" type
    QName type = artifactTemplate.getType();
    if (type == null) {
        throw new RepositoryCorruptException("Type is null for " + id.toReadableString());
    } else {
        ids.add(new ArtifactTypeId(type));
    }
    return ids;
}
Also used : DefinitionsChildId(org.eclipse.winery.common.ids.definitions.DefinitionsChildId) ArtifactTypeId(org.eclipse.winery.common.ids.definitions.ArtifactTypeId) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) RepositoryCorruptException(org.eclipse.winery.repository.exceptions.RepositoryCorruptException)

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