Changeset 2132 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
- Timestamp:
- 08/24/16 10:17:41 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r1889 r2132 25 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 26 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;28 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 29 28 import de.ugoe.cs.util.console.Console; … … 102 101 /** 103 102 * <p> 104 * the temporal relationship rules known to the manager that are executed on whole sessions.105 * The rules are applied in the order they occur in this list.106 * </p>107 */108 private ISessionScopeRule[] sessionScopeRules;109 110 /**111 * <p>112 * the temporal relationship rules known to the manager that are executed on whole sub trees.113 * The rules are applied in the order they occur in this list.114 * </p>115 */116 private ITaskInstanceScopeRule[] taskScopeRules;117 118 /**119 * <p>120 103 * initialize the manager 121 104 * </p> … … 144 127 frameFilter.add(IDialog.class); 145 128 //frameFilter.add(ICanvas.class); 146 147 sessionScopeRules = new ISessionScopeRule[] {148 new SequenceForTaskDetectionRule149 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder),150 new CondenseSimilarTasksRule151 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder),152 /*new DefaultTaskSequenceDetectionRule153 (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder),154 new DefaultTaskSequenceDetectionRule155 (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder),*/156 /*new TreeScopeWrapperRule157 (new DefaultIterationDetectionRule158 (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder)),159 new TreeScopeWrapperRule160 (new DefaultIterationDetectionRule161 (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder)),162 new TreeScopeWrapperRule163 (new DefaultIterationDetectionRule164 (NodeEquality.SEMANTICALLY_EQUAL, taskFactory, taskTreeBuilder))*/165 };166 167 //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter));168 169 taskScopeRules = new ITaskInstanceScopeRule[] {170 //new SequenceOnGuiElementDetectionRule(taskFactory, taskTreeBuilder),171 //new EventSequenceOnSameTargetDetectionRule(taskFactory, taskTreeBuilder),172 //new TrackBarSelectionDetectionRule(taskFactory, taskBuilder),173 //new DefaultGuiEventSequenceDetectionRule(taskFactory, taskTreeBuilder),174 };175 176 }177 178 /**179 * <p>180 * applies the known rules to the provided sessions. For the creation of further tasks,181 * the provided builder and task factory are utilized. The method expects, that no more data182 * is available and, therefore, finalizes the rule application.183 * </p>184 *185 * @param sessions the sessions to be processed186 */187 public void applyRules(List<IUserSession> sessions) {188 applyRules(sessionScopeRules, sessions, "");189 129 } 190 130 … … 197 137 * @param sessions the sessions to be processed 198 138 */ 199 public void applyTaskDetectionRule(List<IUserSession> sessions) { 139 public void applyTaskDetectionRule(List<IUserSession> sessions, 140 TaskEquality minimalTaskEquality, 141 int minimumSequenceCoverage) 142 { 200 143 ISessionScopeRule[] rules = new ISessionScopeRule[] { 201 new SequenceForTaskDetectionRule 202 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder)144 new SequenceForTaskDetectionRule(minimalTaskEquality, taskFactory, taskBuilder, 145 minimumSequenceCoverage) 203 146 }; 204 147 … … 261 204 262 205 //dumpTask(parent, ""); 263 264 for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) {265 noOfRuleApplications +=266 applyRules(taskScopeRules, newParent, logIndent + " ");267 }268 206 } 269 207 } … … 271 209 (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 272 210 273 }274 275 if (noOfRuleApplications <= 0) {276 Console.traceln(Level.FINE, logIndent + "no rules applied --> no temporal " +277 "relationship generated");278 }279 280 return noOfRuleApplications;281 }282 283 /**284 * <p>285 * applies the known rules to the provided parent task. For the creation of further tasks,286 * the provided builder and task factory are utilized. If the finalize parameter is true, the287 * rule application is finalized as far as possible without waiting for further data. If it is288 * false, the rule application is broken up at the first rule returning, that its application289 * would be feasible. The method calls itself for each parent task created through the rule290 * application. In this case, the finalize parameter is always true.291 * </p>292 *293 * @param parent the parent task to apply the rules on294 * @param finalize used to indicate, if the rule application shall break up if a rule would295 * be feasible if further data was available, or not.296 * @param logIndent simply used for logging purposes to indent the log messages depending297 * on the recursion depth of calling this method.298 */299 private int applyRules(ITaskInstanceScopeRule[] rules,300 ITaskInstance taskInstance,301 String logIndent)302 {303 Console.traceln(Level.FINER, logIndent + "applying rules on " + taskInstance);304 305 int noOfRuleApplications = 0;306 307 for (ITaskInstanceScopeRule rule : rules) {308 RuleApplicationResult result;309 do {310 Console.traceln311 (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance);312 result = rule.apply(taskInstance);313 314 if ((result != null) &&315 (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED))316 {317 Console.traceln318 (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance);319 noOfRuleApplications++;320 321 //dumpTask(parent, "");322 323 for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) {324 noOfRuleApplications +=325 applyRules(taskScopeRules, newParent, logIndent + " ");326 }327 }328 }329 while ((result != null) &&330 (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED));331 211 } 332 212
Note: See TracChangeset
for help on using the changeset viewer.