Search in sources :

Example 11 with TNodeTypeImplementation

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

the class EnhancementUtilsTestWithGitBackedRepository method mergeFeatureNodeTypeUbuntu.

@Test
void mergeFeatureNodeTypeUbuntu() throws Exception {
    this.setRevisionTo("origin/plain");
    Map<QName, TExtensibleElements> previousListOfNodeTypes = this.repository.getQNameToElementMapping(NodeTypeId.class);
    String testingFeatureName = "Testing";
    String freezeFeatureName = "Freeze and Defrost";
    String nodeTemplateId = "myId";
    Map<QName, String> ubuntuFeatures = new HashMap<>();
    ubuntuFeatures.put(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-testable-w1"), testingFeatureName);
    ubuntuFeatures.put(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-freezable-w1"), freezeFeatureName);
    TNodeTemplate nodeTemplate = new TNodeTemplate();
    nodeTemplate.setType(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-w1"));
    nodeTemplate.setId(nodeTemplateId);
    TNodeType generatedFeatureEnrichedNodeType = EnhancementUtils.createFeatureNodeType(nodeTemplate, ubuntuFeatures);
    Map<QName, TExtensibleElements> listOfNodeTypes = this.repository.getQNameToElementMapping(NodeTypeId.class);
    QName expectedMergedUbuntuQName = QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes" + EnhancementUtils.GENERATED_NS_SUFFIX + "}Ubuntu_16.04-w1-" + nodeTemplateId + "-" + "Testing-Freeze_and_Defrost" + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + "1");
    assertEquals(1, listOfNodeTypes.size() - previousListOfNodeTypes.size());
    assertEquals(expectedMergedUbuntuQName, generatedFeatureEnrichedNodeType.getQName());
    assertNotNull(generatedFeatureEnrichedNodeType.getWinerysPropertiesDefinition());
    assertEquals(9, generatedFeatureEnrichedNodeType.getWinerysPropertiesDefinition().getPropertyDefinitions().size());
    TNodeTypeImplementation generatedUbuntuImpl = this.repository.getElement(new ArrayList<>(this.repository.getAllElementsReferencingGivenType(NodeTypeImplementationId.class, expectedMergedUbuntuQName)).get(0));
    assertNotNull(generatedUbuntuImpl);
    assertNotNull(generatedUbuntuImpl.getImplementationArtifacts());
    assertEquals(3, generatedUbuntuImpl.getImplementationArtifacts().size());
}
Also used : NodeTypeImplementationId(org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TExtensibleElements(org.eclipse.winery.model.tosca.TExtensibleElements) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Test(org.junit.jupiter.api.Test)

Example 12 with TNodeTypeImplementation

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

the class DASpecification method getSuitableConcreteDA.

public static TDeploymentArtifact getSuitableConcreteDA(TDeploymentArtifact abstractDeploymentArtifact, TNodeTemplate nodeTemplate) {
    TDeploymentArtifact concreteDA = null;
    if (nodeTemplate.getDeploymentArtifacts() != null) {
        List<TDeploymentArtifact> concreteDeploymentArtifacts = nodeTemplate.getDeploymentArtifacts();
        concreteDA = getConcreteDA(abstractDeploymentArtifact, concreteDeploymentArtifacts);
    }
    if (concreteDA == null) {
        List<TNodeTypeImplementation> nodeTypeImplementations = getMatchingNodeTypeImplementations(nodeTemplate.getType());
        for (TNodeTypeImplementation nodeTypeImplementation : nodeTypeImplementations) {
            if (nodeTypeImplementation.getDeploymentArtifacts() != null) {
                List<TDeploymentArtifact> deploymentArtifacts = nodeTypeImplementation.getDeploymentArtifacts();
                concreteDA = getConcreteDA(abstractDeploymentArtifact, deploymentArtifacts);
                if (concreteDA != null) {
                    return concreteDA;
                }
            }
        }
    } else {
        return concreteDA;
    }
    return null;
}
Also used : TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation)

Aggregations

TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)12 QName (javax.xml.namespace.QName)9 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)7 NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)6 TNodeType (org.eclipse.winery.model.tosca.TNodeType)5 HashSet (java.util.HashSet)4 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)4 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)4 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)4 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)4 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)4 IRepository (org.eclipse.winery.repository.backend.IRepository)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)3 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)3 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 List (java.util.List)2 Objects (java.util.Objects)2