Profile.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by EntityEmbeddable.vsl in andromda-ejb3-cartridge on 08/08/2014 12:21:04.
//
package org.andromda.demo.ejb3.registration;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * <p>
 * TODO: Model Documentation for org.andromda.demo.ejb3.registration.Profile
 * </p>
 *
 * Autogenerated POJO EJB class for Profile containing the
 * bulk of the entity implementation.
 *
 * This is autogenerated by AndroMDA using the EJB3
 * cartridge.
 *
 * DO NOT MODIFY this class.
 */
@Entity
@Table(name="PROFILE")
@NamedQuery(name="Profile.findAll", query="SELECT p FROM Profile AS p")
public class Profile
    implements Serializable, Comparable<Profile>{
    private static final long serialVersionUID = 1955105898876417156L;

    // ----------- 4 Attribute Definitions ------------
    protected String code;
    protected String name;
    protected String description;
    protected Long profileId;

    // --------- 1 Relationship Definitions -----------
    protected Registration registration;

    // ---- Manageable Display Attributes (Transient) -----
    protected String registrationLabel;    // Manageable display attribute

    // -------- 4 Attribute Accessors ----------
    /**
     * <p>
     * TODO: Model Documentation for code
     * </p>
     * Get the code property.
     * @return String The value of code
     */
    @Column(name="CODE", unique=true, nullable=false, insertable=true, updatable=true, length=30)
    @NotNull(message="code is required")
    @Size(max=30)
    public String getCode()
    {
        return this.code;
    }

    /**
     * <p>
     * TODO: Model Documentation for code
     * </p>
     * Set the code property.
     * @param value the new value
     */
    public void setCode(String value)
    {
        this.code = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Get the name property.
     * @return String The value of name
     */
    @Column(name="NAME", insertable=true, updatable=true, length=20)
    @Size(max=20)
    public String getName()
    {
        return this.name;
    }

    /**
     * <p>
     * TODO: Model Documentation for name
     * </p>
     * Set the name property.
     * @param value the new value
     */
    public void setName(String value)
    {
        this.name = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for description
     * </p>
     * Get the description property.
     * @return String The value of description
     */
    @Column(name="DESCRIPTION", insertable=true, updatable=true, length=100)
    @Size(max=100)
    public String getDescription()
    {
        return this.description;
    }

    /**
     * <p>
     * TODO: Model Documentation for description
     * </p>
     * Set the description property.
     * @param value the new value
     */
    public void setDescription(String value)
    {
        this.description = value;
    }

    /**
     * <p>
     * TODO: Model Documentation for profileId
     * </p>
     * Get the profileId property.
     * @return Long The value of profileId
     */
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="PROFILE_ID", nullable=false, insertable=true, updatable=true)
    public Long getProfileId()
    {
        return this.profileId;
    }

    /**
     * <p>
     * TODO: Model Documentation for profileId
     * </p>
     * Set the profileId property.
     * @param value the new value
     */
    public void setProfileId(Long value)
    {
        this.profileId = value;
    }


    // ------------- 1 Relations ------------------
    /**
     * <p>
     * TODO: Model Documentation for registration
     * </p>
     * Get the registration
     * @return Registration
     */
    @OneToOne(optional=false)
    @JoinColumn(name="REGISTRATION_FK")
    public Registration getRegistration()
    {
        return this.registration;
    }

   /**
     * <p>
     * TODO: Model Documentation for registration
     * </p>
    * Set the registration
    * @param registrationIn
    */
    public void setRegistration(Registration registrationIn)
    {
        this.registration = registrationIn;
    }

    // -------- Manageable Attribute Display -----------
    /**
     * <p>
     * TODO: Model Documentation for registration
     * </p>
     * Get the registrationLabel
     * @return String

     */
    @Transient
    public String getRegistrationLabel()
    {
        return this.registrationLabel;
    }

    /**
     * <p>
     * TODO: Model Documentation for registration
     * </p>
     * Set the registrationLabel
     * @param registrationLabelIn
     */
    public void setRegistrationLabel (String registrationLabelIn)
    {
        this.registrationLabel = registrationLabelIn;
    }

    // --------------- Constructors -----------------

    /**
     * Default empty no-arg constructor
     */
    public Profile()
    {
        // Default empty constructor
    }

    /**
     * Constructor with all updatable Entity attributes except auto incremented identifiers.
     *
     * @param code String value for the code property required=true lower=1
     * @param name String value for the name property required=false lower=0
     * @param description String value for the description property required=false lower=0
     */
    public Profile(String code, String name, String description)
    {
        this.code = code;
        this.name = name;
        this.description = description;
    }

    /**
     * Constructor with required Entity attributes except auto incremented identifiers.
     *
     * @param code Value for the code property
     */
    public Profile(String code)
    {
        this.code = code;
    }

    /**
     * Constructor with all Entity attribute values and CMR relations.
     *
     * @param code String value for the code property
     * @param name String value for the name property
     * @param description String value for the description property
     * @param registration Registration value for the registration relation
     */
    public Profile(String code, String name, String description, Registration registration)
    {
        // 3 updatableAttributes
        setCode(code);
        setName(name);
        setDescription(description);

        // 1 relations
        setRegistration(registration);
    }

    /**
     * Constructor with required Entity attribute values and required CMR relations.
     *
     * @param code String value for the code property
     * @param registration Registration value for the registration relation
     */
    public Profile(String code, Registration registration)
    {
        // 1 requiredAttributes
        setCode(code);

        // 1 required association relations
        setRegistration(registration);
    }

    // -------- Common Methods -----------
    /**
     * Indicates if the argument is of the same type and all values are equal.
     * @param object The target object to compare with
     * @return boolean True if both objects a 'equal'
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object object)
    {
        if (null == object)
        {
            return false;
        }
        if (this == object)
        {
            return true;
        }
        if (!(object instanceof Profile))
        {
            return false;
        }
        final Profile that = (Profile)object;
        if (this.getProfileId() == null || that.getProfileId() == null || !this.getProfileId().equals(that.getProfileId()))
        {
            return false;
        }
        return true;
    }

    /**
     * Returns a hash code value for the object
     * @return int The hash code value
     * @see Object#hashCode
     */
    @Override
    public int hashCode()
    {
        int hashCode = 0;
        hashCode = 29 * hashCode + (getProfileId() == null ? 0 : getProfileId().hashCode());

        return hashCode;
    }

    /**
     * Returns a String representation of the object
     * @return String Textual representation of the object displaying name/value pairs for all attributes
     * @see Object#toString
     */
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("Profile(");
        sb.append(" code=").append(getCode());
        sb.append(" name=").append(getName());
        sb.append(" description=").append(getDescription());
        sb.append(" profileId=").append(getProfileId());
        sb.append(" registration=").append(getRegistration());
        sb.append(")");
        return sb.toString();
    }

    /**
     * @see Comparable#compareTo
     */
    @Override
    public int compareTo(Profile o)
    {
        int cmp = 0;
        if (this.getProfileId() != null)
        {
            cmp = this.getProfileId().compareTo(o.getProfileId());
        }
        else
        {
            if (this.getCode() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getCode().compareTo(o.getCode()));
            }
            if (this.getName() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getName().compareTo(o.getName()));
            }
            if (this.getDescription() != null)
            {
                cmp = (cmp != 0 ? cmp : this.getDescription().compareTo(o.getDescription()));
            }
        }
        return cmp;
    }


}