package org.mxchange.jusercore.model.user.activity;
import java.text.MessageFormat;
+import java.util.Arrays;
import java.util.List;
import javax.ejb.EJBException;
import javax.ejb.Stateless;
return list;
}
+ @Override
+ @SuppressWarnings ("unchecked")
+ public List<LogableUserActivity> fetchAllUsersActivityLogByMultipleType (final User user, final String[] activityTypes) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityTypes={2} - CALLED!", this.getClass().getSimpleName(), user, activityTypes)); //NOI18N
+
+ // Is user valid?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId{0} is not valid", user.getUserId())); //NOI18N
+ } else if (null == activityTypes) {
+ // Throw NPE again
+ throw new NullPointerException("activityTypes is null"); //NOI18N
+ } else if (activityTypes.length == 0) {
+ // Should not be empty
+ throw new IllegalArgumentException("activityTypes is empty"); //NOI18N
+ }
+
+ // Search for user's activity
+ Query query = this.getEntityManager().createNamedQuery("FindUsersActivityByMultipleTypes", UserActivityLog.class); //NOI18N
+
+ // Set parameters
+ query.setParameter("activityUser", user); //NOI18N
+ query.setParameter("activityTypes", Arrays.asList(activityTypes)); //NOI18N
+
+ // Get list
+ List<LogableUserActivity> list = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+ // Return it
+ return list;
+ }
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public List<LogableUserActivity> fetchAllUsersActivityLogByType (final User user, final String activityType) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityType={2} - CALLED!", this.getClass().getSimpleName(), user, activityType)); //NOI18N
+
+ // Is user valid?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId{0} is not valid", user.getUserId())); //NOI18N
+ } else if (null == activityType) {
+ // Throw NPE again
+ throw new NullPointerException("activityType is null"); //NOI18N
+ } else if (activityType.isEmpty()) {
+ // Should not be empty
+ throw new IllegalArgumentException("activityType is empty"); //NOI18N
+ }
+
+ // Search for user's activity
+ Query query = this.getEntityManager().createNamedQuery("FindUsersActivityByType", UserActivityLog.class); //NOI18N
+
+ // Set parameters
+ query.setParameter("activityUser", user); //NOI18N
+ query.setParameter("activityType", activityType); //NOI18N
+
+ // Get list
+ List<LogableUserActivity> list = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+ // Return it
+ return list;
+ }
+
}