use of org.asqatasun.webapp.dto.ContractInfo 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;
}
use of org.asqatasun.webapp.dto.ContractInfo in project Asqatasun by Asqatasun.
the class ContractSortCommandHelperTest method testGetLastAuditMarkSortValue.
/**
* Test of getLastAuditMarkSortValue method, of class ContractSortCommandHelper.
*/
@Test
public void testGetLastAuditMarkSortValue() {
List<ContractInfo> contractInfoSet = new ArrayList<>();
ContractSortCommand csc = new ContractSortCommand();
ContractInfo c1 = new ContractInfo();
ActInfo lastActInfo1 = new ActInfo();
lastActInfo1.setRawMark(15);
c1.setLastActInfo(lastActInfo1);
c1.setLabel(("A1"));
contractInfoSet.add(c1);
ContractInfo c2 = new ContractInfo();
ActInfo lastActInfo2 = new ActInfo();
lastActInfo2.setRawMark(95);
c2.setLastActInfo(lastActInfo2);
c2.setLabel(("B2"));
contractInfoSet.add(c2);
ContractInfo c3 = new ContractInfo();
ActInfo lastActInfo3 = new ActInfo();
lastActInfo3.setRawMark(53);
c3.setLastActInfo(lastActInfo3);
c3.setLabel(("C3"));
contractInfoSet.add(c3);
ContractInfo c4 = new ContractInfo();
c4.setLastActInfo(null);
c4.setLabel(("D4"));
contractInfoSet.add(c4);
ContractInfo c5 = new ContractInfo();
c5.setLastActInfo(null);
c5.setLabel(("A4"));
contractInfoSet.add(c5);
Map<String, Object> map = new HashMap<>();
map.put("order-choice", SortOrderEnum.ASCENDING.getCode());
map.put("sort-by-choice", "MARK");
csc.setSortOptionMap(map);
contractSortCommandHelper.sortContractInfoSetRegardingCommand(contractInfoSet, csc);
assertTrue(contractInfoSet.get(0).equals(c1));
assertTrue(contractInfoSet.get(1).equals(c3));
assertTrue(contractInfoSet.get(2).equals(c2));
map = new HashMap<>();
map.put("order-choice", SortOrderEnum.DESCENDING.getCode());
map.put("sort-by-choice", "MARK");
csc.setSortOptionMap(map);
contractSortCommandHelper.sortContractInfoSetRegardingCommand(contractInfoSet, csc);
assertTrue(contractInfoSet.get(0).equals(c2));
assertTrue(contractInfoSet.get(1).equals(c3));
assertTrue(contractInfoSet.get(2).equals(c1));
// TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
}
use of org.asqatasun.webapp.dto.ContractInfo in project Asqatasun by Asqatasun.
the class ContractInfoFactory method getContractInfo.
/**
* @param contract
* @return an ContractInfo instance that handles displayable contract data
*/
public ContractInfo getContractInfo(Contract contract) {
ContractInfo contractInfo = new ContractInfo();
contract = contractDataService.read(contract.getId());
setBasicContractInfo(contract, contractInfo);
contractInfo.setExpirationDate(contract.getEndDate());
if (Calendar.getInstance().getTime().after(contract.getEndDate())) {
contractInfo.setContractExpired(true);
}
contractInfo = setLastActInfo(contract, contractInfo);
contractInfo = setAuditResultTrend(contract, contractInfo);
return contractInfo;
}
Aggregations