Ignore:
Timestamp:
04/04/13 16:06:07 (11 years ago)
Author:
pharms
Message:
  • complete refactoring of task tree model with a separation of task models and task instances
  • appropriate adaptation of task tree generation process
  • appropriate adaptation of commands and task tree visualization
Location:
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
    16  
    17 import java.util.List; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1816 
    1917import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2119 
    2220/** 
    2321 * <p> 
    24  * This class is capable of comparing any task tree node which is not an iteration with an 
    25  * iteration. This is needed, because iterations may iterate exactly that node. In this 
    26  * case, the iteration would be equal to that node if it was executed exactly once. The rule 
    27  * returns lexically equal, it the child of the iteration is lexically equal to the node 
     22 * This class is capable of comparing any task which is not an iteration with an 
     23 * iteration. This is needed, because iterations may iterate exactly that task. In this 
     24 * case, the iteration would be equal to that task if it was executed exactly once. The rule 
     25 * returns lexically equal, it the child of the iteration is lexically equal to the task 
    2826 * or if the child of the iteration is a selection and this selections contains a lexically equal 
    29  * node. The same applies for syntactical and semantical equality. 
     27 * task. The same applies for syntactical and semantical equality. 
    3028 * </p> 
    3129 
    3230 * @author Patrick Harms 
    3331 */ 
    34 public class NodeAndIterationComparisonRule implements NodeComparisonRule { 
     32public class TaskAndIterationComparisonRule implements TaskComparisonRule { 
    3533     
    36     /** the rule manager for internally comparing task tree nodes */ 
    37     private NodeEqualityRuleManager mRuleManager; 
     34    /** the rule manager for internally comparing tasks */ 
     35    private TaskEqualityRuleManager mRuleManager; 
    3836 
    3937    /** 
    4038     * <p> 
    41      * simple constructor to provide the rule with the node equality rule manager to be able 
    42      * to perform comparisons of the children of provided task tree nodes 
     39     * simple constructor to provide the rule with the task equality rule manager to be able 
     40     * to perform comparisons of the children of provided tasks 
    4341     * </p> 
    4442     *  
    45      * @param ruleManager the rule manager for comparing task tree nodes 
     43     * @param ruleManager the rule manager for comparing tasks 
    4644     */ 
    47     NodeAndIterationComparisonRule(NodeEqualityRuleManager ruleManager) { 
     45    TaskAndIterationComparisonRule(TaskEqualityRuleManager ruleManager) { 
    4846        super(); 
    4947        mRuleManager = ruleManager; 
     
    5149 
    5250    /* (non-Javadoc) 
    53      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     51     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    5452     */ 
    5553    @Override 
    56     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    57         return ((node1 instanceof IIteration) && (!(node2 instanceof IIteration))) || 
    58                ((node2 instanceof IIteration) && (!(node1 instanceof IIteration))); 
     54    public boolean isApplicable(ITask task1, ITask task2) { 
     55        return ((task1 instanceof IIteration) && (!(task2 instanceof IIteration))) || 
     56               ((task2 instanceof IIteration) && (!(task1 instanceof IIteration))); 
    5957    } 
    6058 
    6159    /* (non-Javadoc) 
    62      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     60     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    6361     */ 
    6462    @Override 
    65     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    66         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    67         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     63    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     64        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     65        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    6866    } 
    6967 
    7068    /* (non-Javadoc) 
    71      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     69     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    7270     */ 
    7371    @Override 
    74     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    75         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    76         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     72    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     73        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     74        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    7775    } 
    7876 
    7977    /* (non-Javadoc) 
    80      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     78     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    8179     */ 
    8280    @Override 
    83     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    84         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    85         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     81    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     82        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     83        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    8684    } 
    8785 
    8886    /* (non-Javadoc) 
    89      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     87     * @see NodeComparisonRule#compare(ITask, ITask) 
    9088     */ 
    9189    @Override 
    92     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    93         return getEquality(node1, node2, null); 
     90    public TaskEquality compare(ITask task1, ITask task2) { 
     91        return getEquality(task1, task2, null); 
    9492    } 
    9593 
     
    9795     *  
    9896     */ 
    99     private NodeEquality getEquality(ITaskTreeNode node1, 
    100                                      ITaskTreeNode node2, 
    101                                      NodeEquality  requiredEqualityLevel) 
    102     { 
     97    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
    10398        IIteration iteration = null; 
    104         ITaskTreeNode node = null; 
     99        ITask task = null; 
    105100         
    106         if (node1 instanceof IIteration) { 
    107             if (node2 instanceof IIteration) { 
     101        if (task1 instanceof IIteration) { 
     102            if (task2 instanceof IIteration) { 
    108103                // the rule is not responsible for two iterations 
    109104                return null; 
    110105            } 
    111106             
    112             iteration = (IIteration) node1; 
    113             node = node2; 
     107            iteration = (IIteration) task1; 
     108            task = task2; 
    114109        } 
    115         else if (node2 instanceof IIteration) { 
    116             if (node1 instanceof IIteration) { 
     110        else if (task2 instanceof IIteration) { 
     111            if (task1 instanceof IIteration) { 
    117112                // the rule is not responsible for two iterations 
    118113                return null; 
    119114            } 
    120115             
    121             iteration = (IIteration) node2; 
    122             node = node1; 
     116            iteration = (IIteration) task2; 
     117            task = task1; 
    123118        } 
    124119        else { 
     
    126121        } 
    127122 
    128         List<ITaskTreeNode> children = iteration.getChildren(); 
     123        ITask child = iteration.getMarkedTask(); 
    129124         
    130         // now, that we found the iteration and the node, lets compare the child of the iteration 
    131         // with the node. 
    132         if (children.size() < 1) { 
     125        // now, that we found the iteration and the task, lets compare the child of the iteration 
     126        // with the task. 
     127        if (child == null) { 
    133128            return null; 
    134129        } 
    135130 
    136         NodeEquality nodeEquality = callRuleManager(children.get(0), node, requiredEqualityLevel); 
     131        TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 
    137132 
    138         // although the subtask may be identical to the node, we can not return identical, as 
    139         // the iteration is not identical to the node, but at most lexically equal 
    140         if (nodeEquality == NodeEquality.IDENTICAL) { 
    141             return NodeEquality.LEXICALLY_EQUAL; 
     133        // although the subtask may be identical to the task, we can not return identical, as 
     134        // the iteration is not identical to the task, but at most lexically equal 
     135        if (taskEquality == TaskEquality.IDENTICAL) { 
     136            return TaskEquality.LEXICALLY_EQUAL; 
    142137        } 
    143138        else { 
    144             return nodeEquality; 
     139            return taskEquality; 
    145140        } 
    146141 
     
    157152     * @return 
    158153     */ 
    159     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    160                                          ITaskTreeNode child2, 
    161                                          NodeEquality requiredEqualityLevel) 
     154    private TaskEquality callRuleManager(ITask        child1, 
     155                                         ITask        child2, 
     156                                         TaskEquality requiredEqualityLevel) 
    162157    { 
    163158        if (requiredEqualityLevel == null) { 
     
    168163        } 
    169164        else { 
    170             return NodeEquality.UNEQUAL; 
     165            return TaskEquality.UNEQUAL; 
    171166        } 
    172167    } 
Note: See TracChangeset for help on using the changeset viewer.