use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.
the class AccountSettingsController method submitChangeTestWeight.
/**
*
* @param refCode
* @param changeTestWeightCommand
* @param result
* @param model
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = TgolKeyStore.TEST_WEIGHT_URL, method = RequestMethod.POST)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String submitChangeTestWeight(@RequestParam(TgolKeyStore.REFERENTIAL_CD_KEY) String refCode, @ModelAttribute(TgolKeyStore.CHANGE_TEST_WEIGHT_COMMAND_KEY) ChangeTestWeightCommand changeTestWeightCommand, BindingResult result, Model model, HttpServletRequest request) throws Exception {
Reference referential = refMap.get(refCode);
if (referential == null || !secondaryLevelMenuDisplayer.isRequestedReferentialModifiable(refCode)) {
throw new ForbiddenPageException();
}
// We check whether the form is valid
changeTestWeightFormValidator.validate(changeTestWeightCommand, result);
// If the form has some errors, we display it again with errors' details
addTestListAndModifiableRefToModel(referential, model);
model.addAttribute(TgolKeyStore.CHANGE_TEST_WEIGHT_COMMAND_KEY, changeTestWeightCommand);
if (!result.hasErrors()) {
ChangeTestWeightCommandFactory.getInstance().updateUserTestWeight(getCurrentUser(), changeTestWeightCommand);
model.addAttribute(TgolKeyStore.TEST_WEIGHT_SUCCESSFULLY_UPDATED_KEY, true);
}
return TgolKeyStore.TEST_WEIGHT_VIEW_NAME;
}
use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.
the class AccountSettingsController method displayChangeTestWeight.
/**
* This method displays the Change Test Weight page for the authentified user.
* This page is displayed if and only if the current user owns at least
* one contract on the wished referential.
*
* @param refCode
* @param request
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.TEST_WEIGHT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayChangeTestWeight(@RequestParam(TgolKeyStore.REFERENTIAL_CD_KEY) String refCode, HttpServletRequest request, Model model) {
Reference referential = refMap.get(refCode);
List<Test> testList = addTestListAndModifiableRefToModel(referential, model);
model.addAttribute(TgolKeyStore.CHANGE_TEST_WEIGHT_COMMAND_KEY, ChangeTestWeightCommandFactory.getInstance().getChangeTestWeightCommand(getCurrentUser(), getLocaleResolver().resolveLocale(request), testList, refCode));
return TgolKeyStore.TEST_WEIGHT_VIEW_NAME;
}
use of org.asqatasun.entity.reference.Reference in project Asqatasun by Asqatasun.
the class PageListControllerTest method setUpThemeDataService.
/**
*
*/
private void setUpThemeDataService() {
mockThemeDataService = createMock(ThemeDataService.class);
mockTheme = createMock(Theme.class);
Collection<Theme> themeCollection = new ArrayList();
themeCollection.add(mockTheme);
Reference mockReference = createMock(Reference.class);
Criterion mockCriterion = createMock(Criterion.class);
Collection<Criterion> criterionCollection = new ArrayList();
criterionCollection.add(mockCriterion);
expect(mockThemeDataService.findAll()).andReturn(themeCollection).anyTimes();
expect(mockTheme.getCriterionList()).andReturn(criterionCollection).anyTimes();
expect(mockCriterion.getReference()).andReturn(mockReference).anyTimes();
expect(mockReference.getCode()).andReturn("AW21").anyTimes();
replay(mockTheme);
replay(mockCriterion);
replay(mockReference);
replay(mockThemeDataService);
}
Aggregations