Search in sources :

Example 26 with WebResource

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

the class WebResourceDAOImplTest method testFindByUrlAndParentWebResource.

public void testFindByUrlAndParentWebResource() {
    WebResource parentWr = webresourceDAO.read(Long.valueOf(1));
    WebResource wr = webresourceDAO.findByUrlAndParentWebResource(URL2, parentWr);
    assertEquals(Long.valueOf(2), wr.getId());
    wr = webresourceDAO.findByUrlAndParentWebResource(URL1, parentWr);
    assertNull(wr);
}
Also used : WebResource(org.asqatasun.entity.subject.WebResource)

Example 27 with WebResource

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

the class WebResourceDAOImplTest method testRetrieveWebResourceFromItsParent.

public void testRetrieveWebResourceFromItsParent() {
    WebResource parentWr = webresourceDAO.read(Long.valueOf(1));
    assertEquals(Long.valueOf(3), webresourceDAO.findNumberOfChildWebResource(parentWr));
    List<WebResource> wrList = webresourceDAO.findWebResourceFromItsParent(parentWr, 0, 1);
    assertEquals(1, wrList.size());
    assertEquals(Long.valueOf(2), ((WebResource) wrList.iterator().next()).getId());
    wrList = webresourceDAO.findWebResourceFromItsParent(parentWr, 1, 10);
    assertEquals(2, wrList.size());
    Iterator iter = wrList.iterator();
    assertEquals(Long.valueOf(3), ((WebResource) iter.next()).getId());
    assertEquals(Long.valueOf(4), ((WebResource) iter.next()).getId());
}
Also used : Iterator(java.util.Iterator) WebResource(org.asqatasun.entity.subject.WebResource)

Example 28 with WebResource

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

the class ContentDAOImplTest method testFindNumberOfSSPFromWebResource.

public void testFindNumberOfSSPFromWebResource() {
    WebResource wr = webresourceDAO.read(Long.valueOf(1));
    assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
    wr = webresourceDAO.read(Long.valueOf(2));
    assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
    wr = webresourceDAO.read(Long.valueOf(8));
    assertEquals(Long.valueOf(1), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
    assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_BAD_GATEWAY));
    assertEquals(Long.valueOf(2), contentDAO.findNumberOfSSPFromWebResource(wr, -1));
    wr = webresourceDAO.read(Long.valueOf(12));
    assertEquals(Long.valueOf(0), contentDAO.findNumberOfSSPFromWebResource(wr, HttpStatus.SC_OK));
}
Also used : WebResource(org.asqatasun.entity.subject.WebResource)

Example 29 with WebResource

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

the class ContentDAOImplTest method testFind.

public void testFind() {
    Audit audit = auditDAO.read(Long.valueOf(1));
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/2.html"));
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/3.html"));
    audit = auditDAO.read(Long.valueOf(3));
    assertEquals(Long.valueOf(10), contentDAO.find(audit, "http://www.mock-url.org/2.html").getId());
    assertNull(contentDAO.find(audit, "http://www.mock-url.org/3.html"));
    WebResource wr = webresourceDAO.read(Long.valueOf(6));
    assertEquals(Long.valueOf(2), contentDAO.find(wr, "http://www.mock-url.org/2.html").getId());
    wr = webresourceDAO.read(Long.valueOf(5));
    assertNull(contentDAO.find(wr, "http://www.mock-url.org/2.html"));
}
Also used : Audit(org.asqatasun.entity.audit.Audit) WebResource(org.asqatasun.entity.subject.WebResource)

Example 30 with WebResource

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

the class WebResourceDAOImpl method ligthRead.

@Override
public WebResource ligthRead(Long webResourceId) {
    try {
        Query query = entityManager.createQuery("SELECT wr FROM " + getEntityClass().getName() + " wr" + " WHERE wr.id = :id");
        query.setParameter("id", webResourceId);
        query.setHint(CACHEABLE_OPTION, TRUE);
        return (WebResource) query.getSingleResult();
    } catch (NoResultException nre) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) WebResource(org.asqatasun.entity.subject.WebResource) NoResultException(javax.persistence.NoResultException)

Aggregations

WebResource (org.asqatasun.entity.subject.WebResource)43 Audit (org.asqatasun.entity.audit.Audit)11 Content (org.asqatasun.entity.audit.Content)11 Site (org.asqatasun.entity.subject.Site)9 ArrayList (java.util.ArrayList)8 ProcessResult (org.asqatasun.entity.audit.ProcessResult)8 Page (org.asqatasun.entity.subject.Page)7 NoResultException (javax.persistence.NoResultException)6 Query (javax.persistence.Query)6 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)6 List (java.util.List)5 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 NonUniqueResultException (javax.persistence.NonUniqueResultException)3 SSP (org.asqatasun.entity.audit.SSP)3 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)3 Contract (org.asqatasun.webapp.entity.contract.Contract)3 Map (java.util.Map)2 ContentLoader (org.asqatasun.contentloader.ContentLoader)2 ContentLoaderFactory (org.asqatasun.contentloader.ContentLoaderFactory)2