Package org.emftrace.metamodel.RuleModel

Examples of org.emftrace.metamodel.RuleModel.BaseCondition


      accessLayer.addElement(project, rule);
      accessLayer.addElement(project, logicCondition);
     
      rule.setConditions(logicCondition);
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      accessLayer.addElement(project, bc1);
      accessLayer.addElement(project, bc2);
     
      logicCondition.getBaseConditions().add(bc1);
View Full Code Here


        rule.getElements().add(e2);
       
        e1.setAlias("number_1");
        e2.setAlias("number_2");
       
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, baseCondition);
        accessLayer.addElement(project, logicCondition);
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition);
        logicCondition.setType(LogicConditionType.AND);
        baseCondition.setSource("number_1::Id");
        baseCondition.setTarget("number_2::Id");
       
        List<EObject[]> tuples = new ArrayList<EObject[]>();
       
        // test "EQUALS":
        baseCondition.setType(BaseConditionType.VALUE_EQUALS);       
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        assertEquals(1, result.get(0).size()); // test this once...
        assertEquals(1, result.get(1).size());
        c1.setId("test_addition");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        assertEquals(0, result.get(0).size());
        assertEquals(0, result.get(1).size());
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "STARTS_WITH":
        c1.setId("test_bla");
        baseCondition.setType(BaseConditionType.VALUE_STARTS_WITH);       
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("bla");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "ENDS_WITH":
        c1.setId("test");
        baseCondition.setType(BaseConditionType.VALUE_ENDS_WITH);       
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("test_bla");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "CONTAINS":
        c1.setId("test_addition");
        baseCondition.setType(BaseConditionType.VALUE_CONTAINS);       
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("tes");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "SIMILAR_TO"
        conditionProcessor.setCorrelation(0.5f);
        c1.setId("test1");
        baseCondition.setType(BaseConditionType.VALUE_SIMILAR_TO);       
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("tast");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
               
        // test "LESSER_THAN":
        c1.setId("1");
        c2.setId("2");
        baseCondition.setType(BaseConditionType.VALUE_LESSER_THAN);
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("2");
        c2.setId("1");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "GREATER_THAN":
        c1.setId("2");
        c2.setId("1");
        baseCondition.setType(BaseConditionType.VALUE_GREATER_THAN);
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        c1.setId("1");
        c2.setId("2");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
       
        // test "IS_PARENT":
        result.get(0).clear();
        result.get(0).add(rule);
        result.get(1).clear();
        result.get(1).add(baseCondition);
        baseCondition.setSource("number_1");
        baseCondition.setTarget("number_2");
        baseCondition.setType(BaseConditionType.MODEL_PARENT_OF);
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        baseCondition.setSource("number_2");
        baseCondition.setTarget("number_1");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
       
        // test "MODEL_EQUALS":
        baseCondition.setType(BaseConditionType.MODEL_EQUALS);
        baseCondition.setSource("e1::Source");
        baseCondition.setTarget("e2");
       
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("TraceLink");
        e2.setType("Actor");
       
        TraceLink link  = LinkModelFactory.eINSTANCE.createTraceLink();
        Actor     actor = URNModelFactory.eINSTANCE.createActor();
       
        accessLayer.addElement(project, link);
        accessLayer.addElement(project, actor);
             
        link.setSource(actor);
       
        result.get(0).clear();
        result.get(1).clear();
        result.get(0).add(link);
        result.get(1).add(actor);
               
        assertEquals(1, result.get(0).size());
        assertEquals(1, result.get(1).size());
        assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        assertEquals(1, result.get(0).size());
        assertEquals(1, result.get(1).size());
       
        baseCondition.setSource("e1::Target");
        assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
        assertEquals(0, result.get(0).size());
        assertEquals(0, result.get(1).size());
    }
View Full Code Here

        rule.getElements().add(e2);
       
        e1.setAlias("number_1");
        e2.setAlias("number_2");
       
        BaseCondition baseCondition1 = RuleModelFactory.eINSTANCE.createBaseCondition();
        BaseCondition baseCondition2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, baseCondition1);
        accessLayer.addElement(project, baseCondition2);
        accessLayer.addElement(project, logicCondition);
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition1);
        logicCondition.getBaseConditions().add(baseCondition2);
        baseCondition1.setSource("number_1::Id");
        baseCondition1.setTarget("number_2::Id");
        baseCondition1.setType(BaseConditionType.VALUE_EQUALS);
        baseCondition2.setSource("number_1::name");
        baseCondition2.setTarget("number_2::name");
        baseCondition2.setType(BaseConditionType.VALUE_EQUALS);
       
        List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
        tuples.add(new ArrayList<EObject[]>());
        tuples.add(new ArrayList<EObject[]>());
       
View Full Code Here

        rule.getElements().add(e2);
       
        e1.setAlias("number_1");
        e2.setAlias("number_2");
       
        BaseCondition baseCondition1 = RuleModelFactory.eINSTANCE.createBaseCondition();
        BaseCondition baseCondition2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, baseCondition1);
        accessLayer.addElement(project, baseCondition2);
        accessLayer.addElement(project, logicCondition);
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition1);
        logicCondition.getBaseConditions().add(baseCondition2);
        baseCondition1.setSource("number_1::Id");
        baseCondition1.setTarget("number_2::Id");
        baseCondition1.setType(BaseConditionType.VALUE_EQUALS);
        baseCondition2.setSource("number_1::name");
        baseCondition2.setTarget("number_2::name");
        baseCondition2.setType(BaseConditionType.VALUE_EQUALS);
       
        c1.setId("1");
        c2.setId("1");
        c1.setName("name");
        c2.setName("name");
View Full Code Here

            rule.getElements().add(e2);
           
            e1.setAlias("number_1");
            e2.setAlias("number_2");
           
            BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
            LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, baseCondition);
            accessLayer.addElement(project, logicCondition);
           
            rule.setConditions(logicCondition);
            logicCondition.getBaseConditions().add(baseCondition);
            logicCondition.setType(LogicConditionType.AND);
            baseCondition.setSource("number_1::Id");
            baseCondition.setTarget("number_2::Id");
           
            List<EObject[]> tuples = new ArrayList<EObject[]>();
           
            // test "EQUALS":
            baseCondition.setType(BaseConditionType.VALUE_EQUALS);       
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            assertEquals(1, result.get(0).size()); // test this once...
            assertEquals(1, result.get(1).size());
            c1.setId("test_addition");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            assertEquals(0, result.get(0).size());
            assertEquals(0, result.get(1).size());
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "STARTS_WITH":
            c1.setId("test_bla");
            baseCondition.setType(BaseConditionType.VALUE_STARTS_WITH);       
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("bla");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "ENDS_WITH":
            c1.setId("test");
            baseCondition.setType(BaseConditionType.VALUE_ENDS_WITH);       
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("test_bla");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "CONTAINS":
            c1.setId("test_addition");
            baseCondition.setType(BaseConditionType.VALUE_CONTAINS);       
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("tes");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "SIMILAR_TO"
            c1.setId("test");
            baseCondition.setType(BaseConditionType.VALUE_SIMILAR_TO);       
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("tast");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
                   
            // test "LESSER_THAN":
            c1.setId("1");
            c2.setId("2");
            baseCondition.setType(BaseConditionType.VALUE_LESSER_THAN);
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("2");
            c2.setId("1");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "GREATER_THAN":
            c1.setId("2");
            c2.setId("1");
            baseCondition.setType(BaseConditionType.VALUE_GREATER_THAN);
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            c1.setId("1");
            c2.setId("2");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
           
            // test "IS_PARENT":
            result.get(0).clear();
            result.get(0).add(rule);
            result.get(1).clear();
            result.get(1).add(baseCondition);
            baseCondition.setSource("number_1");
            baseCondition.setTarget("number_2");
            baseCondition.setType(BaseConditionType.MODEL_PARENT_OF);
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            baseCondition.setSource("number_2");
            baseCondition.setTarget("number_1");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
           
            // test "MODEL_EQUALS":
            baseCondition.setType(BaseConditionType.MODEL_EQUALS);
            baseCondition.setSource("e1::Source");
            baseCondition.setTarget("e2");
           
            e1.setAlias("e1");
            e2.setAlias("e2");
            e1.setType("TraceLink");
            e2.setType("Actor");
           
            TraceLink link  = LinkModelFactory.eINSTANCE.createTraceLink();
            Actor     actor = URNModelFactory.eINSTANCE.createActor();
           
            accessLayer.addElement(project, link);
            accessLayer.addElement(project, actor);
                 
            link.setSource(actor);
           
            result.get(0).clear();
            result.get(1).clear();
            result.get(0).add(link);
            result.get(1).add(actor);
                   
            assertEquals(1, result.get(0).size());
            assertEquals(1, result.get(1).size());
            assertTrue(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            assertEquals(1, result.get(0).size());
            assertEquals(1, result.get(1).size());
           
            baseCondition.setSource("e1::Target");
            assertFalse(conditionProcessor.executeBaseCondition(rule, result, baseCondition, tuples));
            assertEquals(0, result.get(0).size());
            assertEquals(0, result.get(1).size());
        return null;
      }
View Full Code Here

            rule.getElements().add(e2);
           
            e1.setAlias("number_1");
            e2.setAlias("number_2");
           
            BaseCondition baseCondition1 = RuleModelFactory.eINSTANCE.createBaseCondition();
            BaseCondition baseCondition2 = RuleModelFactory.eINSTANCE.createBaseCondition();
            LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, baseCondition1);
            accessLayer.addElement(project, baseCondition2);
            accessLayer.addElement(project, logicCondition);
           
            rule.setConditions(logicCondition);
            logicCondition.getBaseConditions().add(baseCondition1);
            logicCondition.getBaseConditions().add(baseCondition2);
            baseCondition1.setSource("number_1::Id");
            baseCondition1.setTarget("number_2::Id");
            baseCondition1.setType(BaseConditionType.VALUE_EQUALS);
            baseCondition2.setSource("number_1::name");
            baseCondition2.setTarget("number_2::name");
            baseCondition2.setType(BaseConditionType.VALUE_EQUALS);
           
            List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
            tuples.add(new ArrayList<EObject[]>());
            tuples.add(new ArrayList<EObject[]>());
           
View Full Code Here

            rule.getElements().add(e2);
           
            e1.setAlias("number_1");
            e2.setAlias("number_2");
           
            BaseCondition baseCondition1 = RuleModelFactory.eINSTANCE.createBaseCondition();
            BaseCondition baseCondition2 = RuleModelFactory.eINSTANCE.createBaseCondition();
            LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, baseCondition1);
            accessLayer.addElement(project, baseCondition2);
            accessLayer.addElement(project, logicCondition);
           
            rule.setConditions(logicCondition);
            logicCondition.getBaseConditions().add(baseCondition1);
            logicCondition.getBaseConditions().add(baseCondition2);
            baseCondition1.setSource("number_1::Id");
            baseCondition1.setTarget("number_2::Id");
            baseCondition1.setType(BaseConditionType.VALUE_EQUALS);
            baseCondition2.setSource("number_1::name");
            baseCondition2.setTarget("number_2::name");
            baseCondition2.setType(BaseConditionType.VALUE_EQUALS);
           
            c1.setId("1");
            c2.setId("1");
            c1.setName("name");
            c2.setName("name");
View Full Code Here

          rule2LC.setType(LogicConditionType.AND);
         
          impactRule1.setConditions(rule1LC);
          impactRule2.setConditions(rule2LC);
         
          BaseCondition rule1BC1 = RuleModelFactory.eINSTANCE.createBaseCondition();
          BaseCondition rule1BC2 = RuleModelFactory.eINSTANCE.createBaseCondition();
          BaseCondition rule2BC1 = RuleModelFactory.eINSTANCE.createBaseCondition();
          BaseCondition rule2BC2 = RuleModelFactory.eINSTANCE.createBaseCondition();
         
          accessLayer.addElement(project, rule1BC1);
          accessLayer.addElement(project, rule1BC2);
          accessLayer.addElement(project, rule2BC1);
          accessLayer.addElement(project, rule2BC2);
         
          rule1BC1.setType(BaseConditionType.VALUE_EQUALS);
          rule1BC1.setSource("e3::name");
          rule1BC1.setValue("rename");
         
          rule1BC2.setType(BaseConditionType.MODEL_RELATED_TO);
          rule1BC2.setSource("e1");
          rule1BC2.setTarget("e2");
          rule1BC2.setValue("refinement");     
         
          rule2BC1.setType(BaseConditionType.VALUE_EQUALS);
          rule2BC1.setSource("e3::name");
          rule2BC1.setValue("delete");
         
          rule2BC2.setType(BaseConditionType.MODEL_RELATED_TO);
          rule2BC2.setSource("e1");
          rule2BC2.setTarget("e2");
          rule2BC2.setValue("implements");
         
          rule1LC.getBaseConditions().add(rule1BC1);
          rule1LC.getBaseConditions().add(rule1BC2);
          rule2LC.getBaseConditions().add(rule2BC1);
          rule2LC.getBaseConditions().add(rule2BC2);
View Full Code Here

            Rule rule = RuleModelFactory.eINSTANCE.createRule();
            accessLayer.addElement(project, rule);
           
            LogicCondition cnd1 = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, cnd1);
            BaseCondition cnd2 = RuleModelFactory.eINSTANCE.createBaseCondition();
            accessLayer.addElement(project, cnd2);
             
            rule.setRuleID("TestRule");
            rule.setConditions(cnd1);
            cnd1.getBaseConditions().add(cnd2);
            cnd2.setSource("e1::Id");
            cnd2.setTarget("e2::Id");
           
            ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
            ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
            accessLayer.addElement(project, e1);
            accessLayer.addElement(project, e2);
View Full Code Here

            accessLayer.addElement(project, lc1);
            LogicCondition lc2 = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, lc2);
            LogicCondition lc3 = RuleModelFactory.eINSTANCE.createLogicCondition();
            accessLayer.addElement(project, lc3);
            BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
            accessLayer.addElement(project, bc1);
            BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
            accessLayer.addElement(project, bc2);
            BaseCondition bc3 = RuleModelFactory.eINSTANCE.createBaseCondition();
            accessLayer.addElement(project, bc3);
           
            lc2.setType(LogicConditionType.NOT);
             
            rule.setRuleID("TestRule");
            rule.setConditions(lc1);
            lc1.getBaseConditions().add(bc1);
            lc1.getLogicConditions().add(lc2);
            bc1.setSource("e1::name");
            bc1.setTarget("e2::name");
           
            bc2.setSource("e1::name");
            bc2.setValue("test");
           
            bc3.setSource("e1::name");
            bc3.setValue("test2");
           
            ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
            ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
            accessLayer.addElement(project, e1);
            accessLayer.addElement(project, e2);
View Full Code Here

TOP

Related Classes of org.emftrace.metamodel.RuleModel.BaseCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.