@Test public void testExecuteWithResultsBySharedResourceId() { final Long personId1 = 42L; final Long personId2 = 99L; List<Long> peopleIds = sut.execute(new SharedResourceRequest(new Long(5), null)); assertEquals(2, peopleIds.size()); assertTrue(peopleIds.contains(personId1)); assertTrue(peopleIds.contains(personId2)); }
@Override @SuppressWarnings("unchecked") public List<Long> execute(final SharedResourceRequest inRequest) { Long sharedResourceId = null; if (inRequest.getSharedResourceId() != null && inRequest.getSharedResourceId() > 0) { sharedResourceId = inRequest.getSharedResourceId(); } else { List<Long> sharedResourceIds = getEntityManager() .createQuery("SELECT id FROM SharedResource WHERE uniqueKey = :uniqueKey") .setParameter("uniqueKey", inRequest.getUniqueKey().toLowerCase()).setMaxResults(1).getResultList(); if (sharedResourceIds.size() == 0) { return new ArrayList<Long>(); } sharedResourceId = sharedResourceIds.get(0); } List<Long> peopleIds = getEntityManager() .createQuery( "SELECT DISTINCT pk.personId FROM LikedSharedResource " + "WHERE pk.sharedResourceId = :sharedResourceId") .setParameter("sharedResourceId", sharedResourceId).getResultList(); return peopleIds; }
GetPeopleWhoLikedResourceDbMapper extends BaseArgDomainMapper<SharedResourceRequest, List<Long>> { @Override @SuppressWarnings("unchecked") public List<Long> execute(final SharedResourceRequest inRequest) { Long sharedResourceId = null; if (inRequest.getSharedResourceId() != null && inRequest.getSharedResourceId() > 0) { sharedResourceId = inRequest.getSharedResourceId(); } else { List<Long> sharedResourceIds = getEntityManager() .createQuery("SELECT id FROM SharedResource WHERE uniqueKey = :uniqueKey") .setParameter("uniqueKey", inRequest.getUniqueKey().toLowerCase()).setMaxResults(1).getResultList(); if (sharedResourceIds.size() == 0) { return new ArrayList<Long>(); } sharedResourceId = sharedResourceIds.get(0); } List<Long> peopleIds = getEntityManager() .createQuery( "SELECT DISTINCT pk.personId FROM LikedSharedResource " + "WHERE pk.sharedResourceId = :sharedResourceId") .setParameter("sharedResourceId", sharedResourceId).getResultList(); return peopleIds; } }
GetPeopleWhoLikedResourceDbMapper extends BaseArgDomainMapper<SharedResourceRequest, List<Long>> { @Override @SuppressWarnings("unchecked") public List<Long> execute(final SharedResourceRequest inRequest) { Long sharedResourceId = null; if (inRequest.getSharedResourceId() != null && inRequest.getSharedResourceId() > 0) { sharedResourceId = inRequest.getSharedResourceId(); } else { List<Long> sharedResourceIds = getEntityManager() .createQuery("SELECT id FROM SharedResource WHERE uniqueKey = :uniqueKey") .setParameter("uniqueKey", inRequest.getUniqueKey().toLowerCase()).setMaxResults(1).getResultList(); if (sharedResourceIds.size() == 0) { return new ArrayList<Long>(); } sharedResourceId = sharedResourceIds.get(0); } List<Long> peopleIds = getEntityManager() .createQuery( "SELECT DISTINCT pk.personId FROM LikedSharedResource " + "WHERE pk.sharedResourceId = :sharedResourceId") .setParameter("sharedResourceId", sharedResourceId).getResultList(); return peopleIds; }  }
GetPeopleWhoLikedResourceDbMapper extends BaseArgDomainMapper<SharedResourceRequest, List<Long>> { @Override @SuppressWarnings("unchecked") public List<Long> execute(final SharedResourceRequest inRequest) { Long sharedResourceId = null; if (inRequest.getSharedResourceId() != null && inRequest.getSharedResourceId() > 0) { sharedResourceId = inRequest.getSharedResourceId(); } else { List<Long> sharedResourceIds = getEntityManager() .createQuery("SELECT id FROM SharedResource WHERE uniqueKey = :uniqueKey") .setParameter("uniqueKey", inRequest.getUniqueKey().toLowerCase()).setMaxResults(1).getResultList(); if (sharedResourceIds.size() == 0) { return new ArrayList<Long>(); } sharedResourceId = sharedResourceIds.get(0); } List<Long> peopleIds = getEntityManager() .createQuery( "SELECT DISTINCT pk.personId FROM LikedSharedResource " + "WHERE pk.sharedResourceId = :sharedResourceId") .setParameter("sharedResourceId", sharedResourceId).getResultList(); return peopleIds; }  @Override @SuppressWarnings("unchecked") List<Long> execute(final SharedResourceRequest inRequest); }
GetPeopleWhoLikedResourceDbMapper extends BaseArgDomainMapper<SharedResourceRequest, List<Long>> { @Override @SuppressWarnings("unchecked") public List<Long> execute(final SharedResourceRequest inRequest) { Long sharedResourceId = null; if (inRequest.getSharedResourceId() != null && inRequest.getSharedResourceId() > 0) { sharedResourceId = inRequest.getSharedResourceId(); } else { List<Long> sharedResourceIds = getEntityManager() .createQuery("SELECT id FROM SharedResource WHERE uniqueKey = :uniqueKey") .setParameter("uniqueKey", inRequest.getUniqueKey().toLowerCase()).setMaxResults(1).getResultList(); if (sharedResourceIds.size() == 0) { return new ArrayList<Long>(); } sharedResourceId = sharedResourceIds.get(0); } List<Long> peopleIds = getEntityManager() .createQuery( "SELECT DISTINCT pk.personId FROM LikedSharedResource " + "WHERE pk.sharedResourceId = :sharedResourceId") .setParameter("sharedResourceId", sharedResourceId).getResultList(); return peopleIds; }  @Override @SuppressWarnings("unchecked") List<Long> execute(final SharedResourceRequest inRequest);  }