Search in sources :

Example 1 with AuditSetUpCommand

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

the class AuditSetUpCommandFactory method getSiteAuditSetUpCommand.

/**
     *
     * @param contract
     * @param levelFormFieldList
     * @param optionalFormFieldMap
     * @return
     */
public AuditSetUpCommand getSiteAuditSetUpCommand(Contract contract, List<SelectFormField> levelFormFieldList, Map<String, List<AuditSetUpFormField>> optionalFormFieldMap) {
    AuditSetUpCommand siteAuditSetUpCommand = new AuditSetUpCommand();
    siteAuditSetUpCommand.setUrlList(getGroupOfPagesUrl(contract, true));
    siteAuditSetUpCommand.setScope(ScopeEnum.DOMAIN);
    setUpAuditSetUpCommand(siteAuditSetUpCommand, contract, levelFormFieldList, optionalFormFieldMap, ScopeEnum.DOMAIN);
    return siteAuditSetUpCommand;
}
Also used : AuditSetUpCommand(org.asqatasun.webapp.command.AuditSetUpCommand)

Example 2 with AuditSetUpCommand

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

the class AuditSetUpCommandFactory method getScenarioAuditSetUpCommand.

/**
     *
     * @param contract
     * @param scenarioId
     * @param levelFormFieldList
     * @param optionalFormFieldMap
     * @return
     */
public AuditSetUpCommand getScenarioAuditSetUpCommand(Contract contract, String scenarioId, List<SelectFormField> levelFormFieldList, Map<String, List<AuditSetUpFormField>> optionalFormFieldMap) {
    AuditSetUpCommand scenarioAuditSetUpCommand = new AuditSetUpCommand();
    scenarioAuditSetUpCommand.setScope(ScopeEnum.SCENARIO);
    Scenario scenario = scenarioDataService.read(Long.valueOf(scenarioId));
    scenarioAuditSetUpCommand.setScenarioName(scenario.getLabel());
    scenarioAuditSetUpCommand.setScenarioId(scenario.getId());
    setUpAuditSetUpCommand(scenarioAuditSetUpCommand, contract, levelFormFieldList, optionalFormFieldMap, ScopeEnum.SCENARIO);
    return scenarioAuditSetUpCommand;
}
Also used : AuditSetUpCommand(org.asqatasun.webapp.command.AuditSetUpCommand) Scenario(org.asqatasun.webapp.entity.scenario.Scenario)

Example 3 with AuditSetUpCommand

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

the class AuditSetUpFormValidator method validate.

/**
     * The AuditSetUpFormValidator checks whether the options values are 
     * acceptable regarding the FormField internal checker
     * 
     * @param target
     * @param errors 
     */
@Override
public void validate(Object target, Errors errors) {
    AuditSetUpCommand auditSetUpCommand = (AuditSetUpCommand) target;
    AuditSetUpFormField asuff;
    for (Map.Entry<String, String> entry : auditSetUpCommand.getAuditParameter().entrySet()) {
        asuff = auditSetUpFormFieldMap.get(entry.getKey());
        try {
            if (!asuff.getFormField().checkParameters(entry.getValue())) {
                // the auditParameter[] key is due to object mapping of the form
                // management of Spring mvc. Each field is mapped with a method
                // of the mapped object. In this case, the returned object of the method
                // is a map.
                errors.rejectValue("auditParameter[" + entry.getKey() + "]", asuff.getFormField().getErrorI18nKey());
            }
        } catch (NumberFormatException nfe) {
            errors.rejectValue("auditParameter[" + entry.getKey() + "]", asuff.getFormField().getErrorI18nKey());
        }
    }
}
Also used : AuditSetUpCommand(org.asqatasun.webapp.command.AuditSetUpCommand) AuditSetUpFormField(org.asqatasun.webapp.form.parameterization.AuditSetUpFormField)

Example 4 with AuditSetUpCommand

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

the class AbstractAuditSetUpController method displayAuditSetUpView.

/**
     * 
     * @param viewName
     * @param contractId
     * @param scenarioId
     * @param optionFormFieldBuilderMap
     * @param scope
     * @param model
     * @return 
     */
protected String displayAuditSetUpView(String viewName, String contractId, String scenarioId, Map<String, List<AuditSetUpFormFieldBuilderImpl>> optionFormFieldBuilderMap, ScopeEnum scope, Model model) {
    Long contractIdValue;
    try {
        contractIdValue = Long.valueOf(contractId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException(getCurrentUser());
    }
    Contract contract = getContractDataService().read(contractIdValue);
    if (isUserAllowedToDisplaySetUpPage(contract, viewName)) {
        Collection<String> authorisedReferentialList = getAuthorisedReferentialCodeFromContract(contract);
        // Get a fresh list of the auditSetUpFormField that handles the choice
        // of the referential and its level
        List<SelectFormField> refAndLevelFormFieldList = this.getFreshRefAndLevelSetUpFormFieldList(authorisedReferentialList, referentialAndLevelFormFieldBuilderList);
        String defaultRef = getDefaultReferential(authorisedReferentialList);
        AuditSetUpFormFieldHelper.selectDefaultLevelFromRefValue(refAndLevelFormFieldList, defaultRef);
        // Get a fresh map of auditSetUpFormField. The value of the field is
        // them set by Parameter mapping handled by the AuditSetUpCommandObject
        Map<String, List<AuditSetUpFormField>> optionFormFieldMap = this.getFreshAuditSetUpFormFieldMap(contract, optionFormFieldBuilderMap);
        AuditSetUpCommand asuc;
        // instance of AuditSetUpCommand
        switch(scope) {
            case DOMAIN:
                asuc = AuditSetUpCommandFactory.getInstance().getSiteAuditSetUpCommand(contract, refAndLevelFormFieldList, optionFormFieldMap);
                break;
            case FILE:
            case GROUPOFFILES:
                asuc = AuditSetUpCommandFactory.getInstance().getUploadAuditSetUpCommand(contract, refAndLevelFormFieldList, optionFormFieldMap);
                break;
            case SCENARIO:
                asuc = AuditSetUpCommandFactory.getInstance().getScenarioAuditSetUpCommand(contract, scenarioId, refAndLevelFormFieldList, optionFormFieldMap);
                break;
            case PAGE:
            case GROUPOFPAGES:
            default:
                asuc = AuditSetUpCommandFactory.getInstance().getPageAuditSetUpCommand(contract, refAndLevelFormFieldList, optionFormFieldMap);
        }
        model.addAttribute(TgolKeyStore.AUDIT_SET_UP_COMMAND_KEY, asuc);
        model.addAttribute(TgolKeyStore.DEFAULT_PARAM_SET_KEY, asuc.isDefaultParamSet());
        this.prepareFormModel(model, contract, refAndLevelFormFieldList, optionFormFieldMap);
        return viewName;
    } else {
        return TgolKeyStore.ACCESS_DENIED_VIEW_NAME;
    }
}
Also used : AuditSetUpCommand(org.asqatasun.webapp.command.AuditSetUpCommand) Contract(org.asqatasun.webapp.entity.contract.Contract) SelectFormField(org.asqatasun.webapp.form.SelectFormField) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException)

Example 5 with AuditSetUpCommand

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

the class AuditSetUpCommandFactory method getPageAuditSetUpCommand.

/**
     * 
     * @param contract
     * @param url
     * @param auditParamset
     * @return an AuditSetUpCommand instance set for page audit
     */
public AuditSetUpCommand getPageAuditSetUpCommand(Contract contract, String url, Set<Parameter> auditParamset) {
    AuditSetUpCommand pageAuditSetUpCommand = new AuditSetUpCommand();
    pageAuditSetUpCommand.setScope(ScopeEnum.PAGE);
    pageAuditSetUpCommand.setContractId(contract.getId());
    pageAuditSetUpCommand.setRelaunch(true);
    List<String> urlList = new ArrayList();
    urlList.add(url);
    pageAuditSetUpCommand.setUrlList(urlList);
    for (Parameter param : auditParamset) {
        String paramCode = param.getParameterElement().getParameterElementCode();
        if (paramCode.equals(TgolKeyStore.LEVEL_PARAM_KEY)) {
            pageAuditSetUpCommand.setLevel(param.getValue());
        } else {
            pageAuditSetUpCommand.setAuditParameter(paramCode, param.getValue());
        }
    }
    return pageAuditSetUpCommand;
}
Also used : AuditSetUpCommand(org.asqatasun.webapp.command.AuditSetUpCommand) Parameter(org.asqatasun.entity.parameterization.Parameter)

Aggregations

AuditSetUpCommand (org.asqatasun.webapp.command.AuditSetUpCommand)9 Parameter (org.asqatasun.entity.parameterization.Parameter)1 Contract (org.asqatasun.webapp.entity.contract.Contract)1 Scenario (org.asqatasun.webapp.entity.scenario.Scenario)1 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)1 SelectFormField (org.asqatasun.webapp.form.SelectFormField)1 AuditSetUpFormField (org.asqatasun.webapp.form.parameterization.AuditSetUpFormField)1