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.usability; |
---|
16 | |
---|
17 | import java.util.HashMap; |
---|
18 | import java.util.Map; |
---|
19 | |
---|
20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; |
---|
21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
22 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric; |
---|
24 | |
---|
25 | /** |
---|
26 | * TODO comment |
---|
27 | * |
---|
28 | * @version $Revision: $ $Date: 16.07.2012$ |
---|
29 | * @author 2012, last modified by $Author: pharms$ |
---|
30 | */ |
---|
31 | public class EventCoverageQuantileRule implements UsabilityEvaluationRule { |
---|
32 | |
---|
33 | /* |
---|
34 | * (non-Javadoc) |
---|
35 | * |
---|
36 | * @see de.ugoe.cs.usability.UsabilityEvaluationRule#evaluate(TaskTree) |
---|
37 | */ |
---|
38 | @Override |
---|
39 | public UsabilityEvaluationResult evaluate(ITaskModel taskModel) { |
---|
40 | UsabilityEvaluationResult results = new UsabilityEvaluationResult(taskModel); |
---|
41 | |
---|
42 | checkForCooccurrences(results, taskModel); |
---|
43 | |
---|
44 | return results; |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * |
---|
49 | */ |
---|
50 | private void checkForCooccurrences(UsabilityEvaluationResult results, ITaskModel taskModel) { |
---|
51 | for (ITask task : taskModel.getTasks()) { |
---|
52 | // only sequences are important for task cooccurrences |
---|
53 | if (task instanceof ISequence) { |
---|
54 | ISequence sequence = (ISequence) task; |
---|
55 | int ratio = taskModel.getTaskInfo(sequence).getMeasureValue |
---|
56 | (TaskMetric.EVENT_COVERAGE_QUANTILE); |
---|
57 | |
---|
58 | //TODO document magic numbers |
---|
59 | UsabilitySmellIntensity severity = |
---|
60 | UsabilitySmellIntensity.getIntensity(ratio, sequence, taskModel); |
---|
61 | |
---|
62 | if (severity != null) { |
---|
63 | |
---|
64 | double effRatio = 0; |
---|
65 | |
---|
66 | if (ratio >= 990) { |
---|
67 | effRatio = 1; |
---|
68 | } |
---|
69 | else if (ratio >= 975) { |
---|
70 | effRatio = 2.5; |
---|
71 | } |
---|
72 | else if (ratio >= 950) { |
---|
73 | effRatio = 5; |
---|
74 | } |
---|
75 | else if (ratio >= 900) { |
---|
76 | effRatio = 10; |
---|
77 | } |
---|
78 | |
---|
79 | Map<String, Object> parameters = new HashMap<String, Object>(); |
---|
80 | parameters.put("task", sequence); |
---|
81 | parameters.put("ratio", effRatio); |
---|
82 | |
---|
83 | results.addSmell(sequence, severity, |
---|
84 | UsabilitySmellDescription.HIGH_EVENT_COVERAGE, parameters); |
---|
85 | } |
---|
86 | } |
---|
87 | } |
---|
88 | } |
---|
89 | } |
---|