Search in sources :

Example 76 with Site

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

the class AuditResultController method displayCriterionResult.

/**
     *
     * @param webresourceId
     * @param criterionId
     * @param model
     * @return the test-result view name
     */
@RequestMapping(value = TgolKeyStore.CRITERION_RESULT_CONTRACT_URL, method = RequestMethod.GET)
public String displayCriterionResult(@RequestParam(TgolKeyStore.WEBRESOURCE_ID_KEY) String webresourceId, @RequestParam(TgolKeyStore.CRITERION_CODE_KEY) String criterionId, Model model) {
    Long wrId;
    Long critId;
    try {
        wrId = Long.valueOf(webresourceId);
        critId = Long.valueOf(criterionId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenUserException(getCurrentUser());
    }
    WebResource webResource = getWebResourceDataService().ligthRead(wrId);
    if (webResource == null || webResource instanceof Site) {
        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());
        Criterion crit = criterionDataService.read(critId);
        model.addAttribute(TgolKeyStore.CRITERION_LABEL_KEY, crit.getLabel());
        model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
        // 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().getTestResultListFromCriterion(webResource, crit));
        return TgolKeyStore.CRITERION_RESULT_VIEW_NAME;
    } else {
        throw new ForbiddenPageException();
    }
}
Also used : Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) Criterion(org.asqatasun.entity.reference.Criterion) 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

Site (org.asqatasun.entity.subject.Site)76 Page (org.asqatasun.entity.subject.Page)68 WebResource (org.asqatasun.entity.subject.WebResource)9 Audit (org.asqatasun.entity.audit.Audit)7 Query (javax.persistence.Query)6 ArrayList (java.util.ArrayList)5 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)4 Contract (org.asqatasun.webapp.entity.contract.Contract)3 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 List (java.util.List)2 Map (java.util.Map)2 Content (org.asqatasun.entity.audit.Content)2 DefiniteResult (org.asqatasun.entity.audit.DefiniteResult)2 SSP (org.asqatasun.entity.audit.SSP)2 ResultCounter (org.asqatasun.webapp.presentation.data.ResultCounter)2 Secured (org.springframework.security.access.annotation.Secured)2 Criterion (org.asqatasun.entity.reference.Criterion)1 Theme (org.asqatasun.entity.reference.Theme)1