[1138] | 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 java.util.logging.Level;
|
---|
| 18 |
|
---|
| 19 | import com.google.common.base.Optional;
|
---|
| 20 |
|
---|
[1152] | 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1217] | 22 | import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescription;
|
---|
[1138] | 23 | import de.ugoe.cs.autoquest.usability.rules.UsabilityResult;
|
---|
| 24 | import de.ugoe.cs.autoquest.usability.rules.UsabilityRule;
|
---|
| 25 | import de.ugoe.cs.autoquest.usability.rules.UsabilityRuleset;
|
---|
| 26 | import de.ugoe.cs.util.console.Console;
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * <p>
|
---|
[1217] | 30 | * The usability evaluator is responsible for performing a usability evaluation on a task model.
|
---|
| 31 | * Therefore he uses a {@link UsabilityRuleset}.
|
---|
[1138] | 32 | * </p>
|
---|
| 33 | *
|
---|
| 34 | * @author Alexander Deicke
|
---|
| 35 | */
|
---|
| 36 | public class UsabilityEvaluator {
|
---|
[1217] | 37 |
|
---|
| 38 | /**
|
---|
| 39 | * <p>
|
---|
| 40 | * The task model, which should be evaluated.
|
---|
| 41 | * </p>
|
---|
| 42 | */
|
---|
[1152] | 43 | private ITaskModel taskModel;
|
---|
[1138] | 44 |
|
---|
[1217] | 45 | private UsabilityEvaluator(ITaskModel taskModel) {
|
---|
| 46 | this.taskModel = taskModel;
|
---|
[1138] | 47 | }
|
---|
[1217] | 48 |
|
---|
[1138] | 49 | /**
|
---|
| 50 | * <p>
|
---|
[1217] | 51 | * Creates and initializes a new instance.
|
---|
[1138] | 52 | * </p>
|
---|
[1217] | 53 | *
|
---|
| 54 | * @param taskModel
|
---|
| 55 | * task model, which is subject of usability evaluation
|
---|
| 56 | * @return instance of {@link UsabilityEvaluator}
|
---|
[1138] | 57 | */
|
---|
[1217] | 58 | public static UsabilityEvaluator evaluate(ITaskModel taskModel) {
|
---|
| 59 | return new UsabilityEvaluator(taskModel);
|
---|
[1138] | 60 | }
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * <p>
|
---|
[1217] | 64 | * Starts usability evaluation, using given {@link UsabilityRuleset}.
|
---|
[1138] | 65 | * </p>
|
---|
[1217] | 66 | *
|
---|
| 67 | * @param ruleset
|
---|
| 68 | * {@link UsabilityRuleset} used for usability evaluation
|
---|
| 69 | * @return result of usability evaluation as {@link UsabilityResult}
|
---|
[1138] | 70 | */
|
---|
| 71 | public UsabilityResult using(UsabilityRuleset ruleset) {
|
---|
[1152] | 72 | Console.traceln(Level.INFO, "evaluating usability of task tree " + this.taskModel);
|
---|
[1150] | 73 | EvaluationMethodCaller evaluationMethodCaller = new EvaluationMethodCaller();
|
---|
[1138] | 74 | UsabilityResult result = new UsabilityResult();
|
---|
[1217] | 75 | for (UsabilityRule rule : ruleset.evaluationRules()) {
|
---|
| 76 | Optional<UsabilityProblemDescription> defect =
|
---|
| 77 | rule.callEvaluationMethod(evaluationMethodCaller);
|
---|
| 78 | if (defect.isPresent()) {
|
---|
[1319] | 79 | UsabilityProblemDescription description = defect.get();
|
---|
| 80 | logUsabilityProblem(description);
|
---|
| 81 | result.addProblem(description);
|
---|
[1138] | 82 | }
|
---|
| 83 | }
|
---|
| 84 | return result;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[1319] | 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 |
|
---|
[1138] | 108 | }
|
---|