[1493] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
| 2 | // |
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 4 | // you may not use this file except in compliance with the License. |
---|
| 5 | // You may obtain a copy of the License at |
---|
| 6 | // |
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 8 | // |
---|
| 9 | // Unless required by applicable law or agreed to in writing, software |
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 12 | // See the License for the specific language governing permissions and |
---|
| 13 | // limitations under the License. |
---|
| 14 | |
---|
| 15 | package de.ugoe.cs.autoquest.usability; |
---|
| 16 | |
---|
| 17 | import de.ugoe.cs.autoquest.eventcore.Event; |
---|
| 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.DefaultTaskInstanceTraversingVisitor; |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor; |
---|
| 22 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
| 23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * TODO comment |
---|
| 27 | * |
---|
| 28 | * @version $Revision: $ $Date: 16.07.2012$ |
---|
| 29 | * @author 2012, last modified by $Author: pharms$ |
---|
| 30 | */ |
---|
| 31 | public class TaskTreeTestRule implements UsabilityEvaluationRule { |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | * (non-Javadoc) |
---|
| 35 | * |
---|
| 36 | * @see de.ugoe.cs.usability.UsabilityEvaluationRule#evaluate(TaskTree) |
---|
| 37 | */ |
---|
| 38 | @Override |
---|
| 39 | public UsabilityEvaluationResult evaluate(ITaskModel taskModel) { |
---|
| 40 | UsabilityEvaluationResult results = new UsabilityEvaluationResult(taskModel); |
---|
| 41 | |
---|
| 42 | checkTimestamps(taskModel); |
---|
| 43 | |
---|
| 44 | return results; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * <p> |
---|
| 49 | * TODO: comment |
---|
| 50 | * </p> |
---|
| 51 | * |
---|
| 52 | * @param taskModel |
---|
| 53 | */ |
---|
| 54 | private void checkTimestamps(ITaskModel taskModel) { |
---|
| 55 | for (IUserSession session : taskModel.getUserSessions()) { |
---|
| 56 | ITaskInstanceVisitor visitor = new DefaultTaskInstanceTraversingVisitor() { |
---|
| 57 | Event lastEvent = null; |
---|
| 58 | |
---|
| 59 | @Override |
---|
| 60 | public void visit(IEventTaskInstance eventTaskInstance) { |
---|
| 61 | if (lastEvent != null) { |
---|
| 62 | if (eventTaskInstance.getEvent().getTimestamp() < lastEvent.getTimestamp()) { |
---|
| 63 | System.out.println("timestamp problem encountered:"); |
---|
| 64 | System.out.println(" " + lastEvent.getTimestamp() + " " + lastEvent); |
---|
| 65 | System.out.println(" " + eventTaskInstance.getEvent().getTimestamp() + " " + eventTaskInstance.getEvent()); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | lastEvent = eventTaskInstance.getEvent(); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | }; |
---|
| 73 | |
---|
| 74 | for (ITaskInstance instance : session) { |
---|
| 75 | visitor.visit(instance); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | } |
---|