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.commands.usability;
|
---|
16 |
|
---|
17 | import java.util.List;
|
---|
18 |
|
---|
19 | import de.ugoe.cs.autoquest.CommandHelpers;
|
---|
20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
21 | import de.ugoe.cs.autoquest.usability.UsabilityEvaluationManager;
|
---|
22 | import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult;
|
---|
23 | import de.ugoe.cs.util.console.Command;
|
---|
24 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * <p>
|
---|
28 | * This command performs a usability evaluation based on a task tree. It uses the
|
---|
29 | * {@link UsabilityEvaluationManager} for this purpose. Please consult the documentation of the
|
---|
30 | * usability evaluation manager for more details.
|
---|
31 | * </p>
|
---|
32 | *
|
---|
33 | * @author Patrick Harms
|
---|
34 | * @version 1.0
|
---|
35 | */
|
---|
36 | public class CMDevaluateUsability implements Command {
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * (non-Javadoc)
|
---|
40 | *
|
---|
41 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
42 | */
|
---|
43 | @Override
|
---|
44 | public String help() {
|
---|
45 | return "evaluateUsability <tasktree> {<evaluationResult>}";
|
---|
46 | }
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * (non-Javadoc)
|
---|
50 | *
|
---|
51 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
52 | */
|
---|
53 | @Override
|
---|
54 | public void run(List<Object> parameters) {
|
---|
55 | String tasktreeName;
|
---|
56 | String evaluationResult;
|
---|
57 | try {
|
---|
58 | tasktreeName = (String) parameters.get(0);
|
---|
59 | if (parameters.size() > 1) {
|
---|
60 | evaluationResult = (String) parameters.get(1);
|
---|
61 | }
|
---|
62 | else {
|
---|
63 | evaluationResult = "usabilityEvaluationResult";
|
---|
64 | }
|
---|
65 | }
|
---|
66 | catch (Exception e) {
|
---|
67 | throw new IllegalArgumentException("must provide a task tree name");
|
---|
68 | }
|
---|
69 |
|
---|
70 | Object dataObject = GlobalDataContainer.getInstance().getData(tasktreeName);
|
---|
71 | if (dataObject == null) {
|
---|
72 | CommandHelpers.objectNotFoundMessage(tasktreeName);
|
---|
73 | return;
|
---|
74 | }
|
---|
75 | if (!(dataObject instanceof ITaskModel)) {
|
---|
76 | CommandHelpers.objectNotType(tasktreeName, "ITaskTree");
|
---|
77 | return;
|
---|
78 | }
|
---|
79 |
|
---|
80 | ITaskModel taskTree = (ITaskModel) dataObject;
|
---|
81 |
|
---|
82 | UsabilityEvaluationResult result =
|
---|
83 | new UsabilityEvaluationManager().evaluateUsability(taskTree);
|
---|
84 |
|
---|
85 | if (GlobalDataContainer.getInstance().addData(evaluationResult, result)) {
|
---|
86 | CommandHelpers.dataOverwritten(evaluationResult);
|
---|
87 | }
|
---|
88 |
|
---|
89 | }
|
---|
90 |
|
---|
91 | }
|
---|