Search in sources :

Example 1 with ContractSortCommand

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

the class ContractSortCommandHelperTest method testGetLastAuditMarkSortValue.

/**
     * Test of getLastAuditMarkSortValue method, of class ContractSortCommandHelper.
     */
public void testGetLastAuditMarkSortValue() {
    System.out.println("getLastAuditMarkSortValue");
    List<ContractInfo> contractInfoSet = new ArrayList<>();
    ContractSortCommand csc = new ContractSortCommand();
    ContractInfo c1 = new ContractInfoImpl();
    ActInfo lastActInfo1 = new ActInfoImpl();
    lastActInfo1.setRawMark(15);
    c1.setLastActInfo(lastActInfo1);
    c1.setLabel(("A1"));
    contractInfoSet.add(c1);
    ContractInfo c2 = new ContractInfoImpl();
    ActInfo lastActInfo2 = new ActInfoImpl();
    lastActInfo2.setRawMark(95);
    c2.setLastActInfo(lastActInfo2);
    c2.setLabel(("B2"));
    contractInfoSet.add(c2);
    ContractInfo c3 = new ContractInfoImpl();
    ActInfo lastActInfo3 = new ActInfoImpl();
    lastActInfo3.setRawMark(53);
    c3.setLastActInfo(lastActInfo3);
    c3.setLabel(("C3"));
    contractInfoSet.add(c3);
    ContractInfo c4 = new ContractInfoImpl();
    c4.setLastActInfo(null);
    c4.setLabel(("D4"));
    contractInfoSet.add(c4);
    ContractInfo c5 = new ContractInfoImpl();
    c5.setLastActInfo(null);
    c5.setLabel(("A4"));
    contractInfoSet.add(c5);
    ContractSortCommandHelper.setSortByKey("SORTBY");
    ContractSortCommandHelper.setLastAuditMarkSortValue("MARK");
    ContractSortCommandHelper.setSortOrderKey("SORTORDER");
    Map<String, Object> map = new HashMap<>();
    map.put("SORTORDER", SortOrderEnum.ASCENDING.getCode());
    map.put("SORTBY", "MARK");
    csc.setSortOptionMap(map);
    ContractSortCommandHelper.sortContractInfoSetRegardingCommand(contractInfoSet, csc);
    map = new HashMap<>();
    map.put("SORTORDER", SortOrderEnum.DESCENDING.getCode());
    map.put("SORTBY", "MARK");
    csc.setSortOptionMap(map);
    ContractSortCommandHelper.sortContractInfoSetRegardingCommand(contractInfoSet, csc);
//        assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
//        fail("The test case is a prototype.");
}
Also used : ContractInfo(org.asqatasun.webapp.presentation.data.ContractInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ContractInfoImpl(org.asqatasun.webapp.presentation.data.ContractInfoImpl) ActInfo(org.asqatasun.webapp.presentation.data.ActInfo) ActInfoImpl(org.asqatasun.webapp.presentation.data.ActInfoImpl) ContractSortCommand(org.asqatasun.webapp.command.ContractSortCommand)

Example 2 with ContractSortCommand

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

use of org.asqatasun.webapp.command.ContractSortCommand 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

ContractSortCommand (org.asqatasun.webapp.command.ContractSortCommand)3 FormField (org.asqatasun.webapp.form.FormField)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SelectElement (org.asqatasun.webapp.form.SelectElement)1 SelectFormField (org.asqatasun.webapp.form.SelectFormField)1 TextualFormField (org.asqatasun.webapp.form.TextualFormField)1 ActInfo (org.asqatasun.webapp.presentation.data.ActInfo)1 ActInfoImpl (org.asqatasun.webapp.presentation.data.ActInfoImpl)1 ContractInfo (org.asqatasun.webapp.presentation.data.ContractInfo)1 ContractInfoImpl (org.asqatasun.webapp.presentation.data.ContractInfoImpl)1