use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.
the class UserTrackingServiceImpl method getUserActionsByTypeAndMediapackageId.
public UserActionList getUserActionsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit) {
UserActionList result = new UserActionListImpl();
result.setTotal(getTotal(type, mediapackageId));
result.setOffset(offset);
result.setLimit(limit);
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("findUserActionsByTypeAndMediapackageId");
q.setParameter("type", type);
q.setParameter("mediapackageId", mediapackageId);
q.setFirstResult(offset);
if (limit > 0)
q.setMaxResults(limit);
@SuppressWarnings("unchecked") Collection<UserAction> userActions = q.getResultList();
for (UserAction a : userActions) {
result.add(a);
}
return result;
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.
the class UserTrackingServiceImpl method getUserActionsByTypeAndMediapackageIdByDate.
public UserActionList getUserActionsByTypeAndMediapackageIdByDate(String type, String mediapackageId, int offset, int limit) {
UserActionList result = new UserActionListImpl();
result.setTotal(getTotal(type, mediapackageId));
result.setOffset(offset);
result.setLimit(limit);
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("findUserActionsByMediaPackageAndTypeAscendingByDate");
q.setParameter("type", type);
q.setParameter("mediapackageId", mediapackageId);
q.setFirstResult(offset);
if (limit > 0)
q.setMaxResults(limit);
@SuppressWarnings("unchecked") Collection<UserAction> userActions = q.getResultList();
for (UserAction a : userActions) {
result.add(a);
}
return result;
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.
the class UserTrackingServiceImpl method getUserActionsByDay.
@SuppressWarnings("unchecked")
public UserActionList getUserActionsByDay(String day, int offset, int limit) {
UserActionList result = new UserActionListImpl();
int year = Integer.parseInt(day.substring(0, 4));
int month = Integer.parseInt(day.substring(4, 6)) - 1;
int date = Integer.parseInt(day.substring(6, 8));
Calendar calBegin = new GregorianCalendar();
calBegin.set(year, month, date, 0, 0);
Calendar calEnd = new GregorianCalendar();
calEnd.set(year, month, date, 23, 59);
result.setTotal(getTotal(calBegin, calEnd));
result.setOffset(offset);
result.setLimit(limit);
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("findUserActionsByIntervall");
q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
q.setFirstResult(offset);
if (limit > 0)
q.setMaxResults(limit);
Collection<UserAction> userActions = q.getResultList();
for (UserAction a : userActions) {
result.add(a);
}
return result;
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.
the class UserTrackingServiceImpl method getUserActionsByTypeAndDay.
@SuppressWarnings("unchecked")
public UserActionList getUserActionsByTypeAndDay(String type, String day, int offset, int limit) {
UserActionList result = new UserActionListImpl();
int year = Integer.parseInt(day.substring(0, 4));
int month = Integer.parseInt(day.substring(4, 6)) - 1;
int date = Integer.parseInt(day.substring(6, 8));
Calendar calBegin = new GregorianCalendar();
calBegin.set(year, month, date, 0, 0);
Calendar calEnd = new GregorianCalendar();
calEnd.set(year, month, date, 23, 59);
result.setTotal(getTotal(type, calBegin, calEnd));
result.setOffset(offset);
result.setLimit(limit);
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("findUserActionsByTypeAndIntervall");
q.setParameter("type", type);
q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
q.setFirstResult(offset);
if (limit > 0)
q.setMaxResults(limit);
Collection<UserAction> userActions = q.getResultList();
for (UserAction a : userActions) {
result.add(a);
}
return result;
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.
the class UserTrackingServiceImpl method getUserActions.
@SuppressWarnings("unchecked")
public UserActionList getUserActions(int offset, int limit) {
UserActionList result = new UserActionListImpl();
result.setTotal(getTotal());
result.setOffset(offset);
result.setLimit(limit);
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("findUserActions");
q.setFirstResult(offset);
if (limit > 0)
q.setMaxResults(limit);
Collection<UserAction> userActions = q.getResultList();
for (UserAction a : userActions) {
result.add(a);
}
return result;
} finally {
if (em != null && em.isOpen()) {
em.close();
}
}
}
Aggregations