maia_modificado/.svn/pristine/29/29fda7977b36fd442e9a84bfce1...

1115 lines
33 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.acco;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.LockModeType;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Version;
import com.fp.common.helper.Constant;
import com.fp.core.exception.CoreException;
import com.fp.dto.hb.HibernateBean;
/**
* Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENEACCOUNT
*/
@Entity(name = "TgeneAccount")
@Table(name = "TGENEACCOUNT")
public class TgeneAccount 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 TgeneAccount
*/
@EmbeddedId
private TgeneAccountKey pk;
@Column(name = "DATEFROM", nullable = false)
/**
* Fecha desde la cual esta vigente el registro con datos de la cuenta.
*/
private Timestamp datefrom;
@Column(name = "ACCOUNTNAME", nullable = true)
/**
* Nombre de la cuenta
*/
private String accountname;
@Column(name = "PERSONCODE", nullable = true)
/**
* Codigo de persona principal de la cuenta
*/
private Integer personcode;
@Column(name = "MODULECODE", nullable = true)
/**
* Codigo de modulo al que pertenece la cuenta
*/
private String modulecode;
@Column(name = "PRODUCTCODE", nullable = true)
/**
* Codigo de producto
*/
private String productcode;
@Column(name = "SUBPRODUCTCODE", nullable = true)
/**
* Codigo de subproducto
*/
private String subproductcode;
@Column(name = "CURRENCYCODE", nullable = true)
/**
* Codigo de moneda
*/
private String currencycode;
@Column(name = "OFFICECODE", nullable = true)
/**
* Codigo de oficina a la que pertenece la cuenta
*/
private Integer officecode;
@Column(name = "BRANCHCODE", nullable = true)
/**
* Codigo de sucursal a la que pertenece la cuenta
*/
private Integer branchcode;
@Column(name = "OPENOFFICECODE", nullable = true)
/**
* Codigo de oficina de apertura de la cuenta
*/
private Integer openofficecode;
@Column(name = "OPENBRANCHCODE", nullable = true)
/**
* Codigo de sucursal de apertura de la cuenta
*/
private Integer openbranchcode;
@Column(name = "ACCOUNTSTATUSCODE", nullable = true)
/**
* Estatus de cuenta
*/
private String accountstatuscode;
@Column(name = "OFFICER", nullable = true)
/**
* Codigo de usuario oficial de cuenta
*/
private String officer;
@Column(name = "OPENINGUSERCODE", nullable = true)
/**
* Codigo de usuario de apertura de la cuenta
*/
private String openingusercode;
@Column(name = "PERSONSCORECATALOG", nullable = true)
/**
* Codigo de catalogo que contiene la calificacion del cliente A, B, C, D, E
*/
private String personscorecatalog;
@Column(name = "PERSONCATALOGCODE", nullable = true)
/**
* Codigo de tabla de catalogo 011 Codigo de tabla de calificaciones de cleinte
*/
private String personcatalogcode;
@Column(name = "CHARGECATALOG", nullable = true)
/**
* Codigo de catalogo 01 Natural, 02 Juridico
*/
private String chargecatalog;
@Column(name = "CHARGECATALOGCODE", nullable = true)
/**
* Codigo de tabla de catalogo 01 Codigo de tabla de tipos de persona
*/
private String chargecatalogcode;
@Column(name = "RATECATALOG", nullable = true)
/**
* Codigo de catalogo 01 Natural, 02 Juridico
*/
private String ratecatalog;
@Column(name = "RATECATALOGCODE", nullable = true)
/**
* Codigo de tabla de catalogo 01 Codigo de tabla de tipos de persona
*/
private String ratecatalogcode;
@Column(name = "CREDITTYPECODE", nullable = true)
/**
* Codigo de tipo de credito
*/
private String credittypecode;
@Column(name = "OPERATIVCONDITION", nullable = true)
/**
* Codigo de condicion operativa.
*/
private String operativcondition;
@Column(name = "OPERATIONSTATUS", nullable = true)
/**
* Codigo de estatus de la operacion, ORI (Original), REF (refinanciada), RES (restructurada)
*/
private String operationstatus;
@Column(name = "MOTIVESTATUSCATALOG", nullable = true)
/**
* Codigo de catalogo 1 Voluntario, Orden de Gerencia, 3 Orden de la SIB
*/
private String motivestatuscatalog;
@Column(name = "MOTIVESTATUSCATALOGCODE", nullable = true)
/**
* Codigo de tabla de catalogo MOTIVESTATUS
*/
private String motivestatuscatalogcode;
@Column(name = "SECURITYLEVEL", nullable = true)
/**
* Nivel de seguridad de la cuenta
*/
private Integer securitylevel;
@Version
@Column(name = "RECORDVERSION", nullable = true)
/**
* Optimistic locking del registro
*/
private Integer recordversion;
@Column(name = "JOURNALID", nullable = true)
/**
* Numero de mensaje con el cual se cambio algun campo del registro
*/
private String journalid;
@Column(name = "OLDJOURNALID", nullable = true)
/**
* NUmero de mensaje anterior con el que se cambio algun campo de la cuenta
*/
private String oldjournalid;
/** Contructor por defecto */
public TgeneAccount() {
}
/**
* Contructor de TgeneAccount
*
* @param pPk Clave Primaria del entity
* @param pDatefrom Fecha desde la cual esta vigente el registro con datos de la cuenta.
*/
public TgeneAccount(TgeneAccountKey pPk, Timestamp pDatefrom) {
this();
this.pk = pPk;
this.datefrom = pDatefrom;
}
/**
* 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 TgeneAccount
*/
public static TgeneAccount find(EntityManager pEntityManager, TgeneAccountKey pKey) throws Exception {
TgeneAccount obj = pEntityManager.find(TgeneAccount.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TgeneAccount
*
* @return El objeto que referencia a la Clave primaria de TgeneAccount
*/
public TgeneAccountKey getPk() {
return this.pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TgeneAccount
*
* @param pPk El objeto que referencia a la nueva Clave primaria de TgeneAccount
*/
public void setPk(TgeneAccountKey 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 accountname
*
* @return valor de accountname
*/
public String getAccountname() {
return this.accountname;
}
/**
* Fija el valor de accountname
*
* @param pAccountname nuevo Valor de accountname
*/
public void setAccountname(String pAccountname) {
this.accountname = pAccountname;
}
/**
* Obtiene el valor de personcode
*
* @return valor de personcode
*/
public Integer getPersoncode() {
return this.personcode;
}
/**
* Fija el valor de personcode
*
* @param pPersoncode nuevo Valor de personcode
*/
public void setPersoncode(Integer pPersoncode) {
this.personcode = pPersoncode;
}
/**
* Obtiene el valor de modulecode
*
* @return valor de modulecode
*/
public String getModulecode() {
return this.modulecode;
}
/**
* Fija el valor de modulecode
*
* @param pModulecode nuevo Valor de modulecode
*/
public void setModulecode(String pModulecode) {
this.modulecode = pModulecode;
}
/**
* Obtiene el valor de productcode
*
* @return valor de productcode
*/
public String getProductcode() {
return this.productcode;
}
/**
* Fija el valor de productcode
*
* @param pProductcode nuevo Valor de productcode
*/
public void setProductcode(String pProductcode) {
this.productcode = pProductcode;
}
/**
* Obtiene el valor de subproductcode
*
* @return valor de subproductcode
*/
public String getSubproductcode() {
return this.subproductcode;
}
/**
* Fija el valor de subproductcode
*
* @param pSubproductcode nuevo Valor de subproductcode
*/
public void setSubproductcode(String pSubproductcode) {
this.subproductcode = pSubproductcode;
}
/**
* Obtiene el valor de currencycode
*
* @return valor de currencycode
*/
public String getCurrencycode() {
return this.currencycode;
}
/**
* Fija el valor de currencycode
*
* @param pCurrencycode nuevo Valor de currencycode
*/
public void setCurrencycode(String pCurrencycode) {
this.currencycode = pCurrencycode;
}
/**
* Obtiene el valor de officecode
*
* @return valor de officecode
*/
public Integer getOfficecode() {
return this.officecode;
}
/**
* Fija el valor de officecode
*
* @param pOfficecode nuevo Valor de officecode
*/
public void setOfficecode(Integer pOfficecode) {
this.officecode = pOfficecode;
}
/**
* Obtiene el valor de branchcode
*
* @return valor de branchcode
*/
public Integer getBranchcode() {
return this.branchcode;
}
/**
* Fija el valor de branchcode
*
* @param pBranchcode nuevo Valor de branchcode
*/
public void setBranchcode(Integer pBranchcode) {
this.branchcode = pBranchcode;
}
/**
* Obtiene el valor de openofficecode
*
* @return valor de openofficecode
*/
public Integer getOpenofficecode() {
return this.openofficecode;
}
/**
* Fija el valor de openofficecode
*
* @param pOpenofficecode nuevo Valor de openofficecode
*/
public void setOpenofficecode(Integer pOpenofficecode) {
this.openofficecode = pOpenofficecode;
}
/**
* Obtiene el valor de openbranchcode
*
* @return valor de openbranchcode
*/
public Integer getOpenbranchcode() {
return this.openbranchcode;
}
/**
* Fija el valor de openbranchcode
*
* @param pOpenbranchcode nuevo Valor de openbranchcode
*/
public void setOpenbranchcode(Integer pOpenbranchcode) {
this.openbranchcode = pOpenbranchcode;
}
/**
* Obtiene el valor de accountstatuscode
*
* @return valor de accountstatuscode
*/
public String getAccountstatuscode() {
return this.accountstatuscode;
}
/**
* Fija el valor de accountstatuscode
*
* @param pAccountstatuscode nuevo Valor de accountstatuscode
*/
public void setAccountstatuscode(String pAccountstatuscode) {
this.accountstatuscode = pAccountstatuscode;
}
/**
* Obtiene el valor de officer
*
* @return valor de officer
*/
public String getOfficer() {
return this.officer;
}
/**
* Fija el valor de officer
*
* @param pOfficer nuevo Valor de officer
*/
public void setOfficer(String pOfficer) {
this.officer = pOfficer;
}
/**
* Obtiene el valor de openingusercode
*
* @return valor de openingusercode
*/
public String getOpeningusercode() {
return this.openingusercode;
}
/**
* Fija el valor de openingusercode
*
* @param pOpeningusercode nuevo Valor de openingusercode
*/
public void setOpeningusercode(String pOpeningusercode) {
this.openingusercode = pOpeningusercode;
}
/**
* Obtiene el valor de personscorecatalog
*
* @return valor de personscorecatalog
*/
public String getPersonscorecatalog() {
return this.personscorecatalog;
}
/**
* Fija el valor de personscorecatalog
*
* @param pPersonscorecatalog nuevo Valor de personscorecatalog
*/
public void setPersonscorecatalog(String pPersonscorecatalog) {
this.personscorecatalog = pPersonscorecatalog;
}
/**
* Obtiene el valor de personcatalogcode
*
* @return valor de personcatalogcode
*/
public String getPersoncatalogcode() {
return this.personcatalogcode;
}
/**
* Fija el valor de personcatalogcode
*
* @param pPersoncatalogcode nuevo Valor de personcatalogcode
*/
public void setPersoncatalogcode(String pPersoncatalogcode) {
this.personcatalogcode = pPersoncatalogcode;
}
/**
* Obtiene el valor de chargecatalog
*
* @return valor de chargecatalog
*/
public String getChargecatalog() {
return this.chargecatalog;
}
/**
* Fija el valor de chargecatalog
*
* @param pChargecatalog nuevo Valor de chargecatalog
*/
public void setChargecatalog(String pChargecatalog) {
this.chargecatalog = pChargecatalog;
}
/**
* Obtiene el valor de chargecatalogcode
*
* @return valor de chargecatalogcode
*/
public String getChargecatalogcode() {
return this.chargecatalogcode;
}
/**
* Fija el valor de chargecatalogcode
*
* @param pChargecatalogcode nuevo Valor de chargecatalogcode
*/
public void setChargecatalogcode(String pChargecatalogcode) {
this.chargecatalogcode = pChargecatalogcode;
}
/**
* Obtiene el valor de ratecatalog
*
* @return valor de ratecatalog
*/
public String getRatecatalog() {
return this.ratecatalog;
}
/**
* Fija el valor de ratecatalog
*
* @param pRatecatalog nuevo Valor de ratecatalog
*/
public void setRatecatalog(String pRatecatalog) {
this.ratecatalog = pRatecatalog;
}
/**
* Obtiene el valor de ratecatalogcode
*
* @return valor de ratecatalogcode
*/
public String getRatecatalogcode() {
return this.ratecatalogcode;
}
/**
* Fija el valor de ratecatalogcode
*
* @param pRatecatalogcode nuevo Valor de ratecatalogcode
*/
public void setRatecatalogcode(String pRatecatalogcode) {
this.ratecatalogcode = pRatecatalogcode;
}
/**
* Obtiene el valor de credittypecode
*
* @return valor de credittypecode
*/
public String getCredittypecode() {
return this.credittypecode;
}
/**
* Fija el valor de credittypecode
*
* @param pCredittypecode nuevo Valor de credittypecode
*/
public void setCredittypecode(String pCredittypecode) {
this.credittypecode = pCredittypecode;
}
/**
* Obtiene el valor de operativcondition
*
* @return valor de operativcondition
*/
public String getOperativcondition() {
return this.operativcondition;
}
/**
* Fija el valor de operativcondition
*
* @param pOperativcondition nuevo Valor de operativcondition
*/
public void setOperativcondition(String pOperativcondition) {
this.operativcondition = pOperativcondition;
}
/**
* Obtiene el valor de operationstatus
*
* @return valor de operationstatus
*/
public String getOperationstatus() {
return this.operationstatus;
}
/**
* Fija el valor de operationstatus
*
* @param pOperationstatus nuevo Valor de operationstatus
*/
public void setOperationstatus(String pOperationstatus) {
this.operationstatus = pOperationstatus;
}
/**
* Obtiene el valor de motivestatuscatalog
*
* @return valor de motivestatuscatalog
*/
public String getMotivestatuscatalog() {
return this.motivestatuscatalog;
}
/**
* Fija el valor de motivestatuscatalog
*
* @param pMotivestatuscatalog nuevo Valor de motivestatuscatalog
*/
public void setMotivestatuscatalog(String pMotivestatuscatalog) {
this.motivestatuscatalog = pMotivestatuscatalog;
}
/**
* Obtiene el valor de motivestatuscatalogcode
*
* @return valor de motivestatuscatalogcode
*/
public String getMotivestatuscatalogcode() {
return this.motivestatuscatalogcode;
}
/**
* Fija el valor de motivestatuscatalogcode
*
* @param pMotivestatuscatalogcode nuevo Valor de motivestatuscatalogcode
*/
public void setMotivestatuscatalogcode(String pMotivestatuscatalogcode) {
this.motivestatuscatalogcode = pMotivestatuscatalogcode;
}
/**
* Obtiene el valor de securitylevel
*
* @return valor de securitylevel
*/
public Integer getSecuritylevel() {
return this.securitylevel;
}
/**
* Fija el valor de securitylevel
*
* @param pSecuritylevel nuevo Valor de securitylevel
*/
public void setSecuritylevel(Integer pSecuritylevel) {
this.securitylevel = pSecuritylevel;
}
/**
* Obtiene el valor de recordversion
*
* @return valor de recordversion
*/
public Integer getRecordversion() {
return this.recordversion;
}
/**
* Fija el valor de recordversion
*
* @param pRecordversion nuevo Valor de recordversion
*/
public void setRecordversion(Integer pRecordversion) {
this.recordversion = pRecordversion;
}
/**
* 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;
}
/**
* Obtiene el valor de oldjournalid
*
* @return valor de oldjournalid
*/
public String getOldjournalid() {
return this.oldjournalid;
}
/**
* Fija el valor de oldjournalid
*
* @param pOldjournalid nuevo Valor de oldjournalid
*/
public void setOldjournalid(String pOldjournalid) {
this.oldjournalid = pOldjournalid;
}
@Override
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TgeneAccount)) {
return false;
}
TgeneAccount that = (TgeneAccount) 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 TgeneAccount
*
* @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 TgeneAccount */
@Override
public Object createInstance() {
TgeneAccount instance = new TgeneAccount();
instance.setPk(new TgeneAccountKey());
return instance;
}
/**
* Clona la entidad TgeneAccount
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
@Override
public Object cloneMe() throws CloneNotSupportedException {
TgeneAccount p = (TgeneAccount) this.clone();
p.setPk((TgeneAccountKey) this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
// METODOS MANUALES
/**
* Metodo que entrega datos de la tabla dada la clave primaria.
*
* @param pEntityManager referencia de la session a obtener datos del bean.
* @param pAccount Numero de cuenta.
* @param pCompany Codigo de compania al que pertenece la cuenta.
* @return TgeneAccount
*/
public static TgeneAccount findVigenteWhitlock(EntityManager pEntityManager, String pAccount, Integer pCompany) throws Exception {
if (!Constant.isOracleDialect(pEntityManager)) {
TgeneAccount.lockBaseAccount(pEntityManager, pAccount, pCompany);
}
TgeneAccountKey key = new TgeneAccountKey(pAccount, pCompany, Constant.getDefaultExpiryTimestamp());
TgeneAccount obj = pEntityManager.find(TgeneAccount.class, key, LockModeType.PESSIMISTIC_READ);
if (obj == null) {
throw new CoreException("CORE-0007", "CUENTA NO EXISTE: {0} COMPANIA {1}", pAccount, pCompany);
}
return obj;
}
/**
* Bloquea el registro en la base de datos para garantizar una solo actualizacion de saldos.
*
* @param pEntityManager Referencia a una session de base de datos.
* @param pAccount Numero de cuenta.
* @param pCompany Codigo de compania al que pertenece la cuenta.
* @throws Exception
*/
private static void lockBaseAccount(EntityManager pEntityManager, String pAccount, Integer pCompany) throws Exception {
Query qry = pEntityManager.createQuery("update TgeneBaseAccount set lockdb = 'Y' where pk.account = :account and pk.company = :company");
qry.setParameter("account", pAccount);
qry.setParameter("company", pCompany);
qry.executeUpdate();
}
/**
* Sentencia que devuelve datos generales de la cuneta de la tabla TgeneAccount.
*/
private static final String HQL_ACCOUNT_MESSAGE = "from TgeneAccount t " + " where t.pk.account = :account " + " and t.pk.company = :company "
+ " and t.journalid = :journalid ";
/**
* Entrega datos generales de la cuenta.
*
* @param pAccount Numero de cuenta.
* @param pCompany Codigo de compania.
* @param pJournalid Numero de mensaje a obtener la cuenta.
* @return TgeneAccount
* @throws Exception
*/
public static TgeneAccount findByJournalId(EntityManager pEntityManager, String pAccount, Integer pCompany, String pJournalid) throws Exception {
TgeneAccount tgeneAccount = null;
Query qry = pEntityManager.createQuery(HQL_ACCOUNT_MESSAGE);
qry.setParameter("account", pAccount);
qry.setParameter("company", pCompany);
qry.setParameter("journalid", pJournalid);
try {
tgeneAccount = (TgeneAccount) qry.getSingleResult();
} catch (NoResultException e) {
throw new CoreException("CORE-0007", "CUENTA NO EXISTE: {1} COMPANIA {2}", pAccount, pCompany);
}
return tgeneAccount;
}
/**
* Sentencia que devuelve datos generales de la cuneta de la tabla TgeneAccount.
*/
private static final String HQL_ACCOUNT_MESSAGE_ = "from TgeneAccount t " + " where t.journalid = :journalid ";
/**
* Entrega datos generales de la cuenta.
*
* @param pAccount Numero de cuenta.
* @param pCompany Codigo de compania.
* @param pJournalid Numero de mensaje a obtener la cuenta.
* @return TgeneAccount
* @throws Exception
*/
public static TgeneAccount findByJournalId(EntityManager pEntityManager, String pJournalid) throws Exception {
TgeneAccount tgeneAccount = null;
Query qry = pEntityManager.createQuery(HQL_ACCOUNT_MESSAGE_);
qry.setParameter("journalid", pJournalid);
try {
tgeneAccount = (TgeneAccount) qry.getSingleResult();
} catch (NoResultException e) {
throw new CoreException("CORE-0007", "CUENTA NO EXISTE PARA EL MENSAJE: {1} ", pJournalid);
}
return tgeneAccount;
}
/**
* Sentencia que devuelve datos generales de la cuenta de la tabla TgeneAccount.
*/
private static final String HQL_ACCOUNT_OLD_MESSAGE = "from TgeneAccount t " + " where t.pk.account = :account "
+ " and t.pk.company = :company " + " and t.oldjournalid = :oldjournalid ";
/**
* Entrega datos generales de la cuenta.
*
* @param pAccount Numero de cuenta.
* @param pCompany Codigo de compania.
* @param pJournalid Numero de mensaje a obtener la cuenta.
* @return TgeneAccount
* @throws Exception
*/
public static TgeneAccount findByOldJournalid(EntityManager pEntityManager, String pAccount, Integer pCompany, String pOldJournalid)
throws Exception {
TgeneAccount tgeneAccount = null;
Query qry = pEntityManager.createQuery(HQL_ACCOUNT_OLD_MESSAGE);
qry.setParameter("account", pAccount);
qry.setParameter("company", pCompany);
qry.setParameter("oldjournalid", pOldJournalid);
try {
tgeneAccount = (TgeneAccount) qry.getSingleResult();
} catch (NoResultException e) {
throw new CoreException("CORE-0007", "CUENTA NO EXISTE: {1} COMPANIA {2}", pAccount, pCompany);
}
return tgeneAccount;
}
/** Sentencia que devuelve una lista de cuentas dado el codigo de persona. */
private static final String HQL_LIST_ACCOUNT_BY_PERSONCODE = "from TgeneAccount t " + " where t.pk.dateto = :dateto "
+ " and t.pk.company = :company " + " and t.personcode = :personcode ";
/**
* Metodo que entrega una lidta de cuentas dado un codigo de persona.
*
* @param pEntityManager Sessiond e la base de datos.
* @param pCompany Codigo de compania.
* @param pPersoncode Codigo de persona.
* @return List<TgeneAccount>
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static List<TgeneAccount> find(EntityManager pEntityManager, Integer pCompany, Integer pPersoncode) throws Exception {
List<TgeneAccount> ldata = null;
Query qry = pEntityManager.createQuery(HQL_LIST_ACCOUNT_BY_PERSONCODE);
qry.setParameter("dateto", Constant.getDefaultExpiryTimestamp());
qry.setParameter("company", pCompany);
qry.setParameter("personcode", pPersoncode);
ldata = qry.getResultList();
return ldata;
}
/**
* Sentencia que devuelve un registro de la tabla TgeneAccount
*/
private static final String JPQL_TGENE_ACCOUNT = "from TgeneAccount tga" + " where tga.pk.account = :account"
+ " and tga.pk.company = :company" + " and tga.pk.dateto = :dateto";
/**
* Metodo que devuelve un registro de la tabla TGENEACCOUNT
*
* @param account Numero de la cuenta
* @param company Compania a la que pertenece la cuenta
* @param dateto Fecha de vigencia de la tarjeta
* @return
*/
public static TgeneAccount findByFechaVigenciaTarjeta(EntityManager pEntityManager, String account, Integer company, Timestamp dateto)
throws Exception {
Query qry = pEntityManager.createQuery(TgeneAccount.JPQL_TGENE_ACCOUNT);
qry.setParameter("account", account);
qry.setParameter("company", company);
qry.setParameter("dateto", dateto);
try {
return (TgeneAccount) qry.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
private static final String JPQL_CURRENT_BY_PRODUCT = "from TgeneAccount tga "
+ "where tga.modulecode = :modulecode and tga.productcode = :productcode "
+ "and tga.subproductcode IN (:subproductcode) and tga.pk.dateto = :dateto "
+ "and tga.personcode = :personcode and tga.accountstatuscode = :accountstatuscode";
/**
* Permite obtener las cuentas depr<70>stamos que esten en estado vigente a partir de los codigos de productos de
* reestructuracion
*
* @param entityManager Administrador de entidades y persistencia
* @param moduleCode Codigo de modulo
* @param productCode Codigo de producto
* @param subProductCode Codigo de subproducto
* @param personCode Codigo de persona
* @return lista de objetos de tipo {@link TgeneAccount} con el resultado de la operacion
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static List<TgeneAccount> findCurrentByProduct(EntityManager entityManager, String moduleCode, String productCode,
List<String> subProductCode, Integer personCode) throws Exception {
List<TgeneAccount> result = null;
Query qry = entityManager.createQuery(TgeneAccount.JPQL_CURRENT_BY_PRODUCT);
qry.setParameter(com.fp.common.helper.Constant.VMODULECODE, moduleCode);
qry.setParameter(com.fp.common.helper.Constant.VPRODUCTCODE, productCode);
qry.setParameter(com.fp.common.helper.Constant.VSUBPRODUCTCODE, subProductCode);
qry.setParameter(com.fp.common.helper.Constant.VDATETO, Constant.getDefaultExpiryDate());
qry.setParameter("personcode", personCode);
qry.setParameter("accountstatuscode", "VIG");
result = qry.getResultList();
return result;
}
private static final String JPQL_CURRENT_BY_ACCOUNT = "from TgeneAccount tga "
+ "where tga.modulecode = :modulecode and tga.productcode = :productcode "
+ "and tga.pk.account IN (:account) and tga.pk.dateto = :dateto "
+ "and tga.currencycode = :currencycode and tga.accountstatuscode = :accountstatuscode";
/**
* Permite obtener las cuentas depr<70>stamos que esten en estado vigente a partir de los codigos de cuentas de
* prestamo
*
* @param entityManager Administrador de entidades y persistencia
* @param moduleCode Codigo de modulo
* @param productCode Codigo de producto
* @param account Lista de Strings con las cuentas a consultar
* @param currencyCode Codigo de modeda
* @return lista de objetos de tipo {@link TgeneAccount} con el resultado de la operacion
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static List<TgeneAccount> findCurrentByAccount(EntityManager entityManager, String moduleCode, String productCode, List<String> account,
String currencyCode) throws Exception {
List<TgeneAccount> result = null;
Query qry = entityManager.createQuery(TgeneAccount.JPQL_CURRENT_BY_ACCOUNT);
qry.setParameter(com.fp.common.helper.Constant.VMODULECODE, moduleCode);
qry.setParameter(com.fp.common.helper.Constant.VPRODUCTCODE, productCode);
qry.setParameter(com.fp.common.helper.Constant.VACCOUNT, account);
qry.setParameter(com.fp.common.helper.Constant.VDATETO, Constant.getDefaultExpiryDate());
qry.setParameter(com.fp.common.helper.Constant.VCURRENCYCODE, currencyCode);
qry.setParameter("accountstatuscode", "VIG");
result = qry.getResultList();
return result;
}
}