]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 23 Sep 2017 12:09:37 +0000 (14:09 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 23 Sep 2017 12:09:37 +0000 (14:09 +0200)
- 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? ;-)

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/model/receipt/FinancialAdminReceiptSessionBean.java
src/java/org/mxchange/jfinancials/model/receipt/FinancialReceiptSessionBean.java

index 021e3bc33db5dae9a9523983d4458757e3d33b2d..5ad1dd638dc2fb8a63c886dc275d2f2fff5f6e3a 100644 (file)
@@ -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);
 
index 84a6228a8abbbdbccba14b0f91766c134034f4c4..dbf3f4c3057703a4329138ef78c50e88eee1f0c6 100644 (file)
@@ -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.
-        * <p>
-        * @param receipt Receipt instance
-        * <p>
-        * @return Whether the receipt has already been registered
-        */
+       @Override
        public boolean isReceiptRegistered (final BillableReceipt receipt) {
                // Get all receipts
                final List<BillableReceipt> receipts = this.allReceipts();