use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class AbstractAuditResultController method prepareSuccessfullPageData.
/**
* This methods handles audit data in case of page type audit
*
* @param page
* @param audit
* @param model
* @param displayScope
* @param isManualAudit
* @param manualAuditCommand
* @return the success audit page result view name
*/
protected String prepareSuccessfullPageData(Page page, Audit audit, Model model, String displayScope, boolean isManualAudit, ManualAuditCommand manualAuditCommand) {
Contract contract = retrieveContractFromAudit(audit);
if (!audit.getStatus().equals(AuditStatus.COMPLETED) && !audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) && !audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED) && !audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING)) {
return prepareFailedAuditData(audit.getId(), model);
}
model.addAttribute(TgolKeyStore.STATUS_KEY, computeAuditStatus(audit));
model.addAttribute(TgolKeyStore.RESULT_ACTION_LIST_KEY, actionHandler.getActionList("EXPORT"));
// Attributes for breadcrumb
model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
// Add a boolean used to display the breadcrumb.
model.addAttribute(TgolKeyStore.AUTHORIZED_SCOPE_FOR_PAGE_LIST, isAuthorizedScopeForPageList(audit));
// Add a command to relaunch the audit from the result page
model.addAttribute(TgolKeyStore.AUDIT_SET_UP_COMMAND_KEY, auditSetUpCommandFactory.getPageAuditSetUpCommand(contract, page.getURL(), parameterDataService.getParameterSetFromAudit(audit)));
if (StringUtils.equalsIgnoreCase(displayScope, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE)) {
AuditResultSortCommand asuc = ((AuditResultSortCommand) model.asMap().get(TgolKeyStore.AUDIT_RESULT_SORT_COMMAND_KEY));
model.addAttribute(TgolKeyStore.TEST_RESULT_LIST_KEY, testResultFactory.getTestResultSortedByThemeMap(page, pageScope, asuc.getSortOptionMap().get(THEME_SORT_KEY).toString(), getTestResultSortSelection(asuc)));
if (isManualAudit) {
if (manualAuditCommand == null) {
manualAuditCommand = new ManualAuditCommand();
}
manualAuditCommand.setModifedManualResultMap(testResultFactory.getTestResultMap(page, pageScope, asuc.getSortOptionMap().get(THEME_SORT_KEY).toString(), getTestResultSortSelection(asuc)));
model.addAttribute(TgolKeyStore.MANUAL_AUDIT_COMMAND_KEY, manualAuditCommand);
}
return TgolKeyStore.RESULT_PAGE_VIEW_NAME;
} else {
AuditResultSortCommand asuc = ((AuditResultSortCommand) model.asMap().get(TgolKeyStore.AUDIT_RESULT_SORT_COMMAND_KEY));
model.addAttribute(TgolKeyStore.CRITERION_RESULT_LIST_KEY, criterionResultFactory.getCriterionResultSortedByThemeMap(page, asuc.getSortOptionMap().get(THEME_SORT_KEY).toString(), getTestResultSortSelection(asuc)));
return TgolKeyStore.RESULT_PAGE_BY_CRITERION_VIEW_NAME;
}
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class UserManagementController method displayDeleteUserConfirmation.
/**
* @param request
* @param response
* @param model
* @return The pages audit set-up form page
*/
@RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.POST)
@Secured(TgolKeyStore.ROLE_ADMIN_KEY)
public String displayDeleteUserConfirmation(HttpServletRequest request, HttpServletResponse response, Model model) {
Object userId = request.getSession().getAttribute(TgolKeyStore.USER_ID_TO_DELETE_KEY);
Long lUserId;
if (userId instanceof Long) {
lUserId = (Long) userId;
} else {
try {
lUserId = Long.valueOf(userId.toString());
} catch (NumberFormatException nfe) {
throw new ForbiddenUserException();
}
}
User user = getCurrentUser();
User userToDelete = userDataService.read(lUserId);
if (userToDelete == null || user.getId().equals(userToDelete.getId())) {
return TgolKeyStore.ACCESS_DENIED_VIEW_NAME;
}
for (Contract contract : userToDelete.getContractSet()) {
deleteAllAuditsFromContract(contract);
}
userDataService.delete(userToDelete.getId());
request.getSession().removeAttribute(TgolKeyStore.USER_ID_TO_DELETE_KEY);
request.getSession().setAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, userToDelete.getEmail1());
return TgolKeyStore.ADMIN_VIEW_REDIRECT_NAME;
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class PageListController method pageLinkDispatcher.
/**
* This method dispatches the result depending on the parameters passed to
* the request. Only multi-pages audit are considered here.
*
* @param request
* @param model
* @return
* @throws Exception
*/
private String pageLinkDispatcher(HttpServletRequest request, Audit audit, Model model) throws Exception {
if (audit.getSubject() instanceof Page) {
throw new ForbiddenPageException();
}
String status = ServletRequestUtils.getStringParameter(request, STATUS_KEY);
HttpStatusCodeFamily httpStatusCode = getHttpStatusCodeFamily(status);
// the repartion of the pages regarding the httpStatusCode
if (httpStatusCode == null) {
if (!isAuthorizedScopeForPageList(audit)) {
throw new ForbiddenScopeException();
}
try {
Contract currentContract = retrieveContractFromAudit(audit);
model.addAttribute(CONTRACT_NAME_KEY, currentContract.getLabel());
model.addAttribute(CONTRACT_ID_KEY, currentContract.getId());
String testLabel = ServletRequestUtils.getStringParameter(request, TEST_KEY);
if (StringUtils.isNotBlank(testLabel)) {
model.addAttribute(TEST_CODE_KEY, testDataService.getTestFromAuditAndLabel(audit, testLabel));
}
return this.preparePageListData(audit, model);
} catch (ServletRequestBindingException e) {
return OUPS_VIEW_REDIRECT_NAME;
}
} else {
boolean isAuthorizedScopeForPageList = isAuthorizedScopeForPageList(audit);
Contract currentContract = retrieveContractFromAudit(audit);
model.addAttribute(CONTRACT_NAME_KEY, currentContract.getLabel());
model.addAttribute(CONTRACT_ID_KEY, currentContract.getId());
// used in the jsp
if (!isAuthorizedScopeForPageList) {
model.addAttribute(AUDIT_NUMBER_KEY, true);
}
String testLabel = ServletRequestUtils.getStringParameter(request, TEST_KEY);
if (StringUtils.isNotBlank(testLabel)) {
model.addAttribute(TEST_CODE_KEY, testDataService.getTestFromAuditAndLabel(audit, testLabel));
}
return this.preparePageListStatsByHttpStatusCode(audit, model, httpStatusCode, request, false);
}
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractSortCommandHelper method prepareContract.
/**
* This methods retrieves and prepare contract info
*
* @param user
* @param csc the ContractSortCommand
* @param displayOptionFieldsBuilderList
* @param model
* @return
*/
public Collection<Contract> prepareContract(User user, ContractSortCommand csc, List<FormFieldBuilder> displayOptionFieldsBuilderList, Model model) {
csc = prepareDataForSortConsole(user.getId(), csc, displayOptionFieldsBuilderList, model);
List<Contract> contractSet = new LinkedList();
List<String> inclusionSortOccurence = Arrays.asList(csc.getSortOptionMap().get(INCLUSION_CONTRACT_SORT_KEY).toString().split(";"));
List<String> exclusionSortOccurence = Arrays.asList(csc.getSortOptionMap().get(EXCLUSION_CONTRACT_SORT_KEY).toString().split(";"));
for (Contract contract : user.getContractSet()) {
if (isContractLabelIncluded(inclusionSortOccurence, contract.getLabel()) && !isContractLabelExcluded(exclusionSortOccurence, contract.getLabel())) {
contractSet.add(contract);
}
}
sortContractSetRegardingCommand(contractSet, csc);
return contractSet;
}
use of org.asqatasun.entity.contract.Contract in project Asqatasun by Asqatasun.
the class ContractSortCommandHelper method prepareContractInfo.
/**
* This methods retrieves and prepare contract info
*
* @param user
* @param csc the ContractSortCommand
* @param displayOptionFieldsBuilderList
* @param model
* @return
*/
public Collection<ContractInfo> prepareContractInfo(User user, ContractSortCommand csc, List<FormFieldBuilder> displayOptionFieldsBuilderList, Model model) {
csc = prepareDataForSortConsole(user.getId(), csc, displayOptionFieldsBuilderList, model);
List<ContractInfo> contractInfoSet = new LinkedList();
List<String> inclusionSortOccurence;
if (csc.getSortOptionMap().containsKey(INCLUSION_CONTRACT_SORT_KEY)) {
inclusionSortOccurence = Arrays.asList(csc.getSortOptionMap().get(INCLUSION_CONTRACT_SORT_KEY).toString().split(";"));
} else {
inclusionSortOccurence = new ArrayList();
}
List<String> exclusionSortOccurence;
if (csc.getSortOptionMap().containsKey(EXCLUSION_CONTRACT_SORT_KEY)) {
exclusionSortOccurence = Arrays.asList(csc.getSortOptionMap().get(EXCLUSION_CONTRACT_SORT_KEY).toString().split(";"));
} else {
exclusionSortOccurence = new ArrayList();
}
for (Contract contract : contractDataService.getAllContractsByUser(user)) {
if (isContractLabelIncluded(inclusionSortOccurence, contract.getLabel()) && !isContractLabelExcluded(exclusionSortOccurence, contract.getLabel())) {
contractInfoSet.add(contractInfoFactory.getContractInfo(contract));
}
}
if (csc.getSortOptionMap().containsKey(SORT_ORDER_KEY)) {
sortContractInfoSetRegardingCommand(contractInfoSet, csc);
}
return contractInfoSet;
}
Aggregations