Package org.emftrace.metamodel.RuleModel

Examples of org.emftrace.metamodel.RuleModel.BaseCondition


       *  bc2
       *  bc3
       * </OR>
       */
      LogicCondition lc = RuleModelFactory.eINSTANCE.createLogicCondition();
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc3 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      rule.setConditions(lc);
      lc.getBaseConditions().add(bc1);
      lc.getBaseConditions().add(bc2);
      lc.getBaseConditions().add(bc3);
     
      List<BaseCondition> conditions = new ArrayList<BaseCondition>();
      conditions.add(bc1);
      conditions.add(bc2);
      conditions.add(bc3);
     
      ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
     
      rule.getElements().add(e1);
      rule.getElements().add(e2);
     
      // set all the attributes:
      e1.setAlias("e1");
      e2.setAlias("e2");
     
      lc.setType(LogicConditionType.OR);
      bc1.setSource("e1");
      bc2.setSource("e1");
      bc3.setSource("e1");
      bc1.setTarget("e2");
      bc2.setTarget("e2");
      bc3.setTarget("e2");
     
      Concern c1 = URNModelFactory.eINSTANCE.createConcern();
      Concern c2 = URNModelFactory.eINSTANCE.createConcern();
      Concern c3 = URNModelFactory.eINSTANCE.createConcern();
      Concern c4 = URNModelFactory.eINSTANCE.createConcern();
View Full Code Here


    @Test
    public void testJoinTwoElementTuples()
    {
      Rule rule = RuleModelFactory.eINSTANCE.createRule();
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      List<BaseCondition> conditions = new ArrayList<BaseCondition>();
      conditions.add(bc1);
      conditions.add(bc2);
     
      ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition e3 = RuleModelFactory.eINSTANCE.createElementDefinition();
     
      rule.getElements().add(e1);
      rule.getElements().add(e2);
      rule.getElements().add(e3);
     
      // set all the attributes:
      e1.setAlias("e1");
      e2.setAlias("e2");
      e3.setAlias("e3");
     
      List<EObject[]> finalTuples   = new ArrayList<EObject[]>();
      List<EObject[]> currentTuples = new ArrayList<EObject[]>();
     
      Concern c1 = URNModelFactory.eINSTANCE.createConcern();
      Concern c2 = URNModelFactory.eINSTANCE.createConcern();
      Concern c3 = URNModelFactory.eINSTANCE.createConcern();
     
      // test the case that the final tuple list is empty:
     
      bc1.setSource("e1");
      bc1.setTarget("e2");
      bc2.setSource("e2");     
      bc2.setTarget("e3");
     
      currentTuples.add(new EObject[2]);
      currentTuples.get(0)[0] = c1;
      currentTuples.get(0)[1] = c2;
     
      assertTrue(finalTuples.isEmpty());
      joinProcessor.joinFirstTupleList(finalTuples, currentTuples, conditions, 0, rule);
      joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 0, conditions, rule);
      assertEquals(1, finalTuples.size());
      assertEquals(finalTuples.get(0)[0], c1);
      assertEquals(finalTuples.get(0)[1], c2);
      assertEquals(finalTuples.get(0)[2], null);
           
      // test the case that both conditions cover the same elements:
     
      bc1.setSource("e1");
      bc1.setTarget("e2");
      bc2.setSource("e1");
      bc2.setTarget("e2");
     
      currentTuples.add(new EObject[2]);
      currentTuples.get(1)[0] = c1;
      currentTuples.get(1)[1] = c2;
     
      assertEquals(1, finalTuples.size());
      joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 1, conditions, rule);
      assertEquals(1, finalTuples.size());
     
      currentTuples.get(1)[0] = c1;
      currentTuples.get(1)[1] = c3;
     
      joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 1, conditions, rule);
      assertEquals(1, finalTuples.size());
           
      // test the case that both conditions are transitively related:
     
      bc1.setSource("e1");
      bc1.setTarget("e2");
      bc2.setSource("e2");
      bc2.setTarget("e3");
     
      finalTuples.clear();
      finalTuples.add(new EObject[3]);
      finalTuples.get(0)[0] = c1;
      finalTuples.get(0)[1] = c2;
View Full Code Here

      e2.setAlias("e2");
     
      rule.getElements().add(e1);
      rule.getElements().add(e2);
     
      BaseCondition condition = RuleModelFactory.eINSTANCE.createBaseCondition();
      List<BaseCondition> conditions = new ArrayList<BaseCondition>();
      conditions.add(condition);
     
      condition.setSource("e1");
      condition.setTarget("e2");
     
      Concern c1 = URNModelFactory.eINSTANCE.createConcern();
      Concern c2 = URNModelFactory.eINSTANCE.createConcern();
      Concern c3 = URNModelFactory.eINSTANCE.createConcern();
      Concern c4 = URNModelFactory.eINSTANCE.createConcern();
View Full Code Here

      Rule rule = RuleModelFactory.eINSTANCE.createRule();
     
      LogicCondition lc1 = RuleModelFactory.eINSTANCE.createLogicCondition();
      LogicCondition lc2 = RuleModelFactory.eINSTANCE.createLogicCondition();
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc3 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc4 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      List<BaseCondition> conditions = new ArrayList<BaseCondition>();
      conditions.add(bc1);
      conditions.add(bc2);
      conditions.add(bc3);
      conditions.add(bc4);
     
      ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition e3 = RuleModelFactory.eINSTANCE.createElementDefinition();
     
      ActionDefinition a = RuleModelFactory.eINSTANCE.createActionDefinition();
      a.setActionType(ActionType.CREATE_LINK);
       
      rule.getElements().add(e1);
      rule.getElements().add(e2);
      rule.getElements().add(e3);
     
      rule.getActions().add(a);
     
      e1.setAlias("e1");
      e2.setAlias("e2");
      e3.setAlias("e3");
     
      rule.setConditions(lc1);
     
      lc1.setType(LogicConditionType.AND);
      lc2.setType(LogicConditionType.OR);
     
      lc1.getBaseConditions().add(bc1);
      lc1.getBaseConditions().add(bc2);
      lc2.getBaseConditions().add(bc3);
      lc2.getBaseConditions().add(bc4);
     
      lc1.getLogicConditions().add(lc2);
     
      bc1.setSource("e1");
      bc1.setTarget("e2");
      bc2.setSource("e2");
      bc2.setTarget("e3");
      bc3.setSource("e3");
      bc4.setSource("e3");
     
      List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
      tuples.add(new ArrayList<EObject[]>()); // bc1
      tuples.add(new ArrayList<EObject[]>()); // bc2
      tuples.add(new ArrayList<EObject[]>()); // bc3
View Full Code Here

    }
   
    @Test
    public void testHasTarget()
    {
      BaseCondition condition = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      condition.setTarget("e1");     
      assertTrue(ElementResolver.hasTarget(condition));
     
      condition.setTarget("");     
      assertFalse(ElementResolver.hasTarget(condition));
     
      condition.setTarget(null);     
      assertFalse(ElementResolver.hasTarget(condition));
    }
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

    @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));
       
        paths.clear();
       
        baseCondition.setTarget("e1");
       
        ConditionProcessorHelper.findElementsForDeletion(paths, rule, logicCondition);
        assertEquals(2, paths.size());
        assertEquals(1, (int)paths.get(0));
        assertEquals(0, (int)paths.get(1));       
View Full Code Here

        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());
View Full Code Here

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

      accessLayer.addElement(project, lc1);
      accessLayer.addElement(project, lc2);
     
      rule.setConditions(lc1);
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      accessLayer.addElement(project, bc1);
      accessLayer.addElement(project, bc2);
     
      lc1.getLogicConditions().add(lc2);
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.