Search in sources :

Example 46 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 47 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 48 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)

Example 49 with Page

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

the class CrawlerImpl method saveWebResourceFromFetchedPage.

/**
     * 
     * @param curi
     * @param charset
     * @param fetchStatus
     * @param sourceCode
     * @param successfullFetch
     * @return
     */
private SSP saveWebResourceFromFetchedPage(String uri, String charset, int fetchStatus, String sourceCode, boolean successfullFetch) {
    Page page;
    if (mainWebResource instanceof Page) {
        if (!isPageAlreadyFetched) {
            page = (Page) mainWebResource;
            // in case of redirection, we modify the URI of the webresource
            // to ensure the webresource and its SSP have the same URI.
            page.setURL(uri);
            if (successfullFetch) {
                isPageAlreadyFetched = true;
                SSP ssp = createSSPFromPage(uri, charset, page, sourceCode);
                if (persistOnTheFly) {
                    persistSSP(ssp, uri, fetchStatus, page);
                }
                return ssp;
            } else {
                return lastFetchedSSP;
            }
        } else {
            // we don't create SSP anymore. 
            return lastFetchedSSP;
        }
    } else {
        page = webResourceDataService.createPage(uri);
        page.setParent((Site) mainWebResource);
        page.setRank(pageRankCounter);
        pageRankCounter++;
        SSP ssp = createSSPFromPage(uri, charset, page, sourceCode);
        if (persistOnTheFly) {
            persistSSP(ssp, uri, fetchStatus, page);
        }
        return ssp;
    }
}
Also used : Page(org.asqatasun.entity.subject.Page)

Example 50 with Page

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

the class PageFactoryImpl method create.

@Override
public Page create(String url) {
    Page page = new PageImpl();
    page.setURL(url);
    return page;
}
Also used : PageImpl(org.asqatasun.entity.subject.PageImpl) 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