Search in sources :

Example 1 with TImplementationArtifacts

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

the class BackendUtils method getArtifactTemplatesOfReferencedImplementationArtifacts.

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

Example 2 with TImplementationArtifacts

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

the class NodeTypeImplementationResource method getImplementationArtifacts.

/**
 * Even if both node type implementations and relationship type implementations have implementation artifacts, there
 * is no common supertype. To avoid endless casts, we just implement the method here
 */
@Path("implementationartifacts/")
public ImplementationArtifactsResource getImplementationArtifacts() {
    TImplementationArtifacts implementationArtifacts;
    implementationArtifacts = this.getNTI().getImplementationArtifacts();
    if (implementationArtifacts == null) {
        implementationArtifacts = new TImplementationArtifacts();
        this.getNTI().setImplementationArtifacts(implementationArtifacts);
    }
    return new ImplementationArtifactsResource(implementationArtifacts.getImplementationArtifact(), this);
}
Also used : TImplementationArtifacts(org.eclipse.winery.model.tosca.TImplementationArtifacts) ImplementationArtifactsResource(org.eclipse.winery.repository.rest.resources.artifacts.ImplementationArtifactsResource) Path(javax.ws.rs.Path)

Example 3 with TImplementationArtifacts

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

the class IGenericRepository method getReferenceCount.

default int getReferenceCount(ArtifactTemplateId id) {
    // We do not use a database, therefore, we have to go through all possibilities pointing to the artifact template
    // DAs and IAs point to an artifact template
    // DAs are contained in Node Type Implementations and Node Templates
    // IAs are contained in Node Type Implementations and Relationship Type Implementations
    int count = 0;
    Collection<TDeploymentArtifact> allDAs = new HashSet<>();
    Collection<TImplementationArtifact> allIAs = new HashSet<>();
    // handle Node Type Implementation, which contains DAs and IAs
    SortedSet<NodeTypeImplementationId> nodeTypeImplementations = this.getAllDefinitionsChildIds(NodeTypeImplementationId.class);
    for (NodeTypeImplementationId ntiId : nodeTypeImplementations) {
        final TNodeTypeImplementation nodeTypeImplementation = this.getElement(ntiId);
        TDeploymentArtifacts deploymentArtifacts = nodeTypeImplementation.getDeploymentArtifacts();
        if (deploymentArtifacts != null) {
            allDAs.addAll(deploymentArtifacts.getDeploymentArtifact());
        }
        TImplementationArtifacts implementationArtifacts = nodeTypeImplementation.getImplementationArtifacts();
        if (implementationArtifacts != null) {
            allIAs.addAll(implementationArtifacts.getImplementationArtifact());
        }
    }
    // check all Relationshiptype Implementations for IAs
    SortedSet<RelationshipTypeImplementationId> relationshipTypeImplementations = this.getAllDefinitionsChildIds(RelationshipTypeImplementationId.class);
    for (RelationshipTypeImplementationId rtiId : relationshipTypeImplementations) {
        TImplementationArtifacts implementationArtifacts = this.getElement(rtiId).getImplementationArtifacts();
        if (implementationArtifacts != null) {
            allIAs.addAll(implementationArtifacts.getImplementationArtifact());
        }
    }
    // check all node templates for DAs
    SortedSet<ServiceTemplateId> serviceTemplates = this.getAllDefinitionsChildIds(ServiceTemplateId.class);
    for (ServiceTemplateId sid : serviceTemplates) {
        TTopologyTemplate topologyTemplate = this.getElement(sid).getTopologyTemplate();
        if (topologyTemplate != null) {
            List<TEntityTemplate> nodeTemplateOrRelationshipTemplate = topologyTemplate.getNodeTemplateOrRelationshipTemplate();
            for (TEntityTemplate template : nodeTemplateOrRelationshipTemplate) {
                if (template instanceof TNodeTemplate) {
                    TNodeTemplate nodeTemplate = (TNodeTemplate) template;
                    TDeploymentArtifacts deploymentArtifacts = nodeTemplate.getDeploymentArtifacts();
                    if (deploymentArtifacts != null) {
                        allDAs.addAll(deploymentArtifacts.getDeploymentArtifact());
                    }
                }
            }
        }
    }
    // now we have all DAs and IAs
    QName ourQName = id.getQName();
    // check DAs for artifact templates
    for (TDeploymentArtifact da : allDAs) {
        QName artifactRef = da.getArtifactRef();
        if (ourQName.equals(artifactRef)) {
            count++;
        }
    }
    // check IAs for artifact templates
    for (TImplementationArtifact ia : allIAs) {
        QName artifactRef = ia.getArtifactRef();
        if (ourQName.equals(artifactRef)) {
            count++;
        }
    }
    return count;
}
Also used : NodeTypeImplementationId(org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId) TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) QName(javax.xml.namespace.QName) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) RelationshipTypeImplementationId(org.eclipse.winery.common.ids.definitions.RelationshipTypeImplementationId) ServiceTemplateId(org.eclipse.winery.common.ids.definitions.ServiceTemplateId) TImplementationArtifacts(org.eclipse.winery.model.tosca.TImplementationArtifacts) TDeploymentArtifacts(org.eclipse.winery.model.tosca.TDeploymentArtifacts) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) HashSet(java.util.HashSet)

Example 4 with TImplementationArtifacts

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

the class RelationshipTypeImplementationResource method getImplementationArtifacts.

/**
 * Even if both node type implementations and relationship type
 * implementations have implementation artifacts, there is no common
 * supertype. To avoid endless casts, we just implement the method here
 */
@Path("implementationartifacts/")
public ImplementationArtifactsResource getImplementationArtifacts() {
    TImplementationArtifacts implementationArtifacts;
    implementationArtifacts = this.getRTI().getImplementationArtifacts();
    if (implementationArtifacts == null) {
        implementationArtifacts = new TImplementationArtifacts();
        this.getRTI().setImplementationArtifacts(implementationArtifacts);
    }
    return new ImplementationArtifactsResource(implementationArtifacts.getImplementationArtifact(), this);
}
Also used : TImplementationArtifacts(org.eclipse.winery.model.tosca.TImplementationArtifacts) ImplementationArtifactsResource(org.eclipse.winery.repository.rest.resources.artifacts.ImplementationArtifactsResource) Path(javax.ws.rs.Path)

Aggregations

TImplementationArtifacts (org.eclipse.winery.model.tosca.TImplementationArtifacts)4 Path (javax.ws.rs.Path)2 QName (javax.xml.namespace.QName)2 NodeTypeImplementationId (org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId)2 ImplementationArtifactsResource (org.eclipse.winery.repository.rest.resources.artifacts.ImplementationArtifactsResource)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 RelationshipTypeImplementationId (org.eclipse.winery.common.ids.definitions.RelationshipTypeImplementationId)1 ServiceTemplateId (org.eclipse.winery.common.ids.definitions.ServiceTemplateId)1 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)1 TDeploymentArtifacts (org.eclipse.winery.model.tosca.TDeploymentArtifacts)1 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)1 TImplementationArtifact (org.eclipse.winery.model.tosca.TImplementationArtifact)1 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)1 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)1 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)1