[927] | 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 | |
---|
[922] | 15 | package de.ugoe.cs.autoquest.usability; |
---|
[442] | 16 | |
---|
| 17 | import java.util.ArrayList; |
---|
| 18 | import java.util.List; |
---|
[725] | 19 | import java.util.logging.Level; |
---|
[442] | 20 | |
---|
[1148] | 21 | import de.ugoe.cs.autoquest.tasktrees.query.TaskTreeQueryProcessor; |
---|
| 22 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
[725] | 23 | import de.ugoe.cs.util.console.Console; |
---|
[442] | 24 | |
---|
| 25 | /** |
---|
| 26 | * TODO comment |
---|
| 27 | * |
---|
| 28 | * @version $Revision: $ $Date: 16.07.2012$ |
---|
| 29 | * @author 2012, last modified by $Author: pharms$ |
---|
| 30 | */ |
---|
[561] | 31 | public class UsabilityEvaluationManager { |
---|
| 32 | |
---|
| 33 | /** */ |
---|
| 34 | private List<UsabilityEvaluationRule> rules = new ArrayList<UsabilityEvaluationRule>(); |
---|
[442] | 35 | |
---|
[561] | 36 | /** |
---|
| 37 | * TODO: comment |
---|
| 38 | * |
---|
| 39 | */ |
---|
| 40 | public UsabilityEvaluationManager() { |
---|
| 41 | super(); |
---|
| 42 | init(); |
---|
| 43 | } |
---|
[442] | 44 | |
---|
[561] | 45 | /** |
---|
| 46 | * TODO: comment |
---|
| 47 | * |
---|
| 48 | */ |
---|
| 49 | private void init() { |
---|
| 50 | rules.add(new TextInputStatisticsRule()); |
---|
[442] | 51 | } |
---|
| 52 | |
---|
[561] | 53 | /** |
---|
| 54 | * TODO: comment |
---|
| 55 | * |
---|
| 56 | * @param taskTree |
---|
| 57 | */ |
---|
[1148] | 58 | public UsabilityEvaluationResult evaluateUsability(ITaskModel taskTree) { |
---|
[725] | 59 | Console.traceln(Level.INFO, "evaluating usability of task tree " + taskTree); |
---|
[561] | 60 | |
---|
| 61 | List<UsabilityEvaluationResult> results = new ArrayList<UsabilityEvaluationResult>(); |
---|
[1148] | 62 | TaskTreeQueryProcessor queryProcessor = new TaskTreeQueryProcessor(taskTree); |
---|
[561] | 63 | |
---|
| 64 | for (UsabilityEvaluationRule rule : rules) { |
---|
[725] | 65 | Console.traceln(Level.INFO, "applying rule " + rule.getClass().getSimpleName()); |
---|
[1148] | 66 | UsabilityEvaluationResult result = rule.evaluate(queryProcessor); |
---|
[561] | 67 | results.add(result); |
---|
[725] | 68 | Console.traceln(Level.INFO, "the rule found " + result.getAllDefects().size() + |
---|
| 69 | " usability defects, of which " + result.getSevereDefects().size() + |
---|
| 70 | " are severe."); |
---|
[561] | 71 | } |
---|
| 72 | |
---|
| 73 | UsabilityEvaluationResult result = mergeResults(results); |
---|
[725] | 74 | Console.println("the evaluation result contains " + result.getAllDefects().size() + |
---|
| 75 | " defects, of which " + result.getSevereDefects().size() + " are severe."); |
---|
[561] | 76 | return result; |
---|
[442] | 77 | } |
---|
[561] | 78 | |
---|
| 79 | /** |
---|
| 80 | * TODO: comment |
---|
| 81 | * |
---|
| 82 | * @param results |
---|
| 83 | * @return |
---|
| 84 | */ |
---|
| 85 | private UsabilityEvaluationResult mergeResults(List<UsabilityEvaluationResult> results) { |
---|
| 86 | UsabilityEvaluationResult result = new UsabilityEvaluationResult(); |
---|
| 87 | |
---|
| 88 | for (UsabilityEvaluationResult ruleResult : results) { |
---|
| 89 | for (UsabilityDefect defect : ruleResult.getAllDefects()) { |
---|
| 90 | result.addDefect(defect); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | return result; |
---|
| 95 | } |
---|
| 96 | |
---|
[442] | 97 | } |
---|