/*
* HsRelatorioRiscoDataAuto.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 HsRelatorioRiscoDataAuto extends JDOObject
{

	public static final String TABLENAME = "hs_relatorio_risco";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_relatorio_risco.id";
	public static final String RELATORIO_ID = "relatorio_id";
	public static final String RELATORIO_ID_FULL = "hs_relatorio_risco.relatorio_id";
	public static final String TO_RELATORIO_ID = "to relatorio_id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_relatorio_risco.description";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_relatorio_risco.deleted_date";

	public static final String FIELD_NAMES[] = new String[]{
		RELATORIO_ID, TO_RELATORIO_ID, DESCRIPTION, DELETED_DATE, };


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

	private Map<String, Object> dataHash;

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

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

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

	public Integer getRelatorio_id()
	{
		return (Integer) dataHash.get(RELATORIO_ID);
	}

	public void setRelatorio_id(Integer relatorio_idValue )
	{
		dataHash.put(TO_RELATORIO_ID, null);
		dataHash.put(RELATORIO_ID, relatorio_idValue );
	}

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

	public void setToRelatorio_id(com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioData relatorio_idObject )
	{
		if( relatorio_idObject == null )
		{
			dataHash.put(RELATORIO_ID, null);
		}
		else
		{
			dataHash.put(RELATORIO_ID, relatorio_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioData.ID ));
		}
		dataHash.put(TO_RELATORIO_ID, relatorio_idObject);
	}

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

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

	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( RELATORIO_ID.equals( fieldName ) )
		{
			value =  getRelatorio_id();
		}
		else if( TO_RELATORIO_ID.equals( fieldName ) )
		{
			value =  toRelatorio_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( RELATORIO_ID.equals( fieldName ) )
		{
			setRelatorio_id( (Integer) value );
		}
		else if( TO_RELATORIO_ID.equals( fieldName ) )
		{
			setToRelatorio_id( (com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioData) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_RELATORIO_ID) != null )
		{
			toRelatorio_id().save();
			dataHash.put(RELATORIO_ID, toRelatorio_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioData.ID ));
		}

		super.save();
	}

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

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

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

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