Ignore:
Timestamp:
05/19/17 11:31:29 (8 years ago)
Author:
pharms
Message:
  • refactored GUI model so that hierarchical event target structures can also be used and created by plugins not being strictly for GUIs
File:
1 edited

Legend:

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

    r2131 r2146  
    332332                IIteration iteration = iterations.get(currentTask); 
    333333                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. 
    334337                    if (!inReplacement || (iterationInstance.getTask() != iteration)) { 
     338                        // initiate a new replacement by creating the corresponding new instance 
    335339                        if (currentTask instanceof IOptional) { 
    336340                            IOptional optional = optionals.get(iteration); 
     
    347351                    } 
    348352                     
     353                    // add the current task instance to the iteration instance that is going to 
     354                    // replace it 
    349355                    if (currentTask instanceof IOptional) { 
    350356                        ITaskInstance child = ((IOptionalInstance) session.get(index)).getChild(); 
     
    363369                    } 
    364370                     
     371                    // remove the task instance that was added to the replacing iteration instance 
    365372                    taskBuilder.removeTaskInstance(session, index); 
    366373                } 
    367374                else { 
     375                    // no replacement require. Finish previous replacements and continue 
    368376                    if (iterationInstance != null) { 
    369377                        iterationInstance = null; 
     
    384392    /** 
    385393     * <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> 
    387404     * </p> 
    388405     */ 
     
    12171234        List<Subsequence> potentialSuccessors = new LinkedList<Subsequence>(); 
    12181235         
    1219         appData.getStopWatch().start("determine locations"); 
    1220         Map<Subsequence, List<SubsequenceLocation>> allLocations = 
    1221             getLocations(subsequences, appData); 
    1222         appData.getStopWatch().stop("determine locations"); 
    1223          
    12241236        for (Subsequence subsequence : subsequences) { 
    12251237            // Console.traceln 
     
    12401252             
    12411253            List<Collision> precedingCollisions = 
    1242                 getPrecedingCollisions(subsequence, potentialPredecessors, allLocations, appData); 
     1254                getPrecedingCollisions(subsequence, potentialPredecessors, appData); 
    12431255             
    12441256            List<Collision> succeedingCollisions = 
    1245                 getSucceedingCollisions(subsequence, potentialSuccessors, allLocations, appData); 
     1257                getSucceedingCollisions(subsequence, potentialSuccessors, appData); 
    12461258             
    12471259            if ((precedingCollisions.size() <= 0) && (succeedingCollisions.size() <= 0)) { 
     
    14311443     * 
    14321444     */ 
    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) 
    14381448    { 
    14391449        List<Collision> precedingCollisions = new LinkedList<Collision>(); 
     1450        Map<Subsequence, List<SubsequenceLocation>> allLocations = 
     1451            appData.getLastFoundSubsequenceLocations(); 
    14401452         
    14411453        for (SubsequenceLocation location : allLocations.get(subsequence)) { 
     
    14571469     * 
    14581470     */ 
    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) 
    14641474    { 
    14651475        List<Collision> succeedingCollisions = new LinkedList<Collision>(); 
    1466  
     1476        Map<Subsequence, List<SubsequenceLocation>> allLocations = 
     1477            appData.getLastFoundSubsequenceLocations(); 
     1478         
    14671479        for (SubsequenceLocation location : allLocations.get(subsequence)) { 
    14681480            for (Subsequence successor : potentialSuccessors) { 
     
    17241736     * @return 
    17251737     */ 
    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) 
    17291741    { 
    17301742        boolean matchFound; 
     
    21412153         *  
    21422154         */ 
     2155        private Map<Subsequence, List<SubsequenceLocation>> lastFoundSubsequenceLocations; 
     2156         
     2157        /** 
     2158         *  
     2159         */ 
    21432160        private boolean detectedAndReplacedTasks; 
    21442161         
     
    22002217        private void setLastFoundSubsequences(Subsequences lastFoundSequences) { 
    22012218            this.lastFoundSubsequences = lastFoundSequences; 
     2219            this.lastFoundSubsequenceLocations = null; 
    22022220        } 
    22032221 
     
    22072225        private Subsequences getLastFoundSubsequences() { 
    22082226            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; 
    22092262        } 
    22102263 
Note: See TracChangeset for help on using the changeset viewer.