maia_modificado/.svn/pristine/71/7179bd4078aeb7a55413738133d...

324 lines
8.3 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.score;
import com.fp.common.helper.Constant;
import com.fp.dto.hb.Cache;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Query;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import java.io.Serializable;
import javax.persistence.Table;
import com.fp.dto.hb.HibernateBean;
import javax.persistence.Version;
import java.lang.reflect.Field;
import javax.persistence.Transient;
/**
* Clase que implementa la entidad de Hibernate que hace referencia a la tabla
* TGENESCORERANK
*/
@Entity(name = "TgeneScoreRank")
@Table(name = "TGENESCORERANK")
public class TgeneScoreRank extends com.fp.dto.AbstractDataTransport implements
Serializable, HibernateBean, Cloneable, Cache {
/**
* 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 TgeneScoreRank
*/
@EmbeddedId
private TgeneScoreRankKey pk;
@Column(name = "DATEFROM", nullable = true)
/**
* Fecha desde la cual esta vigente el porcentaje de calificacion
*/
private Timestamp datefrom;
@Version
@Column(name = "RECORDVERSION", nullable = true)
/**
* Optimistick locking del registro.
*/
private Integer recordversion;
@Column(name = "DAYSFROM", nullable = true)
/**
* Dias minimos para definir la calificacion del prestamo
*/
private Integer daysfrom;
@Column(name = "DAYSTO", nullable = true)
/**
* Dias maximos para definir la calificacion del prestamo
*/
private Integer daysto;
/** Contructor por defecto */
public TgeneScoreRank() {
}
/**
* Contructor de TgeneScoreRank
*
* @param pPk
* Clave Primaria del entity
*/
public TgeneScoreRank(TgeneScoreRankKey pPk) {
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 TgeneScoreRank
*/
public static TgeneScoreRank find(EntityManager pEntityManager,
TgeneScoreRankKey pKey) throws Exception {
TgeneScoreRank obj = pEntityManager.find(TgeneScoreRank.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TgeneScoreRank
*
* @return El objeto que referencia a la Clave primaria de TgeneScoreRank
*/
public TgeneScoreRankKey getPk() {
return pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TgeneScoreRank
*
* @param pPk
* El objeto que referencia a la nueva Clave primaria de
* TgeneScoreRank
*/
public void setPk(TgeneScoreRankKey pPk) {
pk = pPk;
}
/**
* Obtiene el valor de datefrom
*
* @return valor de datefrom
*/
public Timestamp getDatefrom() {
return datefrom;
}
/**
* Fija el valor de datefrom
*
* @param pDatefrom
* nuevo Valor de datefrom
*/
public void setDatefrom(Timestamp pDatefrom) {
datefrom = pDatefrom;
}
/**
* Obtiene el valor de recordversion
*
* @return valor de recordversion
*/
public Integer getRecordversion() {
return recordversion;
}
/**
* Fija el valor de recordversion
*
* @param pRecordversion
* nuevo Valor de recordversion
*/
public void setRecordversion(Integer pRecordversion) {
recordversion = pRecordversion;
}
/**
* Obtiene el valor de daysfrom
*
* @return valor de daysfrom
*/
public Integer getDaysfrom() {
return daysfrom;
}
/**
* Fija el valor de daysfrom
*
* @param pDaysfrom
* nuevo Valor de daysfrom
*/
public void setDaysfrom(Integer pDaysfrom) {
daysfrom = pDaysfrom;
}
/**
* Obtiene el valor de daysto
*
* @return valor de daysto
*/
public Integer getDaysto() {
return daysto;
}
/**
* Fija el valor de daysto
*
* @param pDaysto
* nuevo Valor de daysto
*/
public void setDaysto(Integer pDaysto) {
daysto = pDaysto;
}
public boolean equals(Object rhs) {
if (rhs == null)
return false;
if (!(rhs instanceof TgeneScoreRank))
return false;
TgeneScoreRank that = (TgeneScoreRank) 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 TgeneScoreRank
*
* @return el hashCode la instancia
*/
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 */
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 TgeneScoreRank */
public Object createInstance() {
TgeneScoreRank instance = new TgeneScoreRank();
instance.setPk(new TgeneScoreRankKey());
return instance;
}
/**
* Clona la entidad TgeneScoreRank
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
public Object cloneMe() throws CloneNotSupportedException {
TgeneScoreRank p = (TgeneScoreRank) this.clone();
p.setPk((TgeneScoreRankKey) this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
//Metodos manuales.
/**Sentencia que entrega la definicion de rangos de calificacion de cartera.*/
private static final String JPQL = "from TgeneScoreRank t "+
" where t.pk.credittypecode = :credittypecode " +
" and t.pk.operationstatus = :operationstatus"+
" and t.pk.modulecode = :modulecode "+
" and t.pk.dateto = :dateto ";
/**
* Metodo que entrega una lista de calificacion de cartera dado el tipo de credito, estado de la operacion y modulo.
* @param pEntityManager Referencia a una session de base de datos.
* @param pCreditType Codigo de tipo de credito, CON consumo, COM comercial, etc
* @param pOperationStatus Estado de la operacion Orginal, Restructurada
* @param pModuleCode Modulo asociado al estado de la operacion.
* @return List<TgeneScoreRank>
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static List<TgeneScoreRank> find(EntityManager pEntityManager,String pCreditType,String pOperationStatus,String pModuleCode) throws Exception {
List<TgeneScoreRank> ldata = null;
Query qry = pEntityManager.createQuery(JPQL);
qry.setParameter("credittypecode", pCreditType);
qry.setParameter("operationstatus", pOperationStatus);
qry.setParameter("modulecode", pModuleCode);
qry.setParameter("dateto", Constant.getDefaultExpiryTimestamp());
ldata = qry.getResultList();
return ldata;
}
/**Sentencia que entrega la definicion de rangos de calificacion de cartera.*/
private static final String JPQL_FIRST_SCORE = "from TgeneScoreRank t "+
" where t.pk.credittypecode = :credittypecode " +
" and t.pk.operationstatus = :operationstatus"+
" and t.pk.modulecode = :modulecode "+
" and t.pk.dateto = :dateto " +
" and 0 between t.daysfrom and t.daysto ";
/**
* Metodo que entrega una lista de calificacion de cartera dado el tipo de credito y modulo.
* @param pEntityManager Referencia a una session de base de datos.
* @param pCreditType Codigo de tipo de credito, CON consumo, COM comercial, etc
* @param pModuleCode Modulo asociado al estado de la operacion.
* @return List<TgeneScoreRank>
* @throws Exception
*/
public static TgeneScoreRank find(EntityManager pEntityManager,String pCreditType,String pModuleCode) throws Exception {
TgeneScoreRank obj = null;
Query qry = pEntityManager.createQuery(JPQL_FIRST_SCORE);
qry.setParameter("credittypecode", pCreditType);
qry.setParameter("operationstatus", "ORI");
qry.setParameter("modulecode", pModuleCode);
qry.setParameter("dateto", Constant.getDefaultExpiryTimestamp());
obj = (TgeneScoreRank)qry.getSingleResult();
return obj;
}
}