Search in sources :

Example 1 with FormField

use of org.asqatasun.webapp.form.FormField in project Asqatasun by Asqatasun.

the class ContractSortCommandHelper method prepareDataForSortConsole.

/**
     * This method prepares the data to be displayed in the sort 
     * (score, alphabetical, date) console of the result page.
     */
private static ContractSortCommand prepareDataForSortConsole(Long userId, ContractSortCommand contractSortCommand, List<FormFieldBuilder> displayOptionFieldsBuilderList, Model model) {
    ContractSortCommand cdc;
    List<FormField> formFieldList;
    if (contractSortCommand == null) {
        formFieldList = FormFieldHelper.getFormFieldBuilderCopy(displayOptionFieldsBuilderList);
        cdc = ContractSortCommandFactory.getInstance().getInitialisedContractDisplayCommand(userId, formFieldList);
    } else {
        formFieldList = FormFieldHelper.getFormFieldBuilderCopy(displayOptionFieldsBuilderList, contractSortCommand.getSortOptionMap());
        cdc = contractSortCommand;
    }
    model.addAttribute(TgolKeyStore.CONTRACT_SORT_FIELD_LIST_KEY, formFieldList);
    model.addAttribute(TgolKeyStore.CONTRACT_SORT_COMMAND_KEY, cdc);
    return cdc;
}
Also used : FormField(org.asqatasun.webapp.form.FormField) ContractSortCommand(org.asqatasun.webapp.command.ContractSortCommand)

Example 2 with FormField

use of org.asqatasun.webapp.form.FormField 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 3 with FormField

use of org.asqatasun.webapp.form.FormField in project Asqatasun by Asqatasun.

the class ContractSortCommandFactory method getInitialisedContractDisplayCommand.

/**
     * 
     * @param userId
     * @param formFieldList
     * @return
     * An initialised auditCommand object for the given contract. This object
     * handles the last values selected by the user
     */
public ContractSortCommand getInitialisedContractDisplayCommand(Long userId, List<FormField> formFieldList) {
    ContractSortCommand contractDisplayCommand = new ContractSortCommand();
    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()) {
                        contractDisplayCommand.getSortOptionMap().put(entry.getKey(), se.getValue());
                    }
                }
            }
        } else if (ff instanceof TextualFormField) {
            contractDisplayCommand.getSortOptionMap().put(((TextualFormField) ff).getI18nKey(), ((TextualFormField) ff).getValue());
        }
    }
    contractDisplayCommand.setUserId(userId);
    return contractDisplayCommand;
}
Also used : SelectElement(org.asqatasun.webapp.form.SelectElement) TextualFormField(org.asqatasun.webapp.form.TextualFormField) List(java.util.List) SelectFormField(org.asqatasun.webapp.form.SelectFormField) FormField(org.asqatasun.webapp.form.FormField) TextualFormField(org.asqatasun.webapp.form.TextualFormField) Map(java.util.Map) ContractSortCommand(org.asqatasun.webapp.command.ContractSortCommand) SelectFormField(org.asqatasun.webapp.form.SelectFormField)

Aggregations

FormField (org.asqatasun.webapp.form.FormField)3 ContractSortCommand (org.asqatasun.webapp.command.ContractSortCommand)2 List (java.util.List)1 Map (java.util.Map)1 AuditResultSortCommand (org.asqatasun.webapp.command.AuditResultSortCommand)1 CheckboxElement (org.asqatasun.webapp.form.CheckboxElement)1 CheckboxFormFieldImpl (org.asqatasun.webapp.form.CheckboxFormFieldImpl)1 SelectElement (org.asqatasun.webapp.form.SelectElement)1 SelectFormField (org.asqatasun.webapp.form.SelectFormField)1 TextualFormField (org.asqatasun.webapp.form.TextualFormField)1