From: Roland Haeder Date: Fri, 9 Oct 2015 12:47:36 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=23f5b8f99433dc1f569df9538078a840495e6084;p=jbonuscard-lib.git Continued: - added business method getUsersList() - exposed all POJO's fields/attributes in its POJI - added named query for finding user's address books Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/addressbook/model/addressbook/Addressbook.java b/src/org/mxchange/addressbook/model/addressbook/Addressbook.java index 26a60b1..9b03baa 100644 --- a/src/org/mxchange/addressbook/model/addressbook/Addressbook.java +++ b/src/org/mxchange/addressbook/model/addressbook/Addressbook.java @@ -17,6 +17,9 @@ package org.mxchange.addressbook.model.addressbook; import java.io.Serializable; +import java.util.Calendar; +import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus; +import org.mxchange.jusercore.model.user.User; /** * A POJI for addressbooks @@ -39,4 +42,59 @@ public interface Addressbook extends Serializable { */ public void setAddressbookId (final Long addressbookId); + /** + * Getter for addressbook creation timestamp + *

+ * @return Addressbook creation timestamp + */ + public Calendar getAddressbookCreated (); + + /** + * Setter for addressbook creation timestamp + *

+ * @param addressbookCreated Addressbook creation timestamp + */ + public void setAddressbookCreated (final Calendar addressbookCreated); + + /** + * Getter for addressbook's name + *

+ * @return Addressbook's name + */ + public String getAddressbookName (); + + /** + * Setter for addressbook's name + *

+ * @param addressbookName Addressbook's name + */ + public void setAddressbookName (final String addressbookName); + + /** + * Getter for addressbook status + *

+ * @return Addressbook status + */ + public AddressbokStatus getAddressbookStatus (); + + /** + * Setter for addressbook status + *

+ * @param addressbookStatus Addressbook status + */ + public void setAddressbookStatus (final AddressbokStatus addressbookStatus); + + /** + * Getter for addressbook's user (owner) + *

+ * @return Addressbook's user (owner) + */ + public User getAddressbookUser (); + + /** + * Setter for addressbook's user (owner) + *

+ * @param addressbookUser Addressbook's user (owner) + */ + public void setAddressbookUser (final User addressbookUser); } diff --git a/src/org/mxchange/addressbook/model/addressbook/AddressbookSessionBeanRemote.java b/src/org/mxchange/addressbook/model/addressbook/AddressbookSessionBeanRemote.java index d0806bd..b8f3c43 100644 --- a/src/org/mxchange/addressbook/model/addressbook/AddressbookSessionBeanRemote.java +++ b/src/org/mxchange/addressbook/model/addressbook/AddressbookSessionBeanRemote.java @@ -17,7 +17,9 @@ package org.mxchange.addressbook.model.addressbook; import java.io.Serializable; +import java.util.List; import javax.ejb.Remote; +import org.mxchange.jusercore.model.user.User; /** * A remote session interface for addressbook handling @@ -26,4 +28,12 @@ import javax.ejb.Remote; */ @Remote public interface AddressbookSessionBeanRemote extends Serializable { + + /** + * Some "getter" for a list of address books the logged-in user has created + *

+ * @param loggedInUser Logged-in user + * @return List of all address books + */ + public List getUsersList (final User loggedInUser); } diff --git a/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java b/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java index b2d8ee4..730e949 100644 --- a/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java +++ b/src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java @@ -27,6 +27,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; @@ -42,6 +44,11 @@ import org.mxchange.jusercore.model.user.User; */ @Entity (name = "addressbooks") @Table (name = "addressbooks") +@NamedQueries ( + { + @NamedQuery (name = "AllUsersAddressbooks", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :param ORDER BY a.addressbookId ASC") + } +) public class UserAddressbook implements Addressbook, Comparable { /** @@ -92,6 +99,16 @@ public class UserAddressbook implements Addressbook, Comparable { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public Calendar getAddressbookCreated () { + return this.addressbookCreated; + } + + @Override + public void setAddressbookCreated (final Calendar addressbookCreated) { + this.addressbookCreated = addressbookCreated; + } + @Override public Long getAddressbookId () { return this.addressbookId; @@ -102,4 +119,33 @@ public class UserAddressbook implements Addressbook, Comparable { this.addressbookId = addressbookId; } + @Override + public String getAddressbookName () { + return this.addressbookName; + } + + @Override + public void setAddressbookName (final String addressbookName) { + this.addressbookName = addressbookName; + } + + @Override + public AddressbokStatus getAddressbookStatus () { + return this.addressbookStatus; + } + + @Override + public void setAddressbookStatus (final AddressbokStatus addressbookStatus) { + this.addressbookStatus = addressbookStatus; + } + + @Override + public User getAddressbookUser () { + return this.addressbookUser; + } + + @Override + public void setAddressbookUser (final User addressbookUser) { + this.addressbookUser = addressbookUser; + } }