source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/UsabilityEvaluator.java @ 1320

Last change on this file since 1320 was 1319, checked in by khartmann, 11 years ago
  • Reworked Filters to use the first instance of a task to provide type and target
  • Added a function to extract all tasks matching a given filter
  • Added simple console feedback for matched usability problems
  • Property svn:mime-type set to text/plain
File size: 3.7 KB
Line 
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
15package de.ugoe.cs.autoquest.usability;
16
17import java.util.logging.Level;
18
19import com.google.common.base.Optional;
20
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
22import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescription;
23import de.ugoe.cs.autoquest.usability.rules.UsabilityResult;
24import de.ugoe.cs.autoquest.usability.rules.UsabilityRule;
25import de.ugoe.cs.autoquest.usability.rules.UsabilityRuleset;
26import de.ugoe.cs.util.console.Console;
27
28/**
29 * <p>
30 * The usability evaluator is responsible for performing a usability evaluation on a task model.
31 * Therefore he uses a {@link UsabilityRuleset}.
32 * </p>
33 *
34 * @author Alexander Deicke
35 */
36public class UsabilityEvaluator {
37
38    /**
39     * <p>
40     * The task model, which should be evaluated.
41     * </p>
42     */
43    private ITaskModel taskModel;
44
45    private UsabilityEvaluator(ITaskModel taskModel) {
46        this.taskModel = taskModel;
47    }
48
49    /**
50     * <p>
51     * Creates and initializes a new instance.
52     * </p>
53     *
54     * @param taskModel
55     *            task model, which is subject of usability evaluation
56     * @return instance of {@link UsabilityEvaluator}
57     */
58    public static UsabilityEvaluator evaluate(ITaskModel taskModel) {
59        return new UsabilityEvaluator(taskModel);
60    }
61
62    /**
63     * <p>
64     * Starts usability evaluation, using given {@link UsabilityRuleset}.
65     * </p>
66     *
67     * @param ruleset
68     *            {@link UsabilityRuleset} used for usability evaluation
69     * @return result of usability evaluation as {@link UsabilityResult}
70     */
71    public UsabilityResult using(UsabilityRuleset ruleset) {
72        Console.traceln(Level.INFO, "evaluating usability of task tree " + this.taskModel);
73        EvaluationMethodCaller evaluationMethodCaller = new EvaluationMethodCaller();
74        UsabilityResult result = new UsabilityResult();
75        for (UsabilityRule rule : ruleset.evaluationRules()) {
76            Optional<UsabilityProblemDescription> defect =
77                rule.callEvaluationMethod(evaluationMethodCaller);
78            if (defect.isPresent()) {
79                UsabilityProblemDescription description = defect.get();
80                logUsabilityProblem(description);
81                result.addProblem(description);
82            }
83        }
84        return result;
85    }
86
87    private void logUsabilityProblem(UsabilityProblemDescription description) {
88        Level level = null;
89        switch (description.getSeverityLevel()) {
90            case NONE:
91                break;
92            case INFO:
93            case LOW:
94                level = Level.INFO;
95                break;
96            case MEDIUM:
97            case HIGH:
98                level = Level.WARNING;
99        }
100        if (level != null) {
101            Console.print(description.getSeverityLevel().toString());
102            Console.print(" : ");
103            Console.println(description.toString());
104            //Console.traceln(level, description.toString());
105        }
106    }
107
108}
Note: See TracBrowser for help on using the repository browser.