@Test 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)); }
@Override public Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode) { if (webResource != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_DISTINCT_SSP); strb.append(SSPImpl.class.getName()); strb.append(" s"); strb.append(JOIN_WR); if (webResource instanceof Page) { strb.append(" WHERE w.id=:idWebResource"); } else if (webResource instanceof Site) { strb.append(" WHERE w.parent.id=:idWebResource"); } if (httpStatusCode != -1) { strb.append(HTTP_STATUS_CONDITION); } else { strb.append(" AND s.httpStatusCode!=:httpStatusCode"); } Query query = entityManager.createQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResource.getId()); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); return (Long) query.getSingleResult(); } else { return (long) 0; } }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode) { if (webResource != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_DISTINCT_SSP); strb.append(SSPImpl.class.getName()); strb.append(" s"); strb.append(JOIN_WR); if (webResource instanceof Page) { strb.append(" WHERE w.id=:idWebResource"); } else if (webResource instanceof Site) { strb.append(" WHERE w.parent.id=:idWebResource"); } if (httpStatusCode != -1) { strb.append(HTTP_STATUS_CONDITION); } else { strb.append(" AND s.httpStatusCode!=:httpStatusCode"); } Query query = entityManager.createQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResource.getId()); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); return (Long) query.getSingleResult(); } else { return (long) 0; } } }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode) { if (webResource != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_DISTINCT_SSP); strb.append(SSPImpl.class.getName()); strb.append(" s"); strb.append(JOIN_WR); if (webResource instanceof Page) { strb.append(" WHERE w.id=:idWebResource"); } else if (webResource instanceof Site) { strb.append(" WHERE w.parent.id=:idWebResource"); } if (httpStatusCode != -1) { strb.append(HTTP_STATUS_CONDITION); } else { strb.append(" AND s.httpStatusCode!=:httpStatusCode"); } Query query = entityManager.createQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResource.getId()); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); return (Long) query.getSingleResult(); } else { return (long) 0; } } ContentDAOImpl(); }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode) { if (webResource != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_DISTINCT_SSP); strb.append(SSPImpl.class.getName()); strb.append(" s"); strb.append(JOIN_WR); if (webResource instanceof Page) { strb.append(" WHERE w.id=:idWebResource"); } else if (webResource instanceof Site) { strb.append(" WHERE w.parent.id=:idWebResource"); } if (httpStatusCode != -1) { strb.append(HTTP_STATUS_CONDITION); } else { strb.append(" AND s.httpStatusCode!=:httpStatusCode"); } Query query = entityManager.createQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResource.getId()); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); return (Long) query.getSingleResult(); } else { return (long) 0; } } 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); }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Long findNumberOfSSPFromWebResource(WebResource webResource, int httpStatusCode) { if (webResource != null) { StringBuilder strb = new StringBuilder(); strb.append(SELECT_DISTINCT_SSP); strb.append(SSPImpl.class.getName()); strb.append(" s"); strb.append(JOIN_WR); if (webResource instanceof Page) { strb.append(" WHERE w.id=:idWebResource"); } else if (webResource instanceof Site) { strb.append(" WHERE w.parent.id=:idWebResource"); } if (httpStatusCode != -1) { strb.append(HTTP_STATUS_CONDITION); } else { strb.append(" AND s.httpStatusCode!=:httpStatusCode"); } Query query = entityManager.createQuery(strb.toString()); query.setParameter(ID_WEB_RESOURCE_KEY, webResource.getId()); query.setParameter(HTTP_STATUS_CODE_KEY, httpStatusCode); return (Long) query.getSingleResult(); } else { return (long) 0; } } 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);  }