Search in sources :

Example 6 with Site

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

the class Rgaa32016Rule120301Test method setUpWebResourceMap.

@Override
protected void setUpWebResourceMap() {
    getWebResourceMap().put("Rgaa32016.Test.12.03.01-4NA-01", getWebResourceFactory().createPage(getTestcasesFilePath() + "rgaa32016/Rgaa32016Rule120301/Rgaa32016.Test.12.03.01-3NMI-01.html"));
    Site site = getWebResourceFactory().createSite("file:Site-NotTested");
    getWebResourceMap().put("Rgaa32016.Test.12.03.01-5NT-01", site);
    Page page = getWebResourceFactory().createPage(getTestcasesFilePath() + "rgaa32016/Rgaa32016Rule120301/Rgaa32016.Test.12.03.01-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("Rgaa32016.Test.12.03.01-5NT-01-page1", page);
    page = getWebResourceFactory().createPage(getTestcasesFilePath() + "rgaa32016/Rgaa32016Rule120301/Rgaa32016.Test.12.03.01-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("Rgaa32016.Test.12.03.01-5NT-01-page1", page);
}
Also used : Site(org.asqatasun.entity.subject.Site) Page(org.asqatasun.entity.subject.Page)

Example 7 with Site

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

the class AbstractRuleImplementationTestCase method getGrossResult.

protected ProcessResult getGrossResult(String pageKey, String siteKey) {
    Site site = (Site) webResourceMap.get(siteKey);
    Collection<ProcessResult> grossResultList = grossResultMap.get(site);
    Page page = (Page) webResourceMap.get(pageKey);
    for (ProcessResult grossResult : grossResultList) {
        if (grossResult.getSubject().equals(page)) {
            return grossResult;
        }
    }
    return null;
}
Also used : Site(org.asqatasun.entity.subject.Site) ProcessResult(org.asqatasun.entity.audit.ProcessResult) Page(org.asqatasun.entity.subject.Page)

Example 8 with Site

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

the class AuditStatisticsFactory method getAuditStatistics.

/**
     * This methods creates an instance of auditStatistics (audit meta-data)
     * with the URL, the date, the number of components (in case of site audit )
     * and the mark of the audit
     *
     * @param webResource
     * @param parametersToDisplay
     * @param displayScope
     * @param isAuditManual
     * @return
     */
public AuditStatistics getAuditStatistics(WebResource webResource, Map<String, String> parametersToDisplay, String displayScope, boolean isAuditManual) {
    AuditStatistics auditStats = new AuditStatisticsImpl();
    auditStats.setUrl(webResource.getURL());
    auditStats.setSnapshotUrl(webResource.getURL());
    auditStats.setRawMark(markFormatter(webResource, true, isAuditManual));
    auditStats.setWeightedMark(markFormatter(webResource, false, isAuditManual));
    Audit audit;
    if (webResource instanceof Site) {
        auditStats.setPageCounter(webResourceDataService.getChildWebResourceCount(webResource).intValue());
        audit = webResource.getAudit();
        auditStats.setAuditedPageCounter(statisticsDataService.getWebResourceCountByAuditAndHttpStatusCode(audit.getId(), HttpStatusCodeFamily.f2xx, null, null).intValue());
    } else if (webResource.getParent() != null) {
        audit = webResource.getParent().getAudit();
    } else {
        audit = webResource.getAudit();
    }
    auditStats.setDate(audit.getDateOfCreation());
    auditStats.setAuditScope(actDataService.getActFromAudit(audit).getScope().getCode());
    ResultCounter resultCounter = auditStats.getResultCounter();
    resultCounter.setPassedCount(0);
    resultCounter.setFailedCount(0);
    resultCounter.setNmiCount(0);
    resultCounter.setNaCount(0);
    resultCounter.setNtCount(0);
    auditStats.setCounterByThemeMap(addCounterByThemeMap(audit, webResource, resultCounter, displayScope, isAuditManual));
    auditStats.setParametersMap(getAuditParameters(audit, parametersToDisplay));
    return auditStats;
}
Also used : AuditStatistics(org.asqatasun.webapp.presentation.data.AuditStatistics) Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) AuditStatisticsImpl(org.asqatasun.webapp.presentation.data.AuditStatisticsImpl) ResultCounter(org.asqatasun.webapp.presentation.data.ResultCounter)

Example 9 with Site

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

the class UploadAuditCommandImpl method createWebResources.

private void createWebResources() {
    WebResource webResource;
    if (fileMap.size() > 1) {
        webResource = getWebResourceDataService().createSite(FileNaming.addProtocolToUrl(fileMap.keySet().iterator().next()));
        getWebResourceDataService().saveOrUpdate(webResource);
        for (String pageUrl : fileMap.keySet()) {
            Page page = getWebResourceDataService().createPage(pageUrl);
            ((Site) webResource).addChild(page);
            getWebResourceDataService().saveOrUpdate(page);
        }
    } else {
        webResource = getWebResourceDataService().createPage(fileMap.keySet().iterator().next());
    }
    // the webresource needs to be persisted a second time because of the
    // relation with the audit
    webResource.setAudit(getAudit());
    getWebResourceDataService().saveOrUpdate(webResource);
    getAudit().setSubject(webResource);
}
Also used : Site(org.asqatasun.entity.subject.Site) WebResource(org.asqatasun.entity.subject.WebResource) Page(org.asqatasun.entity.subject.Page)

Example 10 with Site

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

the class AuditCommandImpl method analyse.

@Override
public void analyse() {
    audit = auditDataService.read(audit.getId());
    if (!audit.getStatus().equals(AuditStatus.ANALYSIS)) {
        LOGGER.warn(new StringBuilder(AUDIT_STATUS_IS_LOGGER_STR).append(audit.getStatus()).append(WHILE_LOGGER_STR).append(AuditStatus.ANALYSIS).append(WAS_REQUIRED_LOGGER_STR).toString());
        return;
    }
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Analysing " + audit.getSubject().getURL());
    }
    // debug tools
    Date beginProcessDate = null;
    Date endProcessDate = null;
    Date endPersistDate;
    Long persistenceDuration = (long) 0;
    WebResource parentWebResource = audit.getSubject();
    if (parentWebResource instanceof Page) {
        analyserService.analyse(parentWebResource, audit);
        webResourceDataService.saveOrUpdate(parentWebResource);
    } else if (parentWebResource instanceof Site) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Analysing results of scope site");
            beginProcessDate = Calendar.getInstance().getTime();
        }
        analyserService.analyse(parentWebResource, audit);
        if (LOGGER.isDebugEnabled()) {
            endProcessDate = Calendar.getInstance().getTime();
            LOGGER.debug(new StringBuilder("Analysing results of scope site took ").append(endProcessDate.getTime() - beginProcessDate.getTime()).append(MS_LOGGER_STR).toString());
        }
        webResourceDataService.saveOrUpdate(parentWebResource);
        if (LOGGER.isDebugEnabled()) {
            endPersistDate = Calendar.getInstance().getTime();
            LOGGER.debug(new StringBuilder("Persisting Analysis results of scope site ").append(endPersistDate.getTime() - endProcessDate.getTime()).append(MS_LOGGER_STR).toString());
            persistenceDuration = persistenceDuration + (endPersistDate.getTime() - endProcessDate.getTime());
        }
        Long nbOfContent = webResourceDataService.getNumberOfChildWebResource(parentWebResource);
        Long i = (long) 0;
        List<WebResource> webResourceList;
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(new StringBuilder("Analysing ").append(nbOfContent).append(" elements ").toString());
        }
        while (i.compareTo(nbOfContent) < 0) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(new StringBuilder("Analysing results of scope page from ").append(i).append(TO_LOGGER_STR).append(i + analyseTreatmentWindow).toString());
                beginProcessDate = Calendar.getInstance().getTime();
            }
            webResourceList = webResourceDataService.getWebResourceFromItsParent(parentWebResource, i.intValue(), analyseTreatmentWindow);
            for (WebResource webResource : webResourceList) {
                if (LOGGER.isDebugEnabled()) {
                    endProcessDate = Calendar.getInstance().getTime();
                    LOGGER.debug(new StringBuilder("Analysing results for page ").append(webResource.getURL()).append(" took ").append(endProcessDate.getTime() - beginProcessDate.getTime()).append(MS_LOGGER_STR).toString());
                }
                analyserService.analyse(webResource, audit);
                if (LOGGER.isDebugEnabled()) {
                    endPersistDate = Calendar.getInstance().getTime();
                    LOGGER.debug(new StringBuilder("Persisting Analysis results for page ").append(webResource.getURL()).append(" took ").append(endPersistDate.getTime() - endProcessDate.getTime()).append(MS_LOGGER_STR).toString());
                    persistenceDuration = persistenceDuration + (endPersistDate.getTime() - endProcessDate.getTime());
                }
            }
            i = i + analyseTreatmentWindow;
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(new StringBuilder("Application spent ").append(persistenceDuration).append(" ms to write in Disk while analysing").toString());
    }
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info(audit.getSubject().getURL() + " has been analysed");
    }
    setStatusToAudit(AuditStatus.COMPLETED);
    if (cleanUpRelatedContent) {
        cleanUpTestData(audit);
    }
}
Also used : Site(org.asqatasun.entity.subject.Site) WebResource(org.asqatasun.entity.subject.WebResource) Page(org.asqatasun.entity.subject.Page)

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