UserAttribute.java 3.5 KB
package org.legrog.entities;

import javax.persistence.*;

/*
    Entité persistante représentant les propriétés qui sont paramétrées pour un utilisateur.
    Migréee depuis la v2.
 */
@Entity
public class UserAttribute {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int userAttributeId;

    public int getUserAttributeId() {
        return userAttributeId;
    }

    /**
     * The linked user.
     */
    @ManyToOne
    @JoinColumn(name = "USER_ID")
    private User user;

    /**
     * Retrieve the user this attribute is attached to.
     * hibernate.many-to-one
     * 		column="ID_UTILISATEUR"
     * 		class="org.roliste.data.db.User"
     *      not-null="true"
     *  	access="property"
     *  	lazy="proxy"
     *      properties-name="PropertyPerUser"
     *      foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR"
     * @return the {link org.roliste.data.db.User} this attribute is attached to.
     * Shall not be <code>null</code>.
     * see #setUser(org.roliste.data.db.User)
     */
    public User getUser() {
        return user;
    }

    /**
     * Set the user this attribute is attached to.
     * @param user the new {link org.roliste.data.db.User} this attribute will be attached to. Shall not be <code>null</code>.
     * @see #getUser()
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * The linked property.
     */
    @ManyToOne
    @JoinColumn(name = "USER_PROPERTY_ID")
    private UserProperty userProperty;

    /**
     * Retrieve the property this attribute is attached to.
     * hibernate.many-to-one
     * 		column="ID_PROP"
     * 		class="org.roliste.data.db.UserProperty"
     *      not-null="true"
     *  	access="property"
     *  	lazy="false"
     *      properties-name="PropertyPerUser"
     *      foreign-key="FK_ATTRIBUTUTILISATEUR_PROPRIETE"
     * @return the {link org.roliste.data.db.UserProperty} this attribute is attached to.
     * Shall not be <code>null</code>.
     * see #setProperty(org.roliste.data.db.UserProperty)
     */
    public UserProperty getProperty() {
        return userProperty;
    }

    /**
     * Set the property this attribute is attached to.
     * @param prop the new {link org.roliste.data.db.UserProperty} this attribute will be attached to. Shall not be <code>null</code>.
     * @see #getProperty()
     */
    public void setProperty(UserProperty prop) {
        userProperty = prop;
    }

    /**
     * The property value.
     */
    private String value;

    /**
     * Returns the property value.
     * @return the {@link String} value. If property is known to be some other kind of value, you shall
     * convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute
     * is the value, or for unset attributes.
     * @see #setValue(String)
     * hibernate.property
     *  	column="ATTR_VALUE"
     *  	access="property"
     *  	length="200"
     */
    public String getValue() {
        return value;
    }

    /**
     * Initializes attribute value.
     * @param value the new {@link String} value.
     * @see #getValue()
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * Returns a string representation of this user attribute definition.
     * @return a string representing this user attribute definition.
     * hidden
     */
    @Override
    public String toString()
    {
        return "ID_ATTR=" + getUserAttributeId() + " ATTR_PROP=" + userProperty + " ATTR_VALUE=" + value;
    }

}