@Test public void testExecute() { List<StreamDTO> results = sut.execute(null); Assert.assertEquals(5, results.size()); Assert.assertEquals(EntityType.GROUP, results.get(0).getEntityType()); Assert.assertEquals(10, results.get(0).getFollowersCount()); Assert.assertEquals(3, results.get(0).getId()); Assert.assertEquals(EntityType.GROUP, results.get(1).getEntityType()); Assert.assertEquals(3, results.get(1).getFollowersCount()); Assert.assertEquals(1, results.get(1).getId()); Assert.assertEquals(EntityType.GROUP, results.get(2).getEntityType()); Assert.assertEquals(1, results.get(2).getFollowersCount()); if (results.get(2).getId() == 4) { Assert.assertEquals(4, results.get(2).getId()); Assert.assertEquals(2, results.get(3).getId()); } else { Assert.assertEquals(2, results.get(2).getId()); Assert.assertEquals(4, results.get(3).getId()); } Assert.assertEquals(EntityType.GROUP, results.get(3).getEntityType()); Assert.assertEquals(1, results.get(2).getFollowersCount()); Assert.assertEquals(EntityType.PERSON, results.get(4).getEntityType()); Assert.assertEquals(1, results.get(4).getFollowersCount()); }
@Override public List<StreamDTO> execute(final Serializable inIgnored) { Query q; List<StreamDTO> results = new ArrayList<StreamDTO>(); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(id, accountId, " + "preferredName, lastName, displayName, displayNameSuffix, followersCount, dateAdded, " + "streamScope.id) " + "FROM Person WHERE followersCount > 0 ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending = false AND followersCount > 0 " + "ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); Collections.sort(results, new StreamDTOFollowerCountDescendingComparator()); if (results.size() > streamCount) { results = results.subList(0, streamCount); } return results; }
GetStreamsByFollowersCountDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override public List<StreamDTO> execute(final Serializable inIgnored) { Query q; List<StreamDTO> results = new ArrayList<StreamDTO>(); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(id, accountId, " + "preferredName, lastName, displayName, displayNameSuffix, followersCount, dateAdded, " + "streamScope.id) " + "FROM Person WHERE followersCount > 0 ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending = false AND followersCount > 0 " + "ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); Collections.sort(results, new StreamDTOFollowerCountDescendingComparator()); if (results.size() > streamCount) { results = results.subList(0, streamCount); } return results; } }
GetStreamsByFollowersCountDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override public List<StreamDTO> execute(final Serializable inIgnored) { Query q; List<StreamDTO> results = new ArrayList<StreamDTO>(); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(id, accountId, " + "preferredName, lastName, displayName, displayNameSuffix, followersCount, dateAdded, " + "streamScope.id) " + "FROM Person WHERE followersCount > 0 ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending = false AND followersCount > 0 " + "ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); Collections.sort(results, new StreamDTOFollowerCountDescendingComparator()); if (results.size() > streamCount) { results = results.subList(0, streamCount); } return results; } GetStreamsByFollowersCountDbMapper(final Integer inStreamCount); }
GetStreamsByFollowersCountDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override public List<StreamDTO> execute(final Serializable inIgnored) { Query q; List<StreamDTO> results = new ArrayList<StreamDTO>(); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(id, accountId, " + "preferredName, lastName, displayName, displayNameSuffix, followersCount, dateAdded, " + "streamScope.id) " + "FROM Person WHERE followersCount > 0 ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending = false AND followersCount > 0 " + "ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); Collections.sort(results, new StreamDTOFollowerCountDescendingComparator()); if (results.size() > streamCount) { results = results.subList(0, streamCount); } return results; } GetStreamsByFollowersCountDbMapper(final Integer inStreamCount); @Override List<StreamDTO> execute(final Serializable inIgnored); }
GetStreamsByFollowersCountDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override public List<StreamDTO> execute(final Serializable inIgnored) { Query q; List<StreamDTO> results = new ArrayList<StreamDTO>(); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(id, accountId, " + "preferredName, lastName, displayName, displayNameSuffix, followersCount, dateAdded, " + "streamScope.id) " + "FROM Person WHERE followersCount > 0 ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending = false AND followersCount > 0 " + "ORDER BY followersCount DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } results.addAll(q.getResultList()); Collections.sort(results, new StreamDTOFollowerCountDescendingComparator()); if (results.size() > streamCount) { results = results.subList(0, streamCount); } return results; } GetStreamsByFollowersCountDbMapper(final Integer inStreamCount); @Override List<StreamDTO> execute(final Serializable inIgnored);  }