/*
* HsLegislacaoDataAuto.java
*
* Generated by com.evutils.codegen.JDOObjectGenerator
*
* Use but DON'T TOUCH
*/
package com.evolute.siprp.server.db.data.siprp_local3;

import com.evolute.utils.jdo.*;
import java.util.HashMap;
import java.util.Map;

class HsLegislacaoDataAuto extends JDOObject
{

	public static final String TABLENAME = "hs_legislacao";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_legislacao.id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_legislacao.description";
	public static final String CATEGORIA_ID = "categoria_id";
	public static final String CATEGORIA_ID_FULL = "hs_legislacao.categoria_id";
	public static final String TO_CATEGORIA_ID = "to categoria_id";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_legislacao.deleted_date";

	public static final String FIELD_NAMES[] = new String[]{
		DESCRIPTION, CATEGORIA_ID, TO_CATEGORIA_ID, DELETED_DATE, };


	protected static final String ALL_FIELD_NAMES[] = new String[]{
		ID, DESCRIPTION, CATEGORIA_ID, DELETED_DATE, };

	private Map<String, Object> dataHash;

	public HsLegislacaoDataAuto()
	{
		dataHash = new HashMap<String, Object>();
	}

	public Integer getId()
	{
		return (Integer) get(ID);
	}

	public void setId(Integer idValue )
	{
		this.set(ID, idValue );
	}

	public String getDescription()
	{
		return (String) get(DESCRIPTION);
	}

	public void setDescription(String descriptionValue )
	{
		this.set(DESCRIPTION, descriptionValue );
	}

	public Integer getCategoria_id()
	{
		return (Integer) dataHash.get(CATEGORIA_ID);
	}

	public void setCategoria_id(Integer categoria_idValue )
	{
		dataHash.put(TO_CATEGORIA_ID, null);
		dataHash.put(CATEGORIA_ID, categoria_idValue );
	}

	public com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData toCategoria_id()
		throws Exception
	{
		if( dataHash.get(TO_CATEGORIA_ID) == null && getCategoria_id() != null )
		{
			dataHash.put(TO_CATEGORIA_ID, getJDOProvider().load(com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData.class, new Object[]{ getCategoria_id() }, new String[]{ com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData.ID }));
		}
		return (com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData) dataHash.get(TO_CATEGORIA_ID);
	}

	public void setToCategoria_id(com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData categoria_idObject )
	{
		if( categoria_idObject == null )
		{
			dataHash.put(CATEGORIA_ID, null);
		}
		else
		{
			dataHash.put(CATEGORIA_ID, categoria_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData.ID ));
		}
		dataHash.put(TO_CATEGORIA_ID, categoria_idObject);
	}

	public java.sql.Timestamp getDeleted_date()
	{
		return (java.sql.Timestamp) get(DELETED_DATE);
	}

	public void setDeleted_date(java.sql.Timestamp deleted_dateValue )
	{
		this.set(DELETED_DATE, deleted_dateValue );
	}

	protected Object innerGet( String fieldName )
		throws Exception
	{
		Object value = null;
		if( CATEGORIA_ID.equals( fieldName ) )
		{
			value =  getCategoria_id();
		}
		else if( TO_CATEGORIA_ID.equals( fieldName ) )
		{
			value =  toCategoria_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( CATEGORIA_ID.equals( fieldName ) )
		{
			setCategoria_id( (Integer) value );
		}
		else if( TO_CATEGORIA_ID.equals( fieldName ) )
		{
			setToCategoria_id( (com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_CATEGORIA_ID) != null )
		{
			toCategoria_id().save();
			dataHash.put(CATEGORIA_ID, toCategoria_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsLegislacaoCategoriaData.ID ));
		}

		super.save();
	}

	public String []getFieldNames()
	{
		return FIELD_NAMES;
	}

	protected String []getAllFieldNames()
	{
		return ALL_FIELD_NAMES;
	}

	public Class<HsLegislacao> getInnerClass()
	{
		return HsLegislacao.class;
	}

	public Integer getJDOPrimaryKey()
	{
		Object obj = this.getId();
		if(obj instanceof JDOObject){
			 obj = ((JDOObject) obj).getInnerObject();
		}
		return (Integer) obj;
	}
}
