Ignore:
Timestamp:
09/26/14 10:46:05 (10 years ago)
Author:
pharms
Message:
  • first version of merging similar task trees
Location:
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java

    r1401 r1767  
    2727import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    2828import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 
    2931import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
    3032import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 
     
    280282    { 
    281283        Map<ITask, IIteration> iterations = new HashMap<ITask, IIteration>(); 
     284        Map<IIteration, IOptional> optionals = new HashMap<IIteration, IOptional>(); 
    282285        Map<IIteration, List<IIterationInstance>> iterationInstances = 
    283286                new HashMap<IIteration, List<IIterationInstance>>(); 
     
    286289            IIteration iteration = taskFactory.createNewIteration(); 
    287290            iterations.put(iteratedTask, iteration); 
     291             
     292            if (iteratedTask instanceof IOptional) { 
     293                IOptional optional = taskFactory.createNewOptional(); 
     294                taskBuilder.setMarkedTask(optional, iteration); 
     295                optionals.put(iteration, optional); 
     296            } 
     297             
    288298            iterationInstances.put(iteration, new LinkedList<IIterationInstance>()); 
    289299        } 
    290300         
     301        IOptionalInstance optionalInstance; 
    291302        IIterationInstance iterationInstance; 
    292303         
    293304        for (IUserSession session : sessions) { 
    294305            int index = 0; 
     306            optionalInstance = null; 
    295307            iterationInstance = null; 
     308            boolean inReplacement = false; 
    296309 
    297310            while (index < session.size()) { 
     
    302315                IIteration iteration = iterations.get(currentTask); 
    303316                if (iteration != null) { 
    304                     if ((iterationInstance == null) || (iterationInstance.getTask() != iteration)) 
    305                     { 
    306                         iterationInstance = taskFactory.createNewTaskInstance(iteration); 
    307                         iterationInstances.get(iteration).add(iterationInstance); 
    308                         taskBuilder.addTaskInstance(session, index, iterationInstance); 
     317                    if (!inReplacement || (iterationInstance.getTask() != iteration)) { 
     318                        if (currentTask instanceof IOptional) { 
     319                            IOptional optional = optionals.get(iteration); 
     320                            optionalInstance = taskFactory.createNewTaskInstance(optional); 
     321                            taskBuilder.addTaskInstance(session, index, optionalInstance); 
     322                        } 
     323                        else { 
     324                            iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     325                            iterationInstances.get(iteration).add(iterationInstance); 
     326                            taskBuilder.addTaskInstance(session, index, iterationInstance); 
     327                        } 
     328                        inReplacement = true; 
    309329                        index++; 
    310330                    } 
    311331                     
    312                     taskBuilder.addChild(iterationInstance, session.get(index)); 
     332                    if (currentTask instanceof IOptional) { 
     333                        ITaskInstance child = ((IOptionalInstance) session.get(index)).getChild(); 
     334                         
     335                        if (child != null) { 
     336                            if (iterationInstance == null) { 
     337                                iterationInstance = taskFactory.createNewTaskInstance(iteration); 
     338                                iterationInstances.get(iteration).add(iterationInstance); 
     339                                taskBuilder.setChild(optionalInstance, iterationInstance); 
     340                            } 
     341                            taskBuilder.addChild(iterationInstance, child); 
     342                        } 
     343                    } 
     344                    else { 
     345                        taskBuilder.addChild(iterationInstance, session.get(index)); 
     346                    } 
     347                     
    313348                    taskBuilder.removeTaskInstance(session, index); 
    314349                } 
     
    316351                    if (iterationInstance != null) { 
    317352                        iterationInstance = null; 
     353                        optionalInstance = null; 
     354                        inReplacement = false; 
    318355                    } 
    319356                    index++; 
     
    544581                    replaceTaskOccurrences(task, appData.getSessions(), sequence); 
    545582                 
    546                 harmonizeSequenceInstancesModel(sequence, sequenceInstances,task.size()); 
     583                harmonizeSequenceInstancesModel(sequence, sequenceInstances, task.size()); 
    547584                appData.detectedAndReplacedTasks 
    548585                    (appData.detectedAndReplacedTasks() || (sequenceInstances.size() > 0)); 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskIdentityComparator.java

    r1401 r1767  
    1616 
    1717import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
     18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    1819import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
    1920 
     
    4344    @Override 
    4445    public boolean equals(ITaskInstance taskInstance1, ITaskInstance taskInstance2) { 
    45         return taskInstance1.getTask() == taskInstance2.getTask(); 
     46        return equals(taskInstance1.getTask(), taskInstance2.getTask()); 
     47    } 
     48 
     49    /* (non-Javadoc) 
     50     * @see TaskInstanceComparator#equals(ITask, ITask) 
     51     */ 
     52    @Override 
     53    public boolean equals(ITask task1, ITask task2) { 
     54        return task1 == task2; 
    4655    }         
    4756 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java

    r1294 r1767  
    148148            new SequenceForTaskDetectionRule 
    149149                (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder), 
     150            new CondenseSimilarTasksRule 
     151                (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder), 
    150152            /*new DefaultTaskSequenceDetectionRule 
    151153                (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder), 
Note: See TracChangeset for help on using the changeset viewer.