Changeset 1217 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/CMDperformUsabilityEvaluation.java
- Timestamp:
- 06/06/13 17:08:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/CMDperformUsabilityEvaluation.java
r1158 r1217 21 21 import de.ugoe.cs.autoquest.CommandHelpers; 22 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 23 import de.ugoe.cs.autoquest.usability.rules. EmptyRuleset;23 import de.ugoe.cs.autoquest.usability.rules.PatternRuleset; 24 24 import de.ugoe.cs.autoquest.usability.rules.UsabilityResult; 25 25 import de.ugoe.cs.autoquest.usability.rules.UsabilityRuleset; … … 29 29 /** 30 30 * <p> 31 * TODO comment31 * Command to perform a automatic usability evaluation for a given task model. 32 32 * </p> 33 33 * … … 36 36 public class CMDperformUsabilityEvaluation implements Command { 37 37 38 /** 39 * <p> 40 * index for name of task model under which it could be retrieved from 41 * {@link GlobalDataContainer} 42 * </p> 43 */ 38 44 private final int taskModelParamaterIndex = 0; 39 45 46 /** 47 * <p> 48 * index for name under which evaluation result should be stored in {@link GlobalDataContainer} 49 * </p> 50 */ 40 51 private final int evaluationResultParameterIndex = 1; 41 52 53 /** 54 * <p> 55 * default name for evaluation result, which is used to store it in {@link GlobalDataContainer} 56 * </p> 57 */ 42 58 private final String defaultEvaluationResultParameterName = "usabilityEvaluationResult"; 43 44 private final UsabilityRuleset defaultUsabilityRuleset = new EmptyRuleset();45 46 /* (non-Javadoc)59 60 /* 61 * (non-Javadoc) 62 * 47 63 * @see de.ugoe.cs.util.console.Command#run(java.util.List) 48 64 */ … … 52 68 Optional<ITaskModel> taskModel = getTaskModelFromDataContainer(nameOfTaskModel); 53 69 if (taskModel.isPresent()) { 54 UsabilityRuleset ruleset = getUsabilityRuleset();70 UsabilityRuleset ruleset = new PatternRuleset(taskModel.get()); 55 71 UsabilityResult result = UsabilityEvaluator.evaluate(taskModel.get()).using(ruleset); 56 72 String evaluationResultParameterName = getEvaluationResultParameter(parameters); 57 73 storeUsabilityResultInDataContainer(evaluationResultParameterName, result); 58 74 } 59 return;60 75 } 61 76 62 77 /** 63 78 * <p> 64 * TODO: comment79 * Gets name of task model from list of parameters. 65 80 * </p> 66 * 81 * 67 82 * @param parameters 68 * @return 83 * parameters for the command 84 * @return name of task model 69 85 */ 70 86 private String getTaskModelParameter(List<Object> parameters) { 71 87 try { 72 88 return (String) parameters.get(taskModelParamaterIndex); 73 } catch (Exception e) { 89 } 90 catch (Exception e) { 74 91 throw new IllegalArgumentException("must provide a task model name"); 75 92 } … … 78 95 /** 79 96 * <p> 80 * TODO: comment 97 * Gets name under which evaluation result should be stored in {@link GlobalDataContainer} from 98 * list of parameters. If not present, the default value {@code usabilityEvaluationResult} is 99 * used! 81 100 * </p> 82 * 101 * 83 102 * @param parameters 84 * @return 103 * parameters for the command 104 * @return name under which evaluation result should be stored 85 105 */ 86 106 private String getEvaluationResultParameter(List<Object> parameters) { 87 if (parameters.size() == 2) {107 if (parameters.size() == 2) { 88 108 return (String) parameters.get(evaluationResultParameterIndex); 89 109 } 90 110 return defaultEvaluationResultParameterName; 91 111 } 92 112 93 113 /** 94 114 * <p> 95 * TODO: comment115 * Retrieves task model from {@link GlobalDataContainer}. 96 116 * </p> 97 * 117 * 98 118 * @param nameOfTaskModel 99 * @return 119 * name of task model, under which it is stored in {@link GlobalDataContainer} 120 * @return if present, task model 100 121 */ 101 122 private Optional<ITaskModel> getTaskModelFromDataContainer(String nameOfTaskModel) { 102 123 Object dataObject = GlobalDataContainer.getInstance().getData(nameOfTaskModel); 103 if (dataObject != null) {104 if (dataObject instanceof ITaskModel) {124 if (dataObject != null) { 125 if (dataObject instanceof ITaskModel) { 105 126 ITaskModel taskModel = (ITaskModel) dataObject; 106 127 return Optional.of(taskModel); 107 } else { 128 } 129 else { 108 130 CommandHelpers.objectNotType(nameOfTaskModel, "ITaskModel"); 109 131 return Optional.absent(); … … 113 135 return Optional.absent(); 114 136 } 115 137 116 138 /** 117 139 * <p> 118 * TODO: comment140 * Stores usability evaluation in {@link GlobalDataContainer}. 119 141 * </p> 120 * 121 * @return 142 * 143 * @param evaluationResultParameterName 144 * name under which usability result should be stored in {@link GlobalDataContainer} 145 * 122 146 */ 123 private UsabilityRuleset getUsabilityRuleset() { 124 // TODO Auto-generated method stub 125 System.out.println("TODO: implement CMDperformUsabilityEvaluation.getUsabilityRuleset "); 126 return this.defaultUsabilityRuleset; 127 } 128 129 /** 130 * <p> 131 * TODO: comment 132 * </p> 133 * @param evaluationResultParameterName 134 * 135 */ 136 private void storeUsabilityResultInDataContainer(String evaluationResultParameterName, UsabilityResult result) { 147 private void storeUsabilityResultInDataContainer(String evaluationResultParameterName, 148 UsabilityResult result) 149 { 137 150 if (GlobalDataContainer.getInstance().addData(evaluationResultParameterName, result)) { 138 151 CommandHelpers.dataOverwritten(evaluationResultParameterName); 139 } 152 } 140 153 } 141 154 142 /* (non-Javadoc) 155 /* 156 * (non-Javadoc) 157 * 143 158 * @see de.ugoe.cs.util.console.Command#help() 144 159 */
Note: See TracChangeset
for help on using the changeset viewer.