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

	public static final String TABLENAME = "hs_posto";

	public static final String ID = "id";
	public static final String ID_FULL = "hs_posto.id";
	public static final String AREA_ID = "area_id";
	public static final String AREA_ID_FULL = "hs_posto.area_id";
	public static final String TO_AREA_ID = "to area_id";
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_posto.description";
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_posto.deleted_date";
	public static final String IS_PRINCIPAL = "is_principal";
	public static final String IS_PRINCIPAL_FULL = "hs_posto.is_principal";

	public static final String FIELD_NAMES[] = new String[]{
		AREA_ID, TO_AREA_ID, DESCRIPTION, DELETED_DATE, IS_PRINCIPAL, };


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

	private Map<String, Object> dataHash;

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

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

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

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

	public void setArea_id(Integer area_idValue )
	{
		dataHash.put(TO_AREA_ID, null);
		dataHash.put(AREA_ID, area_idValue );
	}

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

	public void setToArea_id(com.evolute.siprp.server.db.data.siprp_local3.HsAreaData area_idObject )
	{
		if( area_idObject == null )
		{
			dataHash.put(AREA_ID, null);
		}
		else
		{
			dataHash.put(AREA_ID, area_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsAreaData.ID ));
		}
		dataHash.put(TO_AREA_ID, area_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 Boolean getIs_principal()
	{
		return (Boolean) get(IS_PRINCIPAL);
	}

	public void setIs_principal(Boolean is_principalValue )
	{
		this.set(IS_PRINCIPAL, is_principalValue );
	}

	protected Object innerGet( String fieldName )
		throws Exception
	{
		Object value = null;
		if( TO_AREA_ID.equals( fieldName ) )
		{
			value =  toArea_id();
		}
		else if( AREA_ID.equals( fieldName ) )
		{
			value =  getArea_id();
		}
		else
		{
			value =  dataHash.get( fieldName );
		}
		return value;
	}

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_AREA_ID.equals( fieldName ) )
		{
			setToArea_id( (com.evolute.siprp.server.db.data.siprp_local3.HsAreaData) value );
		}
		else if( AREA_ID.equals( fieldName ) )
		{
			setArea_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_AREA_ID) != null )
		{
			toArea_id().save();
			dataHash.put(AREA_ID, toArea_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsAreaData.ID ));
		}

		super.save();
	}

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

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

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

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