@Test public void testExecuteWithResults() { final long personId1 = 98; final long personId2 = 42; getEntityManager().clear(); List<Long> peopleIds = sut.execute(new SharedResourceRequest("http: 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 p.id FROM Person p, Activity a WHERE p.accountId = a.actorId " + "AND a.actorType = :actorType AND a.sharedLink.id = :sharedResourceId") .setParameter("actorType", ActorType.PERSON).setParameter("sharedResourceId", sharedResourceId) .getResultList(); return peopleIds; }
GetPeopleWhoSharedResourceDbMapper 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 p.id FROM Person p, Activity a WHERE p.accountId = a.actorId " + "AND a.actorType = :actorType AND a.sharedLink.id = :sharedResourceId") .setParameter("actorType", ActorType.PERSON).setParameter("sharedResourceId", sharedResourceId) .getResultList(); return peopleIds; } }
GetPeopleWhoSharedResourceDbMapper 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 p.id FROM Person p, Activity a WHERE p.accountId = a.actorId " + "AND a.actorType = :actorType AND a.sharedLink.id = :sharedResourceId") .setParameter("actorType", ActorType.PERSON).setParameter("sharedResourceId", sharedResourceId) .getResultList(); return peopleIds; }  }
GetPeopleWhoSharedResourceDbMapper 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 p.id FROM Person p, Activity a WHERE p.accountId = a.actorId " + "AND a.actorType = :actorType AND a.sharedLink.id = :sharedResourceId") .setParameter("actorType", ActorType.PERSON).setParameter("sharedResourceId", sharedResourceId) .getResultList(); return peopleIds; }  @Override @SuppressWarnings("unchecked") List<Long> execute(final SharedResourceRequest inRequest); }
GetPeopleWhoSharedResourceDbMapper 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 p.id FROM Person p, Activity a WHERE p.accountId = a.actorId " + "AND a.actorType = :actorType AND a.sharedLink.id = :sharedResourceId") .setParameter("actorType", ActorType.PERSON).setParameter("sharedResourceId", sharedResourceId) .getResultList(); return peopleIds; }  @Override @SuppressWarnings("unchecked") List<Long> execute(final SharedResourceRequest inRequest);  }