Ignore:
Timestamp:
06/06/13 17:08:25 (11 years ago)
Author:
adeicke
Message:
  • Added proper formating and JavaDoc?.
  • Several renaming refactorings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/CMDperformUsabilityEvaluation.java

    r1158 r1217  
    2121import de.ugoe.cs.autoquest.CommandHelpers; 
    2222import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 
    23 import de.ugoe.cs.autoquest.usability.rules.EmptyRuleset; 
     23import de.ugoe.cs.autoquest.usability.rules.PatternRuleset; 
    2424import de.ugoe.cs.autoquest.usability.rules.UsabilityResult; 
    2525import de.ugoe.cs.autoquest.usability.rules.UsabilityRuleset; 
     
    2929/** 
    3030 * <p> 
    31  * TODO comment 
     31 * Command to perform a automatic usability evaluation for a given task model. 
    3232 * </p> 
    3333 *  
     
    3636public class CMDperformUsabilityEvaluation implements Command { 
    3737 
     38    /** 
     39     * <p> 
     40     * index for name of task model under which it could be retrieved from 
     41     * {@link GlobalDataContainer} 
     42     * </p> 
     43     */ 
    3844    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     */ 
    4051    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     */ 
    4258    private final String defaultEvaluationResultParameterName = "usabilityEvaluationResult"; 
    43      
    44     private final UsabilityRuleset defaultUsabilityRuleset = new EmptyRuleset(); 
    45      
    46     /* (non-Javadoc) 
     59 
     60    /* 
     61     * (non-Javadoc) 
     62     *  
    4763     * @see de.ugoe.cs.util.console.Command#run(java.util.List) 
    4864     */ 
     
    5268        Optional<ITaskModel> taskModel = getTaskModelFromDataContainer(nameOfTaskModel); 
    5369        if (taskModel.isPresent()) { 
    54             UsabilityRuleset ruleset = getUsabilityRuleset(); 
     70            UsabilityRuleset ruleset = new PatternRuleset(taskModel.get()); 
    5571            UsabilityResult result = UsabilityEvaluator.evaluate(taskModel.get()).using(ruleset); 
    5672            String evaluationResultParameterName = getEvaluationResultParameter(parameters); 
    5773            storeUsabilityResultInDataContainer(evaluationResultParameterName, result); 
    5874        } 
    59         return; 
    6075    } 
    6176 
    6277    /** 
    6378     * <p> 
    64      * TODO: comment 
     79     * Gets name of task model from list of parameters. 
    6580     * </p> 
    66      * 
     81     *  
    6782     * @param parameters 
    68      * @return 
     83     *            parameters for the command 
     84     * @return name of task model 
    6985     */ 
    7086    private String getTaskModelParameter(List<Object> parameters) { 
    7187        try { 
    7288            return (String) parameters.get(taskModelParamaterIndex); 
    73         } catch (Exception e) { 
     89        } 
     90        catch (Exception e) { 
    7491            throw new IllegalArgumentException("must provide a task model name"); 
    7592        } 
     
    7895    /** 
    7996     * <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! 
    81100     * </p> 
    82      * 
     101     *  
    83102     * @param parameters 
    84      * @return 
     103     *            parameters for the command 
     104     * @return name under which evaluation result should be stored 
    85105     */ 
    86106    private String getEvaluationResultParameter(List<Object> parameters) { 
    87         if(parameters.size() == 2) { 
     107        if (parameters.size() == 2) { 
    88108            return (String) parameters.get(evaluationResultParameterIndex); 
    89109        } 
    90110        return defaultEvaluationResultParameterName; 
    91111    } 
    92      
     112 
    93113    /** 
    94114     * <p> 
    95      * TODO: comment 
     115     * Retrieves task model from {@link GlobalDataContainer}. 
    96116     * </p> 
    97      * 
     117     *  
    98118     * @param nameOfTaskModel 
    99      * @return 
     119     *            name of task model, under which it is stored in {@link GlobalDataContainer} 
     120     * @return if present, task model 
    100121     */ 
    101122    private Optional<ITaskModel> getTaskModelFromDataContainer(String nameOfTaskModel) { 
    102123        Object dataObject = GlobalDataContainer.getInstance().getData(nameOfTaskModel); 
    103         if(dataObject != null) { 
    104             if(dataObject instanceof ITaskModel) { 
     124        if (dataObject != null) { 
     125            if (dataObject instanceof ITaskModel) { 
    105126                ITaskModel taskModel = (ITaskModel) dataObject; 
    106127                return Optional.of(taskModel); 
    107             } else { 
     128            } 
     129            else { 
    108130                CommandHelpers.objectNotType(nameOfTaskModel, "ITaskModel"); 
    109131                return Optional.absent(); 
     
    113135        return Optional.absent(); 
    114136    } 
    115      
     137 
    116138    /** 
    117139     * <p> 
    118      * TODO: comment 
     140     * Stores usability evaluation in {@link GlobalDataContainer}. 
    119141     * </p> 
    120      * 
    121      * @return 
     142     *  
     143     * @param evaluationResultParameterName 
     144     *            name under which usability result should be stored in {@link GlobalDataContainer} 
     145     *  
    122146     */ 
    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    { 
    137150        if (GlobalDataContainer.getInstance().addData(evaluationResultParameterName, result)) { 
    138151            CommandHelpers.dataOverwritten(evaluationResultParameterName); 
    139         }    
     152        } 
    140153    } 
    141154 
    142     /* (non-Javadoc) 
     155    /* 
     156     * (non-Javadoc) 
     157     *  
    143158     * @see de.ugoe.cs.util.console.Command#help() 
    144159     */ 
Note: See TracChangeset for help on using the changeset viewer.