import java.io.Serializable;
import java.util.Calendar;
+import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jusercore.model.user.User;
/**
*/
void setActivityUser (final User activityUser);
+ /**
+ * Getter for user name
+ * <p>
+ * @return User name
+ */
+ String getActivityUserName ();
+
+ /**
+ * Setter for user name
+ * <p>
+ * @param activityUserName User name
+ */
+ void setActivityUserName (final String activityUserName);
+
+ /**
+ * Getter for contact family name
+ * <p>
+ * @return Contact family name
+ */
+ String getActivityContactFamilyName ();
+
+ /**
+ * Setter for contact family name
+ * <p>
+ * @param activityContactFamilyName Contact family name
+ */
+ void setActivityContactFamilyName (final String activityContactFamilyName);
+
+ /**
+ * Getter for contact first name
+ * <p>
+ * @return Contact first name
+ */
+ String getActivityContactFirstName ();
+
+ /**
+ * Setter for contact first name
+ * <p>
+ * @param activityContactFirstName Contact first name
+ */
+ void setActivityContactFirstName (final String activityContactFirstName);
+
+ /**
+ * Getter for contact gender
+ * <p>
+ * @return Contact gender
+ */
+ Gender getActivityContactGender ();
+
+ /**
+ * Setter for contact gender
+ * <p>
+ * @param activityContactGender Contact gender
+ */
+ void setActivityContactGender (final Gender activityContactGender);
+
@Override
boolean equals (final Object object);
*/
package org.mxchange.jusercore.model.user.activity;
+import java.text.MessageFormat;
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.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
@Transient
private static final long serialVersionUID = 12_945_967_867_290_601L;
+ /**
+ * Family name
+ */
+ @Basic (optional = false)
+ @Column (name = "activity_contact_family_name", nullable = false, updatable = false)
+ private String activityContactFamilyName;
+
+ /**
+ * First name
+ */
+ @Basic (optional = false)
+ @Column (name = "activity_contact_first_name", nullable = false, updatable = false)
+ private String activityContactFirstName;
+
+ /**
+ * Gender instance
+ */
+ @Basic (optional = false)
+ @Column (name = "activity_contact_gender", nullable = false, updatable = false)
+ @Enumerated (EnumType.STRING)
+ private Gender activityContactGender;
+
/**
* Primary key
*/
/**
* User instance
*/
- @JoinColumn (name = "activity_user_id", referencedColumnName = "user_id", nullable = false, updatable = false)
- @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.ALL, optional = false)
+ @JoinColumn (name = "activity_user_id", referencedColumnName = "user_id")
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.ALL)
private User activityUser;
+ /**
+ * User name
+ */
+ @Basic (optional = false)
+ @Column (name = "activity_user_name", nullable = false, updatable = false)
+ private String activityUserName;
+
/**
* Default constructor
*/
// Call other constructor
this(activityType, activityUser, activityTimestamp);
+ // Is a message given?
+ if (null == activityMessage) {
+ // Throw NPE
+ throw new NullPointerException("activityMessage is null"); //NOI18N
+ } else if (activityMessage.isEmpty()) {
+ // Empty string
+ throw new IllegalArgumentException("activityMessage is empty"); //NOI18N
+ }
+
// Set message
this.activityMessage = activityMessage;
}
* @param activityTimestamp imestamp
*/
public UserActivityLog (final String activityType, final User activityUser, final Calendar activityTimestamp) {
+ // Make sure all is set
+ if (null == activityType) {
+ // Throw NPE
+ throw new NullPointerException("activityType is null"); //NOI18N
+ } else if (activityType.isEmpty()) {
+ // Empty string
+ throw new IllegalArgumentException("activityType is empty"); //NOI18N
+ } else if (null == activityUser) {
+ // Throw NPE
+ throw new NullPointerException("activityUser is null"); //NOI18N
+ } else if (activityUser.getUserId() == null) {
+ // Throw it again
+ throw new NullPointerException("activityUser.userId is null"); //NOI18N
+ } else if (activityUser.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("activityUser.userId={0} is not valid", activityUser.getUserId())); //NOI18N
+ } else if (null == activityUser.getUserContact()) {
+ // Throw NPE
+ throw new NullPointerException("activityUser.userContact is null"); //NOI18N
+ } else if (null == activityUser.getUserContact().getContactId()) {
+ // Throw NPE
+ throw new NullPointerException("activityUser.userContact.contactId is null"); //NOI18N
+ } else if (activityUser.getUserContact().getContactId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("activityUser.userContact.contactId={0} is not valid", activityUser.getUserContact().getContactId())); //NOI18N
+ } else if (null == activityTimestamp) {
+ // Throw NPE again
+ throw new NullPointerException("activityTimestamp is null"); //NOI18N
+ }
+
// Set all values
this.activityType = activityType;
this.activityUser = activityUser;
this.activityTimestamp = activityTimestamp;
+
+ // Set all user/contact fields
+ this.activityUserName = activityUser.getUserName();
+ this.activityContactGender = activityUser.getUserContact().getContactGender();
+ this.activityContactFirstName = activityUser.getUserContact().getContactFirstName();
+ this.activityContactFamilyName = activityUser.getUserContact().getContactFamilyName();
}
@Override
return true;
}
+ @Override
+ public String getActivityContactFamilyName () {
+ return this.activityContactFamilyName;
+ }
+
+ @Override
+ public void setActivityContactFamilyName (final String activityContactFamilyName) {
+ this.activityContactFamilyName = activityContactFamilyName;
+ }
+
+ @Override
+ public String getActivityContactFirstName () {
+ return this.activityContactFirstName;
+ }
+
+ @Override
+ public void setActivityContactFirstName (final String activityContactFirstName) {
+ this.activityContactFirstName = activityContactFirstName;
+ }
+
+ @Override
+ public Gender getActivityContactGender () {
+ return this.activityContactGender;
+ }
+
+ @Override
+ public void setActivityContactGender (final Gender activityContactGender) {
+ this.activityContactGender = activityContactGender;
+ }
+
@Override
public Long getActivityId () {
return this.activityId;
this.activityUser = activityUser;
}
+ @Override
+ public String getActivityUserName () {
+ return this.activityUserName;
+ }
+
+ @Override
+ public void setActivityUserName (final String activityUserName) {
+ this.activityUserName = activityUserName;
+ }
+
@Override
public int hashCode () {
int hash = 7;