]> git.mxchange.org Git - jjobs-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:43:02 +0000 (21:43 +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/JobsAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java

index 4cbf2d5e59ca06c3f21417f8f17623fff2ba0fc6..315b5a743c3a8a7c040445de79aca64741e07bc0 100644 (file)
@@ -263,7 +263,6 @@ public class JobsAdminUserSessionBean extends BaseJobsDatabaseBean implements Ad
                // Update user
                User managedUser = this.userBean.updateUserData(user);
 
-               // @TODO Create user lock history entry
                // Init variable
                Address emailAddress;
 
index e3cd0fe158e14d4b9033089042fc874493cca02d..b974ffbaca06dd5b886f0ee34f419717abab2a71 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;
@@ -196,4 +197,86 @@ public class JobsUserActivitySessionBean extends BaseDatabaseBean implements Use
                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;
+       }
+
 }