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

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

class RecomendacoesDataAuto extends JDOObject
{

	public static final String TABLENAME = "recomendacoes";

	public static final String ID = "id";
	public static final String ID_FULL = "recomendacoes.id";
	public static final String ANALISE_ID = "analise_id";
	public static final String ANALISE_ID_FULL = "recomendacoes.analise_id";
	public static final String TO_ANALISE_ID = "to analise_id";
	public static final String RECOMENDACAO = "recomendacao";
	public static final String RECOMENDACAO_FULL = "recomendacoes.recomendacao";

	public static final String FIELD_NAMES[] = new String[]{
		ANALISE_ID, TO_ANALISE_ID, RECOMENDACAO, };


	protected static final String ALL_FIELD_NAMES[] = new String[]{
		ID, ANALISE_ID, RECOMENDACAO, };

	private Map<String, Object> dataHash;

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

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

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

	public Integer getAnalise_id()
	{
		return (Integer) dataHash.get(ANALISE_ID);
	}

	public void setAnalise_id(Integer analise_idValue )
	{
		dataHash.put(TO_ANALISE_ID, null);
		dataHash.put(ANALISE_ID, analise_idValue );
	}

	public com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData toAnalise_id()
		throws Exception
	{
		if( dataHash.get(TO_ANALISE_ID) == null && getAnalise_id() != null )
		{
			dataHash.put(TO_ANALISE_ID, getJDOProvider().load(com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData.class, new Object[]{ getAnalise_id() }, new String[]{ com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData.ID }));
		}
		return (com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData) dataHash.get(TO_ANALISE_ID);
	}

	public void setToAnalise_id(com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData analise_idObject )
	{
		if( analise_idObject == null )
		{
			dataHash.put(ANALISE_ID, null);
		}
		else
		{
			dataHash.put(ANALISE_ID, analise_idObject.get( com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData.ID ));
		}
		dataHash.put(TO_ANALISE_ID, analise_idObject);
	}

	public String getRecomendacao()
	{
		return (String) get(RECOMENDACAO);
	}

	public void setRecomendacao(String recomendacaoValue )
	{
		this.set(RECOMENDACAO, recomendacaoValue );
	}

	protected Object innerGet( String fieldName )
		throws Exception
	{
		Object value = null;
		if( TO_ANALISE_ID.equals( fieldName ) )
		{
			value =  toAnalise_id();
		}
		else if( ANALISE_ID.equals( fieldName ) )
		{
			value =  getAnalise_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_ANALISE_ID.equals( fieldName ) )
		{
			setToAnalise_id( (com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData) value );
		}
		else if( ANALISE_ID.equals( fieldName ) )
		{
			setAnalise_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_ANALISE_ID) != null )
		{
			toAnalise_id().save();
			dataHash.put(ANALISE_ID, toAnalise_id().get( com.evolute.siprp.server.db.data.siprp.AnalisesAcidentesData.ID ));
		}

		super.save();
	}

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

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

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

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