@Test public void testExecute() { Calendar cal = Calendar.getInstance(); System.out.println("TIME: " + cal.getTime()); getEntityManager().createQuery("UPDATE DomainGroup SET dateAdded = :dateAdded WHERE id=:id").setParameter( "id", 5L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE Person SET dateAdded = :dateAdded WHERE id=:id").setParameter("id", 4507L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE DomainGroup SET dateAdded = :dateAdded WHERE id=:id").setParameter( "id", 7L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE DomainGroup SET dateAdded = :dateAdded WHERE id=:id").setParameter( "id", 1L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE Person SET dateAdded = :dateAdded WHERE id=:id") .setParameter("id", 99L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE DomainGroup SET dateAdded = :dateAdded WHERE id=:id").setParameter( "id", 2L).setParameter("dateAdded", cal.getTime()).executeUpdate(); getEntityManager().createQuery("UPDATE Person SET dateAdded = :dateAdded WHERE id=:id") .setParameter("id", 42L).setParameter("dateAdded", cal.getTime()).executeUpdate(); cal.add(Calendar.HOUR, -1); getEntityManager().createQuery("UPDATE DomainGroup SET dateAdded = :dateAdded WHERE id=:id").setParameter( "id", 3L).setParameter("dateAdded", cal.getTime()).executeUpdate(); getEntityManager().clear(); List<StreamDTO> results = sut.execute(null); for (StreamDTO result : results) { System.out.println(result.getEntityType() + " - " + result.getId() + " " + result.getDateAdded()); } Assert.assertEquals(4, results.size()); Assert.assertEquals(EntityType.GROUP, results.get(0).getEntityType()); Assert.assertEquals(5, results.get(0).getId()); Assert.assertEquals(EntityType.GROUP, results.get(1).getEntityType()); Assert.assertEquals(1, results.get(1).getId()); Assert.assertEquals(EntityType.GROUP, results.get(2).getEntityType()); Assert.assertEquals(2, results.get(2).getId()); Assert.assertEquals(EntityType.GROUP, results.get(3).getEntityType()); Assert.assertEquals(3, results.get(3).getId()); }
@Override @SuppressWarnings("unchecked") public List<StreamDTO> execute(final Serializable inIgnored) { Query q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending=false ORDER BY dateAdded DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } return q.getResultList(); }
GetStreamsByMostRecentDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override @SuppressWarnings("unchecked") public List<StreamDTO> execute(final Serializable inIgnored) { Query q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending=false ORDER BY dateAdded DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } return q.getResultList(); } }
GetStreamsByMostRecentDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override @SuppressWarnings("unchecked") public List<StreamDTO> execute(final Serializable inIgnored) { Query q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending=false ORDER BY dateAdded DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } return q.getResultList(); } GetStreamsByMostRecentDbMapper(final Integer inStreamCount); }
GetStreamsByMostRecentDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override @SuppressWarnings("unchecked") public List<StreamDTO> execute(final Serializable inIgnored) { Query q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending=false ORDER BY dateAdded DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } return q.getResultList(); } GetStreamsByMostRecentDbMapper(final Integer inStreamCount); @Override @SuppressWarnings("unchecked") List<StreamDTO> execute(final Serializable inIgnored); }
GetStreamsByMostRecentDbMapper extends BaseArgDomainMapper<Serializable, List<StreamDTO>> { @Override @SuppressWarnings("unchecked") public List<StreamDTO> execute(final Serializable inIgnored) { Query q = getEntityManager().createQuery( "SELECT new org.eurekastreams.server.search.modelview.DomainGroupModelView(id, " + "shortName, name, followersCount, dateAdded, streamScope.id, publicGroup) " + "FROM DomainGroup WHERE isPending=false ORDER BY dateAdded DESC"); if (streamCount > 0) { q.setMaxResults(streamCount).getResultList(); } return q.getResultList(); } GetStreamsByMostRecentDbMapper(final Integer inStreamCount); @Override @SuppressWarnings("unchecked") List<StreamDTO> execute(final Serializable inIgnored);  }