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

	public static final String TABLENAME = "hs_area";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_area.id";
	public static final String EMPRESA_ID = "empresa_id";
	public static final String EMPRESA_ID_FULL = "hs_area.empresa_id";
	public static final String TO_EMPRESA_ID = "to empresa_id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_area.description";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_area.deleted_date";
	public static final String ORDEM = "ordem";
	public static final String ORDEM_FULL = "hs_area.ordem";

	public static final String FIELD_NAMES[] = new String[]{
		EMPRESA_ID, TO_EMPRESA_ID, DESCRIPTION, DELETED_DATE, ORDEM, };


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

	private Map<String, Object> dataHash;

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

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

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

	public Integer getEmpresa_id()
	{
		return (Integer) dataHash.get(EMPRESA_ID);
	}

	public void setEmpresa_id(Integer empresa_idValue )
	{
		dataHash.put(TO_EMPRESA_ID, null);
		dataHash.put(EMPRESA_ID, empresa_idValue );
	}

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

	public void setToEmpresa_id(com.evolute.siprp.server.db.data.siprp_local3.EmpresasData empresa_idObject )
	{
		if( empresa_idObject == null )
		{
			dataHash.put(EMPRESA_ID, null);
		}
		else
		{
			dataHash.put(EMPRESA_ID, empresa_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.EmpresasData.ID ));
		}
		dataHash.put(TO_EMPRESA_ID, empresa_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 );
	}

	public Integer getOrdem()
	{
		return (Integer) get(ORDEM);
	}

	public void setOrdem(Integer ordemValue )
	{
		this.set(ORDEM, ordemValue );
	}

	protected Object innerGet( String fieldName )
		throws Exception
	{
		Object value = null;
		if( TO_EMPRESA_ID.equals( fieldName ) )
		{
			value =  toEmpresa_id();
		}
		else if( EMPRESA_ID.equals( fieldName ) )
		{
			value =  getEmpresa_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_EMPRESA_ID.equals( fieldName ) )
		{
			setToEmpresa_id( (com.evolute.siprp.server.db.data.siprp_local3.EmpresasData) value );
		}
		else if( EMPRESA_ID.equals( fieldName ) )
		{
			setEmpresa_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_EMPRESA_ID) != null )
		{
			toEmpresa_id().save();
			dataHash.put(EMPRESA_ID, toEmpresa_id().get( com.evolute.siprp.server.db.data.siprp_local3.EmpresasData.ID ));
		}

		super.save();
	}

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

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

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

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