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> {<maxCount>} {<evaluationResult>} {-mostRepresentativeTasksOnly}";
|
---|
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 = null;
|
---|
56 | String evaluationResult = null;
|
---|
57 | int maxCount = Integer.MAX_VALUE;
|
---|
58 | boolean onlyMostRepresentativeTasks = false;
|
---|
59 |
|
---|
60 | try {
|
---|
61 | for (Object parameter : parameters) {
|
---|
62 | if ("-mostRepresentativeTasksOnly".equals(parameter)) {
|
---|
63 | onlyMostRepresentativeTasks = true;
|
---|
64 | }
|
---|
65 | else if (tasktreeName == null) {
|
---|
66 | tasktreeName = (String) parameter;
|
---|
67 | }
|
---|
68 | else {
|
---|
69 | try {
|
---|
70 | maxCount = Integer.parseInt((String) parameter);
|
---|
71 | }
|
---|
72 | catch (Exception e) {
|
---|
73 | if (evaluationResult == null) {
|
---|
74 | evaluationResult = (String) parameter;
|
---|
75 | }
|
---|
76 | else {
|
---|
77 | throw new IllegalArgumentException("unrecognized Parameter");
|
---|
78 | }
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 | catch (Exception e) {
|
---|
84 | throw new IllegalArgumentException("must provide a task tree name");
|
---|
85 | }
|
---|
86 |
|
---|
87 | if (evaluationResult == null) {
|
---|
88 | evaluationResult = "usabilityEvaluationResult";
|
---|
89 | }
|
---|
90 |
|
---|
91 | Object dataObject = GlobalDataContainer.getInstance().getData(tasktreeName);
|
---|
92 | if (dataObject == null) {
|
---|
93 | CommandHelpers.objectNotFoundMessage(tasktreeName);
|
---|
94 | return;
|
---|
95 | }
|
---|
96 | if (!(dataObject instanceof ITaskModel)) {
|
---|
97 | CommandHelpers.objectNotType(tasktreeName, "ITaskTree");
|
---|
98 | return;
|
---|
99 | }
|
---|
100 |
|
---|
101 | ITaskModel taskTree = (ITaskModel) dataObject;
|
---|
102 |
|
---|
103 | UsabilityEvaluationResult result = new UsabilityEvaluationManager().evaluateUsability
|
---|
104 | (taskTree, maxCount, onlyMostRepresentativeTasks);
|
---|
105 |
|
---|
106 | if (GlobalDataContainer.getInstance().addData(evaluationResult, result)) {
|
---|
107 | CommandHelpers.dataOverwritten(evaluationResult);
|
---|
108 | }
|
---|
109 |
|
---|
110 | }
|
---|
111 |
|
---|
112 | }
|
---|