source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usability/CMDevaluateUsability.java @ 2166

Last change on this file since 2166 was 2166, checked in by pharms, 7 years ago
  • changes for first VR oriented usability evaluation
File size: 3.9 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.commands.usability;
16
17import java.util.List;
18
19import de.ugoe.cs.autoquest.CommandHelpers;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
21import de.ugoe.cs.autoquest.usability.UsabilityEvaluationManager;
22import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult;
23import de.ugoe.cs.util.console.Command;
24import 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 */
36public 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}
Note: See TracBrowser for help on using the repository browser.