Search in sources :

Example 6 with Reference

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;
}
Also used : Reference(org.asqatasun.entity.reference.Reference) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Reference

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;
}
Also used : Test(org.asqatasun.entity.reference.Test) Reference(org.asqatasun.entity.reference.Reference) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Reference

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);
}
Also used : Criterion(org.asqatasun.entity.reference.Criterion) ThemeDataService(org.asqatasun.entity.service.reference.ThemeDataService) Reference(org.asqatasun.entity.reference.Reference) Theme(org.asqatasun.entity.reference.Theme)

Aggregations

Reference (org.asqatasun.entity.reference.Reference)8 Level (org.asqatasun.entity.reference.Level)2 Test (org.asqatasun.entity.reference.Test)2 Secured (org.springframework.security.access.annotation.Secured)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Query (javax.persistence.Query)1 ReferenceDAO (org.asqatasun.entity.dao.reference.ReferenceDAO)1 Parameter (org.asqatasun.entity.parameterization.Parameter)1 Criterion (org.asqatasun.entity.reference.Criterion)1 Theme (org.asqatasun.entity.reference.Theme)1 ThemeDataService (org.asqatasun.entity.service.reference.ThemeDataService)1 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)1