]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Thu, 1 Sep 2016 15:34:20 +0000 (17:34 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 1 Sep 2016 19:42:59 +0000 (21:42 +0200)
- close internal TODO as the user-actiity-log can be used for this
- for this making easily to work, 2 new business methods have been added
- fetchAllUsersActivityLogByType() for a single type per user
- fetchAllUsersActivityLogByMultipleType() for multiple types per user

src/java/org/mxchange/jusercore/model/user/PizzaAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivitySessionBean.java

index 937fea9050b1daebb50eb94273a9ad6a84058fe5..526edd8c851c851d3fb45707e15f21a5d5a12bef 100644 (file)
@@ -263,7 +263,6 @@ public class PizzaAdminUserSessionBean extends BasePizzaDatabaseBean implements
                // Update user
                User managedUser = this.userBean.updateUserData(user);
 
-               // @TODO Create user lock history entry
                // Init variable
                Address emailAddress;
 
index f977e4f5a51d2334894d5d4619f5a7d0fa357821..1e44846fee5af50dd95212684a28f27fcaba4468 100644 (file)
@@ -17,6 +17,7 @@
 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;
@@ -197,4 +198,86 @@ public class PizzaUserActivitySessionBean extends BaseDatabaseBean implements Us
                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;
+       }
+
 }