Search in sources :

Example 51 with Audit

use of org.asqatasun.entity.audit.Audit 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) {
    ActInfo actInfo = new ActInfo();
    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) ActInfo(org.asqatasun.webapp.dto.ActInfo)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)51 WebResource (org.asqatasun.entity.subject.WebResource)12 Test (org.junit.Test)12 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 Parameter (org.asqatasun.entity.parameterization.Parameter)8 Site (org.asqatasun.entity.subject.Site)8 AuditCommand (org.asqatasun.service.command.AuditCommand)7 Secured (org.springframework.security.access.annotation.Secured)7 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)6 Contract (org.asqatasun.entity.contract.Contract)5 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Content (org.asqatasun.entity.audit.Content)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 Page (org.asqatasun.entity.subject.Page)4 AuditImpl (org.asqatasun.entity.audit.AuditImpl)3 SSP (org.asqatasun.entity.audit.SSP)2 Act (org.asqatasun.entity.contract.Act)2 Test (org.asqatasun.entity.reference.Test)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2