Search in sources :

Example 1 with ActInfoImpl

use of org.asqatasun.webapp.presentation.data.ActInfoImpl 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 ActInfoImpl

use of org.asqatasun.webapp.presentation.data.ActInfoImpl in project Asqatasun by Asqatasun.

the class ActInfoFactory method getActInfo.

/**
     * 
     * @param act
     * @return an ActInfo instance that handles displayable act data
     * 
     */
public ActInfo getActInfo(Act act) {
    ActInfoImpl actInfo = new ActInfoImpl();
    actInfo.setDate(act.getEndDate());
    if (act.getAudit() != null) {
        Audit audit = act.getAudit();
        actInfo.setAuditId(audit.getId().intValue());
        actInfo.setScope(act.getScope().getCode().name());
        WebResource wr = audit.getSubject();
        if (wr != null) {
            actInfo.setUrl(wr.getURL());
        }
        //cas automatique
        if (audit.getStatus().equals(AuditStatus.COMPLETED) || audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING) || audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED)) {
            actInfo.setWeightedMark(statisticsDataService.getMarkByWebResourceAndAudit(wr, false, false).intValue());
            actInfo.setRawMark(statisticsDataService.getMarkByWebResourceAndAudit(wr, true, false).intValue());
            if (actInfo.getRawMark() == -1) {
                actInfo.setRawMark(0);
            }
            actInfo.setStatus(TgolKeyStore.COMPLETED_KEY);
        } else if (!contentDataService.hasContent(audit)) {
            actInfo.setStatus(TgolKeyStore.ERROR_LOADING_KEY);
        } else if (!contentDataService.hasAdaptedSSP(audit)) {
            actInfo.setStatus(TgolKeyStore.ERROR_ADAPTING_KEY);
        } else {
            actInfo.setStatus(TgolKeyStore.ERROR_UNKNOWN_KEY);
        }
        //cas manual
        actInfo.setManual(audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING) || audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED));
        if (actInfo.isManual()) {
            actInfo.setDateManual(audit.getManualAuditDateOfCreation());
            actInfo.setWeightedMarkManual(statisticsDataService.getMarkByWebResourceAndAudit(wr, false, true).intValue());
            actInfo.setRawMarkManual(statisticsDataService.getMarkByWebResourceAndAudit(wr, true, true).intValue());
            if (audit.getStatus().equals(AuditStatus.MANUAL_COMPLETED)) {
                actInfo.setStatusManual(TgolKeyStore.COMPLETED_KEY);
            } else if (audit.getStatus().equals(AuditStatus.MANUAL_ANALYSE_IN_PROGRESS) || audit.getStatus().equals(AuditStatus.MANUAL_INITIALIZING)) {
                actInfo.setStatusManual(TgolKeyStore.ONGOING_KEY);
            } else {
                actInfo.setStatusManual(TgolKeyStore.ERROR_UNKNOWN_KEY);
            }
        }
        setActInfoReferential(actInfo, audit);
    }
    return actInfo;
}
Also used : Audit(org.asqatasun.entity.audit.Audit) WebResource(org.asqatasun.entity.subject.WebResource) ActInfoImpl(org.asqatasun.webapp.presentation.data.ActInfoImpl)

Aggregations

ActInfoImpl (org.asqatasun.webapp.presentation.data.ActInfoImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Audit (org.asqatasun.entity.audit.Audit)1 WebResource (org.asqatasun.entity.subject.WebResource)1 ContractSortCommand (org.asqatasun.webapp.command.ContractSortCommand)1 ActInfo (org.asqatasun.webapp.presentation.data.ActInfo)1 ContractInfo (org.asqatasun.webapp.presentation.data.ContractInfo)1 ContractInfoImpl (org.asqatasun.webapp.presentation.data.ContractInfoImpl)1