Search in sources :

Example 1 with WebResource

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

the class WebResourceDAOImpl method read.

@Override
public WebResource read(Long key) {
    try {
        Query query = entityManager.createQuery("SELECT wr FROM " + getEntityClass().getName() + " wr" + " left join fetch wr.processResultSet prs" + " left join fetch prs.remarkSet prk" + " left join fetch prk.elementSet pr" + " WHERE wr.id = :id");
        query.setParameter("id", key);
        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)

Example 2 with WebResource

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

the class WebResourceDAOImpl method findByUrl.

@Override
public WebResource findByUrl(String url) {
    Query query = entityManager.createQuery("SELECT wr FROM " + getEntityClass().getName() + " wr" + " left join fetch wr.processResultSet pr" + " WHERE wr.url = :url");
    query.setParameter("url", url);
    try {
        return (WebResource) query.getSingleResult();
    } catch (NoResultException nre) {
        return null;
    } catch (NonUniqueResultException nure) {
        List<WebResource> queryResult = query.getResultList();
        for (WebResource wr : queryResult) {
            if (StringUtils.equals(wr.getURL(), url)) {
                return wr;
            }
        }
        return null;
    }
}
Also used : NonUniqueResultException(javax.persistence.NonUniqueResultException) Query(javax.persistence.Query) WebResource(org.asqatasun.entity.subject.WebResource) List(java.util.List) NoResultException(javax.persistence.NoResultException)

Example 3 with WebResource

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

the class WebResourceDAOImpl method findParentWebResourceId.

@Override
public Long findParentWebResourceId(Long webresourceId) {
    if (webresourceId == null) {
        return null;
    }
    try {
        Query query = entityManager.createQuery("SELECT r FROM " + getEntityClass().getName() + " r" + " WHERE r.id = :id");
        query.setParameter("id", webresourceId);
        if (query.getSingleResult() != null && ((WebResource) query.getSingleResult()).getParent() != null) {
            return ((WebResource) query.getSingleResult()).getParent().getId();
        } else {
            return null;
        }
    } catch (NoResultException e) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) WebResource(org.asqatasun.entity.subject.WebResource) NoResultException(javax.persistence.NoResultException)

Example 4 with WebResource

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

the class WebResourceDAOImpl method findByAuditAndUrl.

@Override
public WebResource findByAuditAndUrl(Audit audit, String url) {
    Query query = entityManager.createQuery("SELECT wr FROM " + getEntityClass().getName() + " wr" + " left join fetch wr.processResultSet pr" + " WHERE wr.url = :url AND wr.audit = :audit");
    query.setParameter("url", url);
    query.setParameter("audit", audit);
    try {
        return (WebResource) query.getSingleResult();
    } catch (NoResultException nre) {
        return null;
    } catch (NonUniqueResultException nure) {
        List<WebResource> queryResult = query.getResultList();
        for (WebResource wr : queryResult) {
            if (StringUtils.equals(wr.getURL(), url)) {
                return wr;
            }
        }
        return null;
    }
}
Also used : NonUniqueResultException(javax.persistence.NonUniqueResultException) Query(javax.persistence.Query) WebResource(org.asqatasun.entity.subject.WebResource) List(java.util.List) NoResultException(javax.persistence.NoResultException)

Example 5 with WebResource

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

the class ContentDAOImplTest method testFindOrphanContentList.

public void testFindOrphanContentList() {
    WebResource wr = webresourceDAO.read(Long.valueOf(1));
    assertEquals(Long.valueOf(2), contentDAO.findNumberOfOrphanContentFromWebResource(wr));
    List<Content> contentList = contentDAO.findOrphanContentList(wr, 0, 100);
    assertEquals(2, contentList.size());
    assertEquals(Long.valueOf(3), contentDAO.findNumberOfOrphanRelatedContentFromWebResource(wr));
    contentList = contentDAO.findOrphanRelatedContentList(wr, 0, 10);
    assertEquals(3, contentList.size());
    wr = webresourceDAO.read(Long.valueOf(2));
    contentList = contentDAO.findOrphanContentList(wr, 0, 10);
    assertEquals(1, contentList.size());
    contentList = contentDAO.findOrphanRelatedContentList(wr, 0, 10);
    assertEquals(1, contentList.size());
}
Also used : Content(org.asqatasun.entity.audit.Content) WebResource(org.asqatasun.entity.subject.WebResource)

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