Search in sources :

Example 21 with WebResource

use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.

the class AbstractRuleImplementationTestCase method consolidate.

public ProcessResult consolidate(String webResourceKey) {
    LOGGER.debug(this + "::consolidate(\"" + webResourceKey + "\")");
    WebResource webResource = webResourceMap.get(webResourceKey);
    ProcessResult netResult = CONSOLIDATOR_SERVICE.consolidate(grossResultMap.get(webResource), testList).iterator().next();
    netResultMap.put(webResource, netResult);
    return netResult;
}
Also used : ProcessResult(org.asqatasun.entity.audit.ProcessResult) WebResource(org.asqatasun.entity.subject.WebResource)

Example 22 with WebResource

use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.

the class AbstractSiteRuleWithPageResultImplementationTestCase method consolidateWithListAsReturn.

public Collection<ProcessResult> consolidateWithListAsReturn(String webResourceKey) {
    System.out.println(this + "::consolidate(\"" + webResourceKey + "\")");
    WebResource webResource = getWebResourceMap().get(webResourceKey);
    Collection<ProcessResult> netResultList = getConsolidatorService().consolidate(getGrossResultMap().get(webResource), getTestList());
    //        netResultMap.put(webResource, netResult);
    return netResultList;
}
Also used : ProcessResult(org.asqatasun.entity.audit.ProcessResult) WebResource(org.asqatasun.entity.subject.WebResource)

Example 23 with WebResource

use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.

the class AuditExportResultController method exportAuditResultFromContract.

/**
     * The export view is only available for page result
     * 
     * @param webresourceId 
     * @param format 
     * @param request
     * @param response
     * @param model
     * @return
     */
@RequestMapping(value = TgolKeyStore.EXPORT_AUDIT_RESULT_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String exportAuditResultFromContract(@RequestParam(value = TgolKeyStore.WEBRESOURCE_ID_KEY, required = false) String webresourceId, @RequestParam(value = TgolKeyStore.EXPORT_FORMAT_KEY, required = false) String format, HttpServletRequest request, HttpServletResponse response, Model model) {
    if (format == null || webresourceId == null) {
        throw new ForbiddenPageException();
    }
    //We first check that the current user is allowed to display the result
    //of this audit
    Long webResourceIdValue;
    try {
        webResourceIdValue = Long.valueOf(webresourceId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException();
    }
    WebResource webResource = getWebResourceDataService().ligthRead(webResourceIdValue);
    // if the id of the webresource corresponds to a Site webResource
    if (isUserAllowedToDisplayResult(getAuditFromWebResource(webResource))) {
        // data are retrieved to be prepared and displayed
        try {
            prepareSuccessfullAuditDataToExport(webResource, model, getLocaleResolver().resolveLocale(request), format, request, response);
            return null;
        } catch (NotSupportedExportFormatException exc) {
            model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, webresourceId);
            model.addAttribute(TgolKeyStore.EXPORT_FORMAT_KEY, format);
            LOGGER.warn(exc);
            return TgolKeyStore.EXPORT_AUDIT_FORMAT_ERROR_VIEW_REDIRECT_NAME;
        }
    }
    return TgolKeyStore.EXPORT_AUDIT_FORMAT_ERROR_VIEW_REDIRECT_NAME;
}
Also used : WebResource(org.asqatasun.entity.subject.WebResource) NotSupportedExportFormatException(org.asqatasun.webapp.report.service.exception.NotSupportedExportFormatException) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with WebResource

use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.

the class ManualAuditController method dispatchSubmitManualAuditValues.

/**
     * TO DO : replace this method with an call to the orchestrator 
     * to delegate the writes to the engine.
     * 
     * @param webresourceId
     * @param manualAuditCommand
     * @param result
     * @param model
     * @param request
     * @param isValidating
     * @return
     */
private String dispatchSubmitManualAuditValues(String webresourceId, ManualAuditCommand manualAuditCommand, BindingResult result, Model model, HttpServletRequest request, boolean isValidating) {
    WebResource webResource;
    try {
        webResource = getWebResourceDataService().ligthRead(Long.valueOf(webresourceId));
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException();
    }
    if (webResource instanceof Site) {
        throw new ForbiddenPageException();
    }
    Audit audit = getAuditFromWebResource(webResource);
    if (isUserAllowedToDisplayResult(audit)) {
        model.addAttribute(TgolKeyStore.IS_MANUAL_AUDIT_KEY, true);
        List<ProcessResult> processResultList = TestResultFactory.getInstance().getProcessResultListFromTestsResult(manualAuditCommand.getModifiedManualResultMap(), webResource);
        processResultDataService.saveOrUpdate(processResultList);
        /**
             * if save the manual audit for the first time save we set the
             * manual audit start time and status to MANUAL_INITIALIZING
             */
        if (audit.getManualAuditDateOfCreation() == null) {
            audit.setManualAuditDateOfCreation(Calendar.getInstance().getTime());
            audit.setStatus(AuditStatus.MANUAL_INITIALIZING);
            getAuditDataService().update(audit);
        }
        List<ProcessResult> allProcessResultList = TestResultFactory.getInstance().getAllProcessResultListFromTestsResult(manualAuditCommand.getModifiedManualResultMap(), webResource);
        manualAuditCommand.setProcessResultList(allProcessResultList);
        if (isValidating) {
            manualAuditValidator.validate(manualAuditCommand, result);
            if (result.hasErrors()) {
                // ajout message d'erreur.
                model.addAttribute(TgolKeyStore.MANUAL_AUDIT_COMMAND_KEY, manualAuditCommand);
                return dispatchDisplayResultRequest(webResource.getId(), null, model, request, true, manualAuditCommand);
            } else {
                // mettre à jour le statut
                audit.setStatus(AuditStatus.MANUAL_COMPLETED);
                getAuditDataService().update(audit);
                webResourceStatisticsDataService.createWebResourceStatisticsForManualAudit(audit, webResource, allProcessResultList);
                Contract contract = retrieveContractFromAudit(audit);
                model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
                return TgolKeyStore.CONTRACT_VIEW_NAME_REDIRECT;
            }
        }
        webResourceStatisticsDataService.createWebResourceStatisticsForManualAudit(audit, webResource, allProcessResultList);
        return dispatchDisplayResultRequest(webResource.getId(), null, model, request, true, manualAuditCommand);
    } else {
        throw new ForbiddenPageException();
    }
}
Also used : Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) ProcessResult(org.asqatasun.entity.audit.ProcessResult) WebResource(org.asqatasun.entity.subject.WebResource) Contract(org.asqatasun.webapp.entity.contract.Contract) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException)

Example 25 with WebResource

use of org.asqatasun.entity.subject.WebResource in project Asqatasun by Asqatasun.

the class AuditResultController method displayTestResult.

/**
     *
     * @param webresourceId
     * @param testId
     * @param model
     * @return the test-result view name
     */
@RequestMapping(value = TgolKeyStore.TEST_RESULT_CONTRACT_URL, method = RequestMethod.GET)
public String displayTestResult(@RequestParam(TgolKeyStore.WEBRESOURCE_ID_KEY) String webresourceId, @RequestParam(TgolKeyStore.TEST_CODE_KEY) String testId, Model model) {
    Long wrId;
    Long tstId;
    try {
        wrId = Long.valueOf(webresourceId);
        tstId = Long.valueOf(testId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenUserException(getCurrentUser());
    }
    WebResource webResource = getWebResourceDataService().ligthRead(wrId);
    if (webResource == null) {
        throw new ForbiddenPageException();
    }
    Audit audit = getAuditFromWebResource(webResource);
    if (isUserAllowedToDisplayResult(audit)) {
        Contract contract = retrieveContractFromAudit(audit);
        // Attributes for breadcrumb
        model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
        model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
        model.addAttribute(TgolKeyStore.URL_KEY, webResource.getURL());
        Test test = getTestDataService().read(tstId);
        model.addAttribute(TgolKeyStore.TEST_LABEL_KEY, test.getLabel());
        model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
        if (!test.getScope().equals(getPageScope())) {
            model.addAttribute(TgolKeyStore.SITE_SCOPE_TEST_DETAILS_KEY, true);
        } else {
            // Add a boolean used to display the breadcrumb.
            model.addAttribute(TgolKeyStore.AUTHORIZED_SCOPE_FOR_PAGE_LIST, isAuthorizedScopeForPageList(audit));
        }
        model.addAttribute(TgolKeyStore.TEST_RESULT_LIST_KEY, TestResultFactory.getInstance().getTestResultListFromTest(webResource, test));
        return TgolKeyStore.TEST_RESULT_VIEW_NAME;
    } else {
        throw new ForbiddenPageException();
    }
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Test(org.asqatasun.entity.reference.Test) WebResource(org.asqatasun.entity.subject.WebResource) ForbiddenUserException(org.asqatasun.webapp.exception.ForbiddenUserException) Contract(org.asqatasun.webapp.entity.contract.Contract) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

WebResource (org.asqatasun.entity.subject.WebResource)43 Audit (org.asqatasun.entity.audit.Audit)11 Content (org.asqatasun.entity.audit.Content)11 Site (org.asqatasun.entity.subject.Site)9 ArrayList (java.util.ArrayList)8 ProcessResult (org.asqatasun.entity.audit.ProcessResult)8 Page (org.asqatasun.entity.subject.Page)7 NoResultException (javax.persistence.NoResultException)6 Query (javax.persistence.Query)6 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)6 List (java.util.List)5 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 NonUniqueResultException (javax.persistence.NonUniqueResultException)3 SSP (org.asqatasun.entity.audit.SSP)3 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)3 Contract (org.asqatasun.webapp.entity.contract.Contract)3 Map (java.util.Map)2 ContentLoader (org.asqatasun.contentloader.ContentLoader)2 ContentLoaderFactory (org.asqatasun.contentloader.ContentLoaderFactory)2