Changeset 1294 for trunk/autoquest-core-tasktrees/src/main/java/de
- Timestamp:
- 08/14/13 17:04:42 (11 years ago)
- Location:
- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 10 added
- 29 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManager.java
r1154 r1294 21 21 22 22 import de.ugoe.cs.autoquest.eventcore.Event; 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.I Task;23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 24 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 25 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 124 124 public void handleNewEvent(Event event) { 125 125 assertSessionSequence(); 126 ITask eventTask = taskFactory.createNewEventTask(event.getType(), event.getTarget()); 127 taskBuilder.addExecutedTask(currentSession, taskFactory.createNewTaskInstance(eventTask)); 126 String description = event.getType().getName() + " \u21D2 " + event.getTarget(); 127 IEventTask eventTask = taskFactory.createNewEventTask(description); 128 taskBuilder.addExecutedTask 129 (currentSession, taskFactory.createNewTaskInstance(eventTask, event)); 128 130 } 129 131 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRule.java
r1146 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 16 17 import java.util.Collection; 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 18 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 19 23 20 24 /** … … 29 33 30 34 /* (non-Javadoc) 31 * @see NodeComparisonRule#isApplicable(ITask, ITask)35 * @see TaskComparisonRule#isApplicable(ITask, ITask) 32 36 */ 33 37 @Override … … 37 41 38 42 /* (non-Javadoc) 39 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)43 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 40 44 */ 41 45 @Override 42 46 public boolean areLexicallyEqual(ITask task1, ITask task2) { 43 IEventTask eventTask1 = (IEventTask) task1;44 IEventTask eventTask2 = (IEventTask) task2;47 Collection<ITaskInstance> taskInstances1 = task1.getInstances(); 48 Collection<ITaskInstance> taskInstances2 = task2.getInstances(); 45 49 46 return (eventTask1.getEventType().equals(eventTask2.getEventType()) && 47 eventTask1.getEventTarget().equals(eventTask2.getEventTarget())); 50 for (ITaskInstance instance1 : taskInstances1) { 51 boolean found = false; 52 53 for (ITaskInstance instance2 : taskInstances2) { 54 if (areLexicallyEqual(instance1, instance2)) { 55 found = true; 56 break; 57 } 58 } 59 60 if (!found) { 61 return false; 62 } 63 } 64 65 return true; 48 66 } 49 67 50 68 /* (non-Javadoc) 51 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)69 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 52 70 */ 53 71 @Override … … 57 75 58 76 /* (non-Javadoc) 59 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)77 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 60 78 */ 61 79 @Override … … 64 82 } 65 83 84 /* (non-Javadoc) 85 * @see TaskComparisonRule#compare(ITask, ITask) 86 */ 66 87 @Override 67 88 public TaskEquality compare(ITask task1, ITask task2) { … … 74 95 } 75 96 97 98 /* (non-Javadoc) 99 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 100 */ 101 @Override 102 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 103 return 104 (instance1 instanceof IEventTaskInstance) && (instance2 instanceof IEventTaskInstance); 105 } 106 107 /* (non-Javadoc) 108 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 109 */ 110 @Override 111 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 112 IEventTaskInstance eventTask1 = (IEventTaskInstance) instance1; 113 IEventTaskInstance eventTask2 = (IEventTaskInstance) instance2; 114 115 return (eventTask1.getEvent().getType().equals(eventTask2.getEvent().getType()) && 116 eventTask1.getEvent().getTarget().equals(eventTask2.getEvent().getTarget())); 117 } 118 119 /* (non-Javadoc) 120 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 121 */ 122 @Override 123 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 124 return areLexicallyEqual(instance1, instance2); 125 } 126 127 /* (non-Javadoc) 128 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 129 */ 130 @Override 131 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 132 return areLexicallyEqual(instance1, instance2); 133 } 134 135 /* (non-Javadoc) 136 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 137 */ 138 @Override 139 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 140 if (areLexicallyEqual(instance1, instance2)) { 141 return TaskEquality.LEXICALLY_EQUAL; 142 } 143 else { 144 return TaskEquality.UNEQUAL; 145 } 146 } 147 76 148 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRule.java
r1154 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 17 import java.util.Collection; 16 18 17 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; … … 41 43 import de.ugoe.cs.autoquest.eventcore.guimodel.IText; 42 44 import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 43 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask ;45 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 44 46 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 47 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 45 48 46 49 /** … … 61 64 62 65 /* (non-Javadoc) 63 * @see NodeComparisonRule#isApplicable(ITask, ITask)66 * @see TaskComparisonRule#isApplicable(ITask, ITask) 64 67 */ 65 68 @Override 66 69 public boolean isApplicable(ITask task1, ITask task2) { 67 return 68 ((task1 instanceof IEventTask) && (task2 instanceof IEventTask) && 69 (((IEventTask) task1).getEventType() instanceof IInteraction) && 70 (((IEventTask) task2).getEventType() instanceof IInteraction)); 71 } 72 73 /* (non-Javadoc) 74 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 70 for (ITaskInstance instance : task1.getInstances()) { 71 if ((!(instance instanceof IEventTaskInstance)) || 72 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 73 { 74 return false; 75 } 76 } 77 78 for (ITaskInstance instance : task2.getInstances()) { 79 if ((!(instance instanceof IEventTaskInstance)) || 80 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 81 { 82 return false; 83 } 84 } 85 86 return true; 87 } 88 89 /* (non-Javadoc) 90 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 75 91 */ 76 92 @Override … … 81 97 82 98 /* (non-Javadoc) 83 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)99 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 84 100 */ 85 101 @Override … … 90 106 91 107 /* (non-Javadoc) 92 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)108 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 93 109 */ 94 110 @Override … … 99 115 100 116 /* (non-Javadoc) 101 * @see NodeComparisonRule#compare(ITask, ITask)117 * @see TaskComparisonRule#compare(ITask, ITask) 102 118 */ 103 119 @Override … … 106 122 } 107 123 108 /** 109 * 110 */ 111 private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 112 IEventTask eventTask1 = (IEventTask) task1; 113 IEventTask eventTask2 = (IEventTask) task2; 114 115 if (!eventTask1.getEventTarget().equals(eventTask2.getEventTarget())) { 124 /* (non-Javadoc) 125 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#isApplicable(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 126 */ 127 @Override 128 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 129 return 130 (instance1 instanceof IEventTaskInstance) && 131 (instance2 instanceof IEventTaskInstance) && 132 (((IEventTaskInstance) instance1).getEvent().getType() instanceof IInteraction) && 133 (((IEventTaskInstance) instance1).getEvent().getType() instanceof IInteraction); 134 } 135 136 /* (non-Javadoc) 137 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areLexicallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 138 */ 139 @Override 140 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 141 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 142 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 143 } 144 145 /* (non-Javadoc) 146 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areSyntacticallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 147 */ 148 @Override 149 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 150 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 151 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 152 } 153 154 /* (non-Javadoc) 155 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areSemanticallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 156 */ 157 @Override 158 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 159 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 160 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 161 } 162 163 /* (non-Javadoc) 164 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#compare(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 165 */ 166 @Override 167 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 168 return getEquality(instance1, instance2, null); 169 } 170 171 /** 172 * 173 */ 174 private TaskEquality getEquality(ITask task1, 175 ITask task2, 176 TaskEquality requiredEqualityLevel) 177 { 178 Collection<ITaskInstance> taskInstances1 = task1.getInstances(); 179 Collection<ITaskInstance> taskInstances2 = task2.getInstances(); 180 181 TaskEquality checkedEquality = 182 requiredEqualityLevel != null ? requiredEqualityLevel : TaskEquality.SEMANTICALLY_EQUAL; 183 184 TaskEquality commonDenominator = TaskEquality.LEXICALLY_EQUAL; 185 186 for (ITaskInstance instance1 : taskInstances1) { 187 TaskEquality mostConcreteEquality = null; 188 189 for (ITaskInstance instance2 : taskInstances2) { 190 TaskEquality equality = getEquality(instance1, instance2, requiredEqualityLevel); 191 192 if ((equality != null) && ((mostConcreteEquality == null) || 193 (equality.isAtLeast(mostConcreteEquality)))) 194 { 195 mostConcreteEquality = equality; 196 197 if (((requiredEqualityLevel != null) && 198 (mostConcreteEquality.isAtLeast(requiredEqualityLevel))) || 199 (mostConcreteEquality.isAtLeast(TaskEquality.LEXICALLY_EQUAL))) 200 { 201 break; 202 } 203 } 204 } 205 206 commonDenominator = commonDenominator.getCommonDenominator(mostConcreteEquality); 207 208 if (!commonDenominator.isAtLeast(checkedEquality)) { 209 return TaskEquality.UNEQUAL; 210 } 211 } 212 213 return commonDenominator; 214 } 215 216 /** 217 * 218 */ 219 private TaskEquality getEquality(ITaskInstance instance1, 220 ITaskInstance instance2, 221 TaskEquality requiredEqualityLevel) 222 { 223 IEventTaskInstance eventTask1 = (IEventTaskInstance) instance1; 224 IEventTaskInstance eventTask2 = (IEventTaskInstance) instance2; 225 226 if (!eventTask1.getEvent().getTarget().equals(eventTask2.getEvent().getTarget())) { 116 227 return TaskEquality.UNEQUAL; 117 228 } 118 229 119 IInteraction interaction1 = (IInteraction) eventTask1.getEvent Type();120 IInteraction interaction2 = (IInteraction) eventTask2.getEvent Type();230 IInteraction interaction1 = (IInteraction) eventTask1.getEvent().getType(); 231 IInteraction interaction2 = (IInteraction) eventTask2.getEvent().getType(); 121 232 122 233 return compareInteractions 123 (interaction1, interaction2, eventTask1.getEvent Target(), requiredEqualityLevel);234 (interaction1, interaction2, eventTask1.getEvent().getTarget(), requiredEqualityLevel); 124 235 } 125 236 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/IterationComparisonRule.java
r1190 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;18 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;21 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 22 22 23 23 /** … … 82 82 83 83 /* (non-Javadoc) 84 * @see NodeComparisonRule#isApplicable(ITask, ITask)84 * @see TaskComparisonRule#isApplicable(ITask, ITask) 85 85 */ 86 86 @Override … … 90 90 91 91 /* (non-Javadoc) 92 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)92 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 93 93 */ 94 94 @Override 95 95 public boolean areLexicallyEqual(ITask task1, ITask task2) { 96 ITask child1 = ((IIteration) task1).getMarkedTask();97 ITask child2 = ((IIteration) task2).getMarkedTask();98 99 if (child1 != null) {100 if (child2 == null) {101 return false;102 }103 else {104 // iterations may have 3 different structures.105 // 1. they have one child, which is the iterated one106 // 2. they have a sequence of children, which is iterated107 // 3. they have a selection of different iterated variants (usually the variants108 // are semantically equal)109 // check if the type of children match. If not, return false. If they match,110 // use the equality manager to perform further comparisons111 112 if (((child1 instanceof ISelection) && (child2 instanceof ISelection)) ||113 ((child1 instanceof ISequence) && (child2 instanceof ISequence)) ||114 ((child1 instanceof IEventTask) && (child2 instanceof IEventTask)))115 {116 return getNodeEquality117 (child1, child2).isAtLeast(TaskEquality.LEXICALLY_EQUAL);118 }119 }120 }121 else if (child2 == null) {122 return true;123 }124 125 return false;126 }127 128 /* (non-Javadoc)129 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)130 */131 @Override132 public boolean areSyntacticallyEqual(ITask task1, ITask task2) {133 96 ITask child1 = ((IIteration) task1).getMarkedTask(); 134 97 ITask child2 = ((IIteration) task2).getMarkedTask(); … … 146 109 // ignore the type of the children but check them for equality. 147 110 148 return getNodeEquality(child1, child2).isAtLeast(TaskEquality. SYNTACTICALLY_EQUAL);111 return getNodeEquality(child1, child2).isAtLeast(TaskEquality.LEXICALLY_EQUAL); 149 112 } 150 113 } … … 157 120 158 121 /* (non-Javadoc) 159 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 122 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 123 */ 124 @Override 125 public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 126 return areLexicallyEqual(task1, task2); 127 } 128 129 /* (non-Javadoc) 130 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 160 131 */ 161 132 @Override … … 165 136 166 137 /* (non-Javadoc) 167 * @see NodeComparisonRule#compare(ITask, ITask)138 * @see TaskComparisonRule#compare(ITask, ITask) 168 139 */ 169 140 @Override … … 203 174 // all other combinations (i.e. sequence with single child and sequence with selection) 204 175 // can not match 176 } 177 178 /* (non-Javadoc) 179 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 180 */ 181 @Override 182 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 183 return isApplicable(instance1.getTask(), instance2.getTask()); 184 } 185 186 /* (non-Javadoc) 187 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 188 */ 189 @Override 190 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 191 IIterationInstance iteration1 = (IIterationInstance) instance1; 192 IIterationInstance iteration2 = (IIterationInstance) instance2; 193 194 // if both sequences do not have children, they are equal although this doesn't make sense 195 if ((iteration1.size() == 0) && (iteration2.size() == 0)) { 196 return true; 197 } 198 199 if (iteration1.size() != iteration2.size()) { 200 return false; 201 } 202 203 for (int i = 0; i < iteration1.size(); i++) { 204 ITaskInstance child1 = iteration1.get(i); 205 ITaskInstance child2 = iteration2.get(i); 206 207 TaskEquality taskEquality = 208 callRuleManager(child1, child2, TaskEquality.LEXICALLY_EQUAL); 209 210 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 211 return false; 212 } 213 } 214 215 return true; 216 } 217 218 /* (non-Javadoc) 219 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 220 */ 221 @Override 222 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 223 return areLexicallyEqual(instance1, instance2); 224 } 225 226 /* (non-Javadoc) 227 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 228 */ 229 @Override 230 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 231 return areLexicallyEqual(instance1, instance2); 232 } 233 234 /* (non-Javadoc) 235 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 236 */ 237 @Override 238 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 239 if (areLexicallyEqual(instance1, instance2)) { 240 return TaskEquality.LEXICALLY_EQUAL; 241 } 242 else { 243 return TaskEquality.UNEQUAL; 244 } 205 245 } 206 246 … … 272 312 callRuleManager(task, child, commonDenominatorForAllComparisons); 273 313 274 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) 275 { 314 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 276 315 return TaskEquality.UNEQUAL; 277 316 } … … 314 353 } 315 354 } 355 356 /** 357 * <p> 358 * used to to call the task equality rule manager for the comparison of the two provided 359 * children. If no required equality level is provided, than the most concrete equality is 360 * returned. Otherwise, the required equality is returned as long as the children are equal 361 * on that level. 362 * </p> 363 * 364 * @param taskInstance1 the first task instance to be compared 365 * @param taskInstance2 the second task instance to be compared 366 * @param requiredEqualityLevel the equality level to be checked for 367 * 368 * @return the determined equality 369 */ 370 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 371 ITaskInstance taskInstance2, 372 TaskEquality requiredEqualityLevel) 373 { 374 if (requiredEqualityLevel == null) { 375 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 376 } 377 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 378 (taskInstance1, taskInstance2, requiredEqualityLevel)) 379 { 380 return requiredEqualityLevel; 381 } 382 else { 383 return TaskEquality.UNEQUAL; 384 } 385 } 316 386 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 39 41 40 42 /* (non-Javadoc) 41 * @see NodeComparisonRule#isApplicable(ITask, ITask)43 * @see TaskComparisonRule#isApplicable(ITask, ITask) 42 44 */ 43 45 @Override … … 47 49 48 50 /* (non-Javadoc) 49 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)51 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 50 52 */ 51 53 @Override … … 56 58 57 59 /* (non-Javadoc) 58 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)60 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 59 61 */ 60 62 @Override … … 65 67 66 68 /* (non-Javadoc) 67 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)69 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 68 70 */ 69 71 @Override … … 74 76 75 77 /* (non-Javadoc) 76 * @see NodeComparisonRule#compare(ITask, ITask)78 * @see TaskComparisonRule#compare(ITask, ITask) 77 79 */ 78 80 @Override 79 81 public TaskEquality compare(ITask task1, ITask task2) { 80 82 return getEquality(task1, task2, null); 83 } 84 85 /* (non-Javadoc) 86 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 87 */ 88 @Override 89 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 90 return isApplicable(instance1.getTask(), instance2.getTask()); 91 } 92 93 /* (non-Javadoc) 94 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 95 */ 96 @Override 97 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 98 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 99 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 100 } 101 102 /* (non-Javadoc) 103 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 104 */ 105 @Override 106 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 107 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 108 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 109 } 110 111 /* (non-Javadoc) 112 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 113 */ 114 @Override 115 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 116 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 117 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 118 } 119 120 /* (non-Javadoc) 121 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 122 */ 123 @Override 124 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 125 return getEquality(instance1, instance2, null); 81 126 } 82 127 … … 107 152 } 108 153 109 TaskEquality selectionEquality;110 111 154 if (requiredEqualityLevel == null) { 112 155 // calculate the common equality level for all children of both selections. 113 156 // do it in both directions to ensure commutative comparison 114 selectionEquality = getCommonEqualityLevel(children1, children2); 115 if (selectionEquality != TaskEquality.UNEQUAL) { 116 return selectionEquality.getCommonDenominator 117 (getCommonEqualityLevel(children2, children1)); 118 } 119 else { 120 return TaskEquality.UNEQUAL; 121 } 157 return getMostConcreteEqualityLevel(children1, children2); 122 158 } 123 159 else { 124 160 // we are searching for a specific equality 125 if (checkEqualityLevel(children1, children2, requiredEqualityLevel) && 126 checkEqualityLevel(children2, children1, requiredEqualityLevel)) 127 { 161 if (checkEqualityLevel(children1, children2, requiredEqualityLevel)) { 128 162 return requiredEqualityLevel; 129 163 } … … 136 170 /** 137 171 * <p> 138 * determines the commonequality level for all tasks in the first list compared to all139 * tasks in the second list. I f for one task in the first list, there is no equal task in the140 * second list, the method return unequality.172 * determines the most concrete equality level for all tasks in the first list compared to all 173 * tasks in the second list. It is sufficient, if there is one task in one list for which there 174 * exist an equal task in the other list. 141 175 * </p> 142 176 * … … 144 178 * @param children2 the second list to be compared 145 179 * 146 * @return the common task equality identified for all tasks in the first list with respect to 147 * the second list 148 */ 149 private TaskEquality getCommonEqualityLevel(List<ITask> children1, List<ITask> children2) { 150 TaskEquality listEquality = TaskEquality.LEXICALLY_EQUAL; 151 180 * @return the most concrete task equality identified for all tasks in the first list with 181 * respect to the second list 182 */ 183 private TaskEquality getMostConcreteEqualityLevel(List<ITask> children1, List<ITask> children2) 184 { 152 185 TaskEquality childEquality; 153 186 TaskEquality currentEquality; … … 164 197 } 165 198 166 if (childEquality == TaskEquality.SEMANTICALLY_EQUAL) { 167 // as we calculate only the common denominator, we can break up here for 168 // the current child. We will not improve the denominator anymore 169 break; 199 if (childEquality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)) { 200 // as we calculate the most concrete equality, we can break up here 201 return TaskEquality.LEXICALLY_EQUAL; 170 202 } 171 203 } 172 204 } 173 174 if (childEquality == null) { 175 // we did not find any child in the second list, that is equal to the searched 176 // child 177 return TaskEquality.UNEQUAL; 178 } 179 else { 180 listEquality = listEquality.getCommonDenominator(childEquality); 181 } 182 } 183 184 return listEquality; 185 } 186 187 /** 188 * <p> 189 * ensures for the two given lists, that for each task in the first list there is a task 205 } 206 207 // as the comparison should be commutative, we do not need to check, if in list 2 there is 208 // a child equal to one in list 1 209 return TaskEquality.UNEQUAL; 210 } 211 212 /** 213 * <p> 214 * ensures for the two given lists, that for at least one task in the first list there is a task 190 215 * in the second list being on the given level equal to the task in the first list. 191 216 * </p> … … 195 220 * @param requiredEqualityLevel the equality level to be checked for 196 221 * 197 * @return true if each task in the first list has an equal task in the second list when198 * considering the given equality level, false else.222 * @return true if there is a task in the first list that has an equal task in the second list 223 * when considering the given equality level, false else. 199 224 */ 200 225 private boolean checkEqualityLevel(List<ITask> children1, … … 202 227 TaskEquality requiredEqualityLevel) 203 228 { 204 TaskEquality childEquality;205 229 TaskEquality currentEquality; 206 230 for (ITask child1 : children1) { 207 childEquality = null;208 231 for (ITask child2 : children2) { 209 232 currentEquality = callRuleManager(child1, child2, requiredEqualityLevel); … … 212 235 // we found at least one equal child with sufficient equality in the 213 236 // second list. So be can break up for this child. 214 childEquality = currentEquality; 215 break; 237 return true; 216 238 } 217 239 } 218 219 if (childEquality == null) { 220 // we did not find any child in the second list, that is equal to the searched 221 // child 222 return false; 223 } 224 } 225 226 // for all children, we found an equality 227 return true; 240 } 241 242 return false; 228 243 } 229 244 … … 259 274 } 260 275 276 /** 277 * <p> 278 * compares two selection instances with each other checking for the provided required level of 279 * equality. If this level is ensured, the method immediately returns. The more concrete 280 * the required equality level, the more checks this method performs. 281 * </p> 282 * 283 * @param taskInstance1 the first task instance to be compared 284 * @param taskInstance2 the second task instance to be compared 285 * @param requiredEqualityLevel the equality level to be checked for 286 * 287 * @return the determined equality. 288 */ 289 private TaskEquality getEquality(ITaskInstance taskInstance1, 290 ITaskInstance taskInstance2, 291 TaskEquality requiredEqualityLevel) 292 { 293 ITaskInstance child1 = ((ISelectionInstance) taskInstance1).getChild(); 294 ITaskInstance child2 = ((ISelectionInstance) taskInstance2).getChild(); 295 296 // if both selections do not have children, they are lexically equal. If only one of them 297 // has children, they are unequal. 298 if ((child1 == null) && (child2 == null)) { 299 return TaskEquality.LEXICALLY_EQUAL; 300 } 301 else if ((child1 == null) || (child2 == null)) { 302 return TaskEquality.UNEQUAL; 303 } 304 305 TaskEquality equality = callRuleManager(child1, child2, requiredEqualityLevel); 306 307 if (equality == TaskEquality.IDENTICAL) { 308 // two different selection instances can be at most lexically equal even if their 309 // children are identical 310 return TaskEquality.LEXICALLY_EQUAL; 311 } 312 else { 313 return equality; 314 } 315 } 316 317 /** 318 * <p> 319 * used to to call the task equality rule manager for the comparison of the two provided 320 * children. If no required equality level is provided, than the most concrete equality is 321 * returned. Otherwise, the required equality is returned as long as the children are equal 322 * on that level. 323 * </p> 324 * 325 * @param taskInstance1 the first task instance to be compared 326 * @param taskInstance2 the second task instance to be compared 327 * @param requiredEqualityLevel the equality level to be checked for 328 * 329 * @return the determined equality 330 */ 331 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 332 ITaskInstance taskInstance2, 333 TaskEquality requiredEqualityLevel) 334 { 335 if (requiredEqualityLevel == null) { 336 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 337 } 338 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 339 (taskInstance1, taskInstance2, requiredEqualityLevel)) 340 { 341 return requiredEqualityLevel; 342 } 343 else { 344 return TaskEquality.UNEQUAL; 345 } 346 } 261 347 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 34 36 35 37 /* (non-Javadoc) 36 * @see NodeComparisonRule#isApplicable(ITask, ITask)38 * @see TaskComparisonRule#isApplicable(ITask, ITask) 37 39 */ 38 40 @Override … … 42 44 43 45 /* (non-Javadoc) 44 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)46 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 45 47 */ 46 48 @Override … … 51 53 52 54 /* (non-Javadoc) 53 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)55 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 54 56 */ 55 57 @Override … … 60 62 61 63 /* (non-Javadoc) 62 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)64 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 63 65 */ 64 66 @Override … … 69 71 70 72 /* (non-Javadoc) 71 * @see NodeComparisonRule#compare(ITask, ITask)73 * @see TaskComparisonRule#compare(ITask, ITask) 72 74 */ 73 75 @Override 74 76 public TaskEquality compare(ITask task1, ITask task2) { 75 77 return getEquality(task1, task2, null); 78 } 79 80 /* (non-Javadoc) 81 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 82 */ 83 @Override 84 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 85 return isApplicable(instance1.getTask(), instance2.getTask()); 86 } 87 88 /* (non-Javadoc) 89 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 90 */ 91 @Override 92 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 93 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 94 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 95 } 96 97 /* (non-Javadoc) 98 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 99 */ 100 @Override 101 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 102 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 103 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 104 } 105 106 /* (non-Javadoc) 107 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 108 */ 109 @Override 110 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 111 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 112 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 113 } 114 115 /* (non-Javadoc) 116 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 117 */ 118 @Override 119 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 120 return getEquality(instance1, instance2, null); 76 121 } 77 122 … … 149 194 } 150 195 } 196 197 /** 198 * <p> 199 * compares two sequence instances with each other checking for the provided required level of 200 * equality. If this level is ensured, the method immediately returns. The more concrete 201 * the required equality level, the more checks this method performs. 202 * </p> 203 * 204 * @param taskInstance1 the first task instance to be compared 205 * @param taskInstance2 the second task instance to be compared 206 * @param requiredEqualityLevel the equality level to be checked for 207 * 208 * @return the determined equality. 209 */ 210 private TaskEquality getEquality(ITaskInstance taskInstance1, 211 ITaskInstance taskInstance2, 212 TaskEquality requiredEqualityLevel) 213 { 214 ISequenceInstance sequence1 = (ISequenceInstance) taskInstance1; 215 ISequenceInstance sequence2 = (ISequenceInstance) taskInstance2; 216 217 // if both sequences do not have children, they are equal although this doesn't make sense 218 if ((sequence1.size() == 0) && (sequence2.size() == 0)) { 219 return TaskEquality.LEXICALLY_EQUAL; 220 } 221 222 if (sequence1.size() != sequence2.size()) { 223 return TaskEquality.UNEQUAL; 224 } 225 226 TaskEquality resultingEquality = TaskEquality.LEXICALLY_EQUAL; 227 for (int i = 0; i < sequence1.size(); i++) { 228 ITaskInstance child1 = sequence1.get(i); 229 ITaskInstance child2 = sequence2.get(i); 230 231 TaskEquality taskEquality = callRuleManager(child1, child2, requiredEqualityLevel); 232 233 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 234 return TaskEquality.UNEQUAL; 235 } 236 237 resultingEquality = resultingEquality.getCommonDenominator(taskEquality); 238 } 239 240 return resultingEquality; 241 } 242 243 /** 244 * <p> 245 * used to to call the task equality rule manager for the comparison of the two provided 246 * children. If no required equality level is provided, than the most concrete equality is 247 * returned. Otherwise, the required equality is returned as long as the children are equal 248 * on that level. 249 * </p> 250 * 251 * @param taskInstance1 the first task instance to be compared 252 * @param taskInstance2 the second task instance to be compared 253 * @param requiredEqualityLevel the equality level to be checked for 254 * 255 * @return the determined equality 256 */ 257 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 258 ITaskInstance taskInstance2, 259 TaskEquality requiredEqualityLevel) 260 { 261 if (requiredEqualityLevel == null) { 262 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 263 } 264 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 265 (taskInstance1, taskInstance2, requiredEqualityLevel)) 266 { 267 return requiredEqualityLevel; 268 } 269 else { 270 return TaskEquality.UNEQUAL; 271 } 272 } 151 273 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRule.java
r1190 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 19 21 20 22 /** … … 33 35 34 36 /* (non-Javadoc) 35 * @see NodeComparisonRule#isApplicable(ITask, ITask)37 * @see TaskComparisonRule#isApplicable(ITask, ITask) 36 38 */ 37 39 @Override … … 42 44 43 45 /* (non-Javadoc) 44 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)46 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 45 47 */ 46 48 @Override … … 51 53 52 54 /* (non-Javadoc) 53 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)55 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 54 56 */ 55 57 @Override … … 60 62 61 63 /* (non-Javadoc) 62 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)64 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 63 65 */ 64 66 @Override … … 69 71 70 72 /* (non-Javadoc) 71 * @see NodeComparisonRule#compare(ITask, ITask)73 * @see TaskComparisonRule#compare(ITask, ITask) 72 74 */ 73 75 @Override 74 76 public TaskEquality compare(ITask task1, ITask task2) { 75 77 return getEquality(task1, task2, null); 78 } 79 80 /* (non-Javadoc) 81 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 82 */ 83 @Override 84 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 85 return isApplicable(instance1.getTask(), instance2.getTask()); 86 } 87 88 /* (non-Javadoc) 89 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 90 */ 91 @Override 92 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 93 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 94 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 95 } 96 97 /* (non-Javadoc) 98 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 99 */ 100 @Override 101 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 102 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 103 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 104 } 105 106 /* (non-Javadoc) 107 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 108 */ 109 @Override 110 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 111 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 112 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 113 } 114 115 /* (non-Javadoc) 116 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 117 */ 118 @Override 119 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 120 return getEquality(instance1, instance2, null); 76 121 } 77 122 … … 167 212 } 168 213 } 214 215 /** 216 * <p> 217 * compares two task instances with each other checking for the provided required level of 218 * equality. One of the task instances must be a iteration, the other one not. If this is not 219 * the case, the method returns null. The returned equality level is at most lexical equality 220 * as the iteration can not be identical to something not being a iteration. 221 * </p> 222 * 223 * @param taskInstance1 the first task instance to be compared 224 * @param taskInstance2 the second task instance to be compared 225 * @param requiredEqualityLevel the equality level to be checked for 226 * 227 * @return the determined equality. 228 */ 229 private TaskEquality getEquality(ITaskInstance taskInstance1, 230 ITaskInstance taskInstance2, 231 TaskEquality requiredEqualityLevel) 232 { 233 IIterationInstance iteration = null; 234 ITaskInstance task = null; 235 236 if (taskInstance1 instanceof IIterationInstance) { 237 if (taskInstance2 instanceof IIterationInstance) { 238 // the rule is not responsible for two iterations 239 return null; 240 } 241 242 iteration = (IIterationInstance) taskInstance1; 243 task = taskInstance2; 244 } 245 else if (taskInstance2 instanceof IIterationInstance) { 246 if (taskInstance1 instanceof IIterationInstance) { 247 // the rule is not responsible for two iterations 248 return null; 249 } 250 251 iteration = (IIterationInstance) taskInstance2; 252 task = taskInstance1; 253 } 254 else { 255 return null; 256 } 257 258 // now, that we found the iteration and the task, lets compare the children of the iteration 259 // with the task. 260 261 if (iteration.size() < 1) { 262 return null; 263 } 264 265 TaskEquality mostConcreteNodeEquality = null; 266 267 for (ITaskInstance child : iteration) { 268 TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 269 270 if (taskEquality != TaskEquality.UNEQUAL) { 271 if (mostConcreteNodeEquality == null) { 272 mostConcreteNodeEquality = taskEquality; 273 } 274 else if (mostConcreteNodeEquality.isAtLeast(taskEquality)) { 275 mostConcreteNodeEquality = taskEquality; 276 277 } 278 279 if ((requiredEqualityLevel != null) && 280 (mostConcreteNodeEquality.isAtLeast(requiredEqualityLevel))) 281 { 282 // if we found one child of the selection that is as equal as required, then 283 // we can consider the selection to be sufficiently equal to the other task. 284 // So we break up checking further children. 285 break; 286 } 287 } 288 } 289 290 // although the subtask may be identical to the task, we can not return identical, as 291 // the selection is not identical to the task, but at most lexically equal 292 if (mostConcreteNodeEquality == TaskEquality.IDENTICAL) { 293 return TaskEquality.LEXICALLY_EQUAL; 294 } 295 else { 296 return mostConcreteNodeEquality; 297 } 298 299 } 300 301 /** 302 * <p> 303 * used to to call the task equality rule manager for the comparison of the two provided 304 * children. If no required equality level is provided, than the most concrete equality is 305 * returned. Otherwise, the required equality is returned as long as the children are equal 306 * on that level. 307 * </p> 308 * 309 * @param taskInstance1 the first task instance to be compared 310 * @param taskInstance2 the second task instance to be compared 311 * @param requiredEqualityLevel the equality level to be checked for 312 * 313 * @return the determined equality 314 */ 315 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 316 ITaskInstance taskInstance2, 317 TaskEquality requiredEqualityLevel) 318 { 319 if (requiredEqualityLevel == null) { 320 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 321 } 322 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 323 (taskInstance1, taskInstance2, requiredEqualityLevel)) 324 { 325 return requiredEqualityLevel; 326 } 327 else { 328 return TaskEquality.UNEQUAL; 329 } 330 } 169 331 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndSelectionComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 34 36 35 37 /* (non-Javadoc) 36 * @see NodeComparisonRule#isApplicable(ITask, ITask)38 * @see TaskComparisonRule#isApplicable(ITask, ITask) 37 39 */ 38 40 @Override … … 43 45 44 46 /* (non-Javadoc) 45 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)47 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 46 48 */ 47 49 @Override … … 52 54 53 55 /* (non-Javadoc) 54 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)56 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 55 57 */ 56 58 @Override … … 61 63 62 64 /* (non-Javadoc) 63 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)65 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 64 66 */ 65 67 @Override … … 70 72 71 73 /* (non-Javadoc) 72 * @see NodeComparisonRule#compare(ITask, ITask)74 * @see TaskComparisonRule#compare(ITask, ITask) 73 75 */ 74 76 @Override … … 77 79 } 78 80 81 /* (non-Javadoc) 82 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 83 */ 84 @Override 85 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 86 return isApplicable(instance1.getTask(), instance2.getTask()); 87 } 88 89 /* (non-Javadoc) 90 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 91 */ 92 @Override 93 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 94 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 95 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 96 } 97 98 /* (non-Javadoc) 99 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 100 */ 101 @Override 102 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 103 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 104 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 105 } 106 107 /* (non-Javadoc) 108 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 109 */ 110 @Override 111 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 112 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 113 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 114 } 115 116 /* (non-Javadoc) 117 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 118 */ 119 @Override 120 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 121 return getEquality(instance1, instance2, null); 122 } 123 79 124 /** 80 125 * <p> … … 191 236 } 192 237 } 238 239 /** 240 * <p> 241 * compares two task instances with each other checking for the provided required level of 242 * equality. One of the task instances must be a selection, the other one not. If this is not 243 * the case, the method returns null. The returned equality level is at most lexical equality 244 * as the selection can not be identical to something not being a selection. 245 * </p> 246 * 247 * @param taskInstance1 the first task instance to be compared 248 * @param taskInstance2 the second task instance to be compared 249 * @param requiredEqualityLevel the equality level to be checked for 250 * 251 * @return the determined equality. 252 */ 253 private TaskEquality getEquality(ITaskInstance taskInstance1, 254 ITaskInstance taskInstance2, 255 TaskEquality requiredEqualityLevel) 256 { 257 ISelectionInstance selection = null; 258 ITaskInstance task = null; 259 260 if (taskInstance1 instanceof ISelectionInstance) { 261 if (taskInstance2 instanceof ISelectionInstance) { 262 // the rule is not responsible for two selections 263 return null; 264 } 265 266 selection = (ISelectionInstance) taskInstance1; 267 task = taskInstance2; 268 } 269 else if (taskInstance2 instanceof ISelectionInstance) { 270 if (taskInstance1 instanceof ISelectionInstance) { 271 // the rule is not responsible for two selections 272 return null; 273 } 274 275 selection = (ISelectionInstance) taskInstance2; 276 task = taskInstance1; 277 } 278 else { 279 return null; 280 } 281 282 // now, that we found the selection and the task, lets compare the child of the selection 283 // with the task. 284 ITaskInstance child = selection.getChild(); 285 286 if (child == null) { 287 return null; 288 } 289 290 TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 291 292 // although the subtask may be identical to the task, we can not return identical, as 293 // the selection is not identical to the task, but at most lexically equal 294 if (taskEquality == TaskEquality.IDENTICAL) { 295 return TaskEquality.LEXICALLY_EQUAL; 296 } 297 else { 298 return taskEquality; 299 } 300 301 } 302 303 /** 304 * <p> 305 * used to to call the task equality rule manager for the comparison of the two provided 306 * children. If no required equality level is provided, than the most concrete equality is 307 * returned. Otherwise, the required equality is returned as long as the children are equal 308 * on that level. 309 * </p> 310 * 311 * @param taskInstance1 the first task instance to be compared 312 * @param taskInstance2 the second task instance to be compared 313 * @param requiredEqualityLevel the equality level to be checked for 314 * 315 * @return the determined equality 316 */ 317 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 318 ITaskInstance taskInstance2, 319 TaskEquality requiredEqualityLevel) 320 { 321 if (requiredEqualityLevel == null) { 322 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 323 } 324 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 325 (taskInstance1, taskInstance2, requiredEqualityLevel)) 326 { 327 return requiredEqualityLevel; 328 } 329 else { 330 return TaskEquality.UNEQUAL; 331 } 332 } 193 333 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskComparisonRule.java
r1146 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 19 19 20 /** 20 21 * <p> 21 * A task comparison rule is used by the {@link TaskEqualityRuleManager} to compare tasks with22 * each other. It provides several methods to be called for a comparison.22 * A task comparison rule is used by the {@link TaskEqualityRuleManager} to compare tasks and 23 * task instances with each other. It provides several methods to be called for a comparison. 23 24 * </p> 24 25 * … … 90 91 public TaskEquality compare(ITask task1, ITask task2); 91 92 93 /** 94 * <p> 95 * checks if the rule is applicable for comparing the two provided task instances 96 * </p> 97 * 98 * @param instance1 the first task instance to compare 99 * @param instance2 the second task instance to compare 100 * 101 * @return true, if the rule is applicable, false else 102 */ 103 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2); 104 105 /** 106 * <p> 107 * checks, if the provided task instances are lexically equal 108 * </p> 109 * 110 * @param instance1 the first task instance to compare 111 * @param instance2 the second task instance to compare 112 * 113 * @return true, if the tasks are equal, false else 114 */ 115 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2); 116 117 /** 118 * <p> 119 * checks, if the provided task instances are syntactically equal 120 * </p> 121 * 122 * @param instance1 the first task instance to compare 123 * @param instance2 the second task instance to compare 124 * 125 * @return true, if the tasks are equal, false else 126 */ 127 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2); 128 129 /** 130 * <p> 131 * checks, if the provided task instances are semantically equal 132 * </p> 133 * 134 * @param instance1 the first task instance to compare 135 * @param instance2 the second task instance to compare 136 * 137 * @return true, if the tasks are equal, false else 138 */ 139 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2); 140 141 /** 142 * <p> 143 * compares two task instances with each other. The result of the method is either a task 144 * instance equality or null. If it is null, it means, that the rule is not able to correctly 145 * compare the two given task instances 146 * </p> 147 * 148 * @param instance1 the first task instance to compare 149 * @param instance2 the second task instance to compare 150 * 151 * @return as described 152 */ 153 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2); 154 92 155 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java
r1190 r1294 19 19 20 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 22 22 23 /** 23 24 * <p> 24 * The task equality rule manager is capable of comparing tasks based on its internal list25 * of comparison rules. These rules are asked for comparing the two provided tasks. If a rule26 * returns a task equality other than null, this equality is returned. Otherwise the next rule27 * is asked.25 * The task equality rule manager is capable of comparing tasks and task instances based on its 26 * internal list of comparison rules. These rules are asked for comparing the two provided tasks or 27 * task instance. If a rule returns a task equality other than null, this equality is returned. 28 * Otherwise the next rule is asked. 28 29 * </p> 29 30 * 30 * @version $Revision: $ $Date: 19.02.2012$ 31 * @author 2012, last modified by $Author: patrick$ 31 * @author Patrick Harms 32 32 */ 33 33 public class TaskEqualityRuleManager { … … 269 269 } 270 270 271 /** 272 * <p> 273 * this method performs a comparison of the two provided task instances. It iterates its 274 * internal comparison rules. If the first rule returns a task instance equality other than 275 * null, this equality is returned. Otherwise the next rule is tried. If no rule returns an 276 * equality <code>TaskEquality.UNEQUAL</code> is returned. 277 * </p> 278 * 279 * @param instance1 the first task instance to be compared 280 * @param instance2 the second task instance to be compared 281 * 282 * @return as described 283 * 284 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 285 * manager before a call to this method. 286 */ 287 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) 288 throws IllegalStateException 289 { 290 if (mRuleIndex == null) { 291 throw new IllegalStateException("not initialized"); 292 } 293 294 // LOG.info("checking for equality of " + instance1 + " and " + instance2); 295 TaskEquality instanceEquality = null; 296 297 for (TaskComparisonRule rule : mRuleIndex) { 298 if (rule.isApplicable(instance1, instance2)) { 299 instanceEquality = rule.compare(instance1, instance2); 300 if (instanceEquality != null) { 301 // LOG.warning("used rule " + rule + " for equality check"); 302 return instanceEquality; 303 } 304 } 305 } 306 307 // LOG.warning("no rule could be applied --> handling tasks as unequal"); 308 309 return TaskEquality.UNEQUAL; 310 } 311 312 /** 313 * <p> 314 * this method compares two task instances with respect to the given equality level and returns 315 * true, if this level is given. 316 * </p> 317 * 318 * @param instance1 the first task instance to be compared 319 * @param instance2 the second task instance to be compared 320 * @param equalityLevel the level of equality to be checked for 321 * 322 * @return as described 323 * 324 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 325 * manager before a call to this method. 326 */ 327 public boolean areAtLeastEqual(ITaskInstance instance1, 328 ITaskInstance instance2, 329 TaskEquality equalityLevel) 330 { 331 if (equalityLevel == null) { 332 throw new IllegalArgumentException("required equality level must not be null"); 333 } 334 335 switch (equalityLevel) { 336 case IDENTICAL: 337 return areIdentical(instance1, instance2); 338 case LEXICALLY_EQUAL: 339 return areLexicallyEqual(instance1, instance2); 340 case SYNTACTICALLY_EQUAL: 341 return areSyntacticallyEqual(instance1, instance2); 342 case SEMANTICALLY_EQUAL: 343 return areSemanticallyEqual(instance1, instance2); 344 case UNEQUAL: 345 return !areSemanticallyEqual(instance1, instance2); 346 default: 347 throw new IllegalArgumentException("unknown required equality: " + equalityLevel); 348 } 349 } 350 351 /** 352 * <p> 353 * this method checks if the two given task instances are identical. For this, it iterates its 354 * internal comparison rules. If the first rule returns true, than this method returns true 355 * as well. If no rule returns true, this method returns false. 356 * </p> 357 * 358 * @param instance1 the first task instance to be compared 359 * @param instance2 the second task instance to be compared 360 * 361 * @return as described 362 * 363 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 364 * manager before a call to this method. 365 */ 366 public boolean areIdentical(ITaskInstance instance1, ITaskInstance instance2) { 367 if (mRuleIndex == null) { 368 throw new IllegalStateException("not initialized"); 369 } 370 371 for (TaskComparisonRule rule : mRuleIndex) { 372 if (rule.isApplicable(instance1, instance2) && 373 rule.areLexicallyEqual(instance1, instance2)) 374 { 375 return true; 376 } 377 } 378 379 return false; 380 } 381 382 /** 383 * <p> 384 * this method checks if the two given task instances are lexically equal. For this, it 385 * iterates its internal comparison rules. If the first rule returns true, than this method 386 * returns true, as well. If no rule returns true, this method returns false. 387 * </p> 388 * 389 * @param instance1 the first task instance to be compared 390 * @param instance2 the second task instance to be compared 391 * 392 * @return as described 393 * 394 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 395 * manager before a call to this method. 396 */ 397 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 398 if (mRuleIndex == null) { 399 throw new IllegalStateException("not initialized"); 400 } 401 402 for (TaskComparisonRule rule : mRuleIndex) { 403 if (rule.isApplicable(instance1, instance2) && 404 rule.areLexicallyEqual(instance1, instance2)) 405 { 406 return true; 407 } 408 } 409 410 return false; 411 } 412 413 /** 414 * <p> 415 * this method checks if the two given task instances are syntactically equal. For this, it 416 * iterates its internal comparison rules. If the first rule returns true, than this method 417 * returns true, as well. If no rule returns true, this method returns false. 418 * </p> 419 * 420 * @param instance1 the first task instance to be compared 421 * @param instance2 the second task instance to be compared 422 * 423 * @return as described 424 * 425 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 426 * manager before a call to this method. 427 */ 428 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 429 if (mRuleIndex == null) { 430 throw new IllegalStateException("not initialized"); 431 } 432 433 for (TaskComparisonRule rule : mRuleIndex) { 434 if (rule.isApplicable(instance1, instance2) && 435 rule.areSyntacticallyEqual(instance1, instance2)) 436 { 437 return true; 438 } 439 } 440 441 return false; 442 } 443 444 /** 445 * <p> 446 * this method checks if the two given task instances are semantically equal. For this, it 447 * iterates its internal comparison rules. If the first rule returns true, than this method 448 * returns true, as well. If no rule returns true, this method returns false. 449 * </p> 450 * 451 * @param instance1 the first task instance to be compared 452 * @param instance2 the second task instance to be compared 453 * 454 * @return as described 455 * 456 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 457 * manager before a call to this method. 458 */ 459 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 460 if (mRuleIndex == null) { 461 throw new IllegalStateException("not initialized"); 462 } 463 464 for (TaskComparisonRule rule : mRuleIndex) { 465 if (rule.isApplicable(instance1, instance2) && 466 rule.areSemanticallyEqual(instance1, instance2)) 467 { 468 return true; 469 } 470 } 471 472 return false; 473 } 474 271 475 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskIdentityRule.java
r1146 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 19 19 20 /** 20 21 * <p> 21 22 * This comparison rule returns <code>TaskEquality.IDENTICAL</code> if the comparison of the two 22 * tasks using the <code>==</code> operator or the <code>equals</code> method return true.23 * Else it returns null to denote, thatit can not compare the tasks.23 * tasks using the <code>==</code> operator returns true. Else it returns null to denote, that 24 * it can not compare the tasks. 24 25 * </p> 25 26 * … … 30 31 31 32 /* (non-Javadoc) 32 * @see NodeComparisonRule#isApplicable(ITask, ITask)33 * @see TaskComparisonRule#isApplicable(ITask, ITask) 33 34 */ 34 35 @Override … … 38 39 39 40 /* (non-Javadoc) 40 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)41 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 41 42 */ 42 43 @Override … … 46 47 47 48 /* (non-Javadoc) 48 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)49 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 49 50 */ 50 51 @Override … … 54 55 55 56 /* (non-Javadoc) 56 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)57 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 57 58 */ 58 59 @Override … … 62 63 63 64 /* (non-Javadoc) 64 * @see NodeComparisonRule#compare(ITask, ITask)65 * @see TaskComparisonRule#compare(ITask, ITask) 65 66 */ 66 67 @Override … … 74 75 } 75 76 77 /* (non-Javadoc) 78 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 79 */ 80 @Override 81 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 82 return (instance1.getTask() == instance2.getTask()); 83 } 84 85 /* (non-Javadoc) 86 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 87 */ 88 @Override 89 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 90 return (instance1.getTask() == instance2.getTask()); 91 } 92 93 /* (non-Javadoc) 94 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 95 */ 96 @Override 97 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 98 return (instance1.getTask() == instance2.getTask()); 99 } 100 101 /* (non-Javadoc) 102 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 103 */ 104 @Override 105 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 106 return (instance1.getTask() == instance2.getTask()); 107 } 108 109 /* (non-Javadoc) 110 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 111 */ 112 @Override 113 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 114 if (isApplicable(instance1, instance2)) { 115 return TaskEquality.IDENTICAL; 116 } 117 else { 118 return null; 119 } 120 } 121 76 122 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/ITaskInstanceScopeRule.java
r1219 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance List;17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 18 19 19 /** 20 20 * <p> 21 * a task instance list scope rule is able to detected temporal relationships between a list of task22 * instances provided to the {@link #apply(ITaskInstanceList)} method. A rule creates temporal21 * a task instance scope rule is able to detected temporal relationships between the children of 22 * a task instance provided to the {@link #apply(ITaskInstance)} method. A rule creates temporal 23 23 * relationships between the task instances, i.e. substructures in the task tree, if 24 24 * it detects a temporal relationship and instantiates the temporal relationships accordingly. … … 27 27 * @author Patrick Harms 28 28 */ 29 interface ITaskInstance ListScopeRule extends ITemporalRelationshipRule {29 interface ITaskInstanceScopeRule extends ITemporalRelationshipRule { 30 30 31 31 /** 32 32 * <p> 33 * applies the rule to the given task instance list. The returned rule application result is null,33 * applies the rule to the given task instance. The returned rule application result is null, 34 34 * if the rule can not be applied, i.e. it does not detect a temporal relationship. It returns a 35 35 * rule application result with a status {@link RuleApplicationStatus#RULE_APPLICATION_FINISHED} … … 37 37 * </p> 38 38 * 39 * @param taskInstance s the list oftask instances to apply the rule on39 * @param taskInstance the task instances to apply the rule on 40 40 * 41 41 * @return the rule application result as described. 42 42 */ 43 RuleApplicationResult apply(ITaskInstance List taskInstances);43 RuleApplicationResult apply(ITaskInstance taskInstance); 44 44 45 45 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/ITemporalRelationshipRule.java
r1284 r1294 19 19 * a temporal relationship rule is the main interface for all rules applied for generating 20 20 * temporal relationships in a task tree. It is just a marker interface. More important are the 21 * sub interfaces {@link ISessionScopeRule} and {@link ITaskInstance ListScopeRule}.21 * sub interfaces {@link ISessionScopeRule} and {@link ITaskInstanceScopeRule}. 22 22 * </p> 23 23 * -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1281 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 19 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 55 56 int startIndex, 56 57 int endIndex, 57 I Taskmodel,58 ISequence model, 58 59 ITaskFactory taskFactory, 59 60 ITaskBuilder taskBuilder) 60 61 { 61 I TaskInstance subsequence = taskFactory.createNewTaskInstance(model);62 ISequenceInstance subsequence = taskFactory.createNewTaskInstance(model); 62 63 63 64 for (int i = startIndex; i <= endIndex; i++) { … … 83 84 * @return the replacement for the range 84 85 */ 85 static I TaskInstance createNewSubSequenceInRange(ITaskInstanceList parent,86 int startIndex,87 int endIndex,88 ITaskmodel,89 ITaskFactory taskFactory,90 ITaskBuilder taskBuilder)86 static ISequenceInstance createNewSubSequenceInRange(ITaskInstanceList parent, 87 int startIndex, 88 int endIndex, 89 ISequence model, 90 ITaskFactory taskFactory, 91 ITaskBuilder taskBuilder) 91 92 { 92 I TaskInstance subsequence = taskFactory.createNewTaskInstance(model);93 ISequenceInstance subsequence = taskFactory.createNewTaskInstance(model); 93 94 94 95 for (int i = startIndex; i <= endIndex; i++) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
r1287 r1294 26 26 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 27 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 31 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 159 162 SymbolMap<ITaskInstance, ITask> uniqueTasks = 160 163 preparationTaskHandlingStrategy.createSymbolMap(); 161 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();164 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 162 165 163 166 int unifiedTasks = 0; … … 235 238 { 236 239 Map<ITask, IIteration> iterations = new HashMap<ITask, IIteration>(); 237 Map<IIteration, List<I TaskInstance>> iterationInstances =238 new HashMap<IIteration, List<I TaskInstance>>();240 Map<IIteration, List<IIterationInstance>> iterationInstances = 241 new HashMap<IIteration, List<IIterationInstance>>(); 239 242 240 243 for (ITask iteratedTask : iteratedTasks) { 241 244 IIteration iteration = taskFactory.createNewIteration(); 242 245 iterations.put(iteratedTask, iteration); 243 iterationInstances.put(iteration, new LinkedList<I TaskInstance>());244 } 245 246 I TaskInstance iterationInstance = null;246 iterationInstances.put(iteration, new LinkedList<IIterationInstance>()); 247 } 248 249 IIterationInstance iterationInstance = null; 247 250 248 251 for (IUserSession session : sessions) { … … 275 278 } 276 279 277 for (Map.Entry<IIteration, List<ITaskInstance>> entry : iterationInstances.entrySet()) { 280 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances.entrySet()) 281 { 278 282 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 279 283 } … … 283 287 * 284 288 */ 285 private void harmonizeIterationInstancesModel(IIteration iteration,286 List<I TaskInstance> iterationInstances)289 private void harmonizeIterationInstancesModel(IIteration iteration, 290 List<IIterationInstance> iterationInstances) 287 291 { 288 292 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 289 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();293 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 290 294 291 295 // merge the lexically different variants of iterated task to a unique list 292 for (I TaskInstance iterationInstance : iterationInstances) {296 for (IIterationInstance iterationInstance : iterationInstances) { 293 297 for (ITaskInstance executionVariant : iterationInstance) { 294 298 ITask candidate = executionVariant.getTask(); … … 323 327 taskBuilder.setMarkedTask(iteration, selection); 324 328 325 for (I TaskInstance instance : iterationInstances) {329 for (IIterationInstance instance : iterationInstances) { 326 330 for (int i = 0; i < instance.size(); i++) { 327 ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 328 taskBuilder.addChild(selectionInstance, instance.get(i)); 331 ISelectionInstance selectionInstance = 332 taskFactory.createNewTaskInstance(selection); 333 taskBuilder.setChild(selectionInstance, instance.get(i)); 329 334 taskBuilder.setTaskInstance(instance, i, selectionInstance); 330 335 } … … 490 495 Console.traceln(Level.FINEST, "replacing " + sequence.getId() + ": " + task); 491 496 492 List<I TaskInstance> sequenceInstances =497 List<ISequenceInstance> sequenceInstances = 493 498 replaceTaskOccurrences(task, appData.getSessions(), sequence); 494 499 … … 510 515 * 511 516 */ 512 private void harmonizeSequenceInstancesModel(ISequence sequence,513 List<I TaskInstance> sequenceInstances,514 int sequenceLength)517 private void harmonizeSequenceInstancesModel(ISequence sequence, 518 List<ISequenceInstance> sequenceInstances, 519 int sequenceLength) 515 520 { 516 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();521 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 517 522 518 523 // ensure for each subtask that lexically different variants are preserved … … 520 525 List<ITask> subTaskVariants = new LinkedList<ITask>(); 521 526 522 for (I TaskInstance sequenceInstance : sequenceInstances) {527 for (ISequenceInstance sequenceInstance : sequenceInstances) { 523 528 ITask candidate = sequenceInstance.get(subTaskIndex).getTask(); 524 529 … … 556 561 taskBuilder.addChild(sequence, selection); 557 562 558 for (I TaskInstance instance : sequenceInstances) {559 I TaskInstance selectionInstance =563 for (ISequenceInstance instance : sequenceInstances) { 564 ISelectionInstance selectionInstance = 560 565 taskFactory.createNewTaskInstance(selection); 561 taskBuilder. addChild(selectionInstance, instance.get(subTaskIndex));566 taskBuilder.setChild(selectionInstance, instance.get(subTaskIndex)); 562 567 taskBuilder.setTaskInstance(instance, subTaskIndex, selectionInstance); 563 568 } … … 572 577 * @param tree 573 578 */ 574 private List<I TaskInstance> replaceTaskOccurrences(List<ITaskInstance> task,575 List<IUserSession> sessions,576 ISequence temporalTaskModel)579 private List<ISequenceInstance> replaceTaskOccurrences(List<ITaskInstance> task, 580 List<IUserSession> sessions, 581 ISequence temporalTaskModel) 577 582 { 578 List<I TaskInstance> sequenceInstances = new LinkedList<ITaskInstance>();583 List<ISequenceInstance> sequenceInstances = new LinkedList<ISequenceInstance>(); 579 584 580 585 for (IUserSession session : sessions) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskHandlingStrategy.java
r1285 r1294 42 42 * 43 43 */ 44 private Task Comparator comparator;44 private TaskInstanceComparator comparator; 45 45 46 46 /** … … 58 58 } 59 59 else { 60 comparator = new Task Comparator(this.consideredEquality);60 comparator = new TaskInstanceComparator(this.consideredEquality); 61 61 } 62 62 } … … 77 77 * @return 78 78 */ 79 public Task Comparator getTaskComparator() {79 public TaskInstanceComparator getTaskComparator() { 80 80 return comparator; 81 81 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskIdentityComparator.java
r1285 r1294 21 21 * TODO comment 22 22 */ 23 class TaskIdentityComparator extends Task Comparator {23 class TaskIdentityComparator extends TaskInstanceComparator { 24 24 25 25 /** */ -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceComparator.java
r1285 r1294 28 28 * TODO comment 29 29 */ 30 class Task Comparator implements SymbolComparator<ITaskInstance> {30 class TaskInstanceComparator implements SymbolComparator<ITaskInstance> { 31 31 32 32 /** */ … … 54 54 * 55 55 */ 56 public Task Comparator(TaskEquality minimalNodeEquality) {56 public TaskInstanceComparator(TaskEquality minimalNodeEquality) { 57 57 this.minimalNodeEquality = minimalNodeEquality; 58 58 init(); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolBucketedMap.java
r1285 r1294 27 27 28 28 import de.ugoe.cs.autoquest.eventcore.IEventType; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 34 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 35 34 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; … … 81 80 * </p> 82 81 */ 83 private Task Comparator comparator;82 private TaskInstanceComparator comparator; 84 83 85 84 /** … … 117 116 * @throws IllegalArgumentException if the provided comparator is null 118 117 */ 119 public TaskSymbolBucketedMap(Task Comparator comparator) {118 public TaskSymbolBucketedMap(TaskInstanceComparator comparator) { 120 119 if (comparator == null) { 121 120 throw new IllegalArgumentException("comparator must not be null"); … … 400 399 // other = hashCode of name of event type 401 400 402 ITask task = taskInstance.getTask(); 403 404 if (task instanceof IEventTask) { 401 if (taskInstance instanceof IEventTaskInstance) { 405 402 // event tasks are most likely equal to those of the event type with the same name, 406 403 // Afterwards, they may be equal to iterations, optionals, other event tasks, 407 404 // selections, and finally the rest. 408 IEventType eventType = ((IEventTask ) task).getEventType();405 IEventType eventType = ((IEventTaskInstance) taskInstance).getEvent().getType(); 409 406 return new int[] { eventType.getName().hashCode(), 2, 3, 4, 1 }; 410 407 } 411 else if (task instanceof ISequence) {408 else if (taskInstance instanceof ISequenceInstance) { 412 409 return new int[] { 0, 2, 3, 1 }; 413 410 } 414 else if (task instanceof ISelection) {411 else if (taskInstance instanceof ISelectionInstance) { 415 412 return new int[] { 1, 4, 2, 3 }; 416 413 } 417 else if (task instanceof IIteration) {414 else if (taskInstance instanceof IIterationInstance) { 418 415 return new int[] { 2, 1, 4 }; 419 416 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r1189 r1294 26 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 27 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList;29 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 30 29 import de.ugoe.cs.util.console.Console; … … 38 37 * between tasks which are not only a major sequence. I.e. through the application of the 39 38 * rules iterations and selections of tasks are detected. Which kind of temporal relations 40 * between tasks are detected depends on the {@link ITaskInstance ListScopeRule}s known to39 * between tasks are detected depends on the {@link ITaskInstanceScopeRule}s known to 41 40 * this class. 42 41 * </p> 43 * <p>The class holds references to the appropriate {@link ITaskInstance ListScopeRule}s and calls44 * their {@link ITaskInstance ListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)}42 * <p>The class holds references to the appropriate {@link ITaskInstanceScopeRule}s and calls 43 * their {@link ITaskInstanceScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 45 44 * method for each task in the task tree it is needed for. The general behavior of this class is 46 45 * the following: … … 56 55 * <li> 57 56 * the class iterates its internal list of rules and calls their 58 * {@link ITaskInstance ListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)}57 * {@link ITaskInstanceScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 59 58 * method. 60 59 * </li> … … 115 114 * </p> 116 115 */ 117 private ITaskInstance ListScopeRule[] taskScopeRules;116 private ITaskInstanceScopeRule[] taskScopeRules; 118 117 119 118 /** … … 166 165 //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 167 166 168 taskScopeRules = new ITaskInstance ListScopeRule[] {167 taskScopeRules = new ITaskInstanceScopeRule[] { 169 168 //new SequenceOnGuiElementDetectionRule(taskFactory, taskTreeBuilder), 170 169 //new EventSequenceOnSameTargetDetectionRule(taskFactory, taskTreeBuilder), … … 262 261 * on the recursion depth of calling this method. 263 262 */ 264 private int applyRules(ITaskInstance ListScopeRule[] rules,265 ITaskInstance List taskInstances,263 private int applyRules(ITaskInstanceScopeRule[] rules, 264 ITaskInstance taskInstance, 266 265 String logIndent) 267 266 { 268 Console.traceln(Level.FINER, logIndent + "applying rules for " + taskInstances.size() + 269 " task instances"); 267 Console.traceln(Level.FINER, logIndent + "applying rules on " + taskInstance); 270 268 271 269 int noOfRuleApplications = 0; 272 270 273 for (ITaskInstance ListScopeRule rule : rules) {271 for (ITaskInstanceScopeRule rule : rules) { 274 272 RuleApplicationResult result; 275 273 do { 276 274 Console.traceln 277 (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance s);278 result = rule.apply(taskInstance s);275 (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance); 276 result = rule.apply(taskInstance); 279 277 280 278 if ((result != null) && … … 282 280 { 283 281 Console.traceln 284 (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance s);282 (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance); 285 283 noOfRuleApplications++; 286 284 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/IEventTask.java
r1180 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeifc; 16 16 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget;18 import de.ugoe.cs.autoquest.eventcore.IEventType;19 20 17 /** 21 18 * <p> 22 19 * Event tasks represent single events. They have no children and are therefore the leaf nodes of 23 * a task model. They provide information about the event they represent. This includes the event 24 * type and the target. 20 * a task model. They provide information about the event they represent as a String description. 21 * They do not refer to events, as they may represented several semantically equal but lexically 22 * different events. Their description carries as much information as required to show the 23 * level of distinction. 25 24 * </p> 26 25 * … … 29 28 public interface IEventTask extends ITask { 30 29 31 /**32 * <p>33 * return the type of the event represented by this task34 * </p>35 *36 * @return as described37 */38 public IEventType getEventType();39 40 /**41 * <p>42 * return the target of the event represented by this task43 * </p>44 *45 * @return as described46 */47 public IEventTarget getEventTarget();48 49 30 /** 50 31 * <p> -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITask.java
r1180 r1294 16 16 17 17 import java.io.Serializable; 18 import java.util.Collection; 18 19 19 20 /** … … 49 50 */ 50 51 public String getDescription(); 52 53 /** 54 * <p> 55 * returns a collection of all observed instances of this task 56 * </p> 57 * 58 * @return as described 59 */ 60 public Collection<ITaskInstance> getInstances(); 51 61 52 62 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskBuilder.java
r1197 r1294 26 26 /** 27 27 * <p> 28 * adds a child to a taskinstance. May ensure, that the child is a valid child considering28 * adds a child to a sequence instance. May ensure, that the child is a valid child considering 29 29 * the task model of the parent. In that case, an IllegalArgumentException is thrown. 30 30 * </p> 31 31 * 32 * @param taskInstance the instance of add the child to 33 * @param child the child to be added 34 * 35 * @throws IllegalArgumentException as described 36 */ 37 void addChild(ITaskInstance taskInstance, ITaskInstance child) throws IllegalArgumentException; 32 * @param instance the instance of add the child to 33 * @param child the child to be added 34 * 35 * @throws IllegalArgumentException as described 36 */ 37 void addChild(ISequenceInstance instance, ITaskInstance child) throws IllegalArgumentException; 38 39 /** 40 * <p> 41 * adds a child to an iteration instance. May ensure, that the child is a valid child 42 * considering the task model of the parent. In that case, an IllegalArgumentException is 43 * thrown. 44 * </p> 45 * 46 * @param instance the instance of add the child to 47 * @param child the child to be added 48 * 49 * @throws IllegalArgumentException as described 50 */ 51 void addChild(IIterationInstance instance, ITaskInstance child) throws IllegalArgumentException; 52 53 /** 54 * <p> 55 * sets the child of a selection instance. May ensure, that the child is a valid child 56 * considering the task model of the parent. In that case, an IllegalArgumentException is 57 * thrown. 58 * </p> 59 * 60 * @param instance the instance of add the child to 61 * @param child the child to be added 62 * 63 * @throws IllegalArgumentException as described 64 */ 65 void setChild(ISelectionInstance instance, ITaskInstance child) throws IllegalArgumentException; 66 67 /** 68 * <p> 69 * sets the child of an optional instance. May ensure, that the child is a valid child 70 * considering the task model of the parent. In that case, an IllegalArgumentException is 71 * thrown. 72 * </p> 73 * 74 * @param instance the instance of add the child to 75 * @param child the child to be added 76 * 77 * @throws IllegalArgumentException as described 78 */ 79 void setChild(IOptionalInstance instance, ITaskInstance child) throws IllegalArgumentException; 38 80 39 81 /** … … 215 257 void replaceChild(ISelection parent, ITask oldChild, ITask newChild); 216 258 217 /**218 * <p>219 * sets the description of a task220 * </p>221 *222 * @param task the task to set the description of223 * @param description the new description of the task224 */225 void setDescription(ITask task, String description);226 227 259 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskFactory.java
r1191 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 19 import de.ugoe.cs.autoquest.eventcore.Event; 21 20 22 21 /** … … 31 30 /** 32 31 * <p> 33 * creates a new event task with the given type and target32 * creates a new event task with the given description 34 33 * </p> 35 34 * 36 * @param eventType the type of the event represented by the task 37 * @param eventTarget the target of the event represented by the task 35 * @param description the description for the represented events 38 36 * 39 37 * @return the event task 40 38 */ 41 IEventTask createNewEventTask( IEventType eventType, IEventTarget eventTarget);39 IEventTask createNewEventTask(String description); 42 40 43 41 /** … … 79 77 /** 80 78 * <p> 81 * creates a new task instance with the given task as its model 79 * creates a new task instance with the given task as its model representing the provided event 82 80 * </p> 83 81 * 84 * @param task the model of the task instance to be created 82 * @param task the model of the task instance to be created 83 * @param event the event represented by the task instance 85 84 * 86 85 * @return the task instance 87 86 */ 88 I TaskInstance createNewTaskInstance(ITask task);87 IEventTaskInstance createNewTaskInstance(IEventTask task, Event event); 89 88 90 89 /** 91 90 * <p> 92 * creates a new empty task instance list91 * creates a new task instance with the given sequence as its model 93 92 * </p> 94 93 * 95 * @return the task instance list 94 * @param sequence the model of the task instance to be created 95 * 96 * @return the task instance 96 97 */ 97 ITaskInstanceList createNewTaskInstanceList(); 98 ISequenceInstance createNewTaskInstance(ISequence sequence); 99 100 /** 101 * <p> 102 * creates a new task instance with the given iteration as its model 103 * </p> 104 * 105 * @param iteration the model of the task instance to be created 106 * 107 * @return the task instance 108 */ 109 IIterationInstance createNewTaskInstance(IIteration iteration); 110 111 /** 112 * <p> 113 * creates a new task instance with the given optional as its model 114 * </p> 115 * 116 * @param optional the model of the task instance to be created 117 * 118 * @return the task instance 119 */ 120 IOptionalInstance createNewTaskInstance(IOptional optional); 121 122 /** 123 * <p> 124 * creates a new task instance with the given selection as its model 125 * </p> 126 * 127 * @param selection the model of the task instance to be created 128 * 129 * @return the task instance 130 */ 131 ISelectionInstance createNewTaskInstance(ISelection selection); 98 132 99 133 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInstance.java
r1177 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeifc; 16 16 17 import java. util.List;17 import java.io.Serializable; 18 18 19 19 /** 20 20 * <p> 21 21 * a task instance represents the execution of a specific task within a user session. A task 22 * instance is always related to the task that was executed. A task instance may have children 23 * but only if its related task allows to have children. For example, if the represented task is 24 * a sequence then task instance has children and these are instances of the tasks being the 25 * children of the related sequence. 26 * </p> 27 * <p> 28 * An instance of a sequence has the same number of children as the related sequence. An instance 29 * of a selection has only one child which is an instance of exactly one variant contained in the 30 * related selection. An instance of an iteration has zero or more instances of the same task 31 * as children where the task is the child of the related iteration. An instance of an optional 32 * has zero or one child where the task related to child is the child of the optional. A task 33 * instance related to an event task does not have children. 22 * instance is always related to the task that was executed. 34 23 * </p> 35 24 * 36 25 * @author Patrick Harms 37 26 */ 38 public interface ITaskInstance extends ITaskInstanceList { 39 40 /** 41 * <p> 42 * returns the children of the task instance if any. See class description for how many 43 * children can be expected. May return null. 44 * </p> 45 * 46 * @return as described 47 */ 48 public List<ITaskInstance> getChildren(); 27 public interface ITaskInstance extends Serializable, Cloneable { 49 28 50 29 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInstanceList.java
r1177 r1294 19 19 /** 20 20 * <p> 21 * represents a serializable , clonable,iterable representation of a read only list of task21 * represents a serializable and iterable representation of a read only list of task 22 22 * instances. The list is ordered. It does not provide methods for changing it. 23 23 * </p> … … 25 25 * @author Patrick Harms 26 26 */ 27 public interface ITaskInstanceList extends Serializable, Cloneable,Iterable<ITaskInstance> {27 public interface ITaskInstanceList extends Serializable, Iterable<ITaskInstance> { 28 28 29 29 /** … … 48 48 public int size(); 49 49 50 /**51 * <p>52 * clones a task instance list by creating exact clones of each contained instance in their53 * order54 * </p>55 *56 * @return a clone of the task instance list57 */58 public ITaskInstanceList clone();59 60 50 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/EventTask.java
r1255 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget;18 import de.ugoe.cs.autoquest.eventcore.IEventType;19 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; … … 39 37 /** 40 38 * <p> 41 * the type of the represented event 42 * </p> 43 */ 44 private IEventType eventType; 45 46 /** 47 * <p> 48 * the target of the represented event 49 * </p> 50 */ 51 private IEventTarget eventTarget; 52 53 /** 54 * <p> 55 * simple constructor initializing this task with an event type and an event target 39 * simple constructor initializing this task with a description for the represented events 56 40 * </p> 57 41 * 58 * @param eventType the type of the represented event 59 * @param eventTarget the target of the represented event 42 * @param description a description for the represented events 60 43 */ 61 EventTask(IEventType eventType, IEventTarget eventTarget) { 62 super.setDescription(eventType.toString() + " \u21D2 " + eventTarget); 63 this.eventType = eventType; 64 this.eventTarget = eventTarget; 65 } 66 67 /* (non-Javadoc) 68 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventType() 69 */ 70 @Override 71 public IEventType getEventType() { 72 return eventType; 73 } 74 75 /* (non-Javadoc) 76 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventTarget() 77 */ 78 @Override 79 public IEventTarget getEventTarget() { 80 return eventTarget; 44 EventTask(String description) { 45 super.setDescription(description); 81 46 } 82 47 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Task.java
r1215 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import java.util.Collection; 18 import java.util.Collections; 19 import java.util.HashSet; 20 17 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; 19 24 … … 56 61 */ 57 62 private String description; 63 64 /** 65 * <p> 66 * the instances of this task 67 * </p> 68 */ 69 private Collection<ITaskInstance> instances = new HashSet<ITaskInstance>(); 58 70 59 71 /** … … 97 109 public String getDescription() { 98 110 return description; 111 } 112 113 /* (non-Javadoc) 114 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#getInstances() 115 */ 116 @Override 117 public Collection<ITaskInstance> getInstances() { 118 return Collections.unmodifiableCollection(instances); 99 119 } 100 120 … … 163 183 } 164 184 185 /** 186 * <p> 187 * internally used to add an instance to this task 188 * </p> 189 * 190 * @param instance the instance belonging to this task 191 */ 192 void addInstance(ITaskInstance instance) { 193 this.instances.add(instance); 194 } 195 165 196 /* (non-Javadoc) 166 197 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#accept(ITaskVisitor) -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskBuilder.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;20 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 21 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 24 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 41 44 42 45 /* (non-Javadoc) 43 * @see ITaskBuilder#addChild(ITaskInstance,ITaskInstance) 44 */ 45 @Override 46 public void addChild(ITaskInstance parent, ITaskInstance child) throws IllegalArgumentException 47 { 48 if (!(parent instanceof TaskInstance)) { 49 throw new IllegalArgumentException 50 ("illegal type of task instance provided: " + parent.getClass()); 46 * @see ITaskBuilder#addChild(ISequenceInstance, ITaskInstance) 47 */ 48 @Override 49 public void addChild(ISequenceInstance instance, ITaskInstance child) 50 throws IllegalArgumentException 51 { 52 if (!(instance instanceof SequenceInstance)) { 53 throw new IllegalArgumentException 54 ("illegal type of sequence instance provided: " + instance.getClass()); 51 55 } 52 56 53 57 if (!(child instanceof TaskInstance)) { 54 58 throw new IllegalArgumentException 55 ("illegal type of task instance provided: " + parent.getClass()); 56 } 57 58 // check, that the correct number of children for the distinct types are added 59 ITask task = parent.getTask(); 60 61 if (task instanceof IEventTask) { 62 throw new IllegalArgumentException 63 ("can not add children to a task instance of an event task"); 64 } 65 else if (task instanceof ISelection) { 66 if (parent.getChildren().size() > 0) { 67 throw new IllegalArgumentException 68 ("the instance of a selection must have at most one child"); 59 ("illegal type of task instance provided: " + child.getClass()); 60 } 61 62 /*IStructuringTemporalRelationship parentTask = 63 (IStructuringTemporalRelationship) parent.getTask(); 64 65 for (ITask parentTaskChild : parentTask.getChildren()) { 66 if (parentTaskChild.equals(child.getTask())) { 67 foundChildTask = true; 68 break; 69 69 } 70 70 } 71 else if (task instanceof IOptional) { 72 if (parent.getChildren().size() > 1) { 73 throw new IllegalArgumentException 74 ("the instance of an optional must have at most one child"); 75 } 76 } 77 /*else if (task instanceof IIteration) { 78 for (ITaskInstance childInstance : parent.getChildren()) { 79 if (!childInstance.getTask().equals(child.getTask())) { 80 throw new IllegalArgumentException 81 ("all children of an instance of an iteration must have exactly the " + 82 "same type"); 83 } 84 } 85 } 86 87 boolean foundChildTask = false; 88 if (parent.getTask() instanceof IStructuringTemporalRelationship) { 89 IStructuringTemporalRelationship parentTask = 90 (IStructuringTemporalRelationship) parent.getTask(); 91 92 for (ITask parentTaskChild : parentTask.getChildren()) { 93 if (parentTaskChild.equals(child.getTask())) { 94 foundChildTask = true; 95 break; 96 } 97 } 98 } 99 else if (parent.getTask() instanceof IMarkingTemporalRelationship) { 100 IMarkingTemporalRelationship parentTask = 101 (IMarkingTemporalRelationship) parent.getTask(); 102 103 foundChildTask = parentTask.getMarkedTask() != null ? 104 parentTask.getMarkedTask().equals(child.getTask()) : false; 105 } 106 71 107 72 if (!foundChildTask) { 108 73 throw new IllegalArgumentException … … 111 76 }*/ 112 77 113 // finally, after all checks are positive, add the child 114 ((TaskInstance) parent).addChild(child); 78 ((SequenceInstance) instance).addChild(child); 79 } 80 81 /* (non-Javadoc) 82 * @see ITaskBuilder#addChild(ISequenceInstance, int, ITaskInstance) 83 */ 84 public void addChild(ISequenceInstance instance, int index, ITaskInstance child) 85 throws IllegalArgumentException 86 { 87 if (!(instance instanceof SequenceInstance)) { 88 throw new IllegalArgumentException 89 ("illegal type of sequence instance provided: " + instance.getClass()); 90 } 91 92 if (!(child instanceof TaskInstance)) { 93 throw new IllegalArgumentException 94 ("illegal type of task instance provided: " + child.getClass()); 95 } 96 97 /*IStructuringTemporalRelationship parentTask = 98 (IStructuringTemporalRelationship) parent.getTask(); 99 100 for (ITask parentTaskChild : parentTask.getChildren()) { 101 if (parentTaskChild.equals(child.getTask())) { 102 foundChildTask = true; 103 break; 104 } 105 } 106 107 if (!foundChildTask) { 108 throw new IllegalArgumentException 109 ("the task of the child instance to be added does not belong to the children " + 110 "of the task of the parent instance"); 111 }*/ 112 113 ((SequenceInstance) instance).addChild(index, child); 114 } 115 116 /* (non-Javadoc) 117 * @see ITaskBuilder#addChild(IIterationInstance, ITaskInstance) 118 */ 119 @Override 120 public void addChild(IIterationInstance instance, ITaskInstance child) 121 throws IllegalArgumentException 122 { 123 if (!(instance instanceof IterationInstance)) { 124 throw new IllegalArgumentException 125 ("illegal type of iteration instance provided: " + instance.getClass()); 126 } 127 128 if (!(child instanceof TaskInstance)) { 129 throw new IllegalArgumentException 130 ("illegal type of task instance provided: " + child.getClass()); 131 } 132 133 /*IStructuringTemporalRelationship parentTask = 134 (IStructuringTemporalRelationship) parent.getTask(); 135 136 IMarkingTemporalRelationship parentTask = 137 (IMarkingTemporalRelationship) parent.getTask(); 138 139 foundChildTask = parentTask.getMarkedTask() != null ? 140 parentTask.getMarkedTask().equals(child.getTask()) : false; 141 142 if (!foundChildTask) { 143 throw new IllegalArgumentException 144 ("the task of the child instance to be added does not belong to the children " + 145 "of the task of the parent instance"); 146 }*/ 147 148 ((IterationInstance) instance).addChild(child); 149 } 150 151 /* (non-Javadoc) 152 * @see ITaskBuilder#addChild(IIterationInstance, int, ITaskInstance) 153 */ 154 public void addChild(IIterationInstance instance, int index, ITaskInstance child) 155 throws IllegalArgumentException 156 { 157 if (!(instance instanceof IterationInstance)) { 158 throw new IllegalArgumentException 159 ("illegal type of iteration instance provided: " + instance.getClass()); 160 } 161 162 if (!(child instanceof TaskInstance)) { 163 throw new IllegalArgumentException 164 ("illegal type of task instance provided: " + child.getClass()); 165 } 166 167 /*IStructuringTemporalRelationship parentTask = 168 (IStructuringTemporalRelationship) parent.getTask(); 169 170 IMarkingTemporalRelationship parentTask = 171 (IMarkingTemporalRelationship) parent.getTask(); 172 173 foundChildTask = parentTask.getMarkedTask() != null ? 174 parentTask.getMarkedTask().equals(child.getTask()) : false; 175 176 if (!foundChildTask) { 177 throw new IllegalArgumentException 178 ("the task of the child instance to be added does not belong to the children " + 179 "of the task of the parent instance"); 180 }*/ 181 182 ((IterationInstance) instance).addChild(index, child); 183 } 184 185 /* (non-Javadoc) 186 * @see ITaskBuilder#setChild(ISelectionInstance, ITaskInstance) 187 */ 188 @Override 189 public void setChild(ISelectionInstance instance, ITaskInstance child) 190 throws IllegalArgumentException 191 { 192 if (!(instance instanceof SelectionInstance)) { 193 throw new IllegalArgumentException 194 ("illegal type of sequence instance provided: " + instance.getClass()); 195 } 196 197 if (!(child instanceof TaskInstance)) { 198 throw new IllegalArgumentException 199 ("illegal type of task instance provided: " + child.getClass()); 200 } 201 202 /*IStructuringTemporalRelationship parentTask = 203 (IStructuringTemporalRelationship) parent.getTask(); 204 205 for (ITask parentTaskChild : parentTask.getChildren()) { 206 if (parentTaskChild.equals(child.getTask())) { 207 foundChildTask = true; 208 break; 209 } 210 } 211 212 if (!foundChildTask) { 213 throw new IllegalArgumentException 214 ("the task of the child instance to be added does not belong to the children " + 215 "of the task of the parent instance"); 216 }*/ 217 218 ((SelectionInstance) instance).setChild(child); 219 } 220 221 /* (non-Javadoc) 222 * @see ITaskBuilder#setChild(IOptionalInstance, ITaskInstance) 223 */ 224 @Override 225 public void setChild(IOptionalInstance instance, ITaskInstance child) 226 throws IllegalArgumentException 227 { 228 if (!(instance instanceof OptionalInstance)) { 229 throw new IllegalArgumentException 230 ("illegal type of optional instance provided: " + instance.getClass()); 231 } 232 233 if (!(child instanceof TaskInstance)) { 234 throw new IllegalArgumentException 235 ("illegal type of task instance provided: " + child.getClass()); 236 } 237 238 /*IStructuringTemporalRelationship parentTask = 239 (IStructuringTemporalRelationship) parent.getTask(); 240 241 IMarkingTemporalRelationship parentTask = 242 (IMarkingTemporalRelationship) parent.getTask(); 243 244 foundChildTask = parentTask.getMarkedTask() != null ? 245 parentTask.getMarkedTask().equals(child.getTask()) : false; 246 247 if (!foundChildTask) { 248 throw new IllegalArgumentException 249 ("the task of the child instance to be added does not belong to the children " + 250 "of the task of the parent instance"); 251 }*/ 252 253 ((OptionalInstance) instance).setChild(child); 115 254 } 116 255 … … 134 273 135 274 /* (non-Javadoc) 275 * @see ITaskBuilder#addExecutedTask(IUserSession, int, ITaskInstance) 276 */ 277 public void addExecutedTask(IUserSession session, int index, ITaskInstance taskInstance) { 278 if (!(session instanceof UserSession)) { 279 throw new IllegalArgumentException 280 ("illegal type of session provided: " + session.getClass()); 281 } 282 283 if (!(taskInstance instanceof TaskInstance)) { 284 throw new IllegalArgumentException 285 ("illegal type of task instance provided: " + taskInstance.getClass()); 286 } 287 288 ((UserSession) session).addExecutedTask(index, taskInstance); 289 } 290 291 /* (non-Javadoc) 136 292 * @see ITaskBuilder#addTaskInstance(ITaskInstanceList, ITaskInstance) 137 293 */ 138 294 @Override 139 295 public void addTaskInstance(ITaskInstanceList taskInstanceList, ITaskInstance taskInstance) { 140 if (taskInstanceList instanceof TaskInstance) { 141 ((TaskInstance) taskInstanceList).addChild(taskInstance); 296 if (taskInstanceList instanceof SequenceInstance) { 297 addChild((SequenceInstance) taskInstanceList, taskInstance); 298 } 299 else if (taskInstanceList instanceof IterationInstance) { 300 addChild((IterationInstance) taskInstanceList, taskInstance); 142 301 } 143 302 else if (taskInstanceList instanceof UserSession) { 144 ((UserSession) taskInstanceList).addExecutedTask(taskInstance);303 addExecutedTask((UserSession) taskInstanceList, taskInstance); 145 304 } 146 305 else { … … 158 317 ITaskInstance taskInstance) 159 318 { 160 if (taskInstanceList instanceof TaskInstance) { 161 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 319 if (taskInstanceList instanceof SequenceInstance) { 320 addChild((SequenceInstance) taskInstanceList, index, taskInstance); 321 } 322 else if (taskInstanceList instanceof IterationInstance) { 323 addChild((IterationInstance) taskInstanceList, index, taskInstance); 162 324 } 163 325 else if (taskInstanceList instanceof UserSession) { 164 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance);326 addExecutedTask((UserSession) taskInstanceList, index, taskInstance); 165 327 } 166 328 else { … … 178 340 ITaskInstance taskInstance) 179 341 { 180 if (taskInstanceList instanceof TaskInstance) { 181 ((TaskInstance) taskInstanceList).removeChild(index); 182 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 183 } 184 else if (taskInstanceList instanceof UserSession) { 185 ((UserSession) taskInstanceList).removeExecutedTask(index); 186 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance); 187 } 188 else { 189 throw new IllegalArgumentException 190 ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 191 } 342 removeTaskInstance(taskInstanceList, index); 343 addTaskInstance(taskInstanceList, index, taskInstance); 192 344 } 193 345 … … 334 486 @Override 335 487 public void removeTaskInstance(ITaskInstanceList taskInstanceList, int index) { 336 if (taskInstanceList instanceof TaskInstance) { 337 ((TaskInstance) taskInstanceList).removeChild(index); 488 if (taskInstanceList instanceof SequenceInstance) { 489 ((SequenceInstance) taskInstanceList).removeChild(index); 490 } 491 else if (taskInstanceList instanceof IterationInstance) { 492 ((IterationInstance) taskInstanceList).removeChild(index); 338 493 } 339 494 else if (taskInstanceList instanceof UserSession) { … … 369 524 } 370 525 371 /* (non-Javadoc)372 * @see ITaskBuilder#setDescription(ITask, java.lang.String)373 */374 @Override375 public void setDescription(ITask parent, String description) {376 if (!(parent instanceof Task)) {377 throw new IllegalArgumentException378 ("illegal type of task provided: " + parent.getClass());379 }380 381 ((Task) parent).setDescription(description);382 }383 384 526 /** 385 527 * <p> -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskFactory.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 19 import de.ugoe.cs.autoquest.eventcore.Event; 21 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 22 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 23 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 24 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 29 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; … … 43 44 44 45 /* (non-Javadoc) 45 * @see ITaskFactory#createNewEventTask( IEventType, IEventTarget)46 * @see ITaskFactory#createNewEventTask(String) 46 47 */ 47 48 @Override 48 public IEventTask createNewEventTask( IEventType eventType, IEventTarget eventTarget) {49 return new EventTask( eventType, eventTarget);49 public IEventTask createNewEventTask(String description) { 50 return new EventTask(description); 50 51 } 51 52 … … 83 84 84 85 /* (non-Javadoc) 85 * @see ITaskFactory#createNewTaskInstance(I Task)86 * @see ITaskFactory#createNewTaskInstance(IEventTask, Event) 86 87 */ 87 88 @Override 88 public ITaskInstance createNewTaskInstance(ITask task) { 89 return new TaskInstance(task); 89 public IEventTaskInstance createNewTaskInstance(IEventTask task, Event event) { 90 if (!(task instanceof EventTask)) { 91 throw new IllegalArgumentException 92 ("illegal type of event task provided: " + task.getClass()); 93 } 94 95 EventTaskInstance instance = new EventTaskInstance(task, event); 96 ((EventTask) task).addInstance(instance); 97 98 return instance; 90 99 } 91 100 92 101 /* (non-Javadoc) 93 * @see ITaskFactory#createNewTaskInstance List()102 * @see ITaskFactory#createNewTaskInstance(ISequence) 94 103 */ 95 104 @Override 96 public ITaskInstanceList createNewTaskInstanceList() { 97 return new TaskInstance(new Sequence()); 105 public ISequenceInstance createNewTaskInstance(ISequence sequence) { 106 if (!(sequence instanceof Sequence)) { 107 throw new IllegalArgumentException 108 ("illegal type of sequence provided: " + sequence.getClass()); 109 } 110 111 SequenceInstance instance = new SequenceInstance(sequence); 112 ((Sequence) sequence).addInstance(instance); 113 114 return instance; 115 } 116 117 /* (non-Javadoc) 118 * @see ITaskFactory#createNewTaskInstance(IIteration) 119 */ 120 @Override 121 public IIterationInstance createNewTaskInstance(IIteration iteration) { 122 if (!(iteration instanceof Iteration)) { 123 throw new IllegalArgumentException 124 ("illegal type of iteration provided: " + iteration.getClass()); 125 } 126 127 IterationInstance instance = new IterationInstance(iteration); 128 ((Iteration) iteration).addInstance(instance); 129 130 return instance; 131 } 132 133 /* (non-Javadoc) 134 * @see ITaskFactory#createNewTaskInstance(IOptional) 135 */ 136 @Override 137 public IOptionalInstance createNewTaskInstance(IOptional optional) { 138 if (!(optional instanceof Optional)) { 139 throw new IllegalArgumentException 140 ("illegal type of optional provided: " + optional.getClass()); 141 } 142 143 OptionalInstance instance = new OptionalInstance(optional); 144 ((Optional) optional).addInstance(instance); 145 146 return instance; 147 } 148 149 /* (non-Javadoc) 150 * @see ITaskFactory#createNewTaskInstance(ISelection) 151 */ 152 @Override 153 public ISelectionInstance createNewTaskInstance(ISelection selection) { 154 if (!(selection instanceof Selection)) { 155 throw new IllegalArgumentException 156 ("illegal type of optional provided: " + selection.getClass()); 157 } 158 159 SelectionInstance instance = new SelectionInstance(selection); 160 ((Selection) selection).addInstance(instance); 161 162 return instance; 98 163 } 99 164 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java
r1255 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 17 import java.util.Collections;18 import java.util.Iterator;19 import java.util.LinkedList;20 import java.util.List;21 16 22 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 64 59 /** 65 60 * <p> 66 * the children of this task instance which are task instances, as well67 * </p>68 */69 private List<ITaskInstance> children;70 71 /**72 * <p>73 61 * instantiated the task instance with the task that is instantiated by the instance. It also 74 62 * assigns a unique id to the instance using {@link #getNewId()}. … … 102 90 public ITask getTask() { 103 91 return task; 104 }105 106 /* (non-Javadoc)107 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren()108 */109 public synchronized List<ITaskInstance> getChildren() {110 if (children == null) {111 children = new LinkedList<ITaskInstance>();112 }113 114 return Collections.unmodifiableList(children);115 }116 117 /* (non-Javadoc)118 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int)119 */120 @Override121 public ITaskInstance get(int index) {122 if (children == null) {123 throw new IndexOutOfBoundsException(Integer.toString(index));124 }125 else {126 return children.get(index);127 }128 }129 130 /* (non-Javadoc)131 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size()132 */133 @Override134 public int size() {135 if (children == null) {136 return 0;137 }138 else {139 return children.size();140 }141 }142 143 /* (non-Javadoc)144 * @see java.lang.Iterable#iterator()145 */146 @Override147 public Iterator<ITaskInstance> iterator() {148 return getChildren().iterator();149 92 } 150 93 … … 203 146 try { 204 147 clone = (TaskInstance) super.clone(); 205 206 if (children != null) {207 clone.children = new LinkedList<ITaskInstance>();208 209 for (ITaskInstance child : children) {210 clone.children.add(child.clone());211 }212 }213 214 148 } 215 149 catch (CloneNotSupportedException e) { … … 219 153 220 154 return clone; 221 }222 223 /**224 * <p>225 * used to add a child to this task instance226 * </p>227 *228 * @param child the new child of this instance229 */230 synchronized void addChild(ITaskInstance child) {231 if (children == null) {232 children = new LinkedList<ITaskInstance>();233 }234 235 children.add(child);236 }237 238 /**239 * <p>240 * used to add a child to this task instance at a specific position241 * </p>242 *243 * @param index the position of the new child in the list of children244 * @param child the new child of this instance245 */246 synchronized void addChild(int index, ITaskInstance child) {247 if (children == null) {248 children = new LinkedList<ITaskInstance>();249 }250 251 children.add(index, child);252 }253 254 /**255 * <p>256 * removes a child from this task instance at a specific position257 * </p>258 *259 * @param index the position of the child to be removed260 *261 * @return the child remove from the children of this instance262 */263 synchronized ITaskInstance removeChild(int index) {264 if (children != null) {265 return children.remove(index);266 }267 else {268 throw new IllegalArgumentException269 ("this task instance does not have children that can be removed");270 }271 155 } 272 156
Note: See TracChangeset
for help on using the changeset viewer.