]> git.mxchange.org Git - juser-login-core.git/blobdiff - src/org/mxchange/jusercore/model/user/LoginUser.java
updated more fields
[juser-login-core.git] / src / org / mxchange / jusercore / model / user / LoginUser.java
index 182ac68675995120a0252c5da207a881a8cce7a9..36f4dd37f77feef3881f84751e49c732b4ebc4b0 100644 (file)
@@ -70,10 +70,12 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus;
                        @NamedQuery (name = "SearchUserId", query = "SELECT u FROM users AS u WHERE u.userId = :id"),
                        @NamedQuery (name = "SearchEmailAddress", query = "SELECT u FROM users AS u INNER JOIN contacts AS c ON u.userContact = c WHERE LOWER(c.contactEmailAddress) LIKE LOWER(:param)"),
                        @NamedQuery (name = "SearchAllUsersExcept", query = "SELECT u FROM users AS u WHERE u != :user ORDER BY u.userId ASC"),
+                       @NamedQuery (name = "AllUsers", query = "SELECT u FROM users AS u ORDER BY u.userId ASC"),
                        @NamedQuery (name = "AllPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode = :mode ORDER BY u.userId ASC"),
                        @NamedQuery (name = "AllMemberPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode IN (:public, :members) ORDER BY u.userId ASC")
                }
 )
+@SuppressWarnings ("PersistenceUnitPresent")
 public class LoginUser implements User {
 
        /**
@@ -98,7 +100,7 @@ public class LoginUser implements User {
        /**
         * Id number from "contacts" table
         */
-       @JoinColumn (name = "user_contact_id", nullable = false, updatable = false)
+       @JoinColumn (name = "user_contact_id", referencedColumnName = "contact_id", nullable = false, updatable = false, unique = true)
        @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
        private Contact userContact;
 
@@ -113,6 +115,7 @@ public class LoginUser implements User {
        /**
         * Encrypted password
         */
+       @Basic (optional = false)
        @Column (name = "user_encrypted_password", nullable = false)
        private String userEncryptedPassword;
 
@@ -136,21 +139,15 @@ public class LoginUser implements User {
         */
        @Lob
        @Column (name = "user_last_locked_reason")
-       private String lastLockedReason;
+       private String userLastLockedReason;
 
        /**
         * User name
         */
+       @Basic (optional = false)
        @Column (name = "user_name", nullable = false, length = 20)
        private String userName;
 
-       /**
-        * When this user has been updated
-        */
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "user_updated")
-       private Calendar userUpdated;
-
        /**
         * Profile mode of this user
         */
@@ -159,6 +156,13 @@ public class LoginUser implements User {
        @Column (name = "user_profile_mode", nullable = false)
        private ProfileMode userProfileMode;
 
+       /**
+        * When this user has been updated
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "user_updated")
+       private Calendar userUpdated;
+
        /**
         * Default constructor
         */
@@ -169,8 +173,11 @@ public class LoginUser implements User {
 
        @Override
        public void copyAll (final User user) {
-               // Copy also contact data
-               this.getUserContact().copyAll(user.getUserContact());
+               // Is contact set?
+               if (user.getUserContact() instanceof Contact) {
+                       // Copy also contact data
+                       this.getUserContact().copyAll(user.getUserContact());
+               }
 
                // Copy other data
                this.setUserConfirmKey(user.getUserConfirmKey());
@@ -179,14 +186,15 @@ public class LoginUser implements User {
                this.setUserAccountStatus(user.getUserAccountStatus());
                this.setUserCreated(user.getUserCreated());
                this.setUserLastLocked(user.getUserLastLocked());
+               this.setUserUpdated(user.getUserUpdated());
+               this.setUserProfileMode(user.getUserProfileMode());
        }
 
        @Override
        public boolean equals (final Object object) {
-               if (object == null) {
+               if (null == object) {
                        return false;
-               }
-               if (getClass() != object.getClass()) {
+               } else if (this.getClass() != object.getClass()) {
                        return false;
                }
 
@@ -196,16 +204,6 @@ public class LoginUser implements User {
                                (Objects.equals(this.getUserId(), other.getUserId())));
        }
 
-       @Override
-       public String getLastLockedReason () {
-               return this.lastLockedReason;
-       }
-
-       @Override
-       public void setLastLockedReason (final String lastLockedReason) {
-               this.lastLockedReason = lastLockedReason;
-       }
-
        @Override
        public UserAccountStatus getUserAccountStatus () {
                return this.userAccountStatus;
@@ -237,11 +235,13 @@ public class LoginUser implements User {
        }
 
        @Override
+       @SuppressWarnings ("ReturnOfDateField")
        public Calendar getUserCreated () {
                return this.userCreated;
        }
 
        @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
        public void setUserCreated (final Calendar userCreated) {
                this.userCreated = userCreated;
        }
@@ -267,15 +267,27 @@ public class LoginUser implements User {
        }
 
        @Override
+       @SuppressWarnings ("ReturnOfDateField")
        public Calendar getUserLastLocked () {
                return this.userLastLocked;
        }
 
        @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
        public void setUserLastLocked (final Calendar userLastLocked) {
                this.userLastLocked = userLastLocked;
        }
 
+       @Override
+       public String getUserLastLockedReason () {
+               return this.userLastLockedReason;
+       }
+
+       @Override
+       public void setUserLastLockedReason (final String userLastLockedReason) {
+               this.userLastLockedReason = userLastLockedReason;
+       }
+
        @Override
        public String getUserName () {
                return this.userName;
@@ -297,11 +309,13 @@ public class LoginUser implements User {
        }
 
        @Override
+       @SuppressWarnings ("ReturnOfDateField")
        public Calendar getUserUpdated () {
                return this.userUpdated;
        }
 
        @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
        public void setUserUpdated (final Calendar userUpdated) {
                this.userUpdated = userUpdated;
        }
@@ -313,4 +327,5 @@ public class LoginUser implements User {
                hash = 83 * hash + Objects.hashCode(this.getUserId());
                return hash;
        }
+
 }