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

Last change on this file since 2045 was 2045, checked in by pharms, 9 years ago
  • allowed to display only a given amount of smells with the highest event coverage
File size: 3.6 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>}";
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        try {
59            for (Object parameter : parameters) {
60                if (tasktreeName == null) {
61                    tasktreeName = (String) parameter;
62                }
63                else {
64                    try {
65                        maxCount = Integer.parseInt((String) parameter);
66                    }
67                    catch (Exception e) {
68                        if (evaluationResult == null) {
69                            evaluationResult = (String) parameter;
70                        }
71                        else {
72                            throw new IllegalArgumentException("unrecognized Parameter");
73                        }
74                    }
75                }
76            }
77        }
78        catch (Exception e) {
79            throw new IllegalArgumentException("must provide a task tree name");
80        }
81       
82        if (evaluationResult == null) {
83            evaluationResult = "usabilityEvaluationResult";
84        }
85
86        Object dataObject = GlobalDataContainer.getInstance().getData(tasktreeName);
87        if (dataObject == null) {
88            CommandHelpers.objectNotFoundMessage(tasktreeName);
89            return;
90        }
91        if (!(dataObject instanceof ITaskModel)) {
92            CommandHelpers.objectNotType(tasktreeName, "ITaskTree");
93            return;
94        }
95
96        ITaskModel taskTree = (ITaskModel) dataObject;
97       
98        UsabilityEvaluationResult result =
99            new UsabilityEvaluationManager().evaluateUsability(taskTree, maxCount);
100       
101        if (GlobalDataContainer.getInstance().addData(evaluationResult, result)) {
102            CommandHelpers.dataOverwritten(evaluationResult);
103        }
104       
105    }
106
107}
Note: See TracBrowser for help on using the repository browser.