Search in sources :

Example 56 with Page

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

the class AuditExportResultController method prepareSuccessfullAuditDataToExport.

/**
     * 
     * @param page
     * @param model
     * @param locale
     * @param exportFormat
     * @param request
     * @param response
     * @return
     * @throws IOException
     */
private void prepareSuccessfullAuditDataToExport(WebResource webResource, Model model, Locale locale, String exportFormat, HttpServletRequest request, HttpServletResponse response) throws NotSupportedExportFormatException {
    model.addAttribute(TgolKeyStore.LOCALE_KEY, locale);
    Scope scope = getSiteScope();
    if (webResource instanceof Page) {
        scope = getPageScope();
    }
    List<TestResult> testResultList = TestResultFactory.getInstance().getTestResultList(webResource, scope, getLocaleResolver().resolveLocale(request));
    AuditStatistics auditStatistics = getAuditStatistics(webResource, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE, //TODO a revoir dans le cas manuel 
    false);
    model.addAttribute(TgolKeyStore.STATISTICS_KEY, auditStatistics);
    try {
        exportService.export(response, webResource.getId(), auditStatistics, testResultList, locale, exportFormat);
    } catch (ColumnBuilderException | ClassNotFoundException | JRException ex) {
        LOGGER.error(ex);
    }
}
Also used : AuditStatistics(org.asqatasun.webapp.presentation.data.AuditStatistics) ColumnBuilderException(ar.com.fdvs.dj.domain.builders.ColumnBuilderException) Scope(org.asqatasun.entity.reference.Scope) JRException(net.sf.jasperreports.engine.JRException) Page(org.asqatasun.entity.subject.Page) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Example 57 with Page

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

the class AbstractGroupRuleImplementation 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.add(consolidateGroup((Site) key, grossResultList, processRemarkService));
        }
    }
    return consolidateSite(netResultList, processRemarkService);
}
Also used : Site(org.asqatasun.entity.subject.Site) ArrayList(java.util.ArrayList) ProcessResult(org.asqatasun.entity.audit.ProcessResult) WebResource(org.asqatasun.entity.subject.WebResource) List(java.util.List) ArrayList(java.util.ArrayList) Page(org.asqatasun.entity.subject.Page) Map(java.util.Map) DefiniteResult(org.asqatasun.entity.audit.DefiniteResult)

Example 58 with Page

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

the class UploadAuditCommandImplTest method testLoadContent1.

/**
     * Test of loadContent method, of class UploadAuditCommandImpl.
     */
public void testLoadContent1() {
    System.out.println("LoadContent with 1 file");
    mockInitialisationCalls(false, AuditStatus.CONTENT_LOADING);
    fileMap.put("My File Name", "MyFileContent");
    EasyMock.expect(mockAudit.getStatus()).andReturn(AuditStatus.CONTENT_LOADING).once();
    Page mockPage = EasyMock.createMock(Page.class);
    EasyMock.expect(mockWebResourceDataService.createPage("My File Name")).andReturn(mockPage).once();
    mockPage.setAudit(mockAudit);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage)).andReturn(mockPage).once();
    mockAudit.setSubject(mockPage);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockAudit.getSubject()).andReturn(mockPage).once();
    EasyMock.expect(mockContentLoaderService.loadContent(mockPage, fileMap)).andReturn(new ArrayList<Content>()).once();
    mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
    EasyMock.replay(mockPage);
    setReplayMode();
    UploadAuditCommandImpl instance = getInstance();
    instance.loadContent();
    EasyMock.verify(mockPage);
    setVerifyMode();
}
Also used : ArrayList(java.util.ArrayList) Page(org.asqatasun.entity.subject.Page)

Example 59 with Page

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

the class UploadAuditCommandImplTest method testLoadContent2.

/**
     * Test of loadContent method, of class UploadAuditCommandImpl.
     */
public void testLoadContent2() {
    System.out.println("LoadContent with several file");
    mockInitialisationCalls(false, AuditStatus.CONTENT_LOADING);
    fileMap.put("file:///My_File_Name1", "MyFileContent1");
    fileMap.put("file:///My_File_Name2", "MyFileContent2");
    EasyMock.expect(mockAudit.getStatus()).andReturn(AuditStatus.CONTENT_LOADING).once();
    Site mockSite = EasyMock.createMock(Site.class);
    Page mockPage1 = EasyMock.createMock(Page.class);
    Page mockPage2 = EasyMock.createMock(Page.class);
    EasyMock.expect(mockWebResourceDataService.createSite("file:///My_File_Name1")).andReturn(mockSite).once();
    EasyMock.expect(mockWebResourceDataService.createPage("file:///My_File_Name1")).andReturn(mockPage1).once();
    EasyMock.expect(mockWebResourceDataService.createPage("file:///My_File_Name2")).andReturn(mockPage2).once();
    mockSite.addChild(mockPage1);
    EasyMock.expectLastCall().once();
    mockSite.addChild(mockPage2);
    EasyMock.expectLastCall().once();
    mockSite.setAudit(mockAudit);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockSite)).andReturn(mockSite).times(2);
    EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage1)).andReturn(mockSite).once();
    EasyMock.expect(mockWebResourceDataService.saveOrUpdate(mockPage2)).andReturn(mockSite).once();
    mockAudit.setSubject(mockSite);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockAudit.getSubject()).andReturn(mockSite).once();
    EasyMock.expect(mockContentLoaderService.loadContent(mockSite, fileMap)).andReturn(new ArrayList<Content>()).once();
    mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
    EasyMock.replay(mockSite);
    EasyMock.replay(mockPage1);
    EasyMock.replay(mockPage2);
    setReplayMode();
    UploadAuditCommandImpl instance = getInstance();
    instance.loadContent();
    EasyMock.verify(mockSite);
    EasyMock.verify(mockPage1);
    EasyMock.verify(mockPage2);
    setVerifyMode();
}
Also used : Site(org.asqatasun.entity.subject.Site) ArrayList(java.util.ArrayList) Page(org.asqatasun.entity.subject.Page)

Example 60 with Page

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

the class AuditCommandImpl method createEmptyPageResource.

/**
     * Create a webResource of page type and associate it with the current audit
     * @param url 
     */
protected void createEmptyPageResource(String url) {
    Page page = getWebResourceDataService().createPage(url);
    getAudit().setSubject(page);
    getWebResourceDataService().saveOrUpdate(page);
}
Also used : Page(org.asqatasun.entity.subject.Page)

Aggregations

Page (org.asqatasun.entity.subject.Page)77 Site (org.asqatasun.entity.subject.Site)68 WebResource (org.asqatasun.entity.subject.WebResource)7 ArrayList (java.util.ArrayList)6 Query (javax.persistence.Query)6 Audit (org.asqatasun.entity.audit.Audit)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 List (java.util.List)3 Map (java.util.Map)3 SSP (org.asqatasun.entity.audit.SSP)3 Content (org.asqatasun.entity.audit.Content)2 DefiniteResult (org.asqatasun.entity.audit.DefiniteResult)2 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)2 ColumnBuilderException (ar.com.fdvs.dj.domain.builders.ColumnBuilderException)1 IOException (java.io.IOException)1 JRException (net.sf.jasperreports.engine.JRException)1 PreProcessResult (org.asqatasun.entity.audit.PreProcessResult)1 Scope (org.asqatasun.entity.reference.Scope)1 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)1 WebResourceDataService (org.asqatasun.entity.service.subject.WebResourceDataService)1