Search in sources :

Example 1 with TOSCANode

use of org.eclipse.winery.compliance.model.TOSCANode in project winery by eclipse.

the class ComplianceRuleChecker method extractViolatingMappings.

public List<GraphMapping> extractViolatingMappings(TOSCAGraph identifierGraph, List<GraphMapping> identifierMappings, List<GraphMapping> requiredStructureMappings) {
    List<GraphMapping> violatingMappings = new ArrayList<>();
    // for all mappings in identifierMappings, we need to find the corresponding required Structure Mappings
    for (GraphMapping identifierMapping : identifierMappings) {
        boolean foundCorrespondence = false;
        for (GraphMapping requiredStructureMapping : requiredStructureMappings) {
            // get the corresponding TOSCANode from the searchInGraph
            TOSCANode identifierVertexCorrespondence = (TOSCANode) identifierMapping.getVertexCorrespondence(identifierGraph.getReferenceNode(), false);
            foundCorrespondence = (requiredStructureMapping.getVertexCorrespondence(identifierVertexCorrespondence, true) != null) ? true : false;
        }
        if (!foundCorrespondence) {
            violatingMappings.add(identifierMapping);
        }
    }
    return violatingMappings;
}
Also used : ArrayList(java.util.ArrayList) TOSCANode(org.eclipse.winery.compliance.model.TOSCANode) GraphMapping(org.jgrapht.GraphMapping)

Example 2 with TOSCANode

use of org.eclipse.winery.compliance.model.TOSCANode in project winery by eclipse.

the class TOSCATransformer method createAndInitializeTOSCANode.

protected static TOSCANode createAndInitializeTOSCANode(TNodeTemplate nodeTemplate) {
    TOSCANode node = new TOSCANode();
    node.setNodeTemplate(nodeTemplate);
    addTEntityTypes(nodeTemplate.getType(), node, TNodeType.class);
    return node;
}
Also used : TOSCANode(org.eclipse.winery.compliance.model.TOSCANode)

Example 3 with TOSCANode

use of org.eclipse.winery.compliance.model.TOSCANode in project winery by eclipse.

the class TOSCAGraphIsomorphismTest method testTOSCADefaultMatcher.

@Test
public void testTOSCADefaultMatcher() {
    TOSCAEdgeFactory ef = new TOSCAEdgeFactory();
    TOSCAGraph queryGraph = new TOSCAGraph(ef);
    TOSCAGraph searchInGraph = new TOSCAGraph(ef);
    TOSCANode node1 = TOSCAModelHelper.createTOSCANode("node_01", "A");
    TOSCANode node2 = TOSCAModelHelper.createTOSCANode("node_02", "B");
    queryGraph.addVertex(node1);
    queryGraph.addVertex(node2);
    TOSCAEdge edge1 = TOSCAModelHelper.addEdge(queryGraph, node1, node2, "edge_1", "a");
    TOSCANode node3 = TOSCAModelHelper.createTOSCANode("node_03", "A");
    TOSCANode node4 = TOSCAModelHelper.createTOSCANode("node_04", "A");
    TOSCANode node5 = TOSCAModelHelper.createTOSCANode("node_05", "B");
    TOSCANode node6 = TOSCAModelHelper.createTOSCANode("node_06", "B");
    searchInGraph.addVertex(node3);
    searchInGraph.addVertex(node4);
    searchInGraph.addVertex(node5);
    searchInGraph.addVertex(node6);
    TOSCAEdge edge2 = TOSCAModelHelper.addEdge(searchInGraph, node3, node4, "edge_2", "b");
    TOSCAEdge edge3 = TOSCAModelHelper.addEdge(searchInGraph, node3, node5, "edge_3", "a");
    TOSCAEdge edge4 = TOSCAModelHelper.addEdge(searchInGraph, node4, node6, "edge_4", "a");
    TOSCAIsomorphismMatcher matcher = new TOSCAIsomorphismMatcher();
    Iterator<GraphMapping<TOSCANode, TOSCAEdge>> iterator = matcher.findMatches(queryGraph, searchInGraph, null);
    int isomorphismCount = 0;
    while (iterator.hasNext()) {
        isomorphismCount++;
        GraphMapping<TOSCANode, TOSCAEdge> mapping = iterator.next();
        TOSCAEdge edgeCor = mapping.getEdgeCorrespondence(edge1, false);
        TOSCANode nodeCor1 = mapping.getVertexCorrespondence(node1, false);
        TOSCANode nodeCor2 = mapping.getVertexCorrespondence(node2, false);
    }
    assertEquals(2, isomorphismCount);
}
Also used : TOSCAEdge(org.eclipse.winery.compliance.model.TOSCAEdge) TOSCAIsomorphismMatcher(org.eclipse.winery.compliance.matching.TOSCAIsomorphismMatcher) TOSCAGraph(org.eclipse.winery.compliance.model.TOSCAGraph) TOSCANode(org.eclipse.winery.compliance.model.TOSCANode) TOSCAEdgeFactory(org.eclipse.winery.compliance.model.TOSCAEdgeFactory) GraphMapping(org.jgrapht.GraphMapping) Test(org.junit.Test)

Example 4 with TOSCANode

use of org.eclipse.winery.compliance.model.TOSCANode in project winery by eclipse.

the class TOSCAModelHelper method createTOSCANode.

public static TOSCANode createTOSCANode(String id, String name) {
    TNodeTemplate template = new TNodeTemplate();
    template.setName(name);
    TOSCANode node = new TOSCANode();
    node.setNodeTemplate(template);
    return node;
}
Also used : TOSCANode(org.eclipse.winery.compliance.model.TOSCANode) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 5 with TOSCANode

use of org.eclipse.winery.compliance.model.TOSCANode in project winery by eclipse.

the class TOSCAModelHelper method createTOSCANodeOnlyProperties.

public static TOSCANode createTOSCANodeOnlyProperties(TOSCAModelPropertiesBuilder bldr) {
    TOSCANode node = new TOSCANode();
    node.setNodeTemplate(new TNodeTemplate());
    node.getNodeTemplate().setProperties(bldr.build());
    return node;
}
Also used : TOSCANode(org.eclipse.winery.compliance.model.TOSCANode) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Aggregations

TOSCANode (org.eclipse.winery.compliance.model.TOSCANode)9 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)4 GraphMapping (org.jgrapht.GraphMapping)4 TOSCAEdge (org.eclipse.winery.compliance.model.TOSCAEdge)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TOSCAEdgeFactory (org.eclipse.winery.compliance.model.TOSCAEdgeFactory)2 TOSCAGraph (org.eclipse.winery.compliance.model.TOSCAGraph)2 TComplianceRule (org.eclipse.winery.model.tosca.TComplianceRule)2 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)2 Test (org.junit.Test)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 QName (javax.xml.namespace.QName)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ComplianceRuleId (org.eclipse.winery.common.ids.definitions.ComplianceRuleId)1 DefinitionsChildId (org.eclipse.winery.common.ids.definitions.DefinitionsChildId)1 NodeTypeId (org.eclipse.winery.common.ids.definitions.NodeTypeId)1 RelationshipTypeId (org.eclipse.winery.common.ids.definitions.RelationshipTypeId)1 TOSCAModelHelper.createNodeTypeId (org.eclipse.winery.compliance.TOSCAModelHelper.createNodeTypeId)1 TOSCAModelHelper.createTComplianceRule (org.eclipse.winery.compliance.TOSCAModelHelper.createTComplianceRule)1