@Test public void testBasicUserActionLists() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(1, 0, 0, 1); verifyUserActionLists(1, 0, 1, 1); verifyUserActionLists(0, 1, 0, 1); verifyUserActionLists(0, 1, 1, 1); verifyUserActionLists(1, 0, 10, 1); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 20, 30); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(1, 0, 0, 1); verifyUserActionLists(1, 0, 1, 1); verifyUserActionLists(0, 1, 0, 1); verifyUserActionLists(0, 1, 1, 1); verifyUserActionLists(1, 0, 10, 1); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 40, 50); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(2, 0, 0, 2); verifyUserActionLists(1, 0, 1, 2); verifyUserActionLists(1, 1, 0, 2); verifyUserActionLists(1, 1, 1, 2); verifyUserActionLists(2, 0, 10, 2); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 50, 60); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(2, 0, 0, 2); verifyUserActionLists(1, 0, 1, 2); verifyUserActionLists(1, 1, 0, 2); verifyUserActionLists(1, 1, 1, 2); verifyUserActionLists(2, 0, 10, 2); }
public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } }
UserTrackingServiceImpl implements UserTrackingService, ManagedService { public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } } }
UserTrackingServiceImpl implements UserTrackingService, ManagedService { public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } }  }
UserTrackingServiceImpl implements UserTrackingService, ManagedService { public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } }  void activate(); @Override void updated(Dictionary props); int getViews(String mediapackageId); @SuppressWarnings("unchecked") UserAction addUserFootprint(UserAction a, UserSession session); UserAction addUserTrackingEvent(UserAction a, UserSession session); @SuppressWarnings("unchecked") UserActionList getUserActions(int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByType(String type, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByTypeAndDay(String type, String day, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDate(String type, String mediapackageId, int offset,
          int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDescendingDate(String type, String mediapackageId,
          int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByDay(String day, int offset, int limit); Report getReport(int offset, int limit); Report getReport(String from, String to, int offset, int limit); FootprintList getFootprints(String mediapackageId, String userId); @Override UserAction getUserAction(Long id); @Override boolean getUserTrackingEnabled(); }
UserTrackingServiceImpl implements UserTrackingService, ManagedService { public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } }  void activate(); @Override void updated(Dictionary props); int getViews(String mediapackageId); @SuppressWarnings("unchecked") UserAction addUserFootprint(UserAction a, UserSession session); UserAction addUserTrackingEvent(UserAction a, UserSession session); @SuppressWarnings("unchecked") UserActionList getUserActions(int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByType(String type, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByTypeAndDay(String type, String day, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDate(String type, String mediapackageId, int offset,
          int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDescendingDate(String type, String mediapackageId,
          int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByDay(String day, int offset, int limit); Report getReport(int offset, int limit); Report getReport(String from, String to, int offset, int limit); FootprintList getFootprints(String mediapackageId, String userId); @Override UserAction getUserAction(Long id); @Override boolean getUserTrackingEnabled(); static final String PERSISTENCE_UNIT; static final String FOOTPRINT_KEY; static final String DETAILED_TRACKING; static final String IP_LOGGING; static final String USER_LOGGING; static final String SESSION_LOGGING; }