use of org.eclipse.winery.model.tosca.extensions.OTRelationMapping in project winery by eclipse.
the class ComponentPatternDetectionTest method prm2.
private OTPatternRefinementModel prm2() {
// region: detector
TNodeTemplate relationalDb = new TNodeTemplate(new TNodeTemplate.Builder("relationalDb-d2", QName.valueOf("{ns}relational-db")).setX("1").setY("1"));
ModelUtilities.setPropertiesKV(relationalDb, new LinkedHashMap<>());
TNodeTemplate privateCloud = new TNodeTemplate(new TNodeTemplate.Builder("privateCloud-d2", QName.valueOf("{ns}private-cloud")).setX("1").setY("1"));
ModelUtilities.setPropertiesKV(privateCloud, new LinkedHashMap<>());
TRelationshipTemplate relationalDbToPrivateCloud = new TRelationshipTemplate(new TRelationshipTemplate.Builder("relationalDb-privateCloud-d2", QName.valueOf("{ns}hostedOn"), relationalDb, privateCloud));
TTopologyTemplate detector = new TTopologyTemplate(new TTopologyTemplate.Builder().addNodeTemplates(Arrays.asList(relationalDb, privateCloud)).addRelationshipTemplates(Arrays.asList(relationalDbToPrivateCloud)));
// endregion
// region: refinement
TNodeTemplate database = new TNodeTemplate(new TNodeTemplate.Builder("database-rs2", QName.valueOf("{ns}mysql-db-5.7")).setX("1").setY("1"));
TNodeTemplate dbms = new TNodeTemplate(new TNodeTemplate.Builder("dbms-rs2", QName.valueOf("{ns}mysql-dbms-5.7")).setX("1").setY("1"));
TNodeTemplate vm = new TNodeTemplate(new TNodeTemplate.Builder("windows-server-2019-rs2", QName.valueOf("{ns}vm")).setX("1").setY("1"));
TNodeTemplate vsphere = new TNodeTemplate(new TNodeTemplate.Builder("vsphere-rs2", QName.valueOf("{ns}vsphere-7")).setX("1").setY("1"));
LinkedHashMap<String, String> dbProps = new LinkedHashMap<>();
dbProps.put("dbName", "database");
ModelUtilities.setPropertiesKV(database, dbProps);
LinkedHashMap<String, String> dbmsProps = new LinkedHashMap<>();
dbmsProps.put("adminPort", "33062");
ModelUtilities.setPropertiesKV(dbms, dbmsProps);
LinkedHashMap<String, String> vmProps = new LinkedHashMap<>();
vmProps.put("ram", "64GB");
ModelUtilities.setPropertiesKV(vm, vmProps);
LinkedHashMap<String, String> vsphereProps = new LinkedHashMap<>();
vsphereProps.put("api", "vsphere.uni-stuttgart");
ModelUtilities.setPropertiesKV(vsphere, vsphereProps);
TRelationshipTemplate dbToDbms = new TRelationshipTemplate(new TRelationshipTemplate.Builder("db-dbms-rs2", QName.valueOf("{ns}hostedOn"), database, dbms));
TRelationshipTemplate dbmsToVm = new TRelationshipTemplate(new TRelationshipTemplate.Builder("dbms-vm-rs2", QName.valueOf("{ns}hostedOn"), dbms, vm));
TRelationshipTemplate vmToVsphere = new TRelationshipTemplate(new TRelationshipTemplate.Builder("vm-vsphere-rs2", QName.valueOf("{ns}hostedOn"), vm, vsphere));
TTopologyTemplate refinement = new TTopologyTemplate(new TTopologyTemplate.Builder().addNodeTemplates(Arrays.asList(database, dbms, vm, vsphere)).addRelationshipTemplates(Arrays.asList(dbToDbms, dbmsToVm, vmToVsphere)));
// endregion
List<OTPermutationMapping> permutationMappings = new ArrayList<>();
permutationMappings.add(new OTPermutationMapping(new OTPermutationMapping.Builder().setDetectorElement(relationalDb).setRefinementElement(database)));
permutationMappings.add(new OTPermutationMapping(new OTPermutationMapping.Builder().setDetectorElement(privateCloud).setRefinementElement(vsphere)));
List<OTAttributeMapping> attributeMappings = new ArrayList<>();
attributeMappings.add(new OTAttributeMapping(new OTAttributeMapping.Builder().setDetectorElement(relationalDb).setDetectorProperty("name").setRefinementElement(database).setRefinementProperty("dbName").setType(OTAttributeMappingType.SELECTIVE)));
attributeMappings.add(new OTAttributeMapping(new OTAttributeMapping.Builder().setDetectorElement(privateCloud).setDetectorProperty("interface").setRefinementElement(vsphere).setRefinementProperty("api").setType(OTAttributeMappingType.SELECTIVE)));
List<OTRelationMapping> relationMappings = new ArrayList<>();
relationMappings.add(new OTRelationMapping(new OTRelationMapping.Builder().setDetectorElement(relationalDb).setRefinementElement(database).setRelationType("{ns}secureSqlConnection").setValidSourceOrTarget(null).setDirection(OTRelationDirection.INGOING)));
relationMappings.add(new OTRelationMapping(new OTRelationMapping.Builder().setDetectorElement(privateCloud).setRefinementElement(vm).setRelationType("{ns}hostedOn").setValidSourceOrTarget(null).setDirection(OTRelationDirection.INGOING)));
return new OTPatternRefinementModel(new OTPatternRefinementModel.Builder().setDetector(detector).setRefinementStructure(refinement).setPermutationMappings(permutationMappings).setAttributeMappings(attributeMappings).setRelationMappings(relationMappings));
}
use of org.eclipse.winery.model.tosca.extensions.OTRelationMapping in project winery by eclipse.
the class ComponentPatternDetectionTest method prm1.
private OTPatternRefinementModel prm1() {
// region: detector
TNodeTemplate processorD = new TNodeTemplate(new TNodeTemplate.Builder("processor-d1", QName.valueOf("{ns}java-8-app")).setX("1").setY("1"));
LinkedHashMap<String, String> processorDProps = new LinkedHashMap<>();
processorDProps.put("port", "8081");
ModelUtilities.setPropertiesKV(processorD, processorDProps);
TNodeTemplate executionEnv = new TNodeTemplate(new TNodeTemplate.Builder("executionEnv-d1", QName.valueOf("{ns}execution-env")).setX("1").setY("1"));
TNodeTemplate privateCloud = new TNodeTemplate(new TNodeTemplate.Builder("privateCloud-d1", QName.valueOf("{ns}private-cloud")).setX("1").setY("1"));
TRelationshipTemplate processorDToExecutionEnv = new TRelationshipTemplate(new TRelationshipTemplate.Builder("processorD-executionEnv-d1", QName.valueOf("{ns}hostedOn"), processorD, executionEnv));
TRelationshipTemplate executionEnvToPrivateCloud = new TRelationshipTemplate(new TRelationshipTemplate.Builder("executionEnv-privateCloud-d1", QName.valueOf("{ns}hostedOn"), executionEnv, privateCloud));
TTopologyTemplate detector = new TTopologyTemplate(new TTopologyTemplate.Builder().addNodeTemplates(Arrays.asList(processorD, executionEnv, privateCloud)).addRelationshipTemplates(Arrays.asList(processorDToExecutionEnv, executionEnvToPrivateCloud)));
// endregion
// region: refinement
TNodeTemplate processorRs = new TNodeTemplate(new TNodeTemplate.Builder("processor-rs1", QName.valueOf("{ns}java-8-app")).setX("1").setY("1"));
TNodeTemplate webserver = new TNodeTemplate(new TNodeTemplate.Builder("webserver-rs1", QName.valueOf("{ns}tomcat-9")).setX("1").setY("1"));
TNodeTemplate vm = new TNodeTemplate(new TNodeTemplate.Builder("ubuntu-2004-rs1", QName.valueOf("{ns}vm")).setX("1").setY("1"));
TNodeTemplate openstack = new TNodeTemplate(new TNodeTemplate.Builder("openstack-rs1", QName.valueOf("{ns}openstack-victoria")).setX("1").setY("1"));
LinkedHashMap<String, String> processorRsProps = new LinkedHashMap<>();
processorRsProps.put("port", "8081");
ModelUtilities.setPropertiesKV(processorRs, processorRsProps);
LinkedHashMap<String, String> webserverProps = new LinkedHashMap<>();
webserverProps.put("jmxPort", "9091");
ModelUtilities.setPropertiesKV(webserver, webserverProps);
LinkedHashMap<String, String> vmProps = new LinkedHashMap<>();
vmProps.put("ram", "128GB");
ModelUtilities.setPropertiesKV(vm, vmProps);
LinkedHashMap<String, String> openstackProps = new LinkedHashMap<>();
openstackProps.put("api", "openstack.uni-stuttgart");
ModelUtilities.setPropertiesKV(openstack, openstackProps);
TRelationshipTemplate processorToWebserver = new TRelationshipTemplate(new TRelationshipTemplate.Builder("processor-webserver-rs1", QName.valueOf("{ns}hostedOn"), processorRs, webserver));
TRelationshipTemplate webserverToVm = new TRelationshipTemplate(new TRelationshipTemplate.Builder("webserver-vm-rs1", QName.valueOf("{ns}hostedOn"), webserver, vm));
TRelationshipTemplate vmToOpenstack = new TRelationshipTemplate(new TRelationshipTemplate.Builder("vm-openstack-rs1", QName.valueOf("{ns}hostedOn"), vm, openstack));
TTopologyTemplate refinement = new TTopologyTemplate(new TTopologyTemplate.Builder().addNodeTemplates(Arrays.asList(processorRs, webserver, vm, openstack)).addRelationshipTemplates(Arrays.asList(processorToWebserver, webserverToVm, vmToOpenstack)));
// endregion
OTStayMapping stayMapping = new OTStayMapping(new OTStayMapping.Builder().setDetectorElement(processorD).setRefinementElement(processorRs));
List<OTPermutationMapping> permutationMappings = new ArrayList<>();
permutationMappings.add(new OTPermutationMapping(new OTPermutationMapping.Builder().setDetectorElement(executionEnv).setRefinementElement(webserver)));
permutationMappings.add(new OTPermutationMapping(new OTPermutationMapping.Builder().setDetectorElement(privateCloud).setRefinementElement(openstack)));
List<OTAttributeMapping> attributeMappings = new ArrayList<>();
attributeMappings.add(new OTAttributeMapping(new OTAttributeMapping.Builder().setDetectorElement(executionEnv).setDetectorProperty("port").setRefinementElement(webserver).setRefinementProperty("jmxPort").setType(OTAttributeMappingType.SELECTIVE)));
attributeMappings.add(new OTAttributeMapping(new OTAttributeMapping.Builder().setDetectorElement(privateCloud).setDetectorProperty("interface").setRefinementElement(openstack).setRefinementProperty("api").setType(OTAttributeMappingType.SELECTIVE)));
List<OTRelationMapping> relationMappings = new ArrayList<>();
relationMappings.add(new OTRelationMapping(new OTRelationMapping.Builder().setDetectorElement(privateCloud).setRefinementElement(vm).setRelationType("{ns}hostedOn").setValidSourceOrTarget(null).setDirection(OTRelationDirection.INGOING)));
return new OTPatternRefinementModel(new OTPatternRefinementModel.Builder().setDetector(detector).setRefinementStructure(refinement).setStayMappings(Arrays.asList(stayMapping)).setPermutationMappings(permutationMappings).setAttributeMappings(attributeMappings).setRelationMappings(relationMappings));
}
use of org.eclipse.winery.model.tosca.extensions.OTRelationMapping in project winery by eclipse.
the class AbstractRefinementTest method setUp.
protected static void setUp() {
// region *** topology ***
TNodeTemplate nt1 = new TNodeTemplate.Builder("1", QName.valueOf("{http://ex.org}nodeType_1")).setX("10").setY("10").build();
TNodeTemplate nt2 = new TNodeTemplate.Builder("2", QName.valueOf("{http://ex.org}nodeType_2")).setX("110").setY("10").build();
TNodeTemplate nt3 = new TNodeTemplate.Builder("3", QName.valueOf("{http://ex.org}nodeType_3")).setX("210").setY("10").build();
TNodeTemplate nt4 = new TNodeTemplate.Builder("4", QName.valueOf("{http://ex.org}nodeType_4")).setX("110").setY("110").build();
TRelationshipTemplate rt21 = new TRelationshipTemplate.Builder("21", QName.valueOf("{http://ex.org}relType_1"), nt2, nt1).build();
TRelationshipTemplate rt32 = new TRelationshipTemplate.Builder("32", QName.valueOf("{http://ex.org}relType_1"), nt3, nt2).build();
TRelationshipTemplate rt24 = new TRelationshipTemplate.Builder("24", QName.valueOf("{http://ex.org}relType_2"), nt2, nt4).build();
/*
####### (1) ####### (1) #######
# (1) # <----- # (2) # <----- # (3) #
####### ####### #######
| (2)
\/
#######
# (4) #
#######
*/
topology = new TTopologyTemplate.Builder().addNodeTemplate(nt1).addNodeTemplate(nt2).addNodeTemplate(nt3).addNodeTemplate(nt4).addRelationshipTemplate(rt21).addRelationshipTemplate(rt32).addRelationshipTemplate(rt24).build();
// endregion
// region *** topology2 ***
/*
####### (1) #######
# (1) # <----- # (2) #
####### #######
| (2)
\/
#######
# (4) #
#######
*/
topology2 = new TTopologyTemplate.Builder().addNodeTemplate(nt1).addNodeTemplate(nt2).addNodeTemplate(nt4).addRelationshipTemplate(rt21).addRelationshipTemplate(rt24).build();
// endregion
// region *** topology 3 ***
/*
####### (1) #######
# (1) # <----- # (2) #
####### #######
| (2)
\/
#######----|
# (4) # DA |
#######----|
*/
QName artifactTypeFile = new QName("file", "http://example.org/tosca/at");
QName test_da = new QName("test_da", "http://example.org/tosca/atemp/das");
TNodeTemplate nt30 = new TNodeTemplate.Builder("30", QName.valueOf("{http://ex.org}nodeType_4")).setX("110").setY("110").build();
TRelationshipTemplate rt230 = new TRelationshipTemplate.Builder("302", QName.valueOf("{http://ex.org}relType_2"), nt2, nt30).build();
TDeploymentArtifact da = new TDeploymentArtifact.Builder("test_da", artifactTypeFile).setArtifactRef(test_da).build();
nt30.setDeploymentArtifacts(new ArrayList<>(Collections.singletonList(da)));
topology3 = new TTopologyTemplate.Builder().addNodeTemplate(nt1).addNodeTemplate(nt2).addNodeTemplate(nt30).addRelationshipTemplate(rt21).addRelationshipTemplate(rt230).build();
// endregion
// region *** topology4 ***
TRelationshipTemplate rt14 = new TRelationshipTemplate.Builder("14", QName.valueOf("{http://ex.org}relType_1"), nt1, nt4).build();
/*
####### (1) #######
# (3) # -----># (2) #
####### #######
| (2)
\/
####### (1) #######
# (1) # -----># (4) #
####### #######
*/
topology4 = new TTopologyTemplate.Builder().addNodeTemplate(nt1).addNodeTemplate(nt2).addNodeTemplate(nt3).addNodeTemplate(nt4).addRelationshipTemplate(rt32).addRelationshipTemplate(rt14).addRelationshipTemplate(rt24).build();
// endregion
// region *** matching PRM ***
// region *** detector ***
TNodeTemplate nt7 = new TNodeTemplate.Builder("7", QName.valueOf("{http://ex.org}nodeType_2")).build();
TNodeTemplate nt8 = new TNodeTemplate.Builder("8", QName.valueOf("{http://ex.org}nodeType_4")).build();
TRelationshipTemplate rt78 = new TRelationshipTemplate.Builder("78", QName.valueOf("{http://ex.org}relType_2"), nt7, nt8).build();
/*
#######
# (2) #
#######
| (2)
\/
#######
# (4) #
#######
*/
TTopologyTemplate detector = new TTopologyTemplate.Builder().addNodeTemplate(nt7).addNodeTemplate(nt8).addRelationshipTemplate(rt78).build();
// endregion
// region *** refinement structure
TNodeTemplate nt10 = new TNodeTemplate.Builder("10", QName.valueOf("{http://ex.org}nodeType_10")).setX("5").setY("10").build();
TNodeTemplate nt11 = new TNodeTemplate.Builder("11", QName.valueOf("{http://ex.org}nodeType_11")).setX("105").setY("5").build();
TNodeTemplate nt12 = new TNodeTemplate.Builder("12", QName.valueOf("{http://ex.org}nodeType_12")).setX("55").setY("105").build();
TNodeTemplate nt13 = new TNodeTemplate.Builder("13", QName.valueOf("{http://ex.org}nodeType_13")).setX("55").setY("205").build();
TRelationshipTemplate rt1012 = new TRelationshipTemplate.Builder("1012", QName.valueOf("{http://ex.org}relType_2"), nt10, nt12).build();
TRelationshipTemplate rt1112 = new TRelationshipTemplate.Builder("1112", QName.valueOf("{http://ex.org}relType_2"), nt11, nt12).build();
TRelationshipTemplate rt1213 = new TRelationshipTemplate.Builder("1213", QName.valueOf("{http://ex.org}relType_2"), nt12, nt13).build();
/*
######## ########
# (10) # # (11) #
######## ########
| (2) | (2)
+-------|------+
\/
########
# (12) #
########
| (2)
\/
########
# (13) #
########
*/
TTopologyTemplate refinementStructure = new TTopologyTemplate.Builder().addNodeTemplate(nt10).addNodeTemplate(nt11).addNodeTemplate(nt12).addNodeTemplate(nt13).addRelationshipTemplate(rt1012).addRelationshipTemplate(rt1112).addRelationshipTemplate(rt1213).build();
// endregion
// region *** relation mapping ***
OTRelationMapping rm1 = new OTRelationMapping(new OTRelationMapping.Builder());
rm1.setDetectorElement(nt7);
rm1.setRelationType(QName.valueOf("{http://ex.org}relType_1"));
rm1.setDirection(OTRelationDirection.INGOING);
rm1.setValidSourceOrTarget(QName.valueOf("{http://ex.org}nodeType_3"));
rm1.setRefinementElement(nt11);
OTRelationMapping rm2 = new OTRelationMapping(new OTRelationMapping.Builder());
rm2.setDetectorElement(nt7);
rm2.setRelationType(QName.valueOf("{http://ex.org}relType_1"));
rm2.setDirection(OTRelationDirection.OUTGOING);
rm2.setValidSourceOrTarget(QName.valueOf("{http://ex.org}nodeType_1"));
rm2.setRefinementElement(nt10);
// endregion
OTPatternRefinementModel prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2 = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2.setDetector(detector);
prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2.setRefinementTopology(refinementStructure);
ToscaGraph topologyGraph = ToscaTransformer.createTOSCAGraph(topology);
ToscaGraph detectorGraph = ToscaTransformer.createTOSCAGraph(detector);
ToscaIsomorphismMatcher matcher = new ToscaIsomorphismMatcher();
Iterator<GraphMapping<ToscaNode, ToscaEdge>> mappings = matcher.findMatches(detectorGraph, topologyGraph, new ToscaTypeMatcher());
GraphMapping<ToscaNode, ToscaEdge> detectorWithTopologyMapping = mappings.next();
List<OTRelationMapping> relationMappings = new ArrayList<>();
relationMappings.add(rm1);
relationMappings.add(rm2);
prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2.setRelationMappings(relationMappings);
candidateForTopology = new RefinementCandidate(prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2, detectorWithTopologyMapping, detectorGraph, 1);
// endregion
// region *** invalidCandidateForTopology **
OTPatternRefinementModel prmWithNt2HostedOnNt4AndOutgoingRt1AtNt2 = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
prmWithNt2HostedOnNt4AndOutgoingRt1AtNt2.setDetector(detector);
List<OTRelationMapping> relationMappingsNonMatchingPrm = new ArrayList<>();
relationMappingsNonMatchingPrm.add(rm2);
prmWithNt2HostedOnNt4AndOutgoingRt1AtNt2.setRelationMappings(relationMappingsNonMatchingPrm);
invalidCandidateForTopology = new RefinementCandidate(prmWithNt2HostedOnNt4AndOutgoingRt1AtNt2, detectorWithTopologyMapping, detectorGraph, 2);
// endregion
// region *** Candidates for Topology 2 ***
ToscaGraph topology2Graph = ToscaTransformer.createTOSCAGraph(topology2);
GraphMapping<ToscaNode, ToscaEdge> detectorWithTopology2Mapping = matcher.findMatches(detectorGraph, topology2Graph, new ToscaTypeMatcher()).next();
candidateForTopology2 = new RefinementCandidate(prmWithNt2HostedOnNt4AndIngoingRt1AtNt2AndOutgoingRt1AtNt2, detectorWithTopology2Mapping, detectorGraph, 3);
secondValidCandidateForTopology2 = new RefinementCandidate(prmWithNt2HostedOnNt4AndOutgoingRt1AtNt2, detectorWithTopology2Mapping, detectorGraph, 4);
// endregion
// region *** Candidates for Topology 3 ***
ToscaGraph topologyGraph3 = ToscaTransformer.createTOSCAGraph(topology3);
GraphMapping<ToscaNode, ToscaEdge> detectorToTopology3Mapping = new ToscaIsomorphismMatcher().findMatches(detectorGraph, topologyGraph3, new ToscaTypeMatcher()).next();
OTDeploymentArtifactMapping deploymentArtifactMapping1 = new OTDeploymentArtifactMapping(new OTDeploymentArtifactMapping.Builder());
deploymentArtifactMapping1.setId("daMap-1");
deploymentArtifactMapping1.setArtifactType(artifactTypeFile);
deploymentArtifactMapping1.setDetectorElement(nt8);
deploymentArtifactMapping1.setRefinementElement(nt13);
OTPatternRefinementModel matchingPrmWithDa = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
matchingPrmWithDa.setDetector(detector);
matchingPrmWithDa.setRefinementTopology(refinementStructure);
matchingPrmWithDa.setDeploymentArtifactMappings(Collections.singletonList(deploymentArtifactMapping1));
matchingPrmWithDa.setRelationMappings(relationMappings);
candidateForTopology3WithDa = new RefinementCandidate(matchingPrmWithDa, detectorToTopology3Mapping, detectorGraph, 5);
QName artifactTypeZip = new QName("zip", "http://example.org/tosca/at");
OTDeploymentArtifactMapping deploymentArtifactMapping2 = new OTDeploymentArtifactMapping(new OTDeploymentArtifactMapping.Builder());
deploymentArtifactMapping2.setId("daMap-1");
deploymentArtifactMapping2.setArtifactType(artifactTypeZip);
deploymentArtifactMapping2.setDetectorElement(nt7);
deploymentArtifactMapping2.setRefinementElement(nt11);
OTPatternRefinementModel nonMatchingPrmWithDa = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
nonMatchingPrmWithDa.setDetector(detector);
nonMatchingPrmWithDa.setRefinementTopology(refinementStructure);
nonMatchingPrmWithDa.setDeploymentArtifactMappings(Collections.singletonList(deploymentArtifactMapping2));
nonMatchingPrmWithDa.setRelationMappings(relationMappings);
candidateForTopology3WithNotMatchingDa = new RefinementCandidate(nonMatchingPrmWithDa, detectorToTopology3Mapping, detectorGraph, 6);
// endregion
// region *** Candidates for Topology 4 ***
ToscaGraph topology4Graph = ToscaTransformer.createTOSCAGraph(topology4);
GraphMapping<ToscaNode, ToscaEdge> detectorWithTopology4Mapping = matcher.findMatches(detectorGraph, topology4Graph, new ToscaTypeMatcher()).next();
OTRelationMapping rm3 = new OTRelationMapping(new OTRelationMapping.Builder());
rm3.setRelationType(QName.valueOf("{http://ex.org}relType_1"));
rm3.setDirection(OTRelationDirection.INGOING);
rm3.setDetectorElement(nt7);
rm3.setRefinementElement(nt11);
OTPatternRefinementModel prmWithNT2HostedOnNT4AndIngoingRT1AtNT2 = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2.setDetector(detector);
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2.setRefinementTopology(refinementStructure);
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2.setRelationMappings(Collections.singletonList(rm3));
invalidCandidateForTopology4 = new RefinementCandidate(prmWithNT2HostedOnNT4AndIngoingRT1AtNT2, detectorWithTopology4Mapping, detectorGraph, 7);
OTRelationMapping rm4 = new OTRelationMapping(new OTRelationMapping.Builder());
rm4.setRelationType(QName.valueOf("{http://ex.org}relType_1"));
rm4.setDirection(OTRelationDirection.INGOING);
rm4.setDetectorElement(nt8);
rm4.setRefinementElement(nt13);
OTPatternRefinementModel prmWithNT2HostedOnNT4AndIngoingRT1AtNT2AndIngoingRT1AtNT4 = new OTPatternRefinementModel(new OTPatternRefinementModel.Builder());
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2AndIngoingRT1AtNT4.setDetector(detector);
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2AndIngoingRT1AtNT4.setRefinementTopology(refinementStructure);
prmWithNT2HostedOnNT4AndIngoingRT1AtNT2AndIngoingRT1AtNT4.setRelationMappings(Arrays.asList(rm3, rm4));
validCandidateForTopology4 = new RefinementCandidate(prmWithNT2HostedOnNT4AndIngoingRT1AtNT2AndIngoingRT1AtNT4, detectorWithTopology4Mapping, detectorGraph, 8);
// endregion
}
use of org.eclipse.winery.model.tosca.extensions.OTRelationMapping in project winery by eclipse.
the class PermutationHelper method generatePrmWithoutPermutationMaps.
static OTPatternRefinementModel generatePrmWithoutPermutationMaps() {
/*
######## ######## ########
# (1) #---------------> # (11) # -----> # (12) #
######## ######## ########
| (2) |______________| (2)
| (2) \/
\/ ########
########---------------> # (13) #
# (2) # ########
######## | (2)
| \/
| (2) ########
\/ # (15) #
########---------------> ########
# (3) #
########
*/
TTopologyTemplate detector = generateDetectorWithThreePatterns();
// region refinement structure
TNodeTemplate refinementNode_11 = new TNodeTemplate();
refinementNode_11.setType("{http://ex.org}nodeType_11");
refinementNode_11.setId("11");
TNodeTemplate refinementNode_12 = new TNodeTemplate();
refinementNode_12.setType("{http://ex.org}nodeType_12");
refinementNode_12.setId("12");
TNodeTemplate refinementNode_13 = new TNodeTemplate();
refinementNode_13.setType("{http://ex.org}nodeType_13");
refinementNode_13.setId("13");
TNodeTemplate refinementNode_14 = new TNodeTemplate();
refinementNode_14.setType("{http://ex.org}nodeType_14");
refinementNode_14.setId("14");
TNodeTemplate refinementNode_15 = new TNodeTemplate();
refinementNode_15.setType("{http://ex.org}nodeType_15");
refinementNode_15.setId("15");
TRelationshipTemplate node11_hostedOn_node13 = ModelUtilities.createRelationshipTemplate(refinementNode_11, refinementNode_13, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node12_hostedOn_node13 = ModelUtilities.createRelationshipTemplate(refinementNode_12, refinementNode_13, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node13_hostedOn_node14 = ModelUtilities.createRelationshipTemplate(refinementNode_13, refinementNode_14, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node14_hostedOn_node15 = ModelUtilities.createRelationshipTemplate(refinementNode_14, refinementNode_15, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node11_connectsTo_node12 = ModelUtilities.createRelationshipTemplate(refinementNode_11, refinementNode_12, QName.valueOf("{http://ex.org}relType_connectsTo"));
TTopologyTemplate refinementStructure = new TTopologyTemplate.Builder().addNodeTemplate(refinementNode_11).addNodeTemplate(refinementNode_12).addNodeTemplate(refinementNode_13).addNodeTemplate(refinementNode_14).addNodeTemplate(refinementNode_15).addRelationshipTemplate(node11_hostedOn_node13).addRelationshipTemplate(node12_hostedOn_node13).addRelationshipTemplate(node13_hostedOn_node14).addRelationshipTemplate(node14_hostedOn_node15).addRelationshipTemplate(node11_connectsTo_node12).build();
// endregion
// region mappings
OTRelationMapping pattern1_to_node11 = new OTRelationMapping.Builder("rm-1--11").setRelationType(QName.valueOf("{http://ex.org}relType_connectsTo")).setDirection(OTRelationDirection.INGOING).setDetectorElement(detector.getNodeTemplate("1")).setRefinementElement(refinementNode_11).build();
OTRelationMapping pattern2_to_node13 = new OTRelationMapping.Builder("rm-2--13").setRelationType(QName.valueOf("{http://ex.org}relType_hostedOn")).setDirection(OTRelationDirection.INGOING).setDetectorElement(detector.getNodeTemplate("2")).setRefinementElement(refinementNode_13).build();
OTRelationMapping pattern3_to_node14 = new OTRelationMapping.Builder("rm-3-14").setRelationType(QName.valueOf("{http://ex.org}relType_connectsTo")).setDirection(OTRelationDirection.INGOING).setDetectorElement(detector.getNodeTemplate("3")).setRefinementElement(refinementNode_14).build();
return new OTPatternRefinementModel.Builder().setName("SimplePrm").setTargetNamespace("http://ex.org").setDetector(detector).setRefinementStructure(refinementStructure).setRelationMappings(Arrays.asList(pattern1_to_node11, pattern2_to_node13, pattern3_to_node14)).build();
}
use of org.eclipse.winery.model.tosca.extensions.OTRelationMapping in project winery by eclipse.
the class PermutationHelper method generatePrmWithStayMapping.
static OTPatternRefinementModel generatePrmWithStayMapping() {
/*
######## ########
# (1) #----stay-------> # (11) #
######## ########
| (2) |
| (2) \/
\/ ########
########---------------> # (13) #
# (2) #--------+ ########
######## | | (2)
| | \/
| (2 +------> ########
\/ # (15) #
######## ########
# (3) #--------+ | (2)
######## | \/
| ########
+------> # (16) #
########
*/
TTopologyTemplate detector = generateDetectorWithThreePatterns();
// region refinement structure
TNodeTemplate refinementNode_11 = new TNodeTemplate();
refinementNode_11.setType("{http://ex.org}nodeType_11");
refinementNode_11.setId("11");
TNodeTemplate refinementNode_13 = new TNodeTemplate();
refinementNode_13.setType("{http://ex.org}nodeType_13");
refinementNode_13.setId("13");
TNodeTemplate refinementNode_15 = new TNodeTemplate();
refinementNode_15.setType("{http://ex.org}nodeType_15");
refinementNode_15.setId("15");
TNodeTemplate refinementNode_16 = new TNodeTemplate();
refinementNode_16.setType("{http://ex.org}nodeType_16");
refinementNode_16.setId("16");
TRelationshipTemplate node11_hostedOn_node13 = ModelUtilities.createRelationshipTemplate(refinementNode_11, refinementNode_13, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node13_hostedOn_node15 = ModelUtilities.createRelationshipTemplate(refinementNode_13, refinementNode_15, QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate node15_hostedOn_node16 = ModelUtilities.createRelationshipTemplate(refinementNode_15, refinementNode_16, QName.valueOf("{http://ex.org}relType_hostedOn"));
TTopologyTemplate refinementStructure = new TTopologyTemplate.Builder().addNodeTemplate(refinementNode_11).addNodeTemplate(refinementNode_13).addNodeTemplate(refinementNode_15).addNodeTemplate(refinementNode_16).addRelationshipTemplate(node11_hostedOn_node13).addRelationshipTemplate(node13_hostedOn_node15).addRelationshipTemplate(node15_hostedOn_node16).build();
// endregion
// region mappings
OTStayMapping pattern1_to_node11 = new OTStayMapping.Builder("sm-1--11").setDetectorElement(detector.getNodeTemplate("1")).setRefinementElement(refinementNode_11).build();
OTRelationMapping pattern2_to_node13 = new OTRelationMapping.Builder("pm-2--13").setRelationType("{http://ex.org}relType_hostedOn").setDirection(OTRelationDirection.INGOING).setDetectorElement(detector.getNodeTemplate("2")).setRefinementElement(refinementNode_13).build();
OTPermutationMapping pattern2_to_node15 = new OTPermutationMapping.Builder("pm-2--15").setDetectorElement(detector.getNodeTemplate("2")).setRefinementElement(refinementNode_15).build();
OTRelationMapping pattern3_to_node16 = new OTRelationMapping.Builder("pm-3--16").setRelationType(QName.valueOf("{http://ex.org}relType_connectsTo")).setDirection(OTRelationDirection.INGOING).setDetectorElement(detector.getNodeTemplate("3")).setRefinementElement(refinementNode_16).build();
// endregion
// region prm
ArrayList<OTPermutationMapping> mappings = new ArrayList<>();
mappings.add(pattern2_to_node15);
return new OTPatternRefinementModel.Builder().setName("PrmWithStaying").setTargetNamespace("http://ex.org").setDetector(detector).setRefinementStructure(refinementStructure).setRelationMappings(Arrays.asList(pattern2_to_node13, pattern3_to_node16)).setStayMappings(Collections.singletonList(pattern1_to_node11)).setPermutationMappings(mappings).build();
}
Aggregations