Search in sources :

Example 1 with SourceOrTargetElement

use of org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceOrTargetElement in project winery by eclipse.

the class ModelUtilities method instantiateRelationshipTemplate.

/**
 * This method instantiates a {@link TRelationshipTemplate} for a given {@link TRelationshipType}.
 *
 * @param relationshipType   the {@link TRelationshipType} used for the {@link TRelationshipTemplate}
 *                           instantiation.
 * @param sourceNodeTemplate the source {@link TNodeTemplate} of the connection
 * @param targetNodeTemplate the target {@link TNodeTemplate} of the connection
 * @return the instantiated {@link TRelationshipTemplate}
 */
public static TRelationshipTemplate instantiateRelationshipTemplate(TRelationshipType relationshipType, TNodeTemplate sourceNodeTemplate, TNodeTemplate targetNodeTemplate) {
    TRelationshipTemplate relationshipTemplate = new TRelationshipTemplate();
    relationshipTemplate.setId(UUID.randomUUID().toString());
    relationshipTemplate.setName(relationshipType.getName());
    relationshipTemplate.setType(new QName(relationshipType.getTargetNamespace(), relationshipType.getName()));
    // connect the NodeTemplates
    SourceOrTargetElement source = new SourceOrTargetElement();
    source.setRef(sourceNodeTemplate);
    relationshipTemplate.setSourceElement(source);
    SourceOrTargetElement target = new SourceOrTargetElement();
    target.setRef(targetNodeTemplate);
    relationshipTemplate.setTargetElement(target);
    return relationshipTemplate;
}
Also used : QName(javax.xml.namespace.QName) SourceOrTargetElement(org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceOrTargetElement)

Aggregations

QName (javax.xml.namespace.QName)1 SourceOrTargetElement (org.eclipse.winery.model.tosca.TRelationshipTemplate.SourceOrTargetElement)1