/*
 * $Id$
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log$
 * Revision 1.3  2006/09/17 18:50:45  marbobo
 * + Anpassung der equals(), hashCode() und toString() Methoden
 *
 * Revision 1.2  2006/08/31 12:33:27  korowa
 * *** empty log message ***
 *
 * Revision 1.1  2006/08/31 12:17:27  korowa
 * Dynamische Attribute für Users eingefügt
 *
 */

package vkc.db.entities;

import java.io.Serializable;

/**
 * Klasse kapselt Zugehörigkeit zu einem User(UserId), AttributeId, Schlüssel
 * und Wert eines dynamischen Attributes eines Users, und Rechte des Benutzers
 * Attribute zu ändern
 * 
 * @author korowa
 * @version 1.0
 */
public class VKCDynUserAttribute implements Serializable {
	public static final int AUTORIZATION_NO = 0;

	public static final int AUTORIZATION_READ = 1;

	public static final int AUTORIZATION_WRITE = 2;


	private Integer autorization = new Integer(AUTORIZATION_NO);
	private Integer dynaAttrId = VKCEntity.ID_UNDEFINED;
	private Integer userId = VKCEntity.ID_UNDEFINED;

	private String name = "";

	private String value = "";


	public VKCDynUserAttribute() {
	}

	public VKCDynUserAttribute(Integer userId, Integer dynaAttrId, String name,
			String value, Integer autorization) {
		this.dynaAttrId = dynaAttrId;
		this.userId = userId;
		this.name = name;
		this.value = value;
		this.autorization = autorization;
	}

	public Integer getDynaAttrId() {
		return dynaAttrId;
	}

	public void setDynaAttrId(Integer dynaAttrId) {
		this.dynaAttrId = dynaAttrId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public boolean equals(Object o) {
		if (!(o instanceof VKCDynaAttribute)) {
			return false;
		}

		VKCDynaAttribute dynaAttr = (VKCDynaAttribute) o;

		return getDynaAttrId().equals(dynaAttr.getDynaAttrId()) && getName().equals(dynaAttr.getName());
	}

	public int hashCode() {
		return new StringBuffer(getDynaAttrId().toString()).append(getName()).toString().hashCode();
	}

	public String toString() {
		StringBuffer s = new StringBuffer();
		s.append("User dyna attribute properties: userId = ").append(getUserId());
		s.append(" | dynaAttrId = ").append(getDynaAttrId());
		s.append(" | authorizationId = ").append(getAutorization());
		s.append(" | name = ").append(getName());
		s.append(" | value = ").append(getValue());
		
		return s.toString();
	}

	public Integer getAutorization() {
		return autorization;
	}

	public void setAutorization(Integer autorization) {
		this.autorization = autorization;
	}
}