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

	public static final String TABLENAME = "hs_risco";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_risco.id";
	public static final String TEMA_ID = "tema_id";
	public static final String TEMA_ID_FULL = "hs_risco.tema_id";
	public static final String TO_TEMA_ID = "to tema_id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_risco.description";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_risco.deleted_date";

	public static final String FIELD_NAMES[] = new String[]{
		TEMA_ID, TO_TEMA_ID, DESCRIPTION, DELETED_DATE, };


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

	private Map<String, Object> dataHash;

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

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

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

	public Integer getTema_id()
	{
		return (Integer) dataHash.get(TEMA_ID);
	}

	public void setTema_id(Integer tema_idValue )
	{
		dataHash.put(TO_TEMA_ID, null);
		dataHash.put(TEMA_ID, tema_idValue );
	}

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

	public void setToTema_id(com.evolute.siprp.server.db.data.siprp_local3.HsRiscoTemaData tema_idObject )
	{
		if( tema_idObject == null )
		{
			dataHash.put(TEMA_ID, null);
		}
		else
		{
			dataHash.put(TEMA_ID, tema_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsRiscoTemaData.ID ));
		}
		dataHash.put(TO_TEMA_ID, tema_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( TO_TEMA_ID.equals( fieldName ) )
		{
			value =  toTema_id();
		}
		else if( TEMA_ID.equals( fieldName ) )
		{
			value =  getTema_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_TEMA_ID.equals( fieldName ) )
		{
			setToTema_id( (com.evolute.siprp.server.db.data.siprp_local3.HsRiscoTemaData) value );
		}
		else if( TEMA_ID.equals( fieldName ) )
		{
			setTema_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_TEMA_ID) != null )
		{
			toTema_id().save();
			dataHash.put(TEMA_ID, toTema_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsRiscoTemaData.ID ));
		}

		super.save();
	}

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

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

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

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