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

	public static final String TABLENAME = "hs_email_empresa";

	public static final String EMAIL_ID = "email_id";
	public static final String EMAIL_ID_FULL = "hs_email_empresa.email_id";
	public static final String TO_EMAIL_ID = "to email_id";
	public static final String EMPRESA_ID = "empresa_id";
	public static final String EMPRESA_ID_FULL = "hs_email_empresa.empresa_id";
	public static final String TO_EMPRESA_ID = "to empresa_id";

	public static final String FIELD_NAMES[] = new String[]{
		};


	protected static final String ALL_FIELD_NAMES[] = new String[]{
		EMAIL_ID, EMPRESA_ID, };

	private Map<String, Object> dataHash;

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

	public Integer getEmail_id()
	{
		return (Integer) dataHash.get(EMAIL_ID);
	}

	public void setEmail_id(Integer email_idValue )
	{
		dataHash.put(TO_EMAIL_ID, null);
		dataHash.put(EMAIL_ID, email_idValue );
	}

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

	public void setToEmail_id(com.evolute.siprp.server.db.data.siprp_local3.HsEmailData email_idObject )
	{
		if( email_idObject == null )
		{
			dataHash.put(EMAIL_ID, null);
		}
		else
		{
			dataHash.put(EMAIL_ID, email_idObject.get( com.evolute.siprp.server.db.data.siprp_local3.HsEmailData.ID ));
		}
		dataHash.put(TO_EMAIL_ID, email_idObject);
	}

	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);
	}

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

	protected void innerSet( String fieldName, Object value )
		throws Exception
	{
		if( TO_EMAIL_ID.equals( fieldName ) )
		{
			setToEmail_id( (com.evolute.siprp.server.db.data.siprp_local3.HsEmailData) value );
		}
		else 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 if( EMAIL_ID.equals( fieldName ) )
		{
			setEmail_id( (Integer) value );
		}
		else
		{
			dataHash.put( fieldName, value );
		}
	}

	public void save()
		throws Exception
	{
		if( dataHash.get(TO_EMAIL_ID) != null )
		{
			toEmail_id().save();
			dataHash.put(EMAIL_ID, toEmail_id().get( com.evolute.siprp.server.db.data.siprp_local3.HsEmailData.ID ));
		}

		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<HsEmailEmpresa> getInnerClass()
	{
		return HsEmailEmpresa.class;
	}

	public com.evolute.siprp.server.db.data.siprp_local3.HsEmailEmpresaID getJDOPrimaryKey()
	{
		com.evolute.siprp.server.db.data.siprp_local3.HsEmailEmpresaID id = new com.evolute.siprp.server.db.data.siprp_local3.HsEmailEmpresaID();

		Object obj;
		obj = this.getEmail_id();
		if(obj instanceof JDOObject){
			 obj = ((JDOObject) obj).getInnerObject();
		}
		id.email_id = (Integer)obj;

		obj = this.getEmpresa_id();
		if(obj instanceof JDOObject){
			 obj = ((JDOObject) obj).getInnerObject();
		}
		id.empresa_id = (Integer)obj;

		return id;

	}
}
