]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Wed, 24 Aug 2016 15:52:34 +0000 (17:52 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 24 Aug 2016 19:36:41 +0000 (21:36 +0200)
- added EJB for user activity log
- opps, missed this file updating ...

Signed-off-by: Roland Häder <roland@mxchange.org>
nbproject/project.properties
src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java [new file with mode: 0644]

index 8df765fe73013edcd053e1e0c1f217f7b9c2c6bb..5f23680a77ec95d42afe482baa33457dd6a9bb1e 100644 (file)
@@ -39,6 +39,8 @@ file.reference.jphone-core.jar=lib/jphone-core.jar
 file.reference.jphone-lib.jar=lib/jphone-lib.jar
 file.reference.juser-core.jar=lib/juser-core.jar
 file.reference.juser-lib.jar=lib/juser-lib.jar
+file.reference.juser-activity-core.jar=lib/juser-activity-core.jar
+file.reference.juser-activity-lib.jar=lib/juser-activity-lib.jar
 includes=**
 j2ee.compile.on.save=true
 j2ee.deploy.on.save=true
@@ -65,6 +67,8 @@ javac.classpath=\
     ${file.reference.jphone-lib.jar}:\
     ${file.reference.juser-core.jar}:\
     ${file.reference.juser-lib.jar}:\
+    ${file.reference.juser-activity-core.jar}:\
+    ${file.reference.juser-activity-lib.jar}:\
     ${file.reference.jletter-lib.jar}:\
     ${file.reference.jaddressbook-core.jar}:\
     ${file.reference.jaddressbook-lib.jar}:\
@@ -101,7 +105,6 @@ meta.inf.excludes=sun-cmp-mappings.xml
 platform.active=default_platform
 project.jjobs-lib=../jjobs-lib
 project.jjobs-mailer=../jjobs-mailer
-project.juser-core=../juser-core
 project.license=agpl30
 project.serviceLocator.class=org.mxchange.jjobs.mailer.model.delivery.JobsMailer
 reference.jjobs-lib.jar=${project.jjobs-lib}/dist/jjobs-lib.jar
@@ -131,6 +134,8 @@ source.reference.jphone-core.jar=../jphone-core/src/
 source.reference.jphone-lib.jar=../jphone-lib/src/
 source.reference.juser-core.jar=../juser-core/src/
 source.reference.juser-lib.jar=../juser-lib/src/
+source.reference.juser-activity-core.jar=../juser-activity-core/src/
+source.reference.juser-activity-lib.jar=../juser-activity-lib/src/
 source.root=src
 src.dir=${source.root}/java
 test.src.dir=test
diff --git a/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java b/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java
new file mode 100644 (file)
index 0000000..8d0ee4a
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.user.activity;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.Query;
+import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An EJB for user activity log
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@Stateless (name = "userActivity", description = "A bean handling the user data")
+public class JobsUserActivitySessionBean extends BaseJobsDatabaseBean implements UserActivityLogSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 219_568_677_671_054L;
+
+       /**
+        * Default constructor
+        */
+       public JobsUserActivitySessionBean () {
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<LogableUserActivity> fetchAllUsersActivityLog (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLog: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //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
+               }
+
+               // Search for user's activity
+               Query query = this.getEntityManager().createNamedQuery("FindAllUsersActivity", UserActivityLog.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("activityUser", user); //NOI18N
+
+               // Get list
+               List<LogableUserActivity> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLog: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+}