Search in sources :

Example 46 with Site

use of org.asqatasun.entity.subject.Site 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 47 with Site

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

the class AuditCommandImpl method createEmptySiteResource.

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

Example 48 with Site

use of org.asqatasun.entity.subject.Site 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 49 with Site

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

the class AbstractScenarioAuditCommandImplTest method testLoadContent2.

/**
     * Test of loadContent method, of class AbstractScenarioAuditCommandImpl.
     */
public void testLoadContent2() {
    System.out.println("loadContent with site as main resource");
    String myScenario = "My Scenario";
    String myUrl = "My Scenario";
    Site mockSite = createMock(Site.class);
    mockSite.setAudit(mockAudit);
    expectLastCall().once();
    mockAudit.setStatus(AuditStatus.SCENARIO_LOADING);
    expectLastCall().once();
    expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
    expect(mockAudit.getStatus()).andReturn(AuditStatus.SCENARIO_LOADING).once();
    mockAudit.setSubject(mockSite);
    expectLastCall().once();
    expect(mockScenarioLoaderService.loadScenario(mockSite, myScenario)).andReturn(null).once();
    mockAudit.setStatus(AuditStatus.CONTENT_ADAPTING);
    expectLastCall().once();
    expect(mockAuditDataService.saveOrUpdate(mockAudit)).andReturn(mockAudit).once();
    expect(mockWebResourceDataService.createSite(myUrl)).andReturn(mockSite).once();
    expect(mockWebResourceDataService.saveOrUpdate(mockSite)).andReturn(mockSite).once();
    replay(mockSite);
    setReplayMode();
    AbstractScenarioAuditCommandImpl instance = new TestAbstractScenarioAuditCommandImpl();
    instance.setScenarioName(myUrl);
    instance.setScenario(myScenario);
    instance.setIsPage(false);
    instance.init();
    instance.loadContent();
    verify(mockSite);
    setVerifyMode();
}
Also used : Site(org.asqatasun.entity.subject.Site)

Example 50 with Site

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

the class ContentDAOImpl method findNumberOfOrphanContentFromWebResource.

@Override
public Long findNumberOfOrphanContentFromWebResource(WebResource webResource) {
    if (webResource instanceof Page) {
        Query query = entityManager.createQuery(SELECT_DISTINCT_SSP + SSPImpl.class.getName() + " s" + JOIN_WR + WEB_RESOURCE_CONDITION + HTTP_STATUS_CONDITION);
        query.setParameter(WEB_RESOURCE_KEY, webResource);
        query.setParameter(HTTP_STATUS_CODE_KEY, DEFAULT_HTTP_STATUS_VALUE);
        return (Long) query.getSingleResult();
    } else if (webResource instanceof Site) {
        Query query = entityManager.createQuery(SELECT_DISTINCT_SSP + SSPImpl.class.getName() + " s" + JOIN_WR + " JOIN w.parent p" + " WHERE p=:webResource" + HTTP_STATUS_CONDITION);
        query.setParameter(WEB_RESOURCE_KEY, webResource);
        query.setParameter(HTTP_STATUS_CODE_KEY, DEFAULT_HTTP_STATUS_VALUE);
        return (Long) query.getSingleResult();
    }
    return (long) 0;
}
Also used : Site(org.asqatasun.entity.subject.Site) Query(javax.persistence.Query) 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