ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public List<Content> findOrphanContentList( WebResource webResource, int start, int chunkSize) { if (webResource instanceof Page) { Query query = entityManager.createQuery( "SELECT distinct s FROM " + 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); query.setFirstResult(start); query.setMaxResults(chunkSize); return (List<Content>) query.getResultList(); } else if (webResource instanceof Site) { Query query = entityManager.createQuery( "SELECT distinct s FROM " + 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); query.setFirstResult(start); query.setMaxResults(chunkSize); List<Content> contentList = (List<Content>) query.getResultList(); return contentList; } return Collections.emptyList(); } ContentDAOImpl(); @Override Content find(Audit audit, String uri); @Override Content find(WebResource page, String uri); @Override Long findNumberOfSSPContentFromAudit(Audit audit); @Override boolean hasAdaptedSSP(Audit audit); @Override boolean hasContent(Audit audit); @Override Long findNumberOfOrphanContentFromWebResource(WebResource webResource); @Override List<Content> findOrphanContentList(
            WebResource webResource,
            int start,
            int chunkSize); @Override Long findNumberOfOrphanRelatedContentFromWebResource(
            WebResource webResource); @Override List<Content> findOrphanRelatedContentList(
            WebResource webResource,
            int start,
            int chunkSize); @Override Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode); @Override Long findNumberOfRelatedContentFromWebResource(WebResource webResource); @Override Collection<StylesheetContent> findExternalStylesheetFromAudit(Audit audit); @Override void saveContentRelationShip(SSP ssp, Set<Long> relatedContentIdSet); @Override void saveAuditToContent(Long idContent, Long idAudit ); @Override List<Long> getSSPFromWebResource(
            Long webResourceId,
            int httpStatusCode,
            int start,
            int chunkSize); @Override List<Long> getRelatedContentFromWebResource(
            Long webResourceId,
            int start,
            int chunkSize); @Override Content readWithRelatedContent(Long id, boolean isFetchParameters); @Override Collection<RelatedContent> findRelatedContentFromAudit(Audit audit); @Override void deleteContentRelationShip(Long relatedContentId); @Override void deleteRelatedContentFromContent(Content content);  }
@Test 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()); }