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;
}
Aggregations