From ca0161ec263b07acdd383e15dfa8e5940fc48803 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 23 Sep 2017 14:09:37 +0200 Subject: [PATCH] Don't cherry-pick: - added lookup attribute to @EJB annotation as some lookup did not work as expected and this is "guranteed" to work (if you have the right JNDI name, of course) - plus all these EJBs can now be more distributed over separate EJB modules allowing a distributed operation over several data centers, awsome words, right? ;-) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../FinancialAdminReceiptSessionBean.java | 23 +++++++++++++++++-- .../receipt/FinancialReceiptSessionBean.java | 9 +------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/java/org/mxchange/jfinancials/model/receipt/FinancialAdminReceiptSessionBean.java b/src/java/org/mxchange/jfinancials/model/receipt/FinancialAdminReceiptSessionBean.java index 021e3bc..5ad1dd6 100644 --- a/src/java/org/mxchange/jfinancials/model/receipt/FinancialAdminReceiptSessionBean.java +++ b/src/java/org/mxchange/jfinancials/model/receipt/FinancialAdminReceiptSessionBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; import java.util.Date; import javax.ejb.EJB; import javax.ejb.Stateless; +import org.mxchange.jcontactsbusiness.model.employee.Employee; import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; import org.mxchange.jfinancials.exceptions.ReceiptAlreadyAddedException; import org.mxchange.jusercore.model.user.User; @@ -40,8 +41,8 @@ public class FinancialAdminReceiptSessionBean extends BaseFinancialsDatabaseBean /** * General receipt bean */ - @EJB - private FinancialReceiptSessionBean receiptBean; + @EJB (lookup = "java:global/jfinancials-ejb/financialReceipt!org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote") + private FinancialReceiptSessionBeanRemote receiptBean; @Override public BillableReceipt addReceipt (final BillableReceipt receipt) throws ReceiptAlreadyAddedException { @@ -84,6 +85,24 @@ public class FinancialAdminReceiptSessionBean extends BaseFinancialsDatabaseBean // Add created instance receipt.setReceiptCreated(new Date()); + // Is user instance set? + if (receipt.getReceiptUser() instanceof User) { + // Then get managed instanced + final User managedUser = this.createManaged(receipt.getReceiptUser()); + + // Set it back + receipt.setReceiptUser(managedUser); + } + + // Is employee instance set? + if (receipt.getReceiptSellerEmployee() instanceof Employee) { + // Then get managed instanced + final Employee managedEmployee = this.createManaged(receipt.getReceiptSellerEmployee()); + + // Set it back + receipt.setReceiptSellerEmployee(managedEmployee); + } + // Persist it this.getEntityManager().persist(receipt); diff --git a/src/java/org/mxchange/jfinancials/model/receipt/FinancialReceiptSessionBean.java b/src/java/org/mxchange/jfinancials/model/receipt/FinancialReceiptSessionBean.java index 84a6228..dbf3f4c 100644 --- a/src/java/org/mxchange/jfinancials/model/receipt/FinancialReceiptSessionBean.java +++ b/src/java/org/mxchange/jfinancials/model/receipt/FinancialReceiptSessionBean.java @@ -143,14 +143,7 @@ public class FinancialReceiptSessionBean extends BaseFinancialsDatabaseBean impl return receipts; } - /** - * Checks if given receipt is already persisted by checking receipt number - * and branch office combination. - *

- * @param receipt Receipt instance - *

- * @return Whether the receipt has already been registered - */ + @Override public boolean isReceiptRegistered (final BillableReceipt receipt) { // Get all receipts final List receipts = this.allReceipts(); -- 2.39.5