Changeset 1967
- Timestamp:
- 06/15/15 16:06:48 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/CondenseSimilarTasksRule.java
r1953 r1967 578 578 else { 579 579 // its time to create a selection of both variants. If one is already 580 // a selection, it is reused and extended, if required 580 // a selection, it is reused and extended, if required. 581 581 582 ITask expectedChild1 = null; 582 583 ITask expectedChild2 = null; … … 607 608 } 608 609 else if (selection == null) { 609 // none of both is already a selection, so create a new one with both 610 // of the children as variants 611 selection = taskFactory.createNewSelection(); 612 // ((Task) selection).setDescription(selection.getDescription() + 613 // " created for " + delta.getType()); 614 taskBuilder.addChild(selection, child1); 615 taskBuilder.addChild(selection, child2); 616 expectedChild1 = child1; 617 expectedChild2 = child2; 610 // it may also be the case, that one is a child of a selection and occurs 611 // only as such and nowhere else. Then the parent selection is reused and 612 // extended. 613 for (ITask candidate : appData.taskModel.getTasks()) { 614 if (candidate instanceof ISelection) { 615 selection = (ISelection) candidate; 616 ITask existingChildTask = null; 617 618 if (selection.getChildren().contains(child1)) { 619 existingChildTask = child1; 620 } 621 else if (selection.getChildren().contains(child2)) { 622 existingChildTask = child2; 623 } 624 625 if (existingChildTask != null) { 626 int noOfInstances = 0; 627 628 for (ITaskInstance instance : selection.getInstances()) { 629 ITaskInstance childInstance = 630 ((ISelectionInstance) instance).getChild(); 631 632 if (childInstance.getTask() == existingChildTask) { 633 noOfInstances++; 634 } 635 } 636 637 if (noOfInstances < existingChildTask.getInstances().size()) { 638 // not all instances of the existing child task are covered 639 // by the parent selection. Hence, throw selection away and 640 // search for another one 641 selection = null; 642 } 643 else { 644 // found a parent selection --> reuse it but add the new 645 // variant 646 if (child1 == existingChildTask) { 647 addSelectionChildIfRequired(selection, child2); 648 } 649 else { 650 addSelectionChildIfRequired(selection, child1); 651 } 652 expectedChild1 = child1; 653 expectedChild2 = child2; 654 break; 655 } 656 } 657 else { 658 selection = null; 659 } 660 } 661 } 662 663 if (selection == null) { 664 // none of both is already a selection, so create a new one with both 665 // of the children as variants 666 selection = taskFactory.createNewSelection(); 667 // ((Task) selection).setDescription(selection.getDescription() + 668 // " created for " + delta.getType()); 669 taskBuilder.addChild(selection, child1); 670 taskBuilder.addChild(selection, child2); 671 expectedChild1 = child1; 672 expectedChild2 = child2; 673 } 618 674 } 619 675 … … 1148 1204 1149 1205 if (replacement instanceof ISelectionInstance) { 1206 // if the replacement itself is a selection instance, we cannot add 1207 // a selection instance as the child of the parent selection instance. 1208 // therefore, we just use the child of the replacement as new child of the 1209 // existing selection instance 1150 1210 taskBuilder.discardTaskInstance(replacement); 1151 1211 replacement = ((ISelectionInstance) replacement).getChild();
Note: See TracChangeset
for help on using the changeset viewer.