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