Search in sources :

Example 1 with AuditResultSortCommand

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

the class AbstractAuditResultController method prepareDataForSortConsole.

/**
     * This method prepares the data to be displayed in the sort (referential,
     * theme, result types) console of the result page.
     *
     * @param webResourceId
     * @param displayScope
     * @param auditResultSortCommand
     * @param model
     * @param isManualAudit
     */
private void prepareDataForSortConsole(Long webResourceId, String displayScope, AuditResultSortCommand auditResultSortCommand, Model model, boolean isManualAudit) {
    // Meta-statistics have been added to the method previously
    String referentialParameter = ((AuditStatistics) model.asMap().get(TgolKeyStore.STATISTICS_KEY)).getParametersMap().get(TgolKeyStore.REFERENTIAL_PARAM_KEY);
    AuditResultSortCommand asuc;
    List<FormField> formFieldList;
    if (auditResultSortCommand == null) {
        formFieldList = AuditResultSortCommandFactory.getInstance().getFormFieldBuilderCopy(referentialParameter, sortFormFieldBuilderList);
        if (isManualAudit) {
            CheckboxFormFieldImpl ObjectList = (CheckboxFormFieldImpl) formFieldList.get(1);
            List<CheckboxElement> checkboxElementList = ObjectList.getCheckboxElementList();
            for (CheckboxElement checkboxElement : checkboxElementList) {
                if (checkboxElement.getI18nKey().equals("nt")) {
                    checkboxElement.setSelected(true);
                }
            }
        }
        asuc = AuditResultSortCommandFactory.getInstance().getInitialisedAuditResultSortCommand(webResourceId, displayScope, isCriterionViewAccessible(webResourceId, referentialParameter), formFieldList);
    } else {
        formFieldList = AuditResultSortCommandFactory.getInstance().getFormFieldBuilderCopy(referentialParameter, sortFormFieldBuilderList, auditResultSortCommand);
        asuc = auditResultSortCommand;
    }
    model.addAttribute(TgolKeyStore.AUDIT_RESULT_SORT_FIELD_LIST_KEY, formFieldList);
    model.addAttribute(TgolKeyStore.AUDIT_RESULT_SORT_COMMAND_KEY, asuc);
}
Also used : CheckboxFormFieldImpl(org.asqatasun.webapp.form.CheckboxFormFieldImpl) AuditResultSortCommand(org.asqatasun.webapp.command.AuditResultSortCommand) FormField(org.asqatasun.webapp.form.FormField) CheckboxElement(org.asqatasun.webapp.form.CheckboxElement)

Example 2 with AuditResultSortCommand

use of org.asqatasun.webapp.command.AuditResultSortCommand 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, 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.getInstance().getPageAuditSetUpCommand(contract, page.getURL(), getParameterDataService().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.getInstance().getTestResultSortedByThemeMap(page, getPageScope(), asuc.getSortOptionMap().get(themeSortKey).toString(), getTestResultSortSelection(asuc)));
        if (isManualAudit) {
            if (manualAuditCommand == null) {
                manualAuditCommand = new ManualAuditCommand();
            }
            manualAuditCommand.setModifedManualResultMap(TestResultFactory.getInstance().getTestResultMap(page, getPageScope(), asuc.getSortOptionMap().get(themeSortKey).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.getInstance().getCriterionResultSortedByThemeMap(page, asuc.getSortOptionMap().get(themeSortKey).toString(), getTestResultSortSelection(asuc)));
        return TgolKeyStore.RESULT_PAGE_BY_CRITERION_VIEW_NAME;
    }
}
Also used : ManualAuditCommand(org.asqatasun.webapp.command.ManualAuditCommand) Contract(org.asqatasun.webapp.entity.contract.Contract) AuditResultSortCommand(org.asqatasun.webapp.command.AuditResultSortCommand)

Example 3 with AuditResultSortCommand

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

the class AbstractAuditResultController method prepareSuccessfullSiteData.

/**
     * This methods handles audit data in case of the audit is of site type
     *
     * @param site
     * @param audit
     * @param model
     * @return
     * @throws IOException
     */
private String prepareSuccessfullSiteData(Site site, Audit audit, Model model) {
    AuditResultSortCommand asuc = ((AuditResultSortCommand) model.asMap().get(TgolKeyStore.AUDIT_RESULT_SORT_COMMAND_KEY));
    model.addAttribute(TgolKeyStore.TEST_RESULT_LIST_KEY, TestResultFactory.getInstance().getTestResultSortedByThemeMap(site, getSiteScope(), asuc.getSortOptionMap().get(themeSortKey).toString(), getTestResultSortSelection(asuc)));
    // Attributes for breadcrumb
    Contract contract = retrieveContractFromAudit(audit);
    model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
    model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
    model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
    model.addAttribute(TgolKeyStore.RESULT_ACTION_LIST_KEY, actionHandler.getActionList("EXPORT"));
    return TgolKeyStore.RESULT_SITE_VIEW_NAME;
}
Also used : AuditResultSortCommand(org.asqatasun.webapp.command.AuditResultSortCommand) Contract(org.asqatasun.webapp.entity.contract.Contract)

Example 4 with AuditResultSortCommand

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

the class AuditResultSortCommandFactory method getInitialisedAuditResultSortCommand.

/**
     * 
     * @param webResourceId
     * @param displayScope
     * @param displayScopeChoice
     * @param formFieldList
     * @return 
     */
public AuditResultSortCommand getInitialisedAuditResultSortCommand(Long webResourceId, String displayScope, boolean displayScopeChoice, List<FormField> formFieldList) {
    AuditResultSortCommand auditResultSortCommand = new AuditResultSortCommand();
    auditResultSortCommand.setDisplayScope(displayScope);
    auditResultSortCommand.setDisplayScopeChoice(displayScopeChoice);
    for (FormField ff : formFieldList) {
        if (ff instanceof SelectFormField) {
            for (Map.Entry<String, List<SelectElement>> entry : ((SelectFormField) ff).getSelectElementMap().entrySet()) {
                for (SelectElement se : entry.getValue()) {
                    if (se.getDefaultElement() && se.getEnabled()) {
                        auditResultSortCommand.getSortOptionMap().put(entry.getKey(), se.getValue());
                    }
                }
            }
        } else if (ff instanceof CheckboxFormField) {
            CheckboxFormField cff = ((CheckboxFormField) ff);
            String code = cff.getCode();
            List<String> selectedElements = new ArrayList<String>();
            for (CheckboxElement ce : cff.getCheckboxElementList()) {
                if (ce.getEnabled() && ce.getSelected()) {
                    selectedElements.add(ce.getValue());
                }
            }
            auditResultSortCommand.getSortOptionMap().put(code, selectedElements.toArray());
        }
    }
    auditResultSortCommand.setWebResourceId(webResourceId);
    return auditResultSortCommand;
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) AuditResultSortCommand(org.asqatasun.webapp.command.AuditResultSortCommand) Map(java.util.Map)

Aggregations

AuditResultSortCommand (org.asqatasun.webapp.command.AuditResultSortCommand)4 Contract (org.asqatasun.webapp.entity.contract.Contract)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 ManualAuditCommand (org.asqatasun.webapp.command.ManualAuditCommand)1 CheckboxElement (org.asqatasun.webapp.form.CheckboxElement)1 CheckboxFormFieldImpl (org.asqatasun.webapp.form.CheckboxFormFieldImpl)1 FormField (org.asqatasun.webapp.form.FormField)1