Search in sources :

Example 1 with TDeploymentArtifacts

use of org.eclipse.winery.model.tosca.TDeploymentArtifacts 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 2 with TDeploymentArtifacts

use of org.eclipse.winery.model.tosca.TDeploymentArtifacts 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 3 with TDeploymentArtifacts

use of org.eclipse.winery.model.tosca.TDeploymentArtifacts in project winery by eclipse.

the class DeploymentArtifactsResource method getDeploymentArtifacts.

/**
 * Determines the list of DAs belonging to the given node template.
 * <p>
 * If no DAs are existing, an empty list is created in the model for the
 * node template
 */
private static List<TDeploymentArtifact> getDeploymentArtifacts(TNodeTemplate nodeTemplate) {
    TDeploymentArtifacts deploymentArtifacts = nodeTemplate.getDeploymentArtifacts();
    final List<TDeploymentArtifact> res;
    if (deploymentArtifacts == null) {
        deploymentArtifacts = new TDeploymentArtifacts();
        nodeTemplate.setDeploymentArtifacts(deploymentArtifacts);
    }
    res = deploymentArtifacts.getDeploymentArtifact();
    return res;
}
Also used : TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact)

Example 4 with TDeploymentArtifacts

use of org.eclipse.winery.model.tosca.TDeploymentArtifacts in project winery by eclipse.

the class NodeTypeImplementationResource method getDeploymentArtifacts.

/**
 * Only NodeTypes have deployment artifacts, not RelationshipType. Therefore, this method is declared in {@link
 * NodeTypeImplementationResource} and not in {@link EntityTypeImplementationResource}
 */
@Path("deploymentartifacts/")
public DeploymentArtifactsResource getDeploymentArtifacts() {
    TDeploymentArtifacts deploymentArtifacts;
    deploymentArtifacts = this.getNTI().getDeploymentArtifacts();
    if (deploymentArtifacts == null) {
        deploymentArtifacts = new TDeploymentArtifacts();
        this.getNTI().setDeploymentArtifacts(deploymentArtifacts);
    }
    return new DeploymentArtifactsResource(deploymentArtifacts.getDeploymentArtifact(), this);
}
Also used : TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) DeploymentArtifactsResource(org.eclipse.winery.repository.rest.resources.artifacts.DeploymentArtifactsResource) Path(javax.ws.rs.Path)

Example 5 with TDeploymentArtifacts

use of org.eclipse.winery.model.tosca.TDeploymentArtifacts in project winery by eclipse.

the class BackendUtils method getArtifactTemplatesOfReferencedDeploymentArtifacts.

public static Collection<QName> getArtifactTemplatesOfReferencedDeploymentArtifacts(TNodeTemplate nodeTemplate) {
    List<QName> l = new ArrayList<>();
    // DAs may be assigned directly to a node template
    Collection<QName> allReferencedArtifactTemplates = BackendUtils.getAllReferencedArtifactTemplates(nodeTemplate.getDeploymentArtifacts());
    l.addAll(allReferencedArtifactTemplates);
    // DAs may be assigned via node type implementations
    QName nodeTypeQName = nodeTemplate.getType();
    Collection<NodeTypeImplementationId> allNodeTypeImplementations = RepositoryFactory.getRepository().getAllElementsReferencingGivenType(NodeTypeImplementationId.class, nodeTypeQName);
    for (NodeTypeImplementationId nodeTypeImplementationId : allNodeTypeImplementations) {
        TDeploymentArtifacts deploymentArtifacts = RepositoryFactory.getRepository().getElement(nodeTypeImplementationId).getDeploymentArtifacts();
        allReferencedArtifactTemplates = BackendUtils.getAllReferencedArtifactTemplates(deploymentArtifacts);
        l.addAll(allReferencedArtifactTemplates);
    }
    return l;
}
Also used : NodeTypeImplementationId(org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId) TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList)

Aggregations

TDeploymentArtifacts (org.eclipse.winery.model.tosca.TDeploymentArtifacts)7 QName (javax.xml.namespace.QName)5 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)5 HashSet (java.util.HashSet)4 ArtifactTemplateId (org.eclipse.winery.common.ids.definitions.ArtifactTemplateId)3 ArtifactTypeId (org.eclipse.winery.common.ids.definitions.ArtifactTypeId)3 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)3 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)3 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)3 CapabilityTypeId (org.eclipse.winery.common.ids.definitions.CapabilityTypeId)2 NodeTypeId (org.eclipse.winery.common.ids.definitions.NodeTypeId)2 NodeTypeImplementationId (org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId)2 PolicyTypeId (org.eclipse.winery.common.ids.definitions.PolicyTypeId)2 RelationshipTypeId (org.eclipse.winery.common.ids.definitions.RelationshipTypeId)2 RequirementTypeId (org.eclipse.winery.common.ids.definitions.RequirementTypeId)2 TCapability (org.eclipse.winery.model.tosca.TCapability)2 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)2 TPolicy (org.eclipse.winery.model.tosca.TPolicy)2 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)2 TRequirement (org.eclipse.winery.model.tosca.TRequirement)2