diff --git a/org.eclipse.winery.compliance/pom.xml b/org.eclipse.winery.compliance/pom.xml
index c8245f1e7d..d2af0bb892 100644
--- a/org.eclipse.winery.compliance/pom.xml
+++ b/org.eclipse.winery.compliance/pom.xml
@@ -27,37 +27,22 @@
org.eclipse.winery
org.eclipse.winery.model.tosca
2.0.0-SNAPSHOT
-
-
- org.eclipse.winery
- org.eclipse.winery.topologygraph
- 2.0.0-SNAPSHOT
-
-
- org.slf4j
- slf4j-api
- ${org.slf4j}
compile
-
- org.apache.commons
- commons-lang3
- 3.7
-
org.jgrapht
jgrapht-core
- 1.0.1
+ ${org.jgrapht.jgrapht-core.version}
org.eclipse.winery
- org.eclipse.winery.repository
+ org.eclipse.winery.topologygraph
2.0.0-SNAPSHOT
- junit
- junit
- 4.11
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.version}
test
@@ -72,28 +57,30 @@
${org.slf4j}
test
-
- com.google.guava
- guava
- 23.4-jre
-
-
- com.google.code.findbugs
- jsr305
-
-
- com.google.errorprone
- error_prone_annotations
-
-
- com.google.j2objc
- j2objc-annotations
-
-
- org.codehaus.mojo
- animal-sniffer-annotations
-
-
-
+
+
+
+ maven-surefire-plugin
+ 2.21.0
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junit.jupiter.version}
+
+
+
+
+
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
index b5de5c90b7..fab2873ccc 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ComplianceRuleChecker.java
@@ -21,10 +21,10 @@
import java.util.Optional;
import org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
-import org.eclipse.winery.topologygraph.matching.transformation.ToscaTransformer;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
+import org.eclipse.winery.topologygraph.transformation.ToscaTransformer;
import org.eclipse.winery.model.tosca.TComplianceRule;
import org.eclipse.winery.model.tosca.TTopologyTemplate;
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
index 70d8e1b90e..d1b0afa39e 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ServiceTemplateComplianceRuleRuleChecker.java
@@ -20,7 +20,7 @@
import org.eclipse.winery.common.ids.Namespace;
import org.eclipse.winery.common.ids.definitions.ComplianceRuleId;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
import org.eclipse.winery.model.tosca.TComplianceRule;
import org.eclipse.winery.model.tosca.TServiceTemplate;
import org.eclipse.winery.repository.backend.IRepository;
diff --git a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
index 26443eb07f..881fcda34c 100644
--- a/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
+++ b/org.eclipse.winery.compliance/src/main/java/org/eclipse/winery/compliance/checking/ToscaComplianceRuleMatcher.java
@@ -19,9 +19,9 @@
import java.util.stream.Collectors;
import org.eclipse.winery.topologygraph.matching.IToscaMatcher;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEntity;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaEntity;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
import org.eclipse.winery.model.tosca.TEntityType;
import org.eclipse.winery.model.tosca.TPolicy;
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
index e3dc8e8db3..9e9fc2ee47 100644
--- a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaGraphIsomorphismTest.java
@@ -39,11 +39,6 @@
import org.eclipse.winery.compliance.checking.ServiceTemplateCheckingResult;
import org.eclipse.winery.compliance.checking.ServiceTemplateComplianceRuleRuleChecker;
import org.eclipse.winery.compliance.checking.ToscaComplianceRuleMatcher;
-import org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdgeFactory;
-import org.eclipse.winery.topologygraph.matching.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
import org.eclipse.winery.model.tosca.TComplianceRule;
import org.eclipse.winery.model.tosca.TExtensibleElements;
import org.eclipse.winery.model.tosca.TNodeTemplate;
@@ -56,12 +51,16 @@
import org.eclipse.winery.repository.backend.RepositoryFactory;
import org.eclipse.winery.repository.backend.filebased.FilebasedRepository;
import org.eclipse.winery.repository.configuration.FileBasedRepositoryConfiguration;
+import org.eclipse.winery.topologygraph.matching.ToscaIsomorphismMatcher;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaEdgeFactory;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
import org.apache.commons.lang3.StringUtils;
import org.jgrapht.GraphMapping;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static com.google.common.collect.Lists.newArrayList;
import static org.eclipse.winery.compliance.ToscaModelHelper.TEST_TARGET_NAMESPACE;
@@ -78,10 +77,10 @@
import static org.eclipse.winery.compliance.ToscaModelHelper.createTServiceTemplate;
import static org.eclipse.winery.compliance.ToscaModelHelper.createTTopologyTemplate;
import static org.eclipse.winery.compliance.ToscaModelHelper.setDerivedFrom;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ToscaGraphIsomorphismTest {
@@ -98,8 +97,7 @@ private void persist(HashMap allEntitie
}
}
- @Before
- @After
+ @BeforeEach
public void cleanUp() {
repository.doClear();
}
diff --git a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
index 7c72463840..0e8ca72f43 100644
--- a/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
+++ b/org.eclipse.winery.compliance/src/test/java/org/eclipse/winery/compliance/ToscaModelHelper.java
@@ -19,10 +19,10 @@
import org.eclipse.winery.common.ids.definitions.ComplianceRuleId;
import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
-import org.eclipse.winery.topologygraph.matching.transformation.ToscaTransformer;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
+import org.eclipse.winery.topologygraph.transformation.ToscaTransformer;
import org.eclipse.winery.model.tosca.TComplianceRule;
import org.eclipse.winery.model.tosca.TEntityType;
import org.eclipse.winery.model.tosca.TNodeTemplate;
diff --git a/org.eclipse.winery.topologygraph/pom.xml b/org.eclipse.winery.topologygraph/pom.xml
index aae7fcb971..63ca863aa8 100644
--- a/org.eclipse.winery.topologygraph/pom.xml
+++ b/org.eclipse.winery.topologygraph/pom.xml
@@ -33,7 +33,7 @@
org.jgrapht
jgrapht-core
- 1.0.1
+ ${org.jgrapht.jgrapht-core.version}
org.eclipse.winery
@@ -42,5 +42,4 @@
-
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/IToscaMatcher.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/IToscaMatcher.java
index 0117257d27..c7c51d4cfe 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/IToscaMatcher.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/IToscaMatcher.java
@@ -13,12 +13,12 @@
********************************************************************************/
package org.eclipse.winery.topologygraph.matching;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
public interface IToscaMatcher {
- boolean isCompatible(ToscaNode left, ToscaNode right);
+ boolean isCompatible(ToscaNode left, ToscaNode right);
- boolean isCompatible(ToscaEdge left, ToscaEdge right);
+ boolean isCompatible(ToscaEdge left, ToscaEdge right);
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaComparatorProxy.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaComparatorProxy.java
index 0f238cb3af..61f9896eff 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaComparatorProxy.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaComparatorProxy.java
@@ -13,21 +13,21 @@
********************************************************************************/
package org.eclipse.winery.topologygraph.matching;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
public class ToscaComparatorProxy {
- private final IToscaMatcher matcher;
+ private final IToscaMatcher matcher;
- public ToscaComparatorProxy(IToscaMatcher matcher) {
- this.matcher = (matcher != null) ? matcher : new ToscaDefaultMatcher();
- }
+ public ToscaComparatorProxy(IToscaMatcher matcher) {
+ this.matcher = (matcher != null) ? matcher : new ToscaDefaultMatcher();
+ }
- public int compareTypeCompatible(ToscaNode left, ToscaNode right) {
- return matcher.isCompatible(left, right) ? 0 : -1;
- }
+ public int compareTypeCompatible(ToscaNode left, ToscaNode right) {
+ return matcher.isCompatible(left, right) ? 0 : -1;
+ }
- public int compareTypeCompatible(ToscaEdge left, ToscaEdge right) {
- return matcher.isCompatible(left, right) ? 0 : -1;
- }
+ public int compareTypeCompatible(ToscaEdge left, ToscaEdge right) {
+ return matcher.isCompatible(left, right) ? 0 : -1;
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaDefaultMatcher.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaDefaultMatcher.java
index a62e09d38f..2be158b1d1 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaDefaultMatcher.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaDefaultMatcher.java
@@ -13,20 +13,20 @@
********************************************************************************/
package org.eclipse.winery.topologygraph.matching;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
import org.apache.commons.lang3.StringUtils;
public class ToscaDefaultMatcher implements IToscaMatcher {
- @Override
- public boolean isCompatible(ToscaNode left, ToscaNode right) {
- return StringUtils.equals(left.getNodeTemplate().getName(), right.getNodeTemplate().getName());
- }
+ @Override
+ public boolean isCompatible(ToscaNode left, ToscaNode right) {
+ return StringUtils.equals(left.getNodeTemplate().getName(), right.getNodeTemplate().getName());
+ }
- @Override
- public boolean isCompatible(ToscaEdge left, ToscaEdge right) {
- return StringUtils.equals(left.getTemplate().getName(), right.getTemplate().getName());
- }
+ @Override
+ public boolean isCompatible(ToscaEdge left, ToscaEdge right) {
+ return StringUtils.equals(left.getTemplate().getName(), right.getTemplate().getName());
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaIsomorphismMatcher.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaIsomorphismMatcher.java
index cca032883c..7313f6c404 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaIsomorphismMatcher.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/ToscaIsomorphismMatcher.java
@@ -16,22 +16,22 @@
import java.util.Comparator;
import java.util.Iterator;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
import org.jgrapht.GraphMapping;
import org.jgrapht.alg.isomorphism.VF2SubgraphIsomorphismInspector;
public class ToscaIsomorphismMatcher {
- public Iterator> findMatches(ToscaGraph queryGraph, ToscaGraph toSearchIn, IToscaMatcher comp) {
+ public Iterator> findMatches(ToscaGraph queryGraph, ToscaGraph toSearchIn, IToscaMatcher comp) {
- // NEVER CHANGE THE ORDERING OF THE PARAMETERS. THE SWITCH (RIGHT, LEFT) IS DELIBERATE!
- Comparator vertexComparator = (ToscaNode left, ToscaNode right) -> new ToscaComparatorProxy(comp).compareTypeCompatible(right, left);
- Comparator edgeComparator = (ToscaEdge left, ToscaEdge right) -> new ToscaComparatorProxy(comp).compareTypeCompatible(right, left);
+ // NEVER CHANGE THE ORDERING OF THE PARAMETERS. THE SWITCH (RIGHT, LEFT) IS DELIBERATE!
+ Comparator vertexComparator = (ToscaNode left, ToscaNode right) -> new ToscaComparatorProxy(comp).compareTypeCompatible(right, left);
+ Comparator edgeComparator = (ToscaEdge left, ToscaEdge right) -> new ToscaComparatorProxy(comp).compareTypeCompatible(right, left);
- VF2SubgraphIsomorphismInspector inspector = new VF2SubgraphIsomorphismInspector<>(toSearchIn, queryGraph, vertexComparator, edgeComparator);
- return inspector.getMappings();
- }
+ VF2SubgraphIsomorphismInspector inspector = new VF2SubgraphIsomorphismInspector<>(toSearchIn, queryGraph, vertexComparator, edgeComparator);
+ return inspector.getMappings();
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdge.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdge.java
deleted file mode 100644
index 673895fe92..0000000000
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdge.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
- * which is available at https://www.apache.org/licenses/LICENSE-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
- ********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.model;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.eclipse.winery.model.tosca.TRelationshipTemplate;
-import org.eclipse.winery.model.tosca.TRelationshipType;
-
-public class ToscaEdge extends ToscaEntity {
-
- private ToscaNode targetNode;
- private ToscaNode sourceNode;
- private TRelationshipTemplate template;
-
- public ToscaEdge(ToscaNode sourceNode, ToscaNode targetNode) {
- super();
- this.targetNode = targetNode;
- this.sourceNode = sourceNode;
- }
-
- public List getRelationshipTypes() {
- return getTypes().stream().map(tEntityType -> (TRelationshipType) tEntityType).collect(Collectors.toList());
- }
-
- public ToscaNode getTargetNode() {
- return targetNode;
- }
-
- public void setTargetNode(ToscaNode targetNode) {
- this.targetNode = targetNode;
- }
-
- public ToscaNode getSourceNode() {
- return sourceNode;
- }
-
- public void setSourceNode(ToscaNode sourceNode) {
- this.sourceNode = sourceNode;
- }
-
- public TRelationshipTemplate getTemplate() {
- return template;
- }
-
- public void setTemplate(TRelationshipTemplate template) {
- this.template = template;
- this.setId(template.getId());
- }
-}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/transformation/ToscaTransformer.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/transformation/ToscaTransformer.java
deleted file mode 100644
index 7d6b64d07d..0000000000
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/transformation/ToscaTransformer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
- * which is available at https://www.apache.org/licenses/LICENSE-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
- ********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.transformation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.winery.common.ids.definitions.EntityTypeId;
-import org.eclipse.winery.common.ids.definitions.NodeTypeId;
-import org.eclipse.winery.common.ids.definitions.RelationshipTypeId;
-import org.eclipse.winery.model.tosca.TEntityType;
-import org.eclipse.winery.model.tosca.TNodeTemplate;
-import org.eclipse.winery.model.tosca.TNodeType;
-import org.eclipse.winery.model.tosca.TRelationshipTemplate;
-import org.eclipse.winery.model.tosca.TRelationshipType;
-import org.eclipse.winery.model.tosca.TTopologyTemplate;
-import org.eclipse.winery.repository.backend.RepositoryFactory;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdge;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEdgeFactory;
-import org.eclipse.winery.topologygraph.matching.model.ToscaEntity;
-import org.eclipse.winery.topologygraph.matching.model.ToscaGraph;
-import org.eclipse.winery.topologygraph.matching.model.ToscaNode;
-
-import org.eclipse.jdt.annotation.NonNull;
-
-public class ToscaTransformer {
- public static ToscaGraph createTOSCAGraph(TTopologyTemplate topologyTemplate) {
- ToscaGraph graph = new ToscaGraph(new ToscaEdgeFactory());
- @NonNull List relationshipTemplates = topologyTemplate.getRelationshipTemplates();
- @NonNull List nodeTemplates = topologyTemplate.getNodeTemplates();
- Map nodes = new HashMap<>();
- for (TNodeTemplate nodeTemplate : nodeTemplates) {
- ToscaNode node = createAndInitializeTOSCANode(nodeTemplate);
- nodes.put(nodeTemplate, node);
- graph.addVertex(node);
- }
- for (TRelationshipTemplate tRelationshipTemplate : relationshipTemplates) {
- ToscaEdge edge = graph.addEdge(nodes.get(tRelationshipTemplate.getSourceElement().getRef()), nodes.get(tRelationshipTemplate.getTargetElement().getRef()));
- initializeTOSCAEdge(tRelationshipTemplate, edge);
- }
- return graph;
- }
-
- protected static void initializeTOSCAEdge(TRelationshipTemplate tRelationshipTemplate, ToscaEdge edge) {
- edge.setTemplate(tRelationshipTemplate);
- addTEntityTypes(tRelationshipTemplate.getType(), edge, TRelationshipType.class);
- }
-
- protected static ToscaNode createAndInitializeTOSCANode(TNodeTemplate nodeTemplate) {
- ToscaNode node = new ToscaNode();
- node.setNodeTemplate(nodeTemplate);
- addTEntityTypes(nodeTemplate.getType(), node, TNodeType.class);
- return node;
- }
-
- public static void addTEntityTypes(QName nodeTypeQName, ToscaEntity entity, Class extends TEntityType> tEntityTypeClass) {
- TEntityType entityType = getEntityType(nodeTypeQName, tEntityTypeClass);
- entity.addTEntityType(entityType);
-
- Optional.of(entityType).map(TEntityType::getDerivedFrom)
- .map(TEntityType.DerivedFrom::getTypeRef)
- .ifPresent(qName -> addTEntityTypes(qName, entity, tEntityTypeClass));
- }
-
- protected static TEntityType getEntityType(QName qName, Class extends TEntityType> tEntityTypeClass) {
- EntityTypeId ntId = null;
- if (tEntityTypeClass.isAssignableFrom(TNodeType.class)) {
- return RepositoryFactory.getRepository().getElement(new NodeTypeId(qName));
- }
- if (tEntityTypeClass.isAssignableFrom(TRelationshipType.class)) {
- return RepositoryFactory.getRepository().getElement(new RelationshipTypeId(qName));
- }
- return null;
- }
-}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdge.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdge.java
new file mode 100644
index 0000000000..97fb5a6a46
--- /dev/null
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdge.java
@@ -0,0 +1,62 @@
+/********************************************************************************
+ * Copyright (c) 2018 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
+ * which is available at https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+ ********************************************************************************/
+package org.eclipse.winery.topologygraph.model;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.eclipse.winery.model.tosca.TRelationshipTemplate;
+import org.eclipse.winery.model.tosca.TRelationshipType;
+
+public class ToscaEdge extends ToscaEntity {
+
+ private ToscaNode targetNode;
+ private ToscaNode sourceNode;
+ private TRelationshipTemplate template;
+
+ public ToscaEdge(ToscaNode sourceNode, ToscaNode targetNode) {
+ super();
+ this.targetNode = targetNode;
+ this.sourceNode = sourceNode;
+ }
+
+ public List getRelationshipTypes() {
+ return getTypes().stream().map(tEntityType -> (TRelationshipType) tEntityType).collect(Collectors.toList());
+ }
+
+ public ToscaNode getTargetNode() {
+ return targetNode;
+ }
+
+ public void setTargetNode(ToscaNode targetNode) {
+ this.targetNode = targetNode;
+ }
+
+ public ToscaNode getSourceNode() {
+ return sourceNode;
+ }
+
+ public void setSourceNode(ToscaNode sourceNode) {
+ this.sourceNode = sourceNode;
+ }
+
+ public TRelationshipTemplate getTemplate() {
+ return template;
+ }
+
+ public void setTemplate(TRelationshipTemplate template) {
+ this.template = template;
+ this.setId(template.getId());
+ }
+}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdgeFactory.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdgeFactory.java
similarity index 80%
rename from org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdgeFactory.java
rename to org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdgeFactory.java
index e5bda0bac2..51556a644c 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEdgeFactory.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEdgeFactory.java
@@ -11,13 +11,13 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.model;
+package org.eclipse.winery.topologygraph.model;
import org.jgrapht.EdgeFactory;
public class ToscaEdgeFactory implements EdgeFactory {
- public ToscaEdge createEdge(ToscaNode sourceVertex, ToscaNode targetVertex) {
- return new ToscaEdge(sourceVertex, targetVertex);
- }
+ public ToscaEdge createEdge(ToscaNode sourceVertex, ToscaNode targetVertex) {
+ return new ToscaEdge(sourceVertex, targetVertex);
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEntity.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEntity.java
similarity index 61%
rename from org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEntity.java
rename to org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEntity.java
index ce8b73135f..7d2406f818 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaEntity.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaEntity.java
@@ -11,7 +11,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.model;
+package org.eclipse.winery.topologygraph.model;
import java.util.ArrayList;
import java.util.List;
@@ -20,26 +20,26 @@
public abstract class ToscaEntity {
- private final List types = new ArrayList<>();
- private String id;
+ private final List types = new ArrayList<>();
+ private String id;
- public String getId() {
- return id;
- }
+ public String getId() {
+ return id;
+ }
- public void setId(String id) {
- this.id = id;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- public List getTypes() {
- return types;
- }
+ public List getTypes() {
+ return types;
+ }
- public TEntityType getActualType() {
- return types.stream().findFirst().orElse(null);
- }
+ public TEntityType getActualType() {
+ return types.stream().findFirst().orElse(null);
+ }
- public boolean addTEntityType(TEntityType type) {
- return this.types.add(type);
- }
+ public boolean addTEntityType(TEntityType type) {
+ return this.types.add(type);
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaGraph.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaGraph.java
similarity index 66%
rename from org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaGraph.java
rename to org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaGraph.java
index 009c37fa94..f6a0e2f302 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaGraph.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaGraph.java
@@ -11,7 +11,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.model;
+package org.eclipse.winery.topologygraph.model;
import org.apache.commons.lang3.StringUtils;
import org.jgrapht.EdgeFactory;
@@ -19,17 +19,17 @@
public class ToscaGraph extends DefaultDirectedGraph {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public ToscaGraph(EdgeFactory ef) {
- super(ef);
- }
+ public ToscaGraph(EdgeFactory ef) {
+ super(ef);
+ }
- public ToscaNode getNode(String id) {
- return vertexSet().stream().filter(n -> StringUtils.equals(id, n.getId())).findFirst().orElse(null);
- }
+ public ToscaNode getNode(String id) {
+ return vertexSet().stream().filter(n -> StringUtils.equals(id, n.getId())).findFirst().orElse(null);
+ }
- public ToscaNode getReferenceNode() {
- return vertexSet().stream().findAny().orElse(null);
- }
+ public ToscaNode getReferenceNode() {
+ return vertexSet().stream().findAny().orElse(null);
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaNode.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaNode.java
similarity index 66%
rename from org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaNode.java
rename to org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaNode.java
index 69cecc35f2..a17fec0041 100644
--- a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/matching/model/ToscaNode.java
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/model/ToscaNode.java
@@ -11,7 +11,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
********************************************************************************/
-package org.eclipse.winery.topologygraph.matching.model;
+package org.eclipse.winery.topologygraph.model;
import java.util.List;
import java.util.stream.Collectors;
@@ -21,20 +21,20 @@
public class ToscaNode extends ToscaEntity {
- private TNodeTemplate nodeTemplate;
+ private TNodeTemplate nodeTemplate;
- public List getNodeTypes() {
- return getTypes().stream().map(TNodeType.class::cast).collect(Collectors.toList());
- }
+ public List getNodeTypes() {
+ return getTypes().stream().map(TNodeType.class::cast).collect(Collectors.toList());
+ }
- public TNodeTemplate getNodeTemplate() {
- return nodeTemplate;
- }
+ public TNodeTemplate getNodeTemplate() {
+ return nodeTemplate;
+ }
- public void setNodeTemplate(TNodeTemplate nodeTemplate) {
- this.nodeTemplate = nodeTemplate;
- this.setId(nodeTemplate.getId());
- }
+ public void setNodeTemplate(TNodeTemplate nodeTemplate) {
+ this.nodeTemplate = nodeTemplate;
+ this.setId(nodeTemplate.getId());
+ }
}
diff --git a/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/transformation/ToscaTransformer.java b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/transformation/ToscaTransformer.java
new file mode 100644
index 0000000000..145c437d9e
--- /dev/null
+++ b/org.eclipse.winery.topologygraph/src/main/java/org/eclipse/winery/topologygraph/transformation/ToscaTransformer.java
@@ -0,0 +1,91 @@
+/********************************************************************************
+ * Copyright (c) 2018 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
+ * which is available at https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
+ ********************************************************************************/
+package org.eclipse.winery.topologygraph.transformation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.xml.namespace.QName;
+
+import org.eclipse.winery.common.ids.definitions.EntityTypeId;
+import org.eclipse.winery.common.ids.definitions.NodeTypeId;
+import org.eclipse.winery.common.ids.definitions.RelationshipTypeId;
+import org.eclipse.winery.model.tosca.TEntityType;
+import org.eclipse.winery.model.tosca.TNodeTemplate;
+import org.eclipse.winery.model.tosca.TNodeType;
+import org.eclipse.winery.model.tosca.TRelationshipTemplate;
+import org.eclipse.winery.model.tosca.TRelationshipType;
+import org.eclipse.winery.model.tosca.TTopologyTemplate;
+import org.eclipse.winery.repository.backend.RepositoryFactory;
+import org.eclipse.winery.topologygraph.model.ToscaEdge;
+import org.eclipse.winery.topologygraph.model.ToscaEdgeFactory;
+import org.eclipse.winery.topologygraph.model.ToscaEntity;
+import org.eclipse.winery.topologygraph.model.ToscaGraph;
+import org.eclipse.winery.topologygraph.model.ToscaNode;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+public class ToscaTransformer {
+
+ public static ToscaGraph createTOSCAGraph(TTopologyTemplate topologyTemplate) {
+ ToscaGraph graph = new ToscaGraph(new ToscaEdgeFactory());
+ @NonNull List relationshipTemplates = topologyTemplate.getRelationshipTemplates();
+ @NonNull List nodeTemplates = topologyTemplate.getNodeTemplates();
+ Map nodes = new HashMap<>();
+ for (TNodeTemplate nodeTemplate : nodeTemplates) {
+ ToscaNode node = createAndInitializeTOSCANode(nodeTemplate);
+ nodes.put(nodeTemplate, node);
+ graph.addVertex(node);
+ }
+ for (TRelationshipTemplate tRelationshipTemplate : relationshipTemplates) {
+ ToscaEdge edge = graph.addEdge(nodes.get(tRelationshipTemplate.getSourceElement().getRef()), nodes.get(tRelationshipTemplate.getTargetElement().getRef()));
+ initializeTOSCAEdge(tRelationshipTemplate, edge);
+ }
+ return graph;
+ }
+
+ protected static void initializeTOSCAEdge(TRelationshipTemplate tRelationshipTemplate, ToscaEdge edge) {
+ edge.setTemplate(tRelationshipTemplate);
+ addTEntityTypes(tRelationshipTemplate.getType(), edge, TRelationshipType.class);
+ }
+
+ protected static ToscaNode createAndInitializeTOSCANode(TNodeTemplate nodeTemplate) {
+ ToscaNode node = new ToscaNode();
+ node.setNodeTemplate(nodeTemplate);
+ addTEntityTypes(nodeTemplate.getType(), node, TNodeType.class);
+ return node;
+ }
+
+ public static void addTEntityTypes(QName nodeTypeQName, ToscaEntity entity, Class extends TEntityType> tEntityTypeClass) {
+ TEntityType entityType = getEntityType(nodeTypeQName, tEntityTypeClass);
+ entity.addTEntityType(entityType);
+
+ Optional.of(entityType).map(TEntityType::getDerivedFrom)
+ .map(TEntityType.DerivedFrom::getTypeRef)
+ .ifPresent(qName -> addTEntityTypes(qName, entity, tEntityTypeClass));
+ }
+
+ protected static TEntityType getEntityType(QName qName, Class extends TEntityType> tEntityTypeClass) {
+ EntityTypeId ntId = null;
+ if (tEntityTypeClass.isAssignableFrom(TNodeType.class)) {
+ return RepositoryFactory.getRepository().getElement(new NodeTypeId(qName));
+ }
+ if (tEntityTypeClass.isAssignableFrom(TRelationshipType.class)) {
+ return RepositoryFactory.getRepository().getElement(new RelationshipTypeId(qName));
+ }
+ return null;
+ }
+}
diff --git a/pom.xml b/pom.xml
index c5e0da9645..9351defc0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
2.1.0
2.19.0
0.95
+ 1.0.1
1.7.25