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

	public static final String TABLENAME = "hs_relatorio_medida";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_relatorio_medida.id";
	public static final String RISCO_ID = "risco_id";
	public static final String RISCO_ID_FULL = "hs_relatorio_medida.risco_id";
	public static final String TO_RISCO_ID = "to risco_id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_relatorio_medida.description";
	public static final String REQUESITOS_LEGAIS = "requesitos_legais";
	public static final String REQUESITOS_LEGAIS_FULL = "hs_relatorio_medida.requesitos_legais";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_relatorio_medida.deleted_date";

	public static final String FIELD_NAMES[] = new String[]{
		RISCO_ID, TO_RISCO_ID, DESCRIPTION, REQUESITOS_LEGAIS, DELETED_DATE, };


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

	private Map<String, Object> dataHash;

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

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

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

	public Integer getRisco_id()
	{
		return (Integer) dataHash.get(RISCO_ID);
	}

	public void setRisco_id(Integer risco_idValue )
	{
		dataHash.put(TO_RISCO_ID, null);
		dataHash.put(RISCO_ID, risco_idValue );
	}

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

	public void setToRisco_id(com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioRiscoData risco_idObject )
	{
		if( risco_idObject == null )
		{
			dataHash.put(RISCO_ID, null);
		}
		else
		{
			dataHash.put(RISCO_ID, risco_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioRiscoData.ID ));
		}
		dataHash.put(TO_RISCO_ID, risco_idObject);
	}

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

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

	public String getRequesitos_legais()
	{
		return (String) get(REQUESITOS_LEGAIS);
	}

	public void setRequesitos_legais(String requesitos_legaisValue )
	{
		this.set(REQUESITOS_LEGAIS, requesitos_legaisValue );
	}

	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_RISCO_ID.equals( fieldName ) )
		{
			value =  toRisco_id();
		}
		else if( RISCO_ID.equals( fieldName ) )
		{
			value =  getRisco_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_RISCO_ID.equals( fieldName ) )
		{
			setToRisco_id( (com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioRiscoData) value );
		}
		else if( RISCO_ID.equals( fieldName ) )
		{
			setRisco_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_RISCO_ID) != null )
		{
			toRisco_id().save();
			dataHash.put(RISCO_ID, toRisco_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsRelatorioRiscoData.ID ));
		}

		super.save();
	}

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

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

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

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