Search in sources :

Example 36 with TDeploymentArtifact

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

the class DASpecificationTest method getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode.

@Test
public void getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode() throws Exception {
    setRevisionTo("5f63267261584a513dd8a9b7960687cc3dda910a");
    ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
    TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
    assertNotNull(topologyTemplate);
    TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
    assertNotNull(nodeTemplateWithAbstractDA);
    assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
    TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
    TNodeTemplate nodeTemplateConcreteDA1 = topologyTemplate.getNodeTemplate("dressageequipment");
    TRelationshipTemplate relationshipTemplate1 = topologyTemplate.getRelationshipTemplate("con_42");
    TNodeTemplate nodeTemplateConcreteDA2 = topologyTemplate.getNodeTemplate("westernequipment");
    TRelationshipTemplate relationshipTemplate2 = topologyTemplate.getRelationshipTemplate("con_54");
    Set<Pair<TRelationshipTemplate, TNodeTemplate>> concreteDAsAndConnectedNodes = new HashSet<>();
    concreteDAsAndConnectedNodes.add(Pair.of(relationshipTemplate1, nodeTemplateConcreteDA1));
    concreteDAsAndConnectedNodes.add(Pair.of(relationshipTemplate2, nodeTemplateConcreteDA2));
    Set<Pair<TRelationshipTemplate, TNodeTemplate>> actualNodeWithConcreteDA = DASpecification.getNodesWithSuitableConcreteDAAndTheDirectlyConnectedNode(nodeTemplateWithAbstractDA, deploymentArtifact, topologyTemplate);
    assertEquals(concreteDAsAndConnectedNodes, actualNodeWithConcreteDA);
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Pair(org.apache.commons.lang3.tuple.Pair) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 37 with TDeploymentArtifact

use of org.eclipse.winery.model.tosca.TDeploymentArtifact 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();
    assertNotNull(topologyTemplate);
    TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
    assertNotNull(nodeTemplateWithAbstractDA);
    assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
    TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
    QName artifactTypeQName = deploymentArtifact.getArtifactType();
    ArtifactTypeId artifactTypeId = new ArtifactTypeId(artifactTypeQName);
    TArtifactType artifactType = this.repository.getElement(artifactTypeId);
    assertEquals(artifactType.getTargetNamespace(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getTargetNamespace());
    assertEquals(artifactType.getName(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getName());
}
Also used : ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) QName(javax.xml.namespace.QName) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.jupiter.api.Test)

Example 38 with TDeploymentArtifact

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

the class DASpecificationTest method getNodesWithSuitableConcreteDAs.

@Test
public void getNodesWithSuitableConcreteDAs() throws Exception {
    setRevisionTo("5f63267261584a513dd8a9b7960687cc3dda910a");
    ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
    TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
    assertNotNull(topologyTemplate);
    TNodeTemplate nodeTemplate = topologyTemplate.getNodeTemplate("ponycompetition");
    TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
    assertNotNull(nodeTemplateWithAbstractDA);
    assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
    TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
    TNodeTemplate expectedNodeTemplate = topologyTemplate.getNodeTemplate("dressageequipment");
    TNodeTemplate actualNodeWithConcreteDA = DASpecification.getNodesWithSuitableConcreteDAs(nodeTemplate, deploymentArtifact, topologyTemplate);
    assertEquals(expectedNodeTemplate, actualNodeWithConcreteDA);
}
Also used : TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) Test(org.junit.jupiter.api.Test)

Example 39 with TDeploymentArtifact

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

the class TopologyFragmentRefinement method applyDeploymentArtifactMapping.

private boolean applyDeploymentArtifactMapping(RefinementCandidate refinement, TNodeTemplate detectorNode, TNodeTemplate matchingNode, TTopologyTemplate topology, Map<String, String> idMapping) {
    List<OTDeploymentArtifactMapping> deploymentArtifactMappings = ((OTTopologyFragmentRefinementModel) refinement.getRefinementModel()).getDeploymentArtifactMappings();
    return matchingNode.getDeploymentArtifacts() == null || matchingNode.getDeploymentArtifacts().isEmpty() || (deploymentArtifactMappings != null && matchingNode.getDeploymentArtifacts().stream().filter(deploymentArtifact -> deploymentArtifact.getArtifactType() != null).allMatch(deploymentArtifact -> deploymentArtifactMappings.stream().filter(mapping -> mapping.getDetectorElement().getId().equals(detectorNode.getId())).anyMatch(mapping -> {
        if (ModelUtilities.isOfType(mapping.getArtifactType(), deploymentArtifact.getArtifactType(), this.artifactTypes)) {
            if (idMapping != null) {
                TNodeTemplate addedNode = topology.getNodeTemplate(idMapping.get(mapping.getRefinementElement().getId()));
                if (addedNode != null) {
                    List<TDeploymentArtifact> existingDAs = addedNode.getDeploymentArtifacts();
                    if (existingDAs == null) {
                        existingDAs = new ArrayList<>();
                        addedNode.setDeploymentArtifacts(existingDAs);
                    } else if (existingDAs.stream().anyMatch(da -> da.getName().equals(deploymentArtifact.getName()))) {
                        deploymentArtifact.setName(deploymentArtifact.getName() + UUID.randomUUID());
                    }
                    existingDAs.add(deploymentArtifact);
                } else {
                    LOGGER.error("Error while adding Deployment Artifacts! Node was not added to the topology!");
                }
            }
            return true;
        }
        return false;
    })));
}
Also used : OTDeploymentArtifactMapping(org.eclipse.winery.model.tosca.extensions.OTDeploymentArtifactMapping) OTAttributeMapping(org.eclipse.winery.model.tosca.extensions.OTAttributeMapping) TopologyFragmentRefinementModelId(org.eclipse.winery.model.ids.extensions.TopologyFragmentRefinementModelId) GraphMapping(org.jgrapht.GraphMapping) LoggerFactory(org.slf4j.LoggerFactory) RefinementChooser(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementChooser) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) HashMap(java.util.HashMap) IToscaMatcher(org.eclipse.winery.topologygraph.matching.IToscaMatcher) ToscaEdge(org.eclipse.winery.topologygraph.model.ToscaEdge) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BackendUtils(org.eclipse.winery.repository.backend.BackendUtils) Map(java.util.Map) ToscaPrmPropertyMatcher(org.eclipse.winery.topologygraph.matching.ToscaPrmPropertyMatcher) OTRefinementModel(org.eclipse.winery.model.tosca.extensions.OTRefinementModel) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) OTAttributeMappingType(org.eclipse.winery.model.tosca.extensions.OTAttributeMappingType) ArtifactTypeId(org.eclipse.winery.model.ids.definitions.ArtifactTypeId) TArtifactType(org.eclipse.winery.model.tosca.TArtifactType) OTStayMapping(org.eclipse.winery.model.tosca.extensions.OTStayMapping) Logger(org.slf4j.Logger) DefaultRefinementChooser(org.eclipse.winery.model.adaptation.substitution.refinement.DefaultRefinementChooser) RefinementUtils.redirectRelation(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementUtils.redirectRelation) AbstractRefinement(org.eclipse.winery.model.adaptation.substitution.refinement.AbstractRefinement) UUID(java.util.UUID) RefinementId(org.eclipse.winery.model.ids.extensions.RefinementId) Collectors(java.util.stream.Collectors) RefinementUtils(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementUtils) HasId(org.eclipse.winery.model.tosca.HasId) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) ToscaNode(org.eclipse.winery.topologygraph.model.ToscaNode) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) ModelUtilities(org.eclipse.winery.model.tosca.utils.ModelUtilities) ToscaGraph(org.eclipse.winery.topologygraph.model.ToscaGraph) QName(javax.xml.namespace.QName) RefinementCandidate(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementCandidate) OTDeploymentArtifactMapping(org.eclipse.winery.model.tosca.extensions.OTDeploymentArtifactMapping) OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 40 with TDeploymentArtifact

use of org.eclipse.winery.model.tosca.TDeploymentArtifact in project container by OpenTOSCA.

the class BPELPrePhasePlugin method canHandleCreate.

@Override
public boolean canHandleCreate(BPELPlanContext context, final TNodeTemplate nodeTemplate) {
    LOG.debug("Checking if DAs of node template {} can be deployed", nodeTemplate.getId());
    // Find infrastructures of this node and check if we can deploy all of its DA's
    if (nodeTemplate.getDeploymentArtifacts() == null) {
        // No DAs = we can work with that
        return true;
    }
    for (final TDeploymentArtifact da : nodeTemplate.getDeploymentArtifacts()) {
        if (getDeployableInfrastructureNode(nodeTemplate, da, context.getCsar()) == null) {
            LOG.debug("DAs of node template {} can't be deployed", nodeTemplate.getId());
            return false;
        }
    }
    LOG.debug("DAs of node template {} can be deployed", nodeTemplate.getId());
    return true;
}
Also used : TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact)

Aggregations

TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)48 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)28 QName (javax.xml.namespace.QName)23 ArrayList (java.util.ArrayList)14 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)13 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)12 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)12 HashSet (java.util.HashSet)11 List (java.util.List)9 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)9 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)9 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)9 IOException (java.io.IOException)8 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)8 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)7 Test (org.junit.jupiter.api.Test)7 TArtifactType (org.eclipse.winery.model.tosca.TArtifactType)6 TImplementationArtifact (org.eclipse.winery.model.tosca.TImplementationArtifact)6 Node (org.w3c.dom.Node)6 Map (java.util.Map)5