Search in sources :

Example 1 with ChangeTestWeightCommand

use of org.asqatasun.webapp.command.ChangeTestWeightCommand in project Asqatasun by Asqatasun.

the class ChangeTestWeightCommandFactory method getChangeTestWeightCommand.

/**
     * 
     * @param user
     * @param locale
     * @param testList
     * @param referentialKey
     * @return 
     *      an initialised instance of ChangeTestWeightCommand
     */
public ChangeTestWeightCommand getChangeTestWeightCommand(User user, Locale locale, Collection<Test> testList, String referentialKey) {
    Map<String, String> userTestWeight = new HashMap<String, String>();
    NumberFormat nf = NumberFormat.getNumberInstance(locale);
    nf.setMinimumFractionDigits(1);
    nf.setMaximumFractionDigits(1);
    nf.setMaximumIntegerDigits(1);
    nf.setMinimumIntegerDigits(1);
    for (OptionElement oe : optionElementDataService.getOptionElementFromUserAndFamilyCode(user, referentialKey + "_" + optionFamilyCodeStr)) {
        userTestWeight.put(oe.getOption().getCode(), nf.format(Double.valueOf(oe.getValue())));
    }
    for (Test test : testList) {
        if (!userTestWeight.containsKey(test.getCode())) {
            userTestWeight.put(test.getCode(), "");
        }
    }
    ChangeTestWeightCommand changeTestWeightCommand = new ChangeTestWeightCommand();
    changeTestWeightCommand.setTestWeightMap(userTestWeight);
    return changeTestWeightCommand;
}
Also used : Test(org.asqatasun.entity.reference.Test) OptionElement(org.asqatasun.webapp.entity.option.OptionElement) NumberFormat(java.text.NumberFormat) ChangeTestWeightCommand(org.asqatasun.webapp.command.ChangeTestWeightCommand)

Aggregations

NumberFormat (java.text.NumberFormat)1 Test (org.asqatasun.entity.reference.Test)1 ChangeTestWeightCommand (org.asqatasun.webapp.command.ChangeTestWeightCommand)1 OptionElement (org.asqatasun.webapp.entity.option.OptionElement)1