From: Roland Häder Date: Wed, 24 Aug 2016 15:52:34 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ee3a7e445d08b70ee4c9032ea68512b8fd37f40;p=pizzaservice-ejb.git Please cherry-pick: - added EJB for user activity log - opps, missed this file updating ... Signed-off-by: Roland Häder --- diff --git a/nbproject/project.properties b/nbproject/project.properties index 01d5ce7..8e307b4 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -37,6 +37,8 @@ file.reference.jshop-core.jar=lib/jshop-core.jar file.reference.jshop-ee-lib.jar=lib/jshop-ee-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 file.reference.pizzaservice-core.jar=lib/pizzaservice-core.jar file.reference.pizzaservice-mailer.jar=lib/pizzaservice-mailer.jar includes=** @@ -62,6 +64,8 @@ javac.classpath=\ ${file.reference.jcontacts-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.jcustomer-core.jar}:\ ${file.reference.jcustomer-lib.jar}:\ ${file.reference.jphone-core.jar}:\ @@ -99,7 +103,6 @@ javadoc.windowtitle=Pizza-Service EJBs meta.inf=${source.root}/conf meta.inf.excludes=sun-cmp-mappings.xml platform.active=default_platform -project.juser-core=../juser-core project.license=agpl30 project.pizzaservice-lib=../pizzaservice-lib project.pizzaservice-mailer=../../NetBeansProjects/pizzaservice-mailer @@ -129,6 +132,8 @@ source.reference.jshop-core.jar=../../jshop-core/src/ source.reference.jshop-ee-lib.jar=../../jshop-ee-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.reference.pizzaservice-core.jar=../pizzaservice-core/src/ source.reference.pizzaservice-mailer.jar=../pizzaservice-mailer/src/ source.root=src diff --git a/src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivitySessionBean.java b/src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivitySessionBean.java new file mode 100644 index 0000000..6d0de6d --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/user/activity/PizzaUserActivitySessionBean.java @@ -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 . + */ +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.jusercore.model.user.User; +import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; + +/** + * An EJB for user activity log + *

+ * @author Roland Haeder + */ +@Stateless (name = "userActivity", description = "A bean handling the user data") +public class PizzaUserActivitySessionBean extends BasePizzaDatabaseBean implements UserActivityLogSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 219_568_677_671_054L; + + /** + * Default constructor + */ + public PizzaUserActivitySessionBean () { + } + + @Override + @SuppressWarnings ("unchecked") + public List 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 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; + } + +}