maia_modificado/.svn/pristine/e4/e4de58a4aa4241f0076e918fc19...

366 lines
12 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.gene;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fp.common.helper.Constant;
import com.fp.dto.hb.HibernateBean;
/** Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENECASHCLOSEHEADER */
@Entity(name = "TgeneCashCloseHeader")
@Table(name = "TGENECASHCLOSEHEADER")
public class TgeneCashCloseHeader extends com.fp.dto.AbstractDataTransport implements Serializable, HibernateBean, Cloneable {
/**
* HashCode asociado con la Instancia
*/
@Transient
private int hashValue = 0;
/**
* Version de la Clase
*/
private static final long serialVersionUID = 1L;
/**
* Clave primaria de la Entidad TgeneCashCloseHeader
*/
@EmbeddedId
private TgeneCashCloseHeaderKey pk;
@Column(name = "DATEFROM", nullable = true)
/**
* Fecha desde la cual esta vigente el registro
*/
private Timestamp datefrom;
@Column(name = "STATUSCATALOG", nullable = true)
/**
* Codigo de catalogo 01 Natural, 02 Juridico
*/
private String statuscatalog;
@Column(name = "STATUSCATALOGCODE", nullable = true)
/**
* Codigo de tabla de catalogo 01 Codigo de tabla de tipos de persona
*/
private String statuscatalogcode;
@Column(name = "TOTAL", nullable = true)
/**
* Monto total del cierre de caja por moneda
*/
private BigDecimal total;
@Column(name = "JOURNALID", nullable = true)
/**
* Numero de mensaje con el que se genera el financiero.
*/
private String journalid;
/** Contructor por defecto */
public TgeneCashCloseHeader() {
}
/**
* Contructor de TgeneCashCloseHeader
*
* @param pPk Clave Primaria del entity
*/
public TgeneCashCloseHeader(TgeneCashCloseHeaderKey pPk) {
this();
this.pk = pPk;
}
/**
* Metodo que entrega datos de la tabla dada la clave primaria.
*
* @param pEntityManager referencia de la session a obtener datos del bean.
* @param pKey Caleve primaria del bean.
* @return TgeneCashCloseHeader
*/
public static TgeneCashCloseHeader find(EntityManager pEntityManager, TgeneCashCloseHeaderKey pKey) throws Exception {
TgeneCashCloseHeader obj = pEntityManager.find(TgeneCashCloseHeader.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TgeneCashCloseHeader
*
* @return El objeto que referencia a la Clave primaria de TgeneCashCloseHeader
*/
public TgeneCashCloseHeaderKey getPk() {
return this.pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TgeneCashCloseHeader
*
* @param pPk El objeto que referencia a la nueva Clave primaria de TgeneCashCloseHeader
*/
public void setPk(TgeneCashCloseHeaderKey pPk) {
this.pk = pPk;
}
/**
* Obtiene el valor de datefrom
*
* @return valor de datefrom
*/
public Timestamp getDatefrom() {
return this.datefrom;
}
/**
* Fija el valor de datefrom
*
* @param pDatefrom nuevo Valor de datefrom
*/
public void setDatefrom(Timestamp pDatefrom) {
this.datefrom = pDatefrom;
}
/**
* Obtiene el valor de statuscatalog
*
* @return valor de statuscatalog
*/
public String getStatuscatalog() {
return this.statuscatalog;
}
/**
* Fija el valor de statuscatalog
*
* @param pStatuscatalog nuevo Valor de statuscatalog
*/
public void setStatuscatalog(String pStatuscatalog) {
this.statuscatalog = pStatuscatalog;
}
/**
* Obtiene el valor de statuscatalogcode
*
* @return valor de statuscatalogcode
*/
public String getStatuscatalogcode() {
return this.statuscatalogcode;
}
/**
* Fija el valor de statuscatalogcode
*
* @param pStatuscatalogcode nuevo Valor de statuscatalogcode
*/
public void setStatuscatalogcode(String pStatuscatalogcode) {
this.statuscatalogcode = pStatuscatalogcode;
}
/**
* Obtiene el valor de total
*
* @return valor de total
*/
public BigDecimal getTotal() {
return this.total;
}
/**
* Fija el valor de total
*
* @param pTotal nuevo Valor de total
*/
public void setTotal(BigDecimal pTotal) {
this.total = pTotal;
}
/**
* Obtiene el valor de journalid
*
* @return valor de journalid
*/
public String getJournalid() {
return this.journalid;
}
/**
* Fija el valor de journalid
*
* @param pJournalid nuevo Valor de journalid
*/
public void setJournalid(String pJournalid) {
this.journalid = pJournalid;
}
@Override
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TgeneCashCloseHeader)) {
return false;
}
TgeneCashCloseHeader that = (TgeneCashCloseHeader) rhs;
if ((this.getPk() == null) || (that.getPk() == null)) {
return false;
}
return (this.getPk().equals(that.getPk()));
}
/**
* Implementaci<63>n del metodo hashCode de la la entidad TgeneCashCloseHeader
*
* @return el hashCode la instancia
*/
@Override
public int hashCode() {
if (this.hashValue == 0) {
int result = 17;
if (this.getPk() == null) {
result = super.hashCode();
} else {
result = this.getPk().hashCode();
}
this.hashValue = result;
}
return this.hashValue;
}
/** Implementaci<63>n toString */
@Override
public String toString() {
Field[] fs = this.getClass().getDeclaredFields();
String data = "";
for (Field f : fs) {
try {
String name = f.getName();
if (f.getType().getName().compareTo("java.util.Set") == 0) {
continue;
}
if ((name.compareTo("hashValue") == 0) || (name.compareTo("serialVersionUID") == 0)) {
continue;
}
data += name + "=" + f.get(this) + ";";
} catch (Exception e) {
continue;
}
}
if (data.compareTo("") == 0) {
data = super.toString();
}
return data;
}
/** Implementaci<63>n de la creaci<63>n de un bean en blanco TgeneCashCloseHeader */
@Override
public Object createInstance() {
TgeneCashCloseHeader instance = new TgeneCashCloseHeader();
instance.setPk(new TgeneCashCloseHeaderKey());
return instance;
}
/**
* Clona la entidad TgeneCashCloseHeader
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
@Override
public Object cloneMe() throws CloneNotSupportedException {
TgeneCashCloseHeader p = (TgeneCashCloseHeader) this.clone();
p.setPk((TgeneCashCloseHeaderKey) this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
// METODOS MANUALES
/** Sentencia que entrega la los datos de TgeneCashCloseHeader */
private static final String JPQL_CASH_CLOSE_HEADER = " from TgeneCashCloseHeader cch" + " where cch.pk.workingdate = :workingdate"
+ " and cch.pk.usercode = :usercode" + " and cch.pk.currencycode = :currencycode" + " and cch.pk.officecode = :officecode"
+ " and cch.pk.branchcode = :branchcode" + " and cch.pk.companycode = :companycode" + " and cch.pk.dateto = :dateto";
/**
* Metodo que entrega los datos de TgeneCashCloseHeader
*
* @param pEntityManager Session de la base de datos.
* @param workingdate Fecha de trabajo
* @param usercode Codigo de usuario
* @param currencycode Codigo de moneda
* @param companycode Codigo de compania
* @param branchcode Codigo de sucursal
* @param officecode Codigo de oficina
* @return
* @throws Exception
*/
public static TgeneCashCloseHeader find(EntityManager pEntityManager, Date workingdate, String usercode, String currencycode,
Integer companycode, Integer branchcode, Integer officecode) throws Exception {
Query qry = pEntityManager.createQuery(TgeneCashCloseHeader.JPQL_CASH_CLOSE_HEADER);
qry.setParameter(Constant.VWORKINGDATE, workingdate);
qry.setParameter("usercode", usercode);
qry.setParameter("currencycode", currencycode);
qry.setParameter("officecode", officecode);
qry.setParameter("branchcode", branchcode);
qry.setParameter("companycode", companycode);
qry.setParameter("dateto", Constant.getDefaultExpiryDate());
try {
return (TgeneCashCloseHeader) qry.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
/**
* Sentencia que entrega la los datos de TgeneCashCloseHeader
*/
private static final String JPQL_CASH_CLOSE_HEADER_WITH_STATUS = " from TgeneCashCloseHeader cch" + " where cch.pk.workingdate = :workingdate"
+ " and cch.pk.usercode = :usercode" + " and cch.pk.currencycode = :currencycode" + " and cch.pk.officecode = :officecode"
+ " and cch.pk.branchcode = :branchcode" + " and cch.pk.companycode = :companycode" + " and cch.pk.dateto = :dateto"
+ " and cch.statuscatalog = :statuscatalog";
/**
* Metodo que entrega los datos de TgeneCashCloseHeader, dada la fecha de trabajo, usuario y secuencia.
*
* @param pEntityManager Session de la base de datos.
* @param workingdate Fecha de trabajo
* @param usercode Codigo de usuario
* @param workingdate
* @param currencycode
* @param companycode
* @param branchcode
* @param officecode
* @return
* @throws Exception
*/
public static TgeneCashCloseHeader find(EntityManager pEntityManager, String usercode, String statuscatalog, Date workingdate,
String currencycode, Integer companycode, Integer branchcode, Integer officecode) throws Exception {
Query qry = pEntityManager.createQuery(TgeneCashCloseHeader.JPQL_CASH_CLOSE_HEADER_WITH_STATUS);
qry.setParameter(Constant.VWORKINGDATE, workingdate);
qry.setParameter("usercode", usercode);
qry.setParameter("currencycode", currencycode);
qry.setParameter("officecode", officecode);
qry.setParameter("branchcode", branchcode);
qry.setParameter("companycode", companycode);
qry.setParameter("dateto", Constant.getDefaultExpiryDate());
qry.setParameter("statuscatalog", statuscatalog);
try {
return (TgeneCashCloseHeader) qry.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
}