/*
 * $Id: VKCUserCatFavorite.java,v 1.2 2004/08/09 19:15:34 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCUserCatFavorite.java,v $
 * Revision 1.2  2004/08/09 19:15:34  marbobo
 * + Performance-Bugfix
 *
 * Revision 1.1  2004/08/09 16:07:02  jonyp
 * first strike
 *
 *
 */

package vkc.db.entities;

import java.io.Serializable;
import java.sql.Timestamp;

import vkc.db.entities.VKCCategory;
import vkc.db.serializer.VKCCategorySerializer;
import vkc.exception.DBException;

/**
 * Klasse stellt einen UserCatHistory im VKC-System dar
 *
 * @author jonyP
 */
public class VKCUserCatFavorite implements Serializable {
	private Integer userId = new Integer( 0 );
    private Integer categoryId = new Integer( 0 );
    private Timestamp created = new Timestamp( System.currentTimeMillis() );
    private VKCCategory category = null;
    
    /**
     * Konstruktor
     */
    public VKCUserCatFavorite() {
    }
    
    public VKCUserCatFavorite( Integer userId, Integer categoryId, Timestamp created ){
    	this.userId = userId;
    	this.categoryId = categoryId;
    	this.created = created;
    }

	public void setUserId( Integer i ) {
		userId = i;
	}

    public Integer getUserId() {
        return userId;
    }

    public void setCategoryId( Integer i ) {
        categoryId = i;
    }
    
	public Integer getCategoryId() {
		return categoryId;
	}
	
	public VKCCategory getCategory() throws DBException{
        if ( category == null ) {
        	category = VKCCategorySerializer.retrieveCategory( getCategoryId() ); 
        }

		return category;
	}

	public void setCategory( VKCCategory c ) {
		category = c;
	}
	
	public Timestamp getCreated() {
		return created;
	}

	public void setCreated( Timestamp timestamp ) {
		created = timestamp;
	}
}