]> git.mxchange.org Git - juser-login-core.git/commitdiff
added new email change entity with enumeration for change status
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Mar 2016 21:03:46 +0000 (22:03 +0100)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Mar 2016 21:43:54 +0000 (22:43 +0100)
src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java [new file with mode: 0644]
src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java [new file with mode: 0644]
src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java [new file with mode: 0644]
src/org/mxchange/jusercore/model/user/User.java
src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java

diff --git a/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java b/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java
new file mode 100644 (file)
index 0000000..a672c2b
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2016 quix0r
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.email_address;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import org.mxchange.jusercore.model.email_address.status.EmailChangeStatus;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJI for email address changes. This is required to have the user confirm
+ * the change (avoids abuse a bit).
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface ChangeableEmailAddress extends Serializable {
+
+       /**
+        * Getter for email change id
+        * <p>
+        * @return Email change id
+        */
+       Long getEmailChangeId ();
+
+       /**
+        * Setter for email change id
+        * <p>
+        * @param emailChangeId Email change id
+        */
+       void setEmailChangeId (final Long emailChangeId);
+
+       /**
+        * Getter for email address to change to
+        * <p>
+        * @return Email address to change to
+        */
+       String getEmailAddress ();
+
+       /**
+        * Setter for email address to change to
+        * <p>
+        * @param emailAddress Email address to change to
+        */
+       void setEmailAddress (final String emailAddress);
+
+       /**
+        * Getter for created "email change" timestamp
+        * <p>
+        * @return Created "email change" timestamp
+        */
+       Calendar getEmailChangeCreated ();
+
+       /**
+        * Setter for created "email change" timestamp
+        * <p>
+        * @param emailChangeCreated Created "email change" timestamp
+        */
+       void setEmailChangeCreated (final Calendar emailChangeCreated);
+
+       /**
+        * Getter for user initiating the email change
+        * <p>
+        * @return User initiating the email change
+        */
+       User getEmailChangeUser ();
+
+       /**
+        * Setter for user initiating the email change
+        * <p>
+        * @param emailChangeUser User initiating the email change
+        */
+       void setEmailChangeUser (final User emailChangeUser);
+
+       /**
+        * Getter for email change done/undone
+        * <p>
+        * @return Email change done/undone
+        */
+       Calendar getEmailChangeDone ();
+
+       /**
+        * Setter for email change done/undone
+        * <p>
+        * @param emailChangeDone Email change done/undone
+        */
+       void setEmailChangeDone (final Calendar emailChangeDone);
+
+       /**
+        * Getter for email change status
+        * <p>
+        * @return Email change status
+        */
+       EmailChangeStatus getEmailChangeStatus ();
+
+       /**
+        * Setter for email change status
+        * <p>
+        * @param emailChangeStatus Email change status
+        */
+       void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus);
+
+       @Override
+       boolean equals (final Object object);
+
+       @Override
+       int hashCode ();
+}
diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java
new file mode 100644 (file)
index 0000000..e039b2c
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2016 quix0r
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.email_address;
+
+import java.util.Calendar;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Index;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.mxchange.jusercore.model.email_address.status.EmailChangeStatus;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJO for changing email addresses.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Entity (name = "email_changes")
+@Table (
+               name = "email_changes",
+               indexes = {
+                       @Index (name = "email_change_user", columnList = "email_change_user")
+               }
+)
+public class EmailAddressChange implements ChangeableEmailAddress, Comparable<ChangeableEmailAddress> {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 398_459_287_176_139L;
+
+       /**
+        * Email address to change to
+        */
+       @Basic (optional = false)
+       @Column (name = "email_address", length = 100, nullable = false, updatable = false)
+       private String emailAddress;
+
+       /**
+        * Timestamp when this change has been added
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "email_change_created", nullable = false, updatable = false)
+       private Calendar emailChangeCreated;
+
+       /**
+        * Timestamp when this change has been done or undone
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "email_change_done", nullable = false, updatable = false)
+       private Calendar emailChangeDone;
+
+       /**
+        * Email change id
+        */
+       @Id
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       @Column (name = "email_change_id", length = 20, nullable = false, updatable = false)
+       private Long emailChangeId;
+
+       /**
+        * Email change status
+        */
+       @Basic (optional = false)
+       @Column (name = "email_change_status", nullable = false, updatable = false)
+       @Enumerated (EnumType.STRING)
+       private EmailChangeStatus emailChangeStatus;
+
+       /**
+        * User initiating the email change
+        */
+       @Basic (optional = false)
+       @Column (name = "email_change_user_id", length = 20, nullable = false, updatable = false)
+       @OneToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.REFRESH)
+       private User emailChangeUser;
+
+       /**
+        * Default constructor
+        */
+       public EmailAddressChange () {
+               // Set default email change status
+               this.emailChangeStatus = EmailChangeStatus.NEW;
+       }
+
+       @Override
+       public int compareTo (final ChangeableEmailAddress emailAddress) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public boolean equals (final Object object) {
+               if (this == object) {
+                       return true;
+               } else if (object == null) {
+                       return false;
+               } else if (this.getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final ChangeableEmailAddress otherEmail = (ChangeableEmailAddress) object;
+
+               if (!Objects.equals(this.getEmailChangeId(), otherEmail.getEmailChangeId())) {
+                       return false;
+               }
+
+               return Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser());
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 5;
+               hash = 71 * hash + Objects.hashCode(this.emailChangeId);
+               hash = 71 * hash + Objects.hashCode(this.emailChangeUser);
+               return hash;
+       }
+
+       @Override
+       public String getEmailAddress () {
+               return this.emailAddress;
+       }
+
+       @Override
+       public void setEmailAddress (final String emailAddress) {
+               this.emailAddress = emailAddress;
+       }
+
+       @Override
+       public Calendar getEmailChangeCreated () {
+               return this.emailChangeCreated;
+       }
+
+       @Override
+       public void setEmailChangeCreated (final Calendar emailChangeCreated) {
+               this.emailChangeCreated = emailChangeCreated;
+       }
+
+       @Override
+       public Calendar getEmailChangeDone () {
+               return this.emailChangeDone;
+       }
+
+       @Override
+       public void setEmailChangeDone (final Calendar emailChangeDone) {
+               this.emailChangeDone = emailChangeDone;
+       }
+
+       @Override
+       public Long getEmailChangeId () {
+               return this.emailChangeId;
+       }
+
+       @Override
+       public void setEmailChangeId (final Long emailChangeId) {
+               this.emailChangeId = emailChangeId;
+       }
+
+       @Override
+       public EmailChangeStatus getEmailChangeStatus () {
+               return this.emailChangeStatus;
+       }
+
+       @Override
+       public void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus) {
+               this.emailChangeStatus = emailChangeStatus;
+       }
+
+       @Override
+       public User getEmailChangeUser () {
+               return this.emailChangeUser;
+       }
+
+       @Override
+       public void setEmailChangeUser (final User emailChangeUser) {
+               this.emailChangeUser = emailChangeUser;
+       }
+
+}
diff --git a/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java b/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java
new file mode 100644 (file)
index 0000000..5322ded
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.email_address.status;
+
+import java.io.Serializable;
+
+/**
+ * An enumeration for email changing
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public enum EmailChangeStatus implements Serializable {
+
+       /**
+        * Newly added address (default)
+        *//**
+        * Newly added address (default)
+        */
+       NEW("EMAIL_CHANGE_STATUS_NEW"), //NOI18N
+
+       /**
+        * User changed to this address
+        */
+       CHANGED("EMAIL_CHANGE_STATUS_CHANGED"), //NOI18N
+
+       /**
+        * Has withdrawn the action
+        */
+       WITHDRAWN("EMAIL_CHANGE_STATUS_WITHDRAWN"), //NOI18N
+
+       /**
+        * User has "deleted" the entry. This is not done to keep a history of email changes.
+        */
+       DELETED("EMAIL_CHANGE_STATUS_DELETED"); //NOI18N
+
+       /**
+        * Message key
+        */
+       private final String messageKey;
+
+       /**
+        * Constructor with i18n translation key
+        * <p>
+        * @param messageKey Message key (i18n)
+        */
+       private EmailChangeStatus (final String messageKey) {
+               // Set it here
+               this.messageKey = messageKey;
+       }
+
+       /**
+        * Output value (for messages)
+        * <p>
+        * @return the messageKey
+        */
+       public String getMessageKey () {
+               return this.messageKey;
+       }
+
+}
index 5a6ec78d8de0f21a82847fe8d2da75d9f41f6abd..4956567b13a9b05712ec457766850c6f370a7926 100644 (file)
@@ -23,7 +23,7 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
- * A customer interface
+ * A user POPJI
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
index 46cbe1050837d1c3618a7c0a47cb028bf6873e98..328f1244714896843ffdac43192451e80543d1fe 100644 (file)
@@ -19,7 +19,7 @@ package org.mxchange.jusercore.model.user.status;
 import java.io.Serializable;
 
 /**
- * An enum for user's account status like confirmed, locked, etc.
+ * An enumeration for user's account status like confirmed, locked, etc.
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
@@ -36,7 +36,7 @@ public enum UserAccountStatus implements Serializable {
        CONFIRMED("USER_ACCOUNT_STATUS_CONFIRMED"), //NOI18N
 
        /**
-        * Locked (maybe violeted T&C)
+        * Locked (maybe violated T&C)
         */
        LOCKED("USER_ACCOUNT_STATUS_LOCKED"); //NOI18N