Changeset 1107 for trunk/autoquest-core-tasktrees
- Timestamp:
- 02/21/13 18:39:13 (12 years ago)
- Location:
- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation
- Files:
-
- 3 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultEventTargetSequenceDetectionRule.java
r985 r1107 15 15 * @author 2012, last modified by $Author: patrick$ 16 16 */ 17 publicclass DefaultEventTargetSequenceDetectionRule implements TemporalRelationshipRule {17 class DefaultEventTargetSequenceDetectionRule implements TemporalRelationshipRule { 18 18 19 /** 20 * <p> 21 * the task tree node factory to be used for creating substructures for the temporal 22 * relationships identified during rule 23 * </p> 24 */ 25 private ITaskTreeNodeFactory taskTreeNodeFactory; 26 /** 27 * <p> 28 * the task tree builder to be used for creating substructures for the temporal relationships 29 * identified during rule application 30 * </p> 31 */ 32 private ITaskTreeBuilder taskTreeBuilder; 33 34 /** 35 * <p> 36 * instantiates the rule with a task tree node factory and builder to be used during rule 37 * application. 38 * </p> 39 * 40 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 41 * for the temporal relationships identified during rule 42 * application 43 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 44 * the temporal relationships identified during rule application 45 */ 46 DefaultEventTargetSequenceDetectionRule(ITaskTreeNodeFactory taskTreeNodeFactory, 47 ITaskTreeBuilder taskTreeBuilder) 48 { 49 this.taskTreeNodeFactory = taskTreeNodeFactory; 50 this.taskTreeBuilder = taskTreeBuilder; 51 } 52 19 53 /* 20 54 * (non-Javadoc) 21 55 * 22 56 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 23 * TaskTreeBuilder, TaskTreeNodeFactory)57 * boolean) 24 58 */ 25 59 @Override 26 public RuleApplicationResult apply(ITaskTreeNode parent, 27 ITaskTreeBuilder builder, 28 ITaskTreeNodeFactory nodeFactory, 29 boolean finalize) 30 { 60 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 31 61 if (!(parent instanceof ISequence)) { 32 62 return null; … … 59 89 (!(parent.getChildren().get(startingIndex) instanceof ISequence))) 60 90 { 61 handleEventTargetSequence (parent, currentEventTarget, startingIndex,62 endIndex, builder, nodeFactory, result);91 handleEventTargetSequence 92 (parent, currentEventTarget, startingIndex, endIndex, result); 63 93 64 94 result.setRuleApplicationStatus … … 91 121 (!(parent.getChildren().get(startingIndex) instanceof ISequence)))) 92 122 { 93 handleEventTargetSequence (parent, currentEventTarget, startingIndex, endIndex,94 builder, nodeFactory, result);123 handleEventTargetSequence 124 (parent, currentEventTarget, startingIndex, endIndex, result); 95 125 96 126 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FINISHED); … … 106 136 107 137 /** 108 * TODO: comment 109 * 110 * @param child 111 * @return 138 * 112 139 */ 113 140 private IEventTarget determineEventTarget(ITaskTreeNode node) { … … 134 161 135 162 /** 136 * TODO: comment 137 * 163 * 138 164 */ 139 165 private void handleEventTargetSequence(ITaskTreeNode parent, … … 141 167 int startIndex, 142 168 int endIndex, 143 ITaskTreeBuilder builder,144 ITaskTreeNodeFactory nodeFactory,145 169 RuleApplicationResult result) 146 170 { 147 ISequence sequence = nodeFactory.createNewSequence(); 148 builder.setDescription(sequence, "interactions on " + target.getStringIdentifier()); 149 150 for (int i = startIndex; i <= endIndex; i++) { 151 builder.addChild(sequence, parent.getChildren().get(startIndex)); 152 builder.removeChild((ISequence) parent, startIndex); 153 } 154 155 builder.addChild((ISequence) parent, startIndex, sequence); 171 String description = "interactions on " + target.getStringIdentifier(); 172 173 ISequence sequence = RuleUtils.createNewSubSequenceInRange 174 (parent, startIndex, endIndex, description, taskTreeNodeFactory, taskTreeBuilder); 156 175 157 176 result.addNewlyCreatedParentNode(sequence); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultGuiElementSequenceDetectionRule.java
r993 r1107 20 20 * @author 2012, last modified by $Author: patrick$ 21 21 */ 22 public class DefaultGuiElementSequenceDetectionRule implements TemporalRelationshipRule { 23 22 class DefaultGuiElementSequenceDetectionRule implements TemporalRelationshipRule { 23 24 /** 25 * <p> 26 * the task tree node factory to be used for creating substructures for the temporal 27 * relationships identified during rule 28 * </p> 29 */ 30 private ITaskTreeNodeFactory taskTreeNodeFactory; 31 /** 32 * <p> 33 * the task tree builder to be used for creating substructures for the temporal relationships 34 * identified during rule application 35 * </p> 36 */ 37 private ITaskTreeBuilder taskTreeBuilder; 38 24 39 /** 25 40 * <p> … … 31 46 /** 32 47 * <p> 33 * instantiates the rule without a GUI element filter 34 * </p> 35 */ 36 DefaultGuiElementSequenceDetectionRule() { 37 this.guiElementFilter = null; 38 } 39 48 * instantiates the rule with a task tree node factory and builder to be used during rule 49 * application but without a GUI element filter 50 * </p> 51 * 52 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 53 * for the temporal relationships identified during rule 54 * application 55 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 56 * the temporal relationships identified during rule application 57 */ 58 DefaultGuiElementSequenceDetectionRule(ITaskTreeNodeFactory taskTreeNodeFactory, 59 ITaskTreeBuilder taskTreeBuilder) 60 { 61 this(null, taskTreeNodeFactory, taskTreeBuilder); 62 } 63 40 64 /** 41 65 * <p> … … 45 69 * </p> 46 70 * 47 * @param guiElementFilter the GUI element filter to be applied 48 */ 49 DefaultGuiElementSequenceDetectionRule(List<Class<? extends IGUIElement>> guiElementFilter) { 71 * @param guiElementFilter the GUI element filter to be applied 72 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 73 * for the temporal relationships identified during rule 74 * application 75 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 76 * the temporal relationships identified during rule application 77 */ 78 DefaultGuiElementSequenceDetectionRule(List<Class<? extends IGUIElement>> guiElementFilter, 79 ITaskTreeNodeFactory taskTreeNodeFactory, 80 ITaskTreeBuilder taskTreeBuilder) 81 { 50 82 this.guiElementFilter = guiElementFilter; 83 this.taskTreeNodeFactory = taskTreeNodeFactory; 84 this.taskTreeBuilder = taskTreeBuilder; 51 85 } 52 86 … … 55 89 * 56 90 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 57 * TaskTreeBuilder, TaskTreeNodeFactory)91 * boolean) 58 92 */ 59 93 @Override 60 public RuleApplicationResult apply(ITaskTreeNode parent, 61 ITaskTreeBuilder builder, 62 ITaskTreeNodeFactory nodeFactory, 63 boolean finalize) 64 { 94 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 65 95 if (!(parent instanceof ISequence)) { 66 96 return null; … … 95 125 // anything. 96 126 97 RuleApplicationStatus status ;127 RuleApplicationStatus status = null; 98 128 if (initialHierarchyLevel < maxHierarchyDepth) { 99 status = generateSubSequences(parent, hierarchies, initialHierarchyLevel, finalize, 100 builder, nodeFactory, result); 101 } 102 else { 129 status = generateSubSequences 130 (parent, hierarchies, initialHierarchyLevel, finalize, result); 131 } 132 133 if (status == null) { 103 134 status = RuleApplicationStatus.RULE_NOT_APPLIED; 104 135 } … … 121 152 * @param maxHierarchyDepth the maximum hierarchy depth that may apply in this application 122 153 * @param finalize true, if the application shall be finalized, false else 123 * @param builder the builder to use for generating the tree structure124 * @param nodeFactory the node factory to use for generating the tree structure125 154 * @param result the result of the rule application to add newly created parent 126 155 * nodes to … … 136 165 int hierarchyLevel, 137 166 boolean finalize, 138 ITaskTreeBuilder builder,139 ITaskTreeNodeFactory nodeFactory,140 167 RuleApplicationResult result) 141 168 { … … 169 196 } 170 197 else if (nextGuiElementDiffers) { 171 status = condenseSequence (parent, hierarchies, hierarchyLevel, startingIndex,172 index - 1, builder, nodeFactory, result);198 status = condenseSequence 199 (parent, hierarchies, hierarchyLevel, startingIndex, index - 1, result); 173 200 174 201 if (status != null) { … … 195 222 status = condenseSequence 196 223 (parent, hierarchies, hierarchyLevel, startingIndex, 197 parent.getChildren().size() - 1, builder, nodeFactory,result);224 parent.getChildren().size() - 1, result); 198 225 } 199 226 else if (status != RuleApplicationStatus.RULE_APPLICATION_FINISHED) { … … 225 252 * @param startIndex the index of the first child belonging to the subgroup 226 253 * @param endIndex the index of the last child belonging to the subgroup 227 * @param builder the builder to use for generating the tree structure228 * @param nodeFactory the node factory to use for generating the tree structure229 254 * @param result the result of the rule application to add newly created parent nodes to 230 255 * … … 238 263 int startIndex, 239 264 int endIndex, 240 ITaskTreeBuilder builder,241 ITaskTreeNodeFactory nodeFactory,242 265 RuleApplicationResult result) 243 266 { … … 247 270 248 271 if (!onlyASingleChildToReduce || !singleChildIsSequence) { 249 ISequence sequence = nodeFactory.createNewSequence();272 ISequence sequence = taskTreeNodeFactory.createNewSequence(); 250 273 251 274 List<List<IGUIElement>> subHierarchies = new ArrayList<List<IGUIElement>>(); 252 275 List<IGUIElement> newHierarchy = 253 276 hierarchies.get(startIndex).subList(0, hierarchyLevel + 1); 254 builder.setDescription(sequence, "interactions on " + 255 newHierarchy.get(newHierarchy.size() - 1).getStringIdentifier()); 277 taskTreeBuilder.setDescription 278 (sequence, "interactions on " + 279 newHierarchy.get(newHierarchy.size() - 1).getStringIdentifier()); 256 280 257 281 for (int i = startIndex; i <= endIndex; i++) { 258 builder.addChild(sequence, parent.getChildren().get(startIndex));259 builder.removeChild((ISequence) parent, startIndex);282 taskTreeBuilder.addChild(sequence, parent.getChildren().get(startIndex)); 283 taskTreeBuilder.removeChild((ISequence) parent, startIndex); 260 284 261 285 subHierarchies.add(hierarchies.remove(startIndex)); 262 286 } 263 287 264 builder.addChild((ISequence) parent, startIndex, sequence);288 taskTreeBuilder.addChild((ISequence) parent, startIndex, sequence); 265 289 266 290 hierarchies.add(startIndex, newHierarchy); 267 291 268 generateSubSequences 269 (sequence, subHierarchies, hierarchyLevel + 1, true, builder, nodeFactory, result); 292 generateSubSequences(sequence, subHierarchies, hierarchyLevel + 1, true, result); 270 293 271 294 result.addNewlyCreatedParentNode(sequence); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultGuiEventSequenceDetectionRule.java
r987 r1107 1 1 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 2 3 import java.util.Stack; 2 4 3 5 import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; … … 18 20 * @author 2012, last modified by $Author: patrick$ 19 21 */ 20 publicclass DefaultGuiEventSequenceDetectionRule implements TemporalRelationshipRule {22 class DefaultGuiEventSequenceDetectionRule implements TemporalRelationshipRule { 21 23 24 /** 25 * <p> 26 * the task tree node factory to be used for creating substructures for the temporal 27 * relationships identified during rule 28 * </p> 29 */ 30 private ITaskTreeNodeFactory taskTreeNodeFactory; 31 /** 32 * <p> 33 * the task tree builder to be used for creating substructures for the temporal relationships 34 * identified during rule application 35 * </p> 36 */ 37 private ITaskTreeBuilder taskTreeBuilder; 38 39 /** 40 * <p> 41 * instantiates the rule with a task tree node factory and builder to be used during rule 42 * application. 43 * </p> 44 * 45 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 46 * for the temporal relationships identified during rule 47 * application 48 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 49 * the temporal relationships identified during rule application 50 */ 51 DefaultGuiEventSequenceDetectionRule(ITaskTreeNodeFactory taskTreeNodeFactory, 52 ITaskTreeBuilder taskTreeBuilder) 53 { 54 this.taskTreeNodeFactory = taskTreeNodeFactory; 55 this.taskTreeBuilder = taskTreeBuilder; 56 } 57 22 58 /* 23 59 * (non-Javadoc) 24 60 * 25 61 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 26 * TaskTreeBuilder, TaskTreeNodeFactory)62 * boolean) 27 63 */ 28 64 @Override 29 public RuleApplicationResult apply(ITaskTreeNode parent, 30 ITaskTreeBuilder builder, 31 ITaskTreeNodeFactory nodeFactory, 32 boolean finalize) 33 { 65 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 34 66 if (!(parent instanceof ISequence)) { 35 67 return null; … … 37 69 38 70 RuleApplicationResult result = new RuleApplicationResult(); 39 int sequenceStartingIndex = -1;71 Stack<Integer> sequenceStartingIndex = new Stack<Integer>(); 40 72 41 73 int index = 0; … … 47 79 { 48 80 IInteraction eventType = (IInteraction) ((IEventTask) child).getEventType(); 49 50 if (eventType.finishesLogicalSequence() && (sequenceStartingIndex > -1))51 {52 // There are several situations in which this implementation may cause infinite53 // loops. This is because the rule manager will reapply rules until54 // no rule is applied anymore. A sequence identified in a first iteration will55 // be identified as a sequence also in a second iteration. As an example56 // many sequences start with an interaction starting that sequence and end57 // with an interaction ending that sequence. This will be reidentified as58 // further subsequence. It must therefore be assured, that a sequence, that59 // was once identified is not reidentified in a further application of the rule.60 // For this, the implementation performs a kind of dry run. It creates a list of61 // children that would belong to an identified sequence. Only if this list is62 // not a reidentification then a new sequence is created and added to the63 // parent. If it is a reidentification can be identified, if the list of64 // children will contain all children of the parent, or if the list of children65 // only consists of one sequence. Further, an identified sequence must at least66 // have one child.67 if (((sequenceStartingIndex != 0) ||68 (index != (parent.getChildren().size() - 1))) &&69 (((index - sequenceStartingIndex) > 0) ||70 (((index - sequenceStartingIndex) == 0) &&71 (!eventType.startsLogicalSequence()))))72 {73 boolean allNewChildrenAreSequences = true;74 81 75 for (int j = sequenceStartingIndex; 76 ((allNewChildrenAreSequences) && (j < index)); j++) 77 { 78 allNewChildrenAreSequences &= 79 (parent.getChildren().get(j) instanceof ISequence); 80 } 81 82 if (!allNewChildrenAreSequences) { 83 ISequence sequence = nodeFactory.createNewSequence(); 84 85 for (int j = sequenceStartingIndex; j < index; j++) { 86 builder.addChild 87 (sequence, parent.getChildren().get(sequenceStartingIndex)); 88 builder.removeChild((ISequence) parent, sequenceStartingIndex); 89 } 90 91 if (!eventType.startsLogicalSequence()) { 92 builder.addChild 93 (sequence, parent.getChildren().get(sequenceStartingIndex)); 94 builder.removeChild((ISequence) parent, sequenceStartingIndex); 95 } 96 97 builder.addChild((ISequence) parent, sequenceStartingIndex, sequence); 98 99 result.addNewlyCreatedParentNode(sequence); 100 101 builder.setDescription 102 (sequence, "logical sequence started by the first event"); 103 104 result.setRuleApplicationStatus 105 (RuleApplicationStatus.RULE_APPLICATION_FINISHED); 106 return result; 107 } 108 } 82 if (eventType.finishesLogicalSequence() && (sequenceStartingIndex.size() > 0)) { 83 index = handleLogicalSequence(sequenceStartingIndex, index, parent, result); 109 84 } 110 85 111 86 if (eventType.startsLogicalSequence()) { 112 sequenceStartingIndex = index;87 sequenceStartingIndex.push(index); 113 88 } 114 89 } … … 117 92 } 118 93 119 if (sequenceStartingIndex >= 0) { 120 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FEASIBLE); 94 if (sequenceStartingIndex.size() > 0) { 95 if (!finalize) { 96 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FEASIBLE); 97 } 98 else { 99 ITaskTreeNode lastChild = parent.getChildren().get(parent.getChildren().size() - 1); 100 101 if (lastChild instanceof IEventTask) { 102 handleLogicalSequence 103 (sequenceStartingIndex, parent.getChildren().size() - 1, parent, result); 104 } 105 } 121 106 } 122 107 … … 124 109 } 125 110 111 /** 112 * <p> 113 * TODO: comment 114 * </p> 115 * 116 */ 117 private int handleLogicalSequence(Stack<Integer> sequenceStartingIndex, 118 int index, 119 ITaskTreeNode parent, 120 RuleApplicationResult result) 121 { 122 int newIndex = index; 123 IInteraction eventType = 124 (IInteraction) ((IEventTask) parent.getChildren().get(index)).getEventType(); 125 126 // There are several situations in which this implementation may cause infinite 127 // loops. This is because the rule manager will reapply rules until 128 // no rule is applied anymore. A sequence identified in a first iteration will 129 // be identified as a sequence also in a second iteration. As an example 130 // many sequences start with an interaction starting that sequence and end 131 // with an interaction ending that sequence. This will be reidentified as 132 // further subsequence. It must therefore be assured, that a sequence, that 133 // was once identified is not reidentified in a further application of the rule. 134 // For this, the implementation performs a kind of dry run. It creates a list of 135 // children that would belong to an identified sequence. Only if this list is 136 // not a reidentification then a new sequence is created and added to the 137 // parent. If it is a reidentification can be identified, if the list of 138 // children will contain all children of the parent, or if the list of children 139 // only consists of one sequence. Further, an identified sequence must at least 140 // have one child. 141 142 boolean allChildrenBelongToSubSequence = 143 (sequenceStartingIndex.peek() == 0) && (index == (parent.getChildren().size() - 1)); 144 145 boolean atLeastOneChildToCondense = index - sequenceStartingIndex.peek() > 0; 146 147 if (!allChildrenBelongToSubSequence && atLeastOneChildToCondense) { 148 int startIndex = sequenceStartingIndex.pop(); 149 ISequence sequence = taskTreeNodeFactory.createNewSequence(); 150 151 for (int j = startIndex; j < index; j++) { 152 taskTreeBuilder.addChild(sequence, parent.getChildren().get(startIndex)); 153 taskTreeBuilder.removeChild((ISequence) parent, startIndex); 154 } 155 156 if (!eventType.startsLogicalSequence()) { 157 taskTreeBuilder.addChild(sequence, parent.getChildren().get(startIndex)); 158 taskTreeBuilder.removeChild((ISequence) parent, startIndex); 159 newIndex = startIndex; 160 } 161 else { 162 newIndex = startIndex + 1; 163 } 164 165 taskTreeBuilder.addChild((ISequence) parent, startIndex, sequence); 166 167 result.addNewlyCreatedParentNode(sequence); 168 169 taskTreeBuilder.setDescription(sequence, "logical sequence started by the first event"); 170 171 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FINISHED); 172 } 173 174 return newIndex; 175 } 176 126 177 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultIterationDetectionRule.java
r1045 r1107 61 61 * @author Patrick Harms 62 62 */ 63 public class DefaultIterationDetectionRule implements TemporalRelationshipRule { 64 63 class DefaultIterationDetectionRule implements TemporalRelationshipRule { 64 65 /** 66 * <p> 67 * the maximum length for iterated sequences 68 * </p> 69 */ 65 70 private static final int MAX_LENGTH_OF_ITERATED_SEQUENCE = 50; 66 71 67 72 /** 68 73 * <p> 74 * the task tree node factory to be used for creating substructures for the temporal 75 * relationships identified during rule 76 * </p> 77 */ 78 private ITaskTreeNodeFactory taskTreeNodeFactory; 79 /** 80 * <p> 81 * the task tree builder to be used for creating substructures for the temporal relationships 82 * identified during rule application 83 * </p> 84 */ 85 private ITaskTreeBuilder taskTreeBuilder; 86 87 /** 88 * <p> 69 89 * the node equality manager needed for comparing task tree nodes with each other 70 90 * </p> … … 87 107 */ 88 108 DefaultIterationDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager, 89 NodeEquality minimalNodeEquality) 109 NodeEquality minimalNodeEquality, 110 ITaskTreeNodeFactory taskTreeNodeFactory, 111 ITaskTreeBuilder taskTreeBuilder) 90 112 { 91 super();92 113 this.nodeEqualityRuleManager = nodeEqualityRuleManager; 93 114 this.minimalNodeEquality = minimalNodeEquality; 115 this.taskTreeNodeFactory = taskTreeNodeFactory; 116 this.taskTreeBuilder = taskTreeBuilder; 94 117 } 95 118 … … 97 120 * (non-Javadoc) 98 121 * 99 * @see TemporalRelationshipRule#apply(TaskTreeNode, TaskTreeBuilder, TaskTreeNodeFactory) 122 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 123 * boolean) 100 124 */ 101 125 @Override 102 public RuleApplicationResult apply(ITaskTreeNode parent, 103 ITaskTreeBuilder treeBuilder, 104 ITaskTreeNodeFactory nodeFactory, 105 boolean finalize) 106 { 126 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 107 127 if (!(parent instanceof ISequence)) { 108 128 return null; … … 122 142 123 143 124 SubSequences subSequences = getEqualSubsequences(parent , treeBuilder, nodeFactory);144 SubSequences subSequences = getEqualSubsequences(parent); 125 145 126 146 if (subSequences != null) { 127 147 RuleApplicationResult result = new RuleApplicationResult(); 128 148 129 mergeEqualNodes(subSequences.equalVariants , treeBuilder, nodeFactory);130 IIteration newIteration = createIterationBasedOnIdentifiedVariants131 (subSequences, treeBuilder, nodeFactory, result);149 mergeEqualNodes(subSequences.equalVariants); 150 IIteration newIteration = 151 createIterationBasedOnIdentifiedVariants(subSequences, result); 132 152 133 153 determineNewlyCreatedParentTasks(parent, newIteration, result); … … 135 155 // remove iterated children 136 156 for (int j = subSequences.start; j < subSequences.end; j++) { 137 t reeBuilder.removeChild((ISequence) parent, subSequences.start);157 taskTreeBuilder.removeChild((ISequence) parent, subSequences.start); 138 158 } 139 159 140 160 // add the new iteration instead 141 t reeBuilder.addChild((ISequence) parent, subSequences.start, newIteration);161 taskTreeBuilder.addChild((ISequence) parent, subSequences.start, newIteration); 142 162 143 163 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FINISHED); … … 161 181 * 162 182 * @param parent the parent node in which iterations of children shall be found 163 * @param treeBuilder the tree builder that can be used for connecting task tree nodes164 * @param nodeFactory the node factory that can be used for instantiating task tree nodes165 183 * 166 184 * @return the iterated subsequences identified in a specific part (contains the equal … … 168 186 * subpart in which the sequences were found) 169 187 */ 170 private SubSequences getEqualSubsequences(ITaskTreeNode parent, 171 ITaskTreeBuilder treeBuilder, 172 ITaskTreeNodeFactory nodeFactory) 173 { 188 private SubSequences getEqualSubsequences(ITaskTreeNode parent) { 174 189 SubSequences subSequences = null; 175 190 … … 184 199 185 200 boolean foundFurtherVariants = findFurtherVariants 186 (subSequences, parent, start, end, treeBuilder, nodeFactory, 187 useEqualSublistLengths); 201 (subSequences, parent, start, end, useEqualSublistLengths); 188 202 189 203 if (foundFurtherVariants) { … … 247 261 * @param end the end index (exclusive) of the current subpart of children 248 262 * in which iterations are searched for 249 * @param treeBuilder the tree builder that can be used for connecting task tree250 * nodes251 * @param nodeFactory the node factory that can be used for instantiating task tree252 * nodes253 263 * @param useEqualSublistLengths true if the sublists to be searched for all need to have the 254 264 * same length … … 260 270 int start, 261 271 int end, 262 ITaskTreeBuilder treeBuilder,263 ITaskTreeNodeFactory nodeFactory,264 272 boolean useEqualSublistLengths) 265 273 { … … 279 287 } 280 288 281 ISequence furtherVariant = nodeFactory.createNewSequence();289 ISequence furtherVariant = taskTreeNodeFactory.createNewSequence(); 282 290 283 291 for (int j = start; j < start + childCount; j++) { 284 t reeBuilder.addChild(furtherVariant, parent.getChildren().get(j));292 taskTreeBuilder.addChild(furtherVariant, parent.getChildren().get(j)); 285 293 } 286 294 … … 305 313 306 314 foundFurtherVariants = findFurtherVariants 307 (subSequences, parent, start + childCount, end, treeBuilder, nodeFactory, 308 useEqualSublistLengths); 315 (subSequences, parent, start + childCount, end, useEqualSublistLengths); 309 316 310 317 if (foundFurtherVariants) { … … 331 338 * 332 339 * @param nodes the list of nodes to be merged 333 * @param treeBuilder the tree builder that can be used for connecting task tree nodes 334 * @param nodeFactory the node factory that can be used for instantiating task tree nodes 335 */ 336 private void mergeEqualNodes(List<ITaskTreeNode> nodes, 337 ITaskTreeBuilder treeBuilder, 338 ITaskTreeNodeFactory nodeFactory) 339 { 340 */ 341 private void mergeEqualNodes(List<ITaskTreeNode> nodes) { 340 342 int index1 = 0; 341 343 int index2 = 0; … … 349 351 while (index2 < nodes.size()) { 350 352 variant2 = nodes.get(index2); 351 ITaskTreeNode mergedChild = 352 mergeEqualTasks(variant1, variant2, treeBuilder, nodeFactory); 353 ITaskTreeNode mergedChild = mergeEqualTasks(variant1, variant2); 353 354 354 355 if (mergedChild != null) { … … 382 383 * @param node1 the first task to be merged 383 384 * @param node2 the second task to be merged 384 * @param treeBuilder the tree builder that can be used for connecting task tree nodes385 * @param nodeFactory the node factory that can be used for instantiating task tree nodes386 385 * 387 386 * @return the result of the merge 388 387 */ 389 private ITaskTreeNode mergeEqualTasks(ITaskTreeNode node1, 390 ITaskTreeNode node2, 391 ITaskTreeBuilder treeBuilder, 392 ITaskTreeNodeFactory nodeFactory) 393 { 388 private ITaskTreeNode mergeEqualTasks(ITaskTreeNode node1, ITaskTreeNode node2) { 394 389 ITaskTreeNode mergeResult = null; 395 390 396 391 if ((node1 instanceof ISequence) && (node2 instanceof ISequence)) { 397 mergeResult = mergeEqualSequences 398 ((ISequence) node1, (ISequence) node2, treeBuilder, nodeFactory); 392 mergeResult = mergeEqualSequences((ISequence) node1, (ISequence) node2); 399 393 } 400 394 else if ((node1 instanceof ISelection) && (node2 instanceof ISelection)) { 401 mergeResult = mergeEqualSelections 402 ((ISelection) node1, (ISelection) node2, treeBuilder, nodeFactory); 395 mergeResult = mergeEqualSelections((ISelection) node1, (ISelection) node2); 403 396 } 404 397 else if ((node1 instanceof IIteration) && (node2 instanceof IIteration)) { 405 mergeResult = mergeEqualIterations 406 ((IIteration) node1, (IIteration) node2, treeBuilder, nodeFactory); 398 mergeResult = mergeEqualIterations((IIteration) node1, (IIteration) node2); 407 399 } 408 400 else if (node1 instanceof ISelection) { 409 t reeBuilder.addChild((ISelection) node1, node2);401 taskTreeBuilder.addChild((ISelection) node1, node2); 410 402 mergeResult = node1; 411 403 } 412 404 else if (node2 instanceof ISelection) { 413 t reeBuilder.addChild((ISelection) node2, node1);405 taskTreeBuilder.addChild((ISelection) node2, node1); 414 406 mergeResult = node2; 415 407 } 416 408 else if (node1 instanceof IIteration) { 417 mergeResult = mergeEqualTasks 418 (((IIteration) node1).getChildren().get(0), node2, treeBuilder, nodeFactory); 409 mergeResult = mergeEqualTasks(((IIteration) node1).getChildren().get(0), node2); 419 410 420 411 if (mergeResult != null) { 421 IIteration iteration = nodeFactory.createNewIteration();422 t reeBuilder.setChild(iteration, mergeResult);412 IIteration iteration = taskTreeNodeFactory.createNewIteration(); 413 taskTreeBuilder.setChild(iteration, mergeResult); 423 414 mergeResult = iteration; 424 415 } 425 416 } 426 417 else if (node2 instanceof IIteration) { 427 mergeResult = mergeEqualTasks 428 (((IIteration) node2).getChildren().get(0), node1, treeBuilder, nodeFactory); 418 mergeResult = mergeEqualTasks(((IIteration) node2).getChildren().get(0), node1); 429 419 430 420 if (mergeResult != null) { 431 IIteration iteration = nodeFactory.createNewIteration();432 t reeBuilder.setChild(iteration, mergeResult);421 IIteration iteration = taskTreeNodeFactory.createNewIteration(); 422 taskTreeBuilder.setChild(iteration, mergeResult); 433 423 mergeResult = iteration; 434 424 } … … 443 433 444 434 if (mergeResult == null) { 445 mergeResult = nodeFactory.createNewSelection();446 t reeBuilder.addChild((ISelection) mergeResult, node1);447 t reeBuilder.addChild((ISelection) mergeResult, node2);435 mergeResult = taskTreeNodeFactory.createNewSelection(); 436 taskTreeBuilder.addChild((ISelection) mergeResult, node1); 437 taskTreeBuilder.addChild((ISelection) mergeResult, node2); 448 438 } 449 439 … … 463 453 * @param sequence1 the first sequence to be merged 464 454 * @param sequence2 the second sequence to be merged 465 * @param treeBuilder the tree builder that can be used for connecting task tree nodes466 * @param nodeFactory the node factory that can be used for instantiating task tree nodes467 455 * 468 456 * @return the result of the merge or null if merging was not possible 469 457 */ 470 private ISequence mergeEqualSequences(ISequence sequence1, 471 ISequence sequence2, 472 ITaskTreeBuilder treeBuilder, 473 ITaskTreeNodeFactory nodeFactory) 474 { 458 private ISequence mergeEqualSequences(ISequence sequence1, ISequence sequence2) { 475 459 ISequence mergeResult = null; 476 460 477 461 if (sequence1.getChildren().size() == sequence2.getChildren().size()) { 478 mergeResult = nodeFactory.createNewSequence();462 mergeResult = taskTreeNodeFactory.createNewSequence(); 479 463 480 464 for (int i = 0; i < sequence1.getChildren().size(); i++) { 481 465 ITaskTreeNode mergedNode = mergeEqualTasks 482 (sequence1.getChildren().get(i), sequence2.getChildren().get(i), 483 treeBuilder, nodeFactory); 466 (sequence1.getChildren().get(i), sequence2.getChildren().get(i)); 484 467 485 468 if (mergedNode != null) { 486 t reeBuilder.addChild(mergeResult, mergedNode);469 taskTreeBuilder.addChild(mergeResult, mergedNode); 487 470 } 488 471 else { … … 506 489 * @param selection1 the first selection to be merged 507 490 * @param selection2 the second selection to be merged 508 * @param treeBuilder the tree builder that can be used for connecting task tree nodes509 * @param nodeFactory the node factory that can be used for instantiating task tree nodes510 491 * 511 492 * @return the result of the merge which is never null 512 493 */ 513 private ITaskTreeNode mergeEqualSelections(ISelection selection1, 514 ISelection selection2, 515 ITaskTreeBuilder treeBuilder, 516 ITaskTreeNodeFactory nodeFactory) 517 { 494 private ITaskTreeNode mergeEqualSelections(ISelection selection1, ISelection selection2) { 518 495 ISelection mergeResult = selection1; 519 496 … … 526 503 childToMerge = selection2.getChildren().get(i); 527 504 for (int j = 0; j < selection1.getChildren().size(); j++) { 528 mergedChild = mergeEqualTasks 529 (selection1.getChildren().get(j), childToMerge, treeBuilder, nodeFactory); 505 mergedChild = mergeEqualTasks(selection1.getChildren().get(j), childToMerge); 530 506 531 507 // a merge must not be a selection, except it is one of the children. Otherwise … … 538 514 // we found a real merge. So replace the original child in selection 1 with 539 515 // the merged child 540 t reeBuilder.removeChild(selection1, selection1.getChildren().get(j));541 t reeBuilder.addChild(selection1, mergedChild);516 taskTreeBuilder.removeChild(selection1, selection1.getChildren().get(j)); 517 taskTreeBuilder.addChild(selection1, mergedChild); 542 518 mergedChild = null; 543 519 childToMerge = null; … … 547 523 548 524 if (childToMerge != null) { 549 t reeBuilder.addChild(selection1, childToMerge);525 taskTreeBuilder.addChild(selection1, childToMerge); 550 526 } 551 527 } … … 563 539 * @param selection1 the first iteration to be merged 564 540 * @param selection2 the second iteration to be merged 565 * @param treeBuilder the tree builder that can be used for connecting task tree nodes566 * @param nodeFactory the node factory that can be used for instantiating task tree nodes567 541 * 568 542 * @return the result of the merge or null if merging is not possible 569 543 */ 570 private ITaskTreeNode mergeEqualIterations(IIteration iteration1, 571 IIteration iteration2, 572 ITaskTreeBuilder treeBuilder, 573 ITaskTreeNodeFactory nodeFactory) 574 { 544 private ITaskTreeNode mergeEqualIterations(IIteration iteration1, IIteration iteration2) { 575 545 ITaskTreeNode mergedChild = mergeEqualTasks 576 (iteration1.getChildren().get(0), iteration2.getChildren().get(0), 577 treeBuilder, nodeFactory); 546 (iteration1.getChildren().get(0), iteration2.getChildren().get(0)); 578 547 579 548 IIteration mergeResult = null; 580 549 581 550 if (mergedChild != null) { 582 mergeResult = nodeFactory.createNewIteration();583 t reeBuilder.setChild(mergeResult, mergedChild);551 mergeResult = taskTreeNodeFactory.createNewIteration(); 552 taskTreeBuilder.setChild(mergeResult, mergedChild); 584 553 } 585 554 … … 598 567 * 599 568 * @param subsequences the identified and already merged equal subsequences 600 * @param treeBuilder the tree builder that can be used for connecting task tree nodes601 * @param nodeFactory the node factory that can be used for instantiating the iteration602 569 * 603 570 * @return the resulting iteration 604 571 */ 605 572 private IIteration createIterationBasedOnIdentifiedVariants(SubSequences subsequences, 606 ITaskTreeBuilder treeBuilder,607 ITaskTreeNodeFactory nodeFactory,608 573 RuleApplicationResult result) 609 574 { 610 IIteration newIteration = nodeFactory.createNewIteration();575 IIteration newIteration = taskTreeNodeFactory.createNewIteration(); 611 576 result.addNewlyCreatedParentNode(newIteration); 612 577 … … 616 581 // there is only one equal variant and this has only one child. So create an 617 582 // iteration of this child 618 t reeBuilder.setChild583 taskTreeBuilder.setChild 619 584 (newIteration, subsequences.equalVariants.get(0).getChildren().get(0)); 620 585 } 621 586 else { 622 587 // there was an iteration of one equal sequence 623 t reeBuilder.setChild(newIteration, subsequences.equalVariants.get(0));588 taskTreeBuilder.setChild(newIteration, subsequences.equalVariants.get(0)); 624 589 result.addNewlyCreatedParentNode(subsequences.equalVariants.get(0)); 625 590 } … … 628 593 // there are distinct variants of equal subsequences or children --> create an 629 594 // iterated selection 630 ISelection selection = nodeFactory.createNewSelection();595 ISelection selection = taskTreeNodeFactory.createNewSelection(); 631 596 result.addNewlyCreatedParentNode(selection); 632 597 633 598 for (ITaskTreeNode variant : subsequences.equalVariants) { 634 599 if (variant.getChildren().size() == 1) { 635 t reeBuilder.addChild(selection, variant.getChildren().get(0));600 taskTreeBuilder.addChild(selection, variant.getChildren().get(0)); 636 601 } 637 602 else { 638 t reeBuilder.addChild(selection, variant);603 taskTreeBuilder.addChild(selection, variant); 639 604 result.addNewlyCreatedParentNode(variant); 640 605 } 641 606 } 642 607 643 t reeBuilder.setChild(newIteration, selection);608 taskTreeBuilder.setChild(newIteration, selection); 644 609 } 645 610 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRule.java
r922 r1107 1 1 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 2 2 3 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder;4 3 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 5 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory;6 4 7 5 /** 8 6 * <p> 9 * a temporal relation ship is able to detected temporal relationships between the child nodes 10 * of the parent node provided to the 11 * {@link #apply(ITaskTreeNode, ITaskTreeBuilder, ITaskTreeNodeFactory, boolean)} method. A rule 12 * created temporal relationships between the child nodes, i.e. substructures in the task tree, if 7 * a temporal relationship rule is able to detected temporal relationships between the child nodes 8 * of the parent node provided to the {@link #apply(ITaskTreeNode, boolean)} method. A rule 9 * creates temporal relationships between the child nodes, i.e. substructures in the task tree, if 13 10 * it detects a temporal relationship and it can be sure that it is complete. Incomplete but 14 11 * detected temporal relationships may occur, if there can be more children expected to be added … … 23 20 /** 24 21 * <p> 25 * applies the rule to the given parent node. The provided builder and node factory are used 26 * to create substructures in the task tree for the identified temporal relationships. The 27 * finalize parameter is used to command the rule to finish rule applications, in the case it 28 * is known that no further data will be available. 22 * applies the rule to the given parent node. The finalize parameter is used to command the rule 23 * to finish rule applications, in the case it is known that no further data will be available. 29 24 * </p> 30 25 * <p> … … 38 33 * </p> 39 34 * 40 * @param parent the parent node with the children to apply the rule on 41 * @param builder the builder to be used for creating substructures for the identified 42 * temporal relationships 43 * @param nodeFactory the node factory to be used for creating substructures for the identified 44 * temporal relationships 45 * @param finalize true, if the rule shall not expect further children to come and that it 46 * should therefore be applied in any case 35 * @param parent the parent node with the children to apply the rule on 36 * @param finalize true, if the rule shall not expect further children to come and that it 37 * should therefore be applied in any case 47 38 * 48 39 * @return the rule application result as described. 49 40 */ 50 RuleApplicationResult apply(ITaskTreeNode parent, 51 ITaskTreeBuilder builder, 52 ITaskTreeNodeFactory nodeFactory, 53 boolean finalize); 41 RuleApplicationResult apply(ITaskTreeNode parent, 42 boolean finalize); 54 43 55 44 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r987 r1107 79 79 /** 80 80 * <p> 81 * the temporal relationship rule known to the manager. The rules are applied in the order 82 * they occur in this list. 83 * </p> 84 */ 85 private List<TemporalRelationshipRule> rules = new ArrayList<TemporalRelationshipRule>(); 86 87 /** 88 * <p> 89 * initialize the manager with a node equality rule manager to be used by the known rules 90 * for task tree node comparison. 91 * </p> 92 */ 93 public TemporalRelationshipRuleManager(NodeEqualityRuleManager nodeEqualityRuleManager) { 81 * the task tree node factory to be used during rule application 82 * </p> 83 */ 84 private ITaskTreeNodeFactory taskTreeNodeFactory; 85 86 /** 87 * <p> 88 * the task tree builder to be used during rule application 89 * </p> 90 */ 91 private ITaskTreeBuilder taskTreeBuilder; 92 93 /** 94 * <p> 95 * the temporal relationship rules known to the manager that are executed on whole sub trees. 96 * The rules are applied in the order they occur in this list. 97 * </p> 98 */ 99 private TemporalRelationshipRule[] treeScopeRules; 100 101 /** 102 * <p> 103 * the temporal relationship rules known to the manager that are executed on whole sub trees. 104 * The rules are applied in the order they occur in this list. 105 * </p> 106 */ 107 private TemporalRelationshipRule[] nodeScopeRules; 108 109 /** 110 * <p> 111 * initialize the manager 112 * </p> 113 * 114 * @param nodeEqualityRuleManager the node equality rule manager to be used by the known rules 115 * for task tree node comparison during rule application 116 * @param taskTreeNodeFactory the node factory to be used for instantiating new task tree 117 * nodes during rule application 118 * @param taskTreeBuilder the task tree builder to be used for linking task tree nodes 119 * with each other during rule application 120 */ 121 public TemporalRelationshipRuleManager(NodeEqualityRuleManager nodeEqualityRuleManager, 122 ITaskTreeNodeFactory taskTreeNodeFactory, 123 ITaskTreeBuilder taskTreeBuilder) 124 { 94 125 super(); 95 126 this.nodeEqualityRuleManager = nodeEqualityRuleManager; 127 this.taskTreeNodeFactory = taskTreeNodeFactory; 128 this.taskTreeBuilder = taskTreeBuilder; 96 129 } 97 130 … … 107 140 frameFilter.add(IFrame.class); 108 141 frameFilter.add(IDialog.class); 109 110 rules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 111 rules.add(new DefaultGuiElementSequenceDetectionRule()); 112 rules.add(new DefaultEventTargetSequenceDetectionRule()); 113 rules.add(new TrackBarSelectionDetectionRule(nodeEqualityRuleManager)); 114 //rules.add(new DefaultGuiEventSequenceDetectionRule()); 142 //frameFilter.add(ICanvas.class); 143 144 treeScopeRules = new TemporalRelationshipRule[] { 145 new DefaultTaskSequenceDetectionRule 146 (nodeEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL, 147 taskTreeNodeFactory, taskTreeBuilder) 148 }; 115 149 116 rules.add(new DefaultIterationDetectionRule 117 (nodeEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL)); 118 rules.add(new DefaultIterationDetectionRule 119 (nodeEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL)); 120 rules.add(new DefaultIterationDetectionRule 121 (nodeEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL)); 150 //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 151 152 nodeScopeRules = new TemporalRelationshipRule[] { 153 //new DefaultGuiElementSequenceDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 154 //new DefaultEventTargetSequenceDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 155 new TrackBarSelectionDetectionRule 156 (nodeEqualityRuleManager, taskTreeNodeFactory, taskTreeBuilder), 157 //new DefaultGuiEventSequenceDetectionRule(taskTreeNodeFactory, taskTreeBuilder), 158 new DefaultIterationDetectionRule 159 (nodeEqualityRuleManager, NodeEquality.LEXICALLY_EQUAL, 160 taskTreeNodeFactory, taskTreeBuilder), 161 new DefaultIterationDetectionRule 162 (nodeEqualityRuleManager, NodeEquality.SYNTACTICALLY_EQUAL, 163 taskTreeNodeFactory, taskTreeBuilder), 164 new DefaultIterationDetectionRule 165 (nodeEqualityRuleManager, NodeEquality.SEMANTICALLY_EQUAL, 166 taskTreeNodeFactory, taskTreeBuilder) 167 }; 168 169 } 170 171 /** 172 * <p> 173 * applies the known rules to the provided parent node. For the creation of further nodes, 174 * the provided builder and node factory are utilized. The method expectes, that no more data 175 * is available and, therefore, finalizes the rule application. 176 * </p> 177 * 178 * @param nodeFactory the node factory to be used for instantiating new task tree nodes. 179 */ 180 public void applyRules(ITaskTreeNode parent) { 181 applyRules(parent, true); 122 182 } 123 183 … … 132 192 * 133 193 * @param parent the parent node to apply the rules on 134 * @param builder the task tree builder to be used for linking task tree nodes with each135 * other136 * @param nodeFactory the node factory to be used for instantiating new task tree nodes.137 194 * @param finalize used to indicate, if the rule application shall break up if a rule would 138 195 * be feasible if further data was available, or not. 139 196 */ 140 public void applyRules(ITaskTreeNode parent, 141 ITaskTreeBuilder builder, 142 ITaskTreeNodeFactory nodeFactory, 143 boolean finalize) 144 { 145 applyRules(parent, builder, nodeFactory, finalize, ""); 197 public void applyRules(ITaskTreeNode parent, boolean finalize) { 198 applyRules(treeScopeRules, parent, finalize, ""); 146 199 } 147 200 … … 157 210 * 158 211 * @param parent the parent node to apply the rules on 159 * @param builder the task tree builder to be used for linking task tree nodes with each160 * other161 * @param nodeFactory the node factory to be used for instantiating new task tree nodes.162 212 * @param finalize used to indicate, if the rule application shall break up if a rule would 163 213 * be feasible if further data was available, or not. … … 165 215 * on the recursion depth of calling this method. 166 216 */ 167 private int applyRules(ITaskTreeNode parent, 168 ITaskTreeBuilder builder, 169 ITaskTreeNodeFactory nodeFactory, 170 boolean finalize, 171 String logIndent) 217 private int applyRules(TemporalRelationshipRule[] rules, 218 ITaskTreeNode parent, 219 boolean finalize, 220 String logIndent) 172 221 { 173 222 Console.traceln(Level.FINER, logIndent + "applying rules for " + parent); … … 179 228 do { 180 229 Console.traceln(Level.FINER, logIndent + "trying rule " + rule + " on " + parent); 181 result = rule.apply(parent, builder, nodeFactory,finalize);230 result = rule.apply(parent, finalize); 182 231 183 232 if ((result != null) && … … 193 242 for (ITaskTreeNode newParent : result.getNewlyCreatedParentNodes()) { 194 243 noOfRuleApplications += 195 applyRules(n ewParent, builder, nodeFactory, true, logIndent + " ");244 applyRules(nodeScopeRules, newParent, true, logIndent + " "); 196 245 } 197 246 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TrackBarSelectionDetectionRule.java
r1099 r1107 19 19 * @author 2012, last modified by $Author: patrick$ 20 20 */ 21 public class TrackBarSelectionDetectionRule implements TemporalRelationshipRule { 21 class TrackBarSelectionDetectionRule implements TemporalRelationshipRule { 22 /** 23 * <p> 24 * the task tree node factory to be used for creating substructures for the temporal 25 * relationships identified during rule 26 * </p> 27 */ 28 private ITaskTreeNodeFactory taskTreeNodeFactory; 29 /** 30 * <p> 31 * the task tree builder to be used for creating substructures for the temporal relationships 32 * identified during rule application 33 * </p> 34 */ 35 private ITaskTreeBuilder taskTreeBuilder; 22 36 23 /** */ 37 /** 38 * <p> 39 * the node equality manager needed for comparing task tree nodes with each other 40 * </p> 41 */ 24 42 private NodeEqualityRuleManager nodeEqualityRuleManager; 25 43 26 44 /** 27 * 45 * <p> 46 * instantiates the rule and initializes it with a node equality rule manager and the minimal 47 * node equality identified sublist must have to consider them as iterated. 48 * </p> 28 49 */ 29 TrackBarSelectionDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager) { 30 super(); 50 TrackBarSelectionDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager, 51 ITaskTreeNodeFactory taskTreeNodeFactory, 52 ITaskTreeBuilder taskTreeBuilder) 53 { 31 54 this.nodeEqualityRuleManager = nodeEqualityRuleManager; 55 this.taskTreeNodeFactory = taskTreeNodeFactory; 56 this.taskTreeBuilder = taskTreeBuilder; 32 57 } 33 58 … … 35 60 * (non-Javadoc) 36 61 * 37 * @see TemporalRelationshipRule#apply(TaskTreeNode, TaskTreeBuilder, TaskTreeNodeFactory) 62 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 63 * boolean) 38 64 */ 39 65 @Override 40 public RuleApplicationResult apply(ITaskTreeNode parent, 41 ITaskTreeBuilder builder, 42 ITaskTreeNodeFactory nodeFactory, 43 boolean finalize) 44 { 66 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 45 67 if (!(parent instanceof ISequence)) { 46 68 return null; … … 72 94 // Therefore, 73 95 // create an iteration with the different selectable values as selection children 74 handleValueSelections (parent, currentTrackBar, valueSelectionStartIndex, index - 1,75 builder, nodeFactory, result);96 handleValueSelections 97 (parent, currentTrackBar, valueSelectionStartIndex, index - 1, result); 76 98 77 99 return result; … … 84 106 if (finalize) { 85 107 handleValueSelections(parent, currentTrackBar, valueSelectionStartIndex, 86 parent.getChildren().size() - 1, builder, nodeFactory,result);108 parent.getChildren().size() - 1, result); 87 109 } 88 110 else { … … 101 123 int startIndex, 102 124 int endIndex, 103 ITaskTreeBuilder builder,104 ITaskTreeNodeFactory nodeFactory,105 125 RuleApplicationResult result) 106 126 { 107 IIteration iteration = nodeFactory.createNewIteration(); 108 builder.setDescription(iteration, "value selection on " + trackbar.getStringIdentifier()); 127 IIteration iteration = taskTreeNodeFactory.createNewIteration(); 128 taskTreeBuilder.setDescription 129 (iteration, "value selection on " + trackbar.getStringIdentifier()); 109 130 result.addNewlyCreatedParentNode(iteration); 110 131 111 ISelection selection = nodeFactory.createNewSelection();132 ISelection selection = taskTreeNodeFactory.createNewSelection(); 112 133 result.addNewlyCreatedParentNode(selection); 113 builder.setChild(iteration, selection);134 taskTreeBuilder.setChild(iteration, selection); 114 135 115 136 for (int i = endIndex - startIndex; i >= 0; i--) { 116 addChildIfNecessary(selection, parent.getChildren().get(startIndex), builder, 117 nodeFactory, result); 118 builder.removeChild((ISequence) parent, startIndex); 137 addChildIfNecessary(selection, parent.getChildren().get(startIndex), result); 138 taskTreeBuilder.removeChild((ISequence) parent, startIndex); 119 139 } 120 140 121 builder.addChild((ISequence) parent, startIndex, iteration);141 taskTreeBuilder.addChild((ISequence) parent, startIndex, iteration); 122 142 123 143 result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FINISHED); … … 129 149 private void addChildIfNecessary(ISelection parentSelection, 130 150 ITaskTreeNode node, 131 ITaskTreeBuilder builder,132 ITaskTreeNodeFactory nodeFactory,133 151 RuleApplicationResult result) 134 152 { … … 144 162 145 163 // if we did not return in the previous checks, then the node must be added 146 builder.addChild(parentSelection, node);164 taskTreeBuilder.addChild(parentSelection, node); 147 165 } 148 166
Note: See TracChangeset
for help on using the changeset viewer.