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

	public static final String TABLENAME = "plano_areas";

	public static final String DESCRICAO = "descricao";
	public static final String DESCRICAO_FULL = "plano_areas.descricao";
	public static final String PLANO_ID = "plano_id";
	public static final String PLANO_ID_FULL = "plano_areas.plano_id";
	public static final String TO_PLANO_ID = "to plano_id";
	public static final String ID = "id";
	public static final String ID_FULL = "plano_areas.id";
	public static final String AREA_ID = "area_id";
	public static final String AREA_ID_FULL = "plano_areas.area_id";

	public static final String FIELD_NAMES[] = new String[]{
		DESCRICAO, PLANO_ID, TO_PLANO_ID, AREA_ID, };


	protected static final String ALL_FIELD_NAMES[] = new String[]{
		DESCRICAO, PLANO_ID, ID, AREA_ID, };

	private Map<String, Object> dataHash;

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

	public String getDescricao()
	{
		return (String) get(DESCRICAO);
	}

	public void setDescricao(String descricaoValue )
	{
		this.set(DESCRICAO, descricaoValue );
	}

	public Integer getPlano_id()
	{
		return (Integer) dataHash.get(PLANO_ID);
	}

	public void setPlano_id(Integer plano_idValue )
	{
		dataHash.put(TO_PLANO_ID, null);
		dataHash.put(PLANO_ID, plano_idValue );
	}

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

	public void setToPlano_id(com.evolute.siprp.server.db.data.siprp.PlanosActuacaoData plano_idObject )
	{
		if( plano_idObject == null )
		{
			dataHash.put(PLANO_ID, null);
		}
		else
		{
			dataHash.put(PLANO_ID, plano_idObject.get( com.evolute.siprp.server.db.data.siprp.PlanosActuacaoData.ID ));
		}
		dataHash.put(TO_PLANO_ID, plano_idObject);
	}

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

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

	public Integer getArea_id()
	{
		return (Integer) get(AREA_ID);
	}

	public void setArea_id(Integer area_idValue )
	{
		this.set(AREA_ID, area_idValue );
	}

	protected Object innerGet( String fieldName )
		throws Exception
	{
		Object value = null;
		if( TO_PLANO_ID.equals( fieldName ) )
		{
			value =  toPlano_id();
		}
		else if( PLANO_ID.equals( fieldName ) )
		{
			value =  getPlano_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_PLANO_ID.equals( fieldName ) )
		{
			setToPlano_id( (com.evolute.siprp.server.db.data.siprp.PlanosActuacaoData) value );
		}
		else if( PLANO_ID.equals( fieldName ) )
		{
			setPlano_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_PLANO_ID) != null )
		{
			toPlano_id().save();
			dataHash.put(PLANO_ID, toPlano_id().get( com.evolute.siprp.server.db.data.siprp.PlanosActuacaoData.ID ));
		}

		super.save();
	}

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

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

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

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