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;
}
}
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;
}
}
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;
}
}
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;
}
}
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());
}
Aggregations