use of org.asqatasun.entity.subject.Page 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);
}
use of org.asqatasun.entity.subject.Page 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;
}
use of org.asqatasun.entity.subject.Page 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);
}
use of org.asqatasun.entity.subject.Page 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);
}
}
use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.
the class AbstractGroupRuleWithPageResultImplementation method consolidateImpl.
/**
* This is the implementation of the method declared in
* {@link AbstractRuleImplementation}. It encapsulates the main algorithm of
* the consolidation operation of concrete {@link RuleImplementation}
* classes for tests with group scope. It calls the method
* {@link #consolidateGroup(org.asqatasun.entity.subject.Site, java.util.Set)}
* which should consolidate gross results by group. In common cases, this
* method should not be overriden.
*
* @param grossResultMap
* the gross result map to consolidate.
* @return the list of net results from the gross result list.
*/
@Override
protected List<ProcessResult> consolidateImpl(Map<WebResource, List<ProcessResult>> grossResultMap, ProcessRemarkService processRemarkService) {
List<ProcessResult> netResultList = new ArrayList<>();
for (Map.Entry<WebResource, List<ProcessResult>> entry : grossResultMap.entrySet()) {
WebResource key = entry.getKey();
List<ProcessResult> grossResultList = entry.getValue();
if (entry.getKey() instanceof Page) {
DefiniteResult netResult = processResultDataService.getDefiniteResult(test, key);
netResult.setDefiniteValue(TestSolution.NOT_APPLICABLE);
for (ProcessResult grossResult : grossResultList) {
// netResult.addChildResult(grossResult);
netResult.setNetResultAudit(grossResult.getGrossResultAudit());
}
netResultList.add(netResult);
continue;
} else {
netResultList.addAll(consolidateGroup((Site) key, grossResultList, processRemarkService));
}
}
return consolidateSite(netResultList, processRemarkService);
}
Aggregations