Changeset 1290 for trunk/autoquest-core-usability-evaluation/src/main/java
- Timestamp:
- 08/10/13 10:25:24 (11 years ago)
- Location:
- trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/taskmodel/filter
- Files:
-
- 1 added
- 1 deleted
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/taskmodel/filter/ITaskModelFilter.java
r1248 r1290 27 27 * @author Alexander Deicke 28 28 */ 29 public interface TaskModelFilterStrategy{29 public interface ITaskModelFilter { 30 30 31 31 public FilterResult filter(ITaskModel taskModel, EventTargetFilter eventTarget); -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/taskmodel/filter/TaskModelFilter.java
r1248 r1290 15 15 package de.ugoe.cs.autoquest.usability.taskmodel.filter; 16 16 17 import java.util.LinkedList;18 import java.util.Queue;19 20 17 import com.google.common.base.Predicate; 21 18 22 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 23 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship;25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship;26 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; … … 37 32 * @author Alexander Deicke 38 33 */ 39 public class IterativeDFSFilterStrategy implements TaskModelFilterStrategy{34 public class TaskModelFilter implements ITaskModelFilter { 40 35 41 private FilterResult filterStatistic;36 private BFSTaskModelIterator taskModelIterator; 42 37 43 @SuppressWarnings("unchecked") 44 @Override 45 public FilterResult filter(ITaskModel taskModel, EventTargetFilter eventTarget) { 46 Predicate<IEventTarget> filterPredicate = eventTarget.filterPredicate(); 47 this.filterStatistic = new FilterResult(filterPredicate); 48 traverse(taskModel); 49 return this.filterStatistic; 50 } 38 private FilterResult filterStatistic; 51 39 52 @SuppressWarnings("unchecked") 53 @Override 54 public FilterResult filter(ITaskModel taskModel, EventTypeFilter eventType) { 55 Predicate<IEventType> filterPredicate = eventType.filterPredicate(); 56 this.filterStatistic = new FilterResult(filterPredicate); 57 traverse(taskModel); 58 return this.filterStatistic; 59 } 40 @SuppressWarnings("unchecked") 41 @Override 42 public FilterResult filter(ITaskModel taskModel, 43 EventTargetFilter eventTarget) { 44 Predicate<IEventTarget> filterPredicate = eventTarget.filterPredicate(); 45 return setup(taskModel, filterPredicate); 46 } 60 47 61 @SuppressWarnings("unchecked") 62 @Override 63 public FilterResult filter(ITaskModel taskModel, TaskTypeFilter nodeType) { 64 Predicate<ITask> filterPredicate = nodeType.filterPredicate(); 65 this.filterStatistic = new FilterResult(filterPredicate); 66 traverse(taskModel); 67 return this.filterStatistic; 68 } 48 @SuppressWarnings("unchecked") 49 @Override 50 public FilterResult filter(ITaskModel taskModel, EventTypeFilter eventType) { 51 Predicate<IEventType> filterPredicate = eventType.filterPredicate(); 52 return setup(taskModel, filterPredicate); 53 } 69 54 70 private void traverse(ITaskModel taskModel) { 71 Queue<ITask> unvisitedTasks = new LinkedList<ITask>(); 72 unvisitedTasks.addAll(taskModel.getTasks()); 73 while (stillUnvisitedTasks(unvisitedTasks)) { 74 ITask task = unvisitedTasks.poll(); 75 processCurrentTask(task); 76 processChildrenOfCurrentTask(unvisitedTasks, task); 77 } 78 } 55 @SuppressWarnings("unchecked") 56 @Override 57 public FilterResult filter(ITaskModel taskModel, TaskTypeFilter nodeType) { 58 Predicate<ITask> filterPredicate = nodeType.filterPredicate(); 59 return setup(taskModel, filterPredicate); 60 } 79 61 80 private boolean stillUnvisitedTasks(Queue<ITask> unvisitedTasks) { 81 return !unvisitedTasks.isEmpty(); 82 } 62 private FilterResult setup(ITaskModel taskModel, 63 Predicate<?> filterPredicate) { 64 this.filterStatistic = new FilterResult(filterPredicate); 65 this.taskModelIterator = BFSTaskModelIterator.iterator(taskModel); 66 traverse(taskModel); 67 return this.filterStatistic; 68 } 83 69 84 private void processCurrentTask(ITask task) { 85 this.filterStatistic.addTask(task); 86 } 87 88 private void processChildrenOfCurrentTask(Queue<ITask> unvisitedTasks, ITask task) { 89 if (task instanceof IStructuringTemporalRelationship) { 90 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 91 unvisitedTasks.add(child); 92 } 93 } 94 else if (task instanceof IMarkingTemporalRelationship) { 95 unvisitedTasks.add(((IMarkingTemporalRelationship) task).getMarkedTask()); 96 } 97 } 98 70 private void traverse(ITaskModel taskModel) { 71 while (this.taskModelIterator.hasNext()) { 72 ITask task = this.taskModelIterator.next(); 73 this.filterStatistic.addTask(task); 74 } 75 } 99 76 }
Note: See TracChangeset
for help on using the changeset viewer.