/*
* HsArea.java
*
* Generated by com.evutils.codegen.EntityObjectGenerator
*
* Use but DON'T TOUCH
* -> (can't touch this)
*/
package siprp.data.inner;


public class HsArea extends siprp.data.BaseObject
{
	private static final java.util.HashMap<String,Integer> FIELD_INDEXES = new java.util.HashMap<String,Integer>();

	static
	{
		FIELD_INDEXES.put( HsArea.ID, HsArea.ID_INDEX );
		FIELD_INDEXES.put( HsArea.ID_FULL, HsArea.ID_INDEX );
		com.evolute.entity.evo.EvoDataObject.register( HsArea.CLASS_IDENTIFIER, HsArea.EMPRESA_ID, HsArea.TO_EMPRESA_ID ); 
		FIELD_INDEXES.put( HsArea.EMPRESA_ID, HsArea.EMPRESA_ID_INDEX );
		FIELD_INDEXES.put( HsArea.EMPRESA_ID_FULL, HsArea.EMPRESA_ID_INDEX );
		FIELD_INDEXES.put( HsArea.TO_EMPRESA_ID, HsArea.TO_EMPRESA_ID_INDEX );
		FIELD_INDEXES.put( HsArea.DESCRIPTION, HsArea.DESCRIPTION_INDEX );
		FIELD_INDEXES.put( HsArea.DESCRIPTION_FULL, HsArea.DESCRIPTION_INDEX );
		FIELD_INDEXES.put( HsArea.DELETED_DATE, HsArea.DELETED_DATE_INDEX );
		FIELD_INDEXES.put( HsArea.DELETED_DATE_FULL, HsArea.DELETED_DATE_INDEX );
		FIELD_INDEXES.put( HsArea.ORDEM, HsArea.ORDEM_INDEX );
		FIELD_INDEXES.put( HsArea.ORDEM_FULL, HsArea.ORDEM_INDEX );
	}

	private final java.util.HashMap< String, Boolean > LAZY_LOADED_OBJECTS = new java.util.HashMap< String, Boolean >();


	public static final com.evolute.entity.ForeignKey ForeignKeyempresa_idToempresas = 
		new com.evolute.entity.ForeignKey( HsArea.class, HsArea.EMPRESA_ID, siprp.data.outer.EmpresasData.class, siprp.data.outer.EmpresasData.ID );

	public static final String TABLENAME = "hs_area";


	public static final String CLASS_IDENTIFIER = "hs_area1277401737160";

	public static final int _INVALID__INDEX = -1;
	public static final String ID = "id";
	public static final String ID_FULL = "hs_area.id";
	public static final int ID_INDEX = 0;
	public static final String EMPRESA_ID = "empresa_id";
	public static final String EMPRESA_ID_FULL = "hs_area.empresa_id";
	public static final int EMPRESA_ID_INDEX = 1;
	public static final String TO_EMPRESA_ID = "to_empresa_id";
	public static final int TO_EMPRESA_ID_INDEX = 2;
	public static final String DESCRIPTION = "description";
	public static final String DESCRIPTION_FULL = "hs_area.description";
	public static final int DESCRIPTION_INDEX = 3;
	public static final String DELETED_DATE = "deleted_date";
	public static final String DELETED_DATE_FULL = "hs_area.deleted_date";
	public static final int DELETED_DATE_INDEX = 4;
	public static final String ORDEM = "ordem";
	public static final String ORDEM_FULL = "hs_area.ordem";
	public static final int ORDEM_INDEX = 5;

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

	public static final String FIELD_NAMES_FULL[] = new String[]{
		TABLENAME + "." + EMPRESA_ID, TABLENAME + "." + TO_EMPRESA_ID, TABLENAME + "." + DESCRIPTION, TABLENAME + "." + DELETED_DATE, TABLENAME + "." + ORDEM, };

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


	protected static final String PK_FIELD_NAMES[] = new String[]{
		ID, };


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

	private Integer id;
	private Integer empresa_id;
	private siprp.data.outer.EmpresasData to_empresa_id;
	private String description;
	private java.sql.Timestamp deleted_date;
	private Integer ordem;

	protected com.evolute.entity.utils.IntegerPrimaryKey primaryKey;

	public HsArea()
	{
		super();
		dirtyProperties = new boolean[]{ false, false, false, 
			false, false, false };
	}

	public Integer getId()
	{
		try
		{
			setLastAccess( System.currentTimeMillis() );
			prepare( ID );
		}
		catch( java.lang.Exception ex )
		{
			throw new RuntimeException( ex );
		}
		return this.id;
	}

	public void setId( Integer id )
	{
		try
		{
			setLockedForRefresh( true );
			preProcess( ID, id );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.id = id;
		LAZY_LOADED_OBJECTS.put( ID, Boolean.TRUE );
	}

	public java.util.List<siprp.data.outer.HsPostoData>fromHsPosto_area_id()
	{
		java.util.List<siprp.data.outer.HsPostoData> result = null;
		try
		{
			result = fromReference( siprp.data.outer.HsPostoData.class , getPrimaryKey().getMap().get("id"), "area_id" );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		return result;
	}

	public Integer getEmpresa_id()
	{
		try
		{
			setLastAccess( System.currentTimeMillis() );
			prepare( EMPRESA_ID );
		}
		catch( java.lang.Exception ex )
		{
			throw new RuntimeException( ex );
		}
		return this.empresa_id;
	}

	public void setEmpresa_id( Integer empresa_id )
	{
		try
		{
			setLockedForRefresh( true );
			preProcess( EMPRESA_ID, empresa_id );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.empresa_id = empresa_id;
		LAZY_LOADED_OBJECTS.put( EMPRESA_ID, Boolean.TRUE );
	}

	public siprp.data.outer.EmpresasData toEmpresa_id()
	{
		try
		{
			prepare( TO_EMPRESA_ID );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		return this.to_empresa_id;
	}

	public void setToEmpresa_id( siprp.data.outer.EmpresasData to_empresa_id )
	{
		try
		{
			preProcess( TO_EMPRESA_ID, to_empresa_id );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.to_empresa_id = to_empresa_id;
	}

	public String getDescription()
	{
		try
		{
			setLastAccess( System.currentTimeMillis() );
			prepare( DESCRIPTION );
		}
		catch( java.lang.Exception ex )
		{
			throw new RuntimeException( ex );
		}
		return this.description;
	}

	public void setDescription( String description )
	{
		try
		{
			setLockedForRefresh( true );
			preProcess( DESCRIPTION, description );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.description = description;
		LAZY_LOADED_OBJECTS.put( DESCRIPTION, Boolean.TRUE );
	}

	public java.sql.Timestamp getDeleted_date()
	{
		try
		{
			setLastAccess( System.currentTimeMillis() );
			prepare( DELETED_DATE );
		}
		catch( java.lang.Exception ex )
		{
			throw new RuntimeException( ex );
		}
		return this.deleted_date;
	}

	public void setDeleted_date( java.sql.Timestamp deleted_date )
	{
		try
		{
			setLockedForRefresh( true );
			preProcess( DELETED_DATE, deleted_date );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.deleted_date = deleted_date;
		LAZY_LOADED_OBJECTS.put( DELETED_DATE, Boolean.TRUE );
	}

	public Integer getOrdem()
	{
		try
		{
			setLastAccess( System.currentTimeMillis() );
			prepare( ORDEM );
		}
		catch( java.lang.Exception ex )
		{
			throw new RuntimeException( ex );
		}
		return this.ordem;
	}

	public void setOrdem( Integer ordem )
	{
		try
		{
			setLockedForRefresh( true );
			preProcess( ORDEM, ordem );
		}
		catch( com.evolute.entity.evo.EvoDataException edex )
		{
			throw new RuntimeException( edex );
		}
		this.ordem = ordem;
		LAZY_LOADED_OBJECTS.put( ORDEM, Boolean.TRUE );
	}

	public Object get( String fieldName )
	{
		Object value = null;
		Integer index = getFieldIndex( fieldName );
		switch( index )
		{
			case HsArea.ID_INDEX:
				value = getId();
				break;
			case HsArea.EMPRESA_ID_INDEX:
				value = getEmpresa_id();
				break;
			case HsArea.TO_EMPRESA_ID_INDEX:
				value = toEmpresa_id();
				break;
			case HsArea.DESCRIPTION_INDEX:
				value = getDescription();
				break;
			case HsArea.DELETED_DATE_INDEX:
				value = getDeleted_date();
				break;
			case HsArea.ORDEM_INDEX:
				value = getOrdem();
				break;
		}
		return value;
	}

	public Object rawGet( String fieldName )
	{
		Object value = null;
		Integer index = getFieldIndex( fieldName );
		switch( index )
		{
			case HsArea.ID_INDEX:
				value = this.id;
				break;
			case HsArea.EMPRESA_ID_INDEX:
				value = this.empresa_id;
				break;
			case HsArea.TO_EMPRESA_ID_INDEX:
				value = this.to_empresa_id;
				break;
			case HsArea.DESCRIPTION_INDEX:
				value = this.description;
				break;
			case HsArea.DELETED_DATE_INDEX:
				value = this.deleted_date;
				break;
			case HsArea.ORDEM_INDEX:
				value = this.ordem;
				break;
		}
		return value;
	}

	public void set( String fieldName, Object value )
	{
		Integer index = getFieldIndex( fieldName );
		switch( index )
		{
			case HsArea.ID_INDEX:
				setId( ( Integer ) value );
				break;
			case HsArea.EMPRESA_ID_INDEX:
				setEmpresa_id( ( Integer ) value );
				break;
			case HsArea.TO_EMPRESA_ID_INDEX:
				setToEmpresa_id( ( siprp.data.outer.EmpresasData ) value );
				break;
			case HsArea.DESCRIPTION_INDEX:
				setDescription( ( String ) value );
				break;
			case HsArea.DELETED_DATE_INDEX:
				setDeleted_date( ( java.sql.Timestamp ) value );
				break;
			case HsArea.ORDEM_INDEX:
				setOrdem( ( Integer ) value );
				break;
		}
	}

	public void rawSet( String fieldName, Object value )
	{
		Integer index = getFieldIndex( fieldName );
		switch( index )
		{
			case HsArea.ID_INDEX:
				this.id = ( Integer ) value;
				break;
			case HsArea.EMPRESA_ID_INDEX:
				this.empresa_id = ( Integer ) value;
				break;
			case HsArea.TO_EMPRESA_ID_INDEX:
				this.to_empresa_id = ( siprp.data.outer.EmpresasData ) value;
				break;
			case HsArea.DESCRIPTION_INDEX:
				this.description = ( String ) value;
				break;
			case HsArea.DELETED_DATE_INDEX:
				this.deleted_date = ( java.sql.Timestamp ) value;
				break;
			case HsArea.ORDEM_INDEX:
				this.ordem = ( Integer ) value;
				break;
		}
	}

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

	public String []getFieldNamesFull()
	{
		return FIELD_NAMES_FULL;
	}

	public String []getDBFieldNames()
	{
		return DB_FIELD_NAMES;
	}

	public String []getPrimaryKeyNames()
	{
		return PK_FIELD_NAMES;
	}

	public String []getDefaultLoadSet()
	{
		return DEFAULT_LOAD_SET;
	}

	public String getPrimaryKeyName()
	{
		return PK_FIELD_NAMES[ 0 ];
	}

	public Class<?> getFieldClass( String fieldName )
	{
		Integer index = getFieldIndex( fieldName );
		Class<?> theClass = null;
		switch( index )
		{
			case HsArea.ID_INDEX:
				theClass = Integer.class;
				break;
			case HsArea.EMPRESA_ID_INDEX:
				theClass = Integer.class;
				break;
			case HsArea.TO_EMPRESA_ID_INDEX:
				theClass = siprp.data.outer.EmpresasData.class;
				break;
			case HsArea.DESCRIPTION_INDEX:
				theClass = String.class;
				break;
			case HsArea.DELETED_DATE_INDEX:
				theClass = java.sql.Timestamp.class;
				break;
			case HsArea.ORDEM_INDEX:
				theClass = Integer.class;
				break;
		}
		return theClass;
	}

	public Integer getFieldIndex( String fieldName )
	{
		Integer index = FIELD_INDEXES.get( fieldName );
		return index != null ? index : HsArea._INVALID__INDEX;
	}

	public String getTableName()
	{
		return TABLENAME;
	}

	public String getClassIdentifier()
	{
		return CLASS_IDENTIFIER;
	}

	@Override
	protected void setPrimaryKeyFromVirtual2DArray( com.evolute.utils.arrays.Virtual2DArray array, int row, int col )
	{
		if( primaryKey == null )
		{
			primaryKey = new com.evolute.entity.utils.IntegerPrimaryKey( TABLENAME, HsArea.PK_FIELD_NAMES );
			primaryKey.set( 0, ( Integer ) array.get( row, col + 0 ) );
		}
		setId( ( Integer ) array.get( row, col + 0 ) );
	}

	@Override
	public com.evolute.entity.utils.IntegerPrimaryKey getPrimaryKey()
	{
		return primaryKey;
	}

	public void initLazyLoadFields()
	{
	}

	public boolean isPropertyLoaded( String fieldName )
	{
		if ( LAZY_LOADED_OBJECTS.get( fieldName ) == null )
		{
			return true;
		}
		else
		{
			return LAZY_LOADED_OBJECTS.get( fieldName );
		}
	}
}
