@Test public void testFind() { Audit audit = auditDAO.read(Long.valueOf(1)); assertNull(contentDAO.find(audit, "http: assertNull(contentDAO.find(audit, "http: audit = auditDAO.read(Long.valueOf(3)); assertEquals(Long.valueOf(10), contentDAO.find(audit, "http: assertNull(contentDAO.find(audit, "http: WebResource wr = webresourceDAO.read(Long.valueOf(6)); assertEquals(Long.valueOf(2), contentDAO.find(wr, "http: wr = webresourceDAO.read(Long.valueOf(5)); assertNull(contentDAO.find(wr, "http: }
@Override public Content find(Audit audit, String uri) { Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode"); query.setParameter(AUDIT_KEY, audit); query.setParameter("uri", uri); query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK); try { return (Content) query.getSingleResult(); } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { List<Content> queryResult = query.getResultList(); for (Content content : queryResult) { if (StringUtils.equals(content.getURI(),uri)) { return content; } } return null; } }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Content find(Audit audit, String uri) { Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode"); query.setParameter(AUDIT_KEY, audit); query.setParameter("uri", uri); query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK); try { return (Content) query.getSingleResult(); } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { List<Content> queryResult = query.getResultList(); for (Content content : queryResult) { if (StringUtils.equals(content.getURI(),uri)) { return content; } } return null; } } }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Content find(Audit audit, String uri) { Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode"); query.setParameter(AUDIT_KEY, audit); query.setParameter("uri", uri); query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK); try { return (Content) query.getSingleResult(); } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { List<Content> queryResult = query.getResultList(); for (Content content : queryResult) { if (StringUtils.equals(content.getURI(),uri)) { return content; } } return null; } } ContentDAOImpl(); }
ContentDAOImpl extends AbstractJPADAO<Content, Long> implements
        ContentDAO { @Override public Content find(Audit audit, String uri) { Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode"); query.setParameter(AUDIT_KEY, audit); query.setParameter("uri", uri); query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK); try { return (Content) query.getSingleResult(); } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { List<Content> queryResult = query.getResultList(); for (Content content : queryResult) { if (StringUtils.equals(content.getURI(),uri)) { return content; } } return null; } } 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 Content find(Audit audit, String uri) { Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode"); query.setParameter(AUDIT_KEY, audit); query.setParameter("uri", uri); query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK); try { return (Content) query.getSingleResult(); } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { List<Content> queryResult = query.getResultList(); for (Content content : queryResult) { if (StringUtils.equals(content.getURI(),uri)) { return content; } } return null; } } 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);  }