Changeset 2146 for trunk/autoquest-core-tasktrees/src/main/java
- Timestamp:
- 05/19/17 11:31:29 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
r2131 r2146 332 332 IIteration iteration = iterations.get(currentTask); 333 333 if (iteration != null) { 334 // replacement required. Check if we already replaced a previous child, or if 335 // we did, if the current child needs to be in the same iteration instance or 336 // a new one. 334 337 if (!inReplacement || (iterationInstance.getTask() != iteration)) { 338 // initiate a new replacement by creating the corresponding new instance 335 339 if (currentTask instanceof IOptional) { 336 340 IOptional optional = optionals.get(iteration); … … 347 351 } 348 352 353 // add the current task instance to the iteration instance that is going to 354 // replace it 349 355 if (currentTask instanceof IOptional) { 350 356 ITaskInstance child = ((IOptionalInstance) session.get(index)).getChild(); … … 363 369 } 364 370 371 // remove the task instance that was added to the replacing iteration instance 365 372 taskBuilder.removeTaskInstance(session, index); 366 373 } 367 374 else { 375 // no replacement require. Finish previous replacements and continue 368 376 if (iterationInstance != null) { 369 377 iterationInstance = null; … … 384 392 /** 385 393 * <p> 386 * TODO clarify why this is done 394 * This may not be required anymore. The goal was the following. Consider two subsequent task 395 * instances which are detected to be repeating tasks on a level defined by the 396 * preparationTaskHandlingStrategy. Then the replacement of these iterated tasks by iteration 397 * instances would result in an iteration instance with two children, both of them having a 398 * different task assigned which does not match the child of the iteration model. This needs 399 * to be harmonized afterwards. 400 * </p> 401 * <p> 402 * <b>But, because we introduced the harmonization of event tasks directly at the beginning and 403 * afterwards, we compare only based on object identity, this may not be required anymore.</b> 387 404 * </p> 388 405 */ … … 1217 1234 List<Subsequence> potentialSuccessors = new LinkedList<Subsequence>(); 1218 1235 1219 appData.getStopWatch().start("determine locations");1220 Map<Subsequence, List<SubsequenceLocation>> allLocations =1221 getLocations(subsequences, appData);1222 appData.getStopWatch().stop("determine locations");1223 1224 1236 for (Subsequence subsequence : subsequences) { 1225 1237 // Console.traceln … … 1240 1252 1241 1253 List<Collision> precedingCollisions = 1242 getPrecedingCollisions(subsequence, potentialPredecessors, a llLocations, appData);1254 getPrecedingCollisions(subsequence, potentialPredecessors, appData); 1243 1255 1244 1256 List<Collision> succeedingCollisions = 1245 getSucceedingCollisions(subsequence, potentialSuccessors, a llLocations, appData);1257 getSucceedingCollisions(subsequence, potentialSuccessors, appData); 1246 1258 1247 1259 if ((precedingCollisions.size() <= 0) && (succeedingCollisions.size() <= 0)) { … … 1431 1443 * 1432 1444 */ 1433 private List<Collision> getPrecedingCollisions 1434 (Subsequence subsequence, 1435 List<Subsequence> potentialPredecessors, 1436 Map<Subsequence, List<SubsequenceLocation>> allLocations, 1437 RuleApplicationData appData) 1445 private List<Collision> getPrecedingCollisions(Subsequence subsequence, 1446 List<Subsequence> potentialPredecessors, 1447 RuleApplicationData appData) 1438 1448 { 1439 1449 List<Collision> precedingCollisions = new LinkedList<Collision>(); 1450 Map<Subsequence, List<SubsequenceLocation>> allLocations = 1451 appData.getLastFoundSubsequenceLocations(); 1440 1452 1441 1453 for (SubsequenceLocation location : allLocations.get(subsequence)) { … … 1457 1469 * 1458 1470 */ 1459 private List<Collision> getSucceedingCollisions 1460 (Subsequence subsequence, 1461 List<Subsequence> potentialSuccessors, 1462 Map<Subsequence, List<SubsequenceLocation>> allLocations, 1463 RuleApplicationData appData) 1471 private List<Collision> getSucceedingCollisions(Subsequence subsequence, 1472 List<Subsequence> potentialSuccessors, 1473 RuleApplicationData appData) 1464 1474 { 1465 1475 List<Collision> succeedingCollisions = new LinkedList<Collision>(); 1466 1476 Map<Subsequence, List<SubsequenceLocation>> allLocations = 1477 appData.getLastFoundSubsequenceLocations(); 1478 1467 1479 for (SubsequenceLocation location : allLocations.get(subsequence)) { 1468 1480 for (Subsequence successor : potentialSuccessors) { … … 1724 1736 * @return 1725 1737 */ 1726 private int getSubListIndex(ITaskInstanceList list,1727 Subsequence subsequence,1728 int startIndex)1738 private static int getSubListIndex(ITaskInstanceList list, 1739 Subsequence subsequence, 1740 int startIndex) 1729 1741 { 1730 1742 boolean matchFound; … … 2141 2153 * 2142 2154 */ 2155 private Map<Subsequence, List<SubsequenceLocation>> lastFoundSubsequenceLocations; 2156 2157 /** 2158 * 2159 */ 2143 2160 private boolean detectedAndReplacedTasks; 2144 2161 … … 2200 2217 private void setLastFoundSubsequences(Subsequences lastFoundSequences) { 2201 2218 this.lastFoundSubsequences = lastFoundSequences; 2219 this.lastFoundSubsequenceLocations = null; 2202 2220 } 2203 2221 … … 2207 2225 private Subsequences getLastFoundSubsequences() { 2208 2226 return lastFoundSubsequences; 2227 } 2228 2229 /** 2230 * @return the lastFoundSequences 2231 */ 2232 private Map<Subsequence, List<SubsequenceLocation>> getLastFoundSubsequenceLocations() { 2233 if (lastFoundSubsequenceLocations != null) { 2234 return lastFoundSubsequenceLocations; 2235 } 2236 2237 lastFoundSubsequenceLocations = 2238 new IdentityHashMap<Subsequence, List<SubsequenceLocation>>(); 2239 2240 // fill the map with empty locations 2241 for (Subsequence subsequence : lastFoundSubsequences) { 2242 lastFoundSubsequenceLocations.put 2243 (subsequence, new LinkedList<SubsequenceLocation>()); 2244 } 2245 2246 for (IUserSession session : sessions) { 2247 for (Subsequence candidate : lastFoundSubsequences) { 2248 int index = -1; 2249 do { 2250 index = getSubListIndex(session, candidate, index + 1); 2251 2252 if (index > -1) { 2253 lastFoundSubsequenceLocations.get 2254 (candidate).add(new SubsequenceLocation(session, index)); 2255 } 2256 } 2257 while (index > -1); 2258 } 2259 } 2260 2261 return lastFoundSubsequenceLocations; 2209 2262 } 2210 2263
Note: See TracChangeset
for help on using the changeset viewer.