Changeset 1217 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/result/UsabilityProblemDescriptionResolver.java
- Timestamp:
- 06/06/13 17:08:25 (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/result/UsabilityProblemDescriptionResolver.java
r1216 r1217 33 33 /** 34 34 * <p> 35 * TODO comment35 * Helper class, which creates a {@link UsabilityProblemDescription} for a usability rule. 36 36 * </p> 37 37 * 38 38 * @author Alexander Deicke 39 39 */ 40 public class DefectDescriptionResolver { 41 40 public class UsabilityProblemDescriptionResolver { 41 42 /** 43 * <p> 44 * .properties file, which contains all details concerning a usability defect. 45 * </p> 46 */ 42 47 private final String defectDescriptionFile = "defects.props"; 43 48 44 49 /** 45 50 * <p> 46 * TODO: comment51 * Creates a defect description for a {@link UsabilityRule}. 47 52 * </p> 48 53 * 49 54 * @param name 50 * @return 51 */ 52 public UsabilityDefect descriptionFor(String usabilityRuleName) { 55 * of usability rule 56 * @return defect description for usability rule 57 */ 58 public UsabilityProblemDescription descriptionFor(String usabilityRuleName) { 53 59 Props allProperties = initProperties(); 54 60 Map<String, String> usabilityRuleProperties = … … 59 65 /** 60 66 * <p> 61 * TODO: comment62 * </p> 63 * 64 * @return 67 * Initializes the properties, which are used to create the defect description. 68 * </p> 69 * 70 * @return properties needed to create defect description 65 71 */ 66 72 private Props initProperties() { … … 77 83 /** 78 84 * <p> 79 * TODO: comment80 * </p> 81 * 82 * @return 85 * Loads the .properties file from the system. 86 * </p> 87 * 88 * @return iff present, {@link File} object of the .properties file 83 89 */ 84 90 private Optional<File> getDefectDescriptionFile() { … … 94 100 } 95 101 102 /** 103 * 104 * <p> 105 * Loads the values from the .properties. 106 * </p> 107 * 108 * @param defectDescriptionFile 109 * .properties file 110 * @param props 111 * object, which stores the loaded values 112 */ 96 113 private void loadProperties(Optional<File> defectDescriptionFile, Props props) { 97 114 try { … … 105 122 /** 106 123 * <p> 107 * TODO: comment 108 * </p> 109 * 110 * @return 124 * Returns all existing properties for a given usability rule. 125 * </p> 126 * 127 * @param allProperties 128 * all properties available 129 * @param usabilityRuleName 130 * name of usability rule 131 * @return all properties of certain usability rule 111 132 */ 112 133 private Map<String, String> allUsabilityRuleProperties(Props allProperties, 113 134 String usabilityRuleName) 114 135 { 115 136 Map<String, String> usabilityRuleProperties = Maps.newHashMap(); … … 120 141 /** 121 142 * <p> 122 * TODO: comment143 * Creates the usability defect. 123 144 * </p> 124 145 * 125 146 * @param usabilityRuleProperties 126 * @return 127 */ 128 private UsabilityDefect createUsabilityDefect(Map<String, String> usabilityRuleProperties) { 147 * all properties needed for creation. 148 * @return defect description for a usability rule 149 */ 150 private UsabilityProblemDescription createUsabilityDefect(Map<String, String> usabilityRuleProperties) 151 { 129 152 String description = 130 Iterables.getOnlyElement(Maps.filterKeys(usabilityRuleProperties, descriptionProperty()).values()); 131 EnumMap<UsabilityDefectSeverityLevel, Double> severity = 153 Iterables.getOnlyElement(Maps 154 .filterKeys(usabilityRuleProperties, descriptionProperty()).values()); 155 EnumMap<UsabilityProblemSeverityLevel, Double> severity = 132 156 getSeverityMap(usabilityRuleProperties); 133 return new Usability Defect(description, severity);134 } 135 136 /** 137 * <p> 138 * TODO: comment139 * </p> 140 * 141 * @return 157 return new UsabilityProblemDescription(description, severity); 158 } 159 160 /** 161 * <p> 162 * Gets the description property. 163 * </p> 164 * 165 * @return description property 142 166 */ 143 167 private Predicate<String> descriptionProperty() { … … 150 174 }; 151 175 } 152 153 /** 154 * <p> 155 * TODO: comment 176 177 /** 178 * <p> 179 * Creates severity level map for defect description, by matching all entried from .properties 180 * file to corresponding {@link UsabilityProblemSeverityLevel}. 156 181 * </p> 157 182 * 158 183 * @param usabilityRuleProperties 159 * @return 160 */ 161 private EnumMap<UsabilityDefectSeverityLevel, Double> getSeverityMap(Map<String, String> usabilityRuleProperties) 184 * all properties of certain usability rule 185 * @return assignment of {@link UsabilityProblemSeverityLevel} and corresponding threshold 186 */ 187 private EnumMap<UsabilityProblemSeverityLevel, Double> getSeverityMap(Map<String, String> usabilityRuleProperties) 162 188 { 163 EnumMap<Usability DefectSeverityLevel, Double> severityMap =164 Maps.newEnumMap(Usability DefectSeverityLevel.class);189 EnumMap<UsabilityProblemSeverityLevel, Double> severityMap = 190 Maps.newEnumMap(UsabilityProblemSeverityLevel.class); 165 191 Map<String, String> allSeverityProperties = 166 192 Maps.filterEntries(usabilityRuleProperties, allSeverityProperties()); 167 193 for (Entry<String, String> severityProperty : allSeverityProperties.entrySet()) { 168 Usability DefectSeverityLevel severityLevel =194 UsabilityProblemSeverityLevel severityLevel = 169 195 getSeverityLevel(severityProperty.getKey()); 170 196 Double rule = Double.valueOf(severityProperty.getValue()); … … 176 202 /** 177 203 * <p> 178 * TODO: comment 179 * </p> 180 * 181 * @param key 182 * @return 183 */ 184 private UsabilityDefectSeverityLevel getSeverityLevel(String severityProperty) { 204 * Matches severity level from .properties file against {@link UsabilityProblemSeverityLevel}. 205 * </p> 206 * 207 * @param severityProperty 208 * severity level from .properties file 209 * @return matching {@link UsabilityProblemSeverityLevel} 210 */ 211 private UsabilityProblemSeverityLevel getSeverityLevel(String severityProperty) { 185 212 int startSeverityLevel = severityProperty.lastIndexOf(".") + 1; 186 String severit LevelIdentifier =213 String severityLevelIdentifier = 187 214 severityProperty.substring(startSeverityLevel).toUpperCase(); 188 return Usability DefectSeverityLevel.valueOf(severitLevelIdentifier);189 } 190 191 /** 192 * <p> 193 * TODO: comment194 * </p> 195 * 196 * @return 215 return UsabilityProblemSeverityLevel.valueOf(severityLevelIdentifier); 216 } 217 218 /** 219 * <p> 220 * Gets the severity level properties. 221 * </p> 222 * 223 * @return severity level 197 224 */ 198 225 private Predicate<Entry<String, String>> allSeverityProperties() {
Note: See TracChangeset
for help on using the changeset viewer.