Package org.emftrace.metamodel.RuleModel

Examples of org.emftrace.metamodel.RuleModel.LogicCondition


            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[]>());
           
            // test "AND":
            c1.setId("creator");
            c2.setId("creator");
            c1.setName("name");
            c2.setName("name");
            logicCondition.setType(LogicConditionType.AND);
            assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            c1.setId("creator__");
            assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "OR":
            logicCondition.setType(LogicConditionType.OR);
            assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            c2.setName("name___");
            assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "XOR":
            c1.setId("creator");
            logicCondition.setType(LogicConditionType.XOR);
            assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            c1.setId("creator");
            c2.setId("creator");
            c1.setName("name");
            c2.setName("name");
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
            assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
            result.get(1).add(c2);
           
            // test "NOT":
            c1.setId("creator__");
            logicCondition.setType(LogicConditionType.NOT);
            logicCondition.getBaseConditions().remove(baseCondition2);
            assertEquals(2, result.size());
            assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
            result.get(0).clear();
            result.get(0).add(c1);
            result.get(1).clear();
View Full Code Here


            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");
            logicCondition.setType(LogicConditionType.AND);
           
            List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
            tuples.add(new ArrayList<EObject[]>());
            tuples.add(new ArrayList<EObject[]>());
           
View Full Code Here

          rule2Action.setImpactedElement("e2");
         
          impactRule1.getActions().add(rule1Action);
          impactRule2.getActions().add(rule2Action);
         
          LogicCondition rule1LC = RuleModelFactory.eINSTANCE.createLogicCondition();
          LogicCondition rule2LC = RuleModelFactory.eINSTANCE.createLogicCondition();
         
          accessLayer.addElement(project, rule1LC);
          accessLayer.addElement(project, rule2LC);
         
          rule1LC.setType(LogicConditionType.AND);
          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);
         
          RuleCatalog impactRules = RuleModelFactory.eINSTANCE.createRuleCatalog();
         
          accessLayer.addElement(project, impactRules);
         
View Full Code Here

            c2.setId("test_user");
                   
            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();
View Full Code Here

            c2.setName("42");
           
            Rule rule = RuleModelFactory.eINSTANCE.createRule();
            accessLayer.addElement(project, rule);
           
            LogicCondition lc1 = RuleModelFactory.eINSTANCE.createLogicCondition();
            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);
            e1.setAlias("e1");
            e2.setAlias("e2");
            e1.setType("Concern");
            e2.setType("Concern");
           
            rule.getElements().add(e1);
            rule.getElements().add(e2);
           
            LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
            accessLayer.addElement(project, l1);
            l1.setName("Test");
           
            LinkType l2 = LinkModelFactory.eINSTANCE.createLinkType();
            accessLayer.addElement(project, l2);
            l2.setName("TestRelation");
           
            ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
            accessLayer.addElement(project, a1);
            a1.setSourceElement("e1");
            a1.setTargetElement("e2");
            a1.setResultType("Test");
            a1.setActionType(ActionType.CREATE_LINK);
           
            rule.getActions().add(a1);
           
            /*
             * case 1:
             *
             * <and>
             *     e1.name = e2.name
             *      <not>
             *         e1.name = "test"
             *      </not>
             * </and>
             */
           
             lc2.getBaseConditions().add(bc2);
            
             assertEquals(0, accessLayer.getElements(project, "TraceLink").size());       
             ruleEngine.applyRule(project, null, rule);
             assertEquals(1, accessLayer.getElements(project, "TraceLink").size());
           
            /*
             * case 2:
             *
             * <and>
             *     e1.name = e2.name
             *      <not>
             *        <and>
             *             e1.name = "test"
             *              e1.name = "test2"
             *          </and>
             *      </not>
             * </and>
             */
           
             a1.setResultType("TestRelation");
             lc2.getBaseConditions().clear();
             lc2.getLogicConditions().add(lc3);
             lc3.getBaseConditions().add(bc2);
             lc3.getBaseConditions().add(bc3);
            
             assertEquals(1, accessLayer.getElements(project, "TraceLink").size());       
             ruleEngine.applyRule(project, null, rule);
             assertEquals(2, accessLayer.getElements(project, "TraceLink").size());
          return null;
View Full Code Here

            tuples.get(0).get(0)[1] = c2;
   
            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.setConditions(cnd1);
            cnd1.getBaseConditions().add(cnd2);
            cnd2.setSource("Test");
            cnd2.setTarget("Test");
           
            ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
            ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
            accessLayer.addElement(project, e1);
            accessLayer.addElement(project, e2);
            e1.setAlias("e1");
            e2.setAlias("e2");
            e1.setType("Concern");
            e2.setType("Concern");
           
            rule.getElements().add(e1);
            rule.getElements().add(e2);
            rule.setRuleID("TestRule");
           
            LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
            accessLayer.addElement(project, l1);
            l1.setName("Test");
           
            ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
            accessLayer.addElement(project, a1);
            a1.setSourceElement("e1");
            a1.setTargetElement("e2");
            a1.setResultType("Test");
            a1.setActionType(ActionType.CREATE_LINK);
           
            BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
            baseCondition.setSource("e1");
            baseCondition.setTarget("e2");
                   
            LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
            logicCondition.getBaseConditions().add(baseCondition);
           
            rule.setConditions(logicCondition);
           
            rule.getActions().add(a1);
           
View Full Code Here

    {
        List<String> elements = new ArrayList<String>();
        elements.add("e1");
        elements.add("e2");
       
        LogicCondition c1 = RuleModelFactory.eINSTANCE.createLogicCondition();
        LogicCondition c2 = RuleModelFactory.eINSTANCE.createLogicCondition();
        BaseCondition b1 = RuleModelFactory.eINSTANCE.createBaseCondition();
        b1.setSource("e1::name");
        b1.setTarget("e2::name");
        b1.setType(BaseConditionType.VALUE_EQUALS);
       
        assertFalse(ruleValidator.checkLogicCondition(c1, elements));
        c1.getLogicConditions().add(c2);
        assertFalse(ruleValidator.checkLogicCondition(c1, elements));
        c2.getBaseConditions().add(b1);
        assertTrue(ruleValidator.checkLogicCondition(c1, elements));
    }
View Full Code Here

      public Void call() throws Exception
      {
            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.setConditions(cnd1);
            cnd1.getBaseConditions().add(cnd2);
            cnd2.setSource("e1::creator");
            cnd2.setTarget("e2::creator");
           
            ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
            ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
View Full Code Here

   
    @Test
    public void testFindElementsForDeletion()
    {
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        e1.setAlias("e1");
        e2.setAlias("e2");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
              
        rule.setConditions(logicCondition);
               
        List<Integer> paths = new ArrayList<Integer>();
       
        ConditionProcessorHelper.findElementsForDeletion(paths, rule, logicCondition);
        assertTrue(paths.isEmpty());
       
        logicCondition.getBaseConditions().add(baseCondition);
        baseCondition.setSource("e2");
       
        ConditionProcessorHelper.findElementsForDeletion(paths, rule, logicCondition);
        assertEquals(1, paths.size());
        assertEquals(1, (int)paths.get(0));
View Full Code Here

        l2.add(new ArrayList<EObject>());
        l2.add(new ArrayList<EObject>());
        l2.get(1).add(c2);
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        e1.setAlias("e1");
        e2.setAlias("e2");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        baseCondition.setSource("e2");
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition);
       
        assertEquals(1, l1.get(0).size());
        assertEquals(1, l1.get(1).size());
        assertEquals(0, l2.get(0).size());
        assertEquals(1, l2.get(1).size());
View Full Code Here

TOP

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

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.