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

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 3.0 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.ITaskTree;
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> {<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 ITaskTree)) {
76            CommandHelpers.objectNotType(tasktreeName, "ITaskTree");
77            return;
78        }
79
80        ITaskTree taskTree = (ITaskTree) 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}
Note: See TracBrowser for help on using the repository browser.