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/TaskAndSelectionComparisonRule.java

    r1125 r1146  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     15package de.ugoe.cs.autoquest.tasktrees.taskequality; 
    1616 
    1717import java.util.List; 
    1818 
    1919import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
     20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2121 
    2222/** 
    2323 * <p> 
    24  * This class is capable of comparing any task tree node which is not a selection with a 
    25  * selection. This is needed, because selections may contain exactly that node. Therefore, if 
    26  * this node is selected out of a selection the selection is equal to the node itself.  
    27  * The rule returns lexically equal, it the selection contains a lexically equal node. The same 
     24 * This class is capable of comparing any task which is not a selection with a 
     25 * selection. This is needed, because selections may contain exactly that task. Therefore, if 
     26 * this task is selected out of a selection the selection is equal to the task itself.  
     27 * The rule returns lexically equal, if the selection contains a lexically equal task. The same 
    2828 * applies for syntactical and semantical equality. 
    2929 * </p> 
     
    3131 * @author Patrick Harms 
    3232 */ 
    33 public class NodeAndSelectionComparisonRule implements NodeComparisonRule { 
     33public class TaskAndSelectionComparisonRule implements TaskComparisonRule { 
    3434     
    35     /** the rule manager for internally comparing task tree nodes */ 
    36     private NodeEqualityRuleManager mRuleManager; 
     35    /** the rule manager for internally comparing tasks */ 
     36    private TaskEqualityRuleManager mRuleManager; 
    3737     
    3838    /** 
    3939     * <p> 
    40      * simple constructor to provide the rule with the node equality rule manager to be able 
    41      * to perform comparisons of the children of provided task tree nodes 
     40     * simple constructor to provide the rule with the task equality rule manager to be able 
     41     * to perform comparisons of the children of provided tasks 
    4242     * </p> 
    4343     *  
    44      * @param ruleManager the rule manager for comparing task tree nodes 
     44     * @param ruleManager the rule manager for comparing tasks 
    4545     */ 
    46     NodeAndSelectionComparisonRule(NodeEqualityRuleManager ruleManager) { 
     46    TaskAndSelectionComparisonRule(TaskEqualityRuleManager ruleManager) { 
    4747        super(); 
    4848        mRuleManager = ruleManager; 
     
    5050 
    5151    /* (non-Javadoc) 
    52      * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     52     * @see NodeComparisonRule#isApplicable(ITask, ITask) 
    5353     */ 
    5454    @Override 
    55     public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
    56         return ((node1 instanceof ISelection) && (!(node2 instanceof ISelection))) || 
    57                ((node2 instanceof ISelection) && (!(node1 instanceof ISelection))); 
     55    public boolean isApplicable(ITask task1, ITask task2) { 
     56        return ((task1 instanceof ISelection) && (!(task2 instanceof ISelection))) || 
     57               ((task2 instanceof ISelection) && (!(task1 instanceof ISelection))); 
    5858    } 
    5959 
    6060    /* (non-Javadoc) 
    61      * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     61     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 
    6262     */ 
    6363    @Override 
    64     public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    65         NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
    66         return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     64    public boolean areLexicallyEqual(ITask task1, ITask task2) { 
     65        TaskEquality equality = getEquality(task1, task2, TaskEquality.LEXICALLY_EQUAL); 
     66        return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 
    6767    } 
    6868 
    6969    /* (non-Javadoc) 
    70      * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     70     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask) 
    7171     */ 
    7272    @Override 
    73     public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    74         NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
    75         return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     73    public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 
     74        TaskEquality equality = getEquality(task1, task2, TaskEquality.SYNTACTICALLY_EQUAL); 
     75        return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 
    7676    } 
    7777 
    7878    /* (non-Javadoc) 
    79      * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     79     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 
    8080     */ 
    8181    @Override 
    82     public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    83         NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
    84         return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     82    public boolean areSemanticallyEqual(ITask task1, ITask task2) { 
     83        TaskEquality equality = getEquality(task1, task2, TaskEquality.SEMANTICALLY_EQUAL); 
     84        return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 
    8585    } 
    8686 
    8787    /* (non-Javadoc) 
    88      * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     88     * @see NodeComparisonRule#compare(ITask, ITask) 
    8989     */ 
    9090    @Override 
    91     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    92         return getEquality(node1, node2, null); 
     91    public TaskEquality compare(ITask task1, ITask task2) { 
     92        return getEquality(task1, task2, null); 
    9393    } 
    9494     
     
    9696     *  
    9797     */ 
    98     private NodeEquality getEquality(ITaskTreeNode node1, 
    99                                      ITaskTreeNode node2, 
    100                                      NodeEquality  requiredEqualityLevel) 
    101     { 
     98    private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 
    10299        ISelection selection = null; 
    103         ITaskTreeNode node = null; 
     100        ITask task = null; 
    104101         
    105         if (node1 instanceof ISelection) { 
    106             if (node2 instanceof ISelection) { 
     102        if (task1 instanceof ISelection) { 
     103            if (task2 instanceof ISelection) { 
    107104                // the rule is not responsible for two selections 
    108105                return null; 
    109106            } 
    110107             
    111             selection = (ISelection) node1; 
    112             node = node2; 
     108            selection = (ISelection) task1; 
     109            task = task2; 
    113110        } 
    114         else if (node2 instanceof ISelection) { 
    115             if (node1 instanceof ISelection) { 
     111        else if (task2 instanceof ISelection) { 
     112            if (task1 instanceof ISelection) { 
    116113                // the rule is not responsible for two selections 
    117114                return null; 
    118115            } 
    119116             
    120             selection = (ISelection) node2; 
    121             node = node1; 
     117            selection = (ISelection) task2; 
     118            task = task1; 
    122119        } 
    123120        else { 
     
    125122        } 
    126123 
    127         // now, that we found the selection and the node, lets compare the children of the selection 
    128         // with the node. 
    129         List<ITaskTreeNode> children = selection.getChildren(); 
     124        // now, that we found the selection and the task, lets compare the children of the selection 
     125        // with the task. 
     126        List<ITask> children = selection.getChildren(); 
    130127         
    131128        if (children.size() < 1) { 
     
    133130        } 
    134131 
    135         NodeEquality mostConcreteNodeEquality = null; 
     132        TaskEquality mostConcreteNodeEquality = null; 
    136133         
    137         for (ITaskTreeNode child : children) { 
    138             NodeEquality nodeEquality = callRuleManager(child, node, requiredEqualityLevel); 
     134        for (ITask child : children) { 
     135            TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 
    139136             
    140             if (nodeEquality != NodeEquality.UNEQUAL) { 
     137            if (taskEquality != TaskEquality.UNEQUAL) { 
    141138                if (mostConcreteNodeEquality == null) { 
    142                     mostConcreteNodeEquality = nodeEquality; 
     139                    mostConcreteNodeEquality = taskEquality; 
    143140                } 
    144                 else if (mostConcreteNodeEquality.isAtLeast(nodeEquality)) { 
    145                     mostConcreteNodeEquality = nodeEquality; 
     141                else if (mostConcreteNodeEquality.isAtLeast(taskEquality)) { 
     142                    mostConcreteNodeEquality = taskEquality; 
    146143                     
    147144                } 
     
    151148                { 
    152149                    // if we found one child of the selection that is as equal as required, then 
    153                     // we can consider the selection to be sufficiently equal to the other node. 
     150                    // we can consider the selection to be sufficiently equal to the other task. 
    154151                    // So we break up checking further children. 
    155152                    break; 
     
    158155        } 
    159156         
    160         // although the subtask may be identical to the node, we can not return identical, as 
    161         // the selection is not identical to the node, but at most lexically equal 
    162         if (mostConcreteNodeEquality == NodeEquality.IDENTICAL) { 
    163             return NodeEquality.LEXICALLY_EQUAL; 
     157        // although the subtask may be identical to the task, we can not return identical, as 
     158        // the selection is not identical to the task, but at most lexically equal 
     159        if (mostConcreteNodeEquality == TaskEquality.IDENTICAL) { 
     160            return TaskEquality.LEXICALLY_EQUAL; 
    164161        } 
    165162        else { 
     
    179176     * @return 
    180177     */ 
    181     private NodeEquality callRuleManager(ITaskTreeNode child1, 
    182                                          ITaskTreeNode child2, 
    183                                          NodeEquality requiredEqualityLevel) 
     178    private TaskEquality callRuleManager(ITask        child1, 
     179                                         ITask        child2, 
     180                                         TaskEquality requiredEqualityLevel) 
    184181    { 
    185182        if (requiredEqualityLevel == null) { 
     
    190187        } 
    191188        else { 
    192             return NodeEquality.UNEQUAL; 
     189            return TaskEquality.UNEQUAL; 
    193190        } 
    194191    } 
Note: See TracChangeset for help on using the changeset viewer.