@Test public void testGetFollowerAndCoordinatorPersonIds() { DomainGroup group = jpaGroupMapper.findById(1); Long[] ids = jpaGroupMapper.getFollowerAndCoordinatorPersonIds(group); List<Long> idsList = Arrays.asList(ids); assertEquals(3, idsList.size()); final long burnsId = 99L; final long smithersId = 98L; final long fordId = 42L; assertTrue(idsList.contains(burnsId)); assertTrue(idsList.contains(smithersId)); assertTrue(idsList.contains(fordId)); }
@SuppressWarnings("unchecked") public Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup) { HashSet<Long> peopleIds = new HashSet<Long>(); Query q = getEntityManager().createQuery("SELECT pk.followerId FROM GroupFollower WHERE followingId=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT p.id FROM Person p, DomainGroup g WHERE p MEMBER OF g.coordinators AND g.id=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); return peopleIds.toArray(new Long[peopleIds.size()]); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { @SuppressWarnings("unchecked") public Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup) { HashSet<Long> peopleIds = new HashSet<Long>(); Query q = getEntityManager().createQuery("SELECT pk.followerId FROM GroupFollower WHERE followingId=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT p.id FROM Person p, DomainGroup g WHERE p MEMBER OF g.coordinators AND g.id=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); return peopleIds.toArray(new Long[peopleIds.size()]); } }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { @SuppressWarnings("unchecked") public Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup) { HashSet<Long> peopleIds = new HashSet<Long>(); Query q = getEntityManager().createQuery("SELECT pk.followerId FROM GroupFollower WHERE followingId=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT p.id FROM Person p, DomainGroup g WHERE p MEMBER OF g.coordinators AND g.id=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); return peopleIds.toArray(new Long[peopleIds.size()]); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { @SuppressWarnings("unchecked") public Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup) { HashSet<Long> peopleIds = new HashSet<Long>(); Query q = getEntityManager().createQuery("SELECT pk.followerId FROM GroupFollower WHERE followingId=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT p.id FROM Person p, DomainGroup g WHERE p MEMBER OF g.coordinators AND g.id=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); return peopleIds.toArray(new Long[peopleIds.size()]); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") DomainGroup findByShortName(final String groupShortName); void addFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String shortName, final int start, final int end); PagedSet<Followable> getFollowing(final String accountId, final int start, final int end); @SuppressWarnings("unchecked") boolean isFollowing(final String followerAccountId, final String shortName); void removeFollower(final long followerId, final long followingId); void removeGroupCoordinator(final long followerId, final long followingId); @SuppressWarnings("unchecked") Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup); void deleteById(final long id); boolean isInputUserGroupCoordinator(final long followerId, final long followingId); boolean isGroupPrivate(final long followingId); int getGroupCoordinatorCount(final long followingId); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { @SuppressWarnings("unchecked") public Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup) { HashSet<Long> peopleIds = new HashSet<Long>(); Query q = getEntityManager().createQuery("SELECT pk.followerId FROM GroupFollower WHERE followingId=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT p.id FROM Person p, DomainGroup g WHERE p MEMBER OF g.coordinators AND g.id=:groupId") .setParameter("groupId", domainGroup.getId()); peopleIds.addAll(q.getResultList()); return peopleIds.toArray(new Long[peopleIds.size()]); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") DomainGroup findByShortName(final String groupShortName); void addFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String shortName, final int start, final int end); PagedSet<Followable> getFollowing(final String accountId, final int start, final int end); @SuppressWarnings("unchecked") boolean isFollowing(final String followerAccountId, final String shortName); void removeFollower(final long followerId, final long followingId); void removeGroupCoordinator(final long followerId, final long followingId); @SuppressWarnings("unchecked") Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup); void deleteById(final long id); boolean isInputUserGroupCoordinator(final long followerId, final long followingId); boolean isGroupPrivate(final long followingId); int getGroupCoordinatorCount(final long followingId);  }