346 lines
12 KiB
Plaintext
Executable File
346 lines
12 KiB
Plaintext
Executable File
package com.fp.persistence.pgeneral.acco;
|
||
|
||
import javax.persistence.EmbeddedId;
|
||
import javax.persistence.Entity;
|
||
import javax.persistence.Column;
|
||
import javax.persistence.EntityManager;
|
||
import java.io.Serializable;
|
||
import java.math.BigDecimal;
|
||
import javax.persistence.Table;
|
||
import com.fp.dto.hb.HibernateBean;
|
||
import java.lang.reflect.Field;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
import javax.persistence.Query;
|
||
import javax.persistence.Transient;
|
||
|
||
/**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENEWARRANTYACCOUNT*/
|
||
@Entity(name = "TgeneWarrantyAccount")
|
||
@Table(name = "TGENEWARRANTYACCOUNT")
|
||
public class TgeneWarrantyAccount 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 TgeneWarrantyAccount
|
||
*/
|
||
@EmbeddedId
|
||
private TgeneWarrantyAccountKey pk;
|
||
@Column(name = "SOLICITUDNUMBER", nullable = false)
|
||
/**
|
||
* Numero de solicitud
|
||
*/
|
||
private String solicitudnumber;
|
||
@Column(name = "SOLICITUDSEQUENCE", nullable = false)
|
||
/**
|
||
* secuencia interna de solicitud
|
||
*/
|
||
private Integer solicitudsequence;
|
||
@Column(name = "WARRANTYSEQUENCE", nullable = false)
|
||
/**
|
||
* Secuencia interna de la solicitud de la garantia.
|
||
*/
|
||
private Integer warrantysequence;
|
||
@Column(name = "PERSONCODE", nullable = false)
|
||
/**
|
||
* Codigo de persona asociada a una garantia existente, o codigo de persona al cual se le asocia una nueva garantia.
|
||
*/
|
||
private Integer personcode;
|
||
@Column(name = "WARRANTYTYPE", nullable = true)
|
||
/**
|
||
* Codigo de tipo de garantia
|
||
*/
|
||
private String warrantytype;
|
||
@Column(name = "PROPERTYTYPE", nullable = true)
|
||
/**
|
||
* Tipo de bien, Edficaciones
|
||
*/
|
||
private String propertytype;
|
||
@Column(name = "GUARANTEEVALUE", nullable = true)
|
||
/**
|
||
* Valor garantizado, una operacion puede estar avalada o garantiza por mas de una garantia.
|
||
*/
|
||
private BigDecimal guaranteevalue;
|
||
|
||
/**Contructor por defecto*/
|
||
public TgeneWarrantyAccount() {
|
||
}
|
||
|
||
/**Contructor de TgeneWarrantyAccount
|
||
@param pPk Clave Primaria del entity
|
||
@param pSolicitudnumber Numero de solicitud
|
||
@param pSolicitudsequence secuencia interna de solicitud
|
||
@param pWarrantysequence Secuencia interna de la solicitud de la garantia.
|
||
@param pPersoncode Codigo de persona asociada a una garantia existente, o codigo de persona al cual se le asocia una nueva garantia.
|
||
*/
|
||
public TgeneWarrantyAccount(TgeneWarrantyAccountKey pPk, String pSolicitudnumber, Integer pSolicitudsequence, Integer pWarrantysequence, Integer pPersoncode) {
|
||
this();
|
||
pk = pPk;
|
||
solicitudnumber = pSolicitudnumber;
|
||
solicitudsequence = pSolicitudsequence;
|
||
warrantysequence = pWarrantysequence;
|
||
personcode = pPersoncode;
|
||
}
|
||
|
||
/**
|
||
* 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 TgeneWarrantyAccount
|
||
*/
|
||
public static TgeneWarrantyAccount find(EntityManager pEntityManager, TgeneWarrantyAccountKey pKey) throws Exception {
|
||
TgeneWarrantyAccount obj = pEntityManager.find(TgeneWarrantyAccount.class, pKey);
|
||
return obj;
|
||
}
|
||
|
||
/**Entrega la Clave primaria de TgeneWarrantyAccount
|
||
@return El objeto que referencia a la Clave primaria de TgeneWarrantyAccount
|
||
*/
|
||
public TgeneWarrantyAccountKey getPk() {
|
||
return pk;
|
||
}
|
||
|
||
/**Fija un nuevo valor a la Clave primaria de TgeneWarrantyAccount
|
||
@param pPk El objeto que referencia a la nueva Clave primaria de TgeneWarrantyAccount
|
||
*/
|
||
public void setPk(TgeneWarrantyAccountKey pPk) {
|
||
pk = pPk;
|
||
}
|
||
|
||
/**Obtiene el valor de solicitudnumber
|
||
@return valor de solicitudnumber*/
|
||
public String getSolicitudnumber() {
|
||
return solicitudnumber;
|
||
}
|
||
|
||
/**Fija el valor de solicitudnumber
|
||
@param pSolicitudnumber nuevo Valor de solicitudnumber*/
|
||
public void setSolicitudnumber(String pSolicitudnumber) {
|
||
solicitudnumber = pSolicitudnumber;
|
||
}
|
||
|
||
/**Obtiene el valor de solicitudsequence
|
||
@return valor de solicitudsequence*/
|
||
public Integer getSolicitudsequence() {
|
||
return solicitudsequence;
|
||
}
|
||
|
||
/**Fija el valor de solicitudsequence
|
||
@param pSolicitudsequence nuevo Valor de solicitudsequence*/
|
||
public void setSolicitudsequence(Integer pSolicitudsequence) {
|
||
solicitudsequence = pSolicitudsequence;
|
||
}
|
||
|
||
/**Obtiene el valor de warrantysequence
|
||
@return valor de warrantysequence*/
|
||
public Integer getWarrantysequence() {
|
||
return warrantysequence;
|
||
}
|
||
|
||
/**Fija el valor de warrantysequence
|
||
@param pWarrantysequence nuevo Valor de warrantysequence*/
|
||
public void setWarrantysequence(Integer pWarrantysequence) {
|
||
warrantysequence = pWarrantysequence;
|
||
}
|
||
|
||
/**Obtiene el valor de personcode
|
||
@return valor de personcode*/
|
||
public Integer getPersoncode() {
|
||
return personcode;
|
||
}
|
||
|
||
/**Fija el valor de personcode
|
||
@param pPersoncode nuevo Valor de personcode*/
|
||
public void setPersoncode(Integer pPersoncode) {
|
||
personcode = pPersoncode;
|
||
}
|
||
|
||
/**Obtiene el valor de warrantytype
|
||
@return valor de warrantytype*/
|
||
public String getWarrantytype() {
|
||
return warrantytype;
|
||
}
|
||
|
||
/**Fija el valor de warrantytype
|
||
@param pWarrantytype nuevo Valor de warrantytype*/
|
||
public void setWarrantytype(String pWarrantytype) {
|
||
warrantytype = pWarrantytype;
|
||
}
|
||
|
||
/**Obtiene el valor de propertytype
|
||
@return valor de propertytype*/
|
||
public String getPropertytype() {
|
||
return propertytype;
|
||
}
|
||
|
||
/**Fija el valor de propertytype
|
||
@param pPropertytype nuevo Valor de propertytype*/
|
||
public void setPropertytype(String pPropertytype) {
|
||
propertytype = pPropertytype;
|
||
}
|
||
|
||
/**Obtiene el valor de guaranteevalue
|
||
@return valor de guaranteevalue*/
|
||
public BigDecimal getGuaranteevalue() {
|
||
return guaranteevalue;
|
||
}
|
||
|
||
/**Fija el valor de guaranteevalue
|
||
@param pGuaranteevalue nuevo Valor de guaranteevalue*/
|
||
public void setGuaranteevalue(BigDecimal pGuaranteevalue) {
|
||
guaranteevalue = pGuaranteevalue;
|
||
}
|
||
|
||
public boolean equals(Object rhs) {
|
||
if (rhs == null) {
|
||
return false;
|
||
}
|
||
if (!(rhs instanceof TgeneWarrantyAccount)) {
|
||
return false;
|
||
}
|
||
TgeneWarrantyAccount that = (TgeneWarrantyAccount) 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 TgeneWarrantyAccount
|
||
@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 TgeneWarrantyAccount
|
||
*/
|
||
public Object createInstance() {
|
||
TgeneWarrantyAccount instance = new TgeneWarrantyAccount();
|
||
instance.setPk(new TgeneWarrantyAccountKey());
|
||
return instance;
|
||
}
|
||
|
||
/**Clona la entidad TgeneWarrantyAccount
|
||
@see com.fp.dto.hb.HibernateBean#cloneMe()
|
||
*/
|
||
public Object cloneMe() throws CloneNotSupportedException {
|
||
TgeneWarrantyAccount p = (TgeneWarrantyAccount) this.clone();
|
||
p.setPk((TgeneWarrantyAccountKey) this.pk.cloneMe());
|
||
return p;
|
||
}
|
||
//METODOS MANUALES
|
||
/** Sentencia que entrega datos de TgeneWarrantyAccount, par el un numero de garantia. */
|
||
private static final String JPQL_WARR_ACCO = "from TgeneWarrantyAccount gwa where gwa.pk.warraccount= :warraccount"
|
||
+ " and gwa.pk.company= :companycod and gwa.pk.warrcompany= :companycod ";
|
||
|
||
/**
|
||
* Metodo que devuelve una lista de TgeneWarrantyAccount dado el numero de cuenta de un prestamo.
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param company Codigo de la compania.
|
||
* @param warracco Numero de la garantia.
|
||
* @return List<TgeneWarrantyAccount>
|
||
* @throws Exception
|
||
*/
|
||
public static List<TgeneWarrantyAccount> find(EntityManager pEntityManager, Integer company, String warracco) throws Exception {
|
||
List<TgeneWarrantyAccount> lwarrantAccount = new ArrayList<TgeneWarrantyAccount>();
|
||
Query qry = pEntityManager.createQuery(TgeneWarrantyAccount.JPQL_WARR_ACCO);
|
||
qry.setParameter("companycod", company);
|
||
qry.setParameter("warraccount", warracco);
|
||
lwarrantAccount = (List<TgeneWarrantyAccount>) qry.getResultList();
|
||
return lwarrantAccount;
|
||
}
|
||
/** Sentencia que entrega datos de TgeneWarrantyAccount, dado el numero de la operacion. */
|
||
private static final String JPQL_ACCO_OPERAT = "from TgeneWarrantyAccount gwa where gwa.pk.account= :account"
|
||
+ " and gwa.pk.company= :companycod and gwa.pk.warrcompany= :companycod ";
|
||
|
||
/**
|
||
* Metodo que devuelve una lista de TgeneWarrantyAccount dado el numero de cuenta asociado a una garantia
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param company Codigo de la compania.
|
||
* @param account Numero de la garantia.
|
||
* @return List<TgeneWarrantyAccount>
|
||
* @throws Exception
|
||
*/
|
||
public static List<TgeneWarrantyAccount> findPerAccount(EntityManager pEntityManager, Integer company, String account) throws Exception {
|
||
List<TgeneWarrantyAccount> lwarrantAccount = new ArrayList<TgeneWarrantyAccount>();
|
||
Query qry = pEntityManager.createQuery(TgeneWarrantyAccount.JPQL_ACCO_OPERAT);
|
||
qry.setParameter("companycod", company);
|
||
qry.setParameter("account", account);
|
||
lwarrantAccount = (List<TgeneWarrantyAccount>) qry.getResultList();
|
||
return lwarrantAccount;
|
||
}
|
||
|
||
/**
|
||
* Sentencia que entrega datos de TgeneWarrantyAccount, par el un numero de
|
||
* cuenta respaldada por una garantia.
|
||
*/
|
||
private static final String JPQL_ACCOUNT = " from TgeneWarrantyAccount gwa " +
|
||
" where gwa.pk.account= :accountparam " +
|
||
" and gwa.pk.company= :companyparam";
|
||
|
||
/**
|
||
*
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param company Codigo de la compania.
|
||
* @param account Numero de la garantia.
|
||
* @return List<TgeneWarrantyAccount>
|
||
* @throws Exception
|
||
*/
|
||
public static List<TgeneWarrantyAccount> findByAccount(
|
||
EntityManager pEntityManager, Integer company, String account)
|
||
throws Exception {
|
||
List<TgeneWarrantyAccount> lwarrantAccount = new ArrayList<TgeneWarrantyAccount>();
|
||
Query qry = pEntityManager
|
||
.createQuery(TgeneWarrantyAccount.JPQL_ACCOUNT);
|
||
qry.setParameter("companyparam", company);
|
||
qry.setParameter("accountparam", account);
|
||
lwarrantAccount = (List<TgeneWarrantyAccount>) qry.getResultList();
|
||
return lwarrantAccount;
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|