package com.fp.persistence.pgeneral.auth; import java.io.Serializable; import java.lang.reflect.Field; import java.math.BigDecimal; import java.util.List; import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.Query; import javax.persistence.Table; import javax.persistence.Transient; import com.fp.dto.hb.HibernateBean; /**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENEEXCEPTIONS*/ @Entity(name="TgeneExceptions") @Table(name="TGENEEXCEPTIONS") public class TgeneExceptions 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 TgeneExceptions */ @EmbeddedId private TgeneExceptionsKey pk; @Column(name="PROFILECODE", nullable=true) /** * Codigo de perfil de usuario */ private String profilecode; @Column(name="CONDITION", nullable=true) /** * Condicion a evaluar */ private String condition; @Column(name="STRINGVALUE", nullable=true) /** * Valor a compar con el dato del campo */ private String stringvalue; @Column(name="NUMERICVALUE", nullable=true) /** * Valor a compar con el dato del campo */ private BigDecimal numericvalue; @Column(name="TITLE", nullable=true) /** * Titulo de la condicion a generar, ejemplo MONTO > 100 */ private String title; @Column(name="COMMAND", nullable=true) /** * Clase que genera una condicion especial, ejemplo nacionalidad = ECUATORIANA */ private String command; /**Contructor por defecto*/ public TgeneExceptions(){ } /**Contructor de TgeneExceptions @param pPk Clave Primaria del entity */ public TgeneExceptions(TgeneExceptionsKey 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 TgeneExceptions */ public static TgeneExceptions find(EntityManager pEntityManager,TgeneExceptionsKey pKey) throws Exception{ TgeneExceptions obj = pEntityManager.find(TgeneExceptions.class,pKey); return obj; } /**Entrega la Clave primaria de TgeneExceptions @return El objeto que referencia a la Clave primaria de TgeneExceptions */ public TgeneExceptionsKey getPk(){ return pk; } /**Fija un nuevo valor a la Clave primaria de TgeneExceptions @param pPk El objeto que referencia a la nueva Clave primaria de TgeneExceptions */ public void setPk(TgeneExceptionsKey pPk){ pk=pPk; } /**Obtiene el valor de profilecode @return valor de profilecode*/ public String getProfilecode(){ return profilecode; } /**Fija el valor de profilecode @param pProfilecode nuevo Valor de profilecode*/ public void setProfilecode(String pProfilecode){ profilecode=pProfilecode; } /**Obtiene el valor de condition @return valor de condition*/ public String getCondition(){ return condition; } /**Fija el valor de condition @param pCondition nuevo Valor de condition*/ public void setCondition(String pCondition){ condition=pCondition; } /**Obtiene el valor de stringvalue @return valor de stringvalue*/ public String getStringvalue(){ return stringvalue; } /**Fija el valor de stringvalue @param pStringvalue nuevo Valor de stringvalue*/ public void setStringvalue(String pStringvalue){ stringvalue=pStringvalue; } /**Obtiene el valor de numericvalue @return valor de numericvalue*/ public BigDecimal getNumericvalue(){ return numericvalue; } /**Fija el valor de numericvalue @param pNumericvalue nuevo Valor de numericvalue*/ public void setNumericvalue(BigDecimal pNumericvalue){ numericvalue=pNumericvalue; } /**Obtiene el valor de title @return valor de title*/ public String getTitle(){ return title; } /**Fija el valor de title @param pTitle nuevo Valor de title*/ public void setTitle(String pTitle){ title=pTitle; } /**Obtiene el valor de command @return valor de command*/ public String getCommand(){ return command; } /**Fija el valor de command @param pCommand nuevo Valor de command*/ public void setCommand(String pCommand){ command=pCommand; } public boolean equals(Object rhs){ if (rhs == null)return false; if (! (rhs instanceof TgeneExceptions))return false; TgeneExceptions that = (TgeneExceptions) rhs; if (this.getPk() == null || that.getPk() == null) return false; return (this.getPk().equals(that.getPk())); } /**Implementación del metodo hashCode de la la entidad TgeneExceptions @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ó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ón de la creación de un bean en blanco TgeneExceptions */ public Object createInstance(){ TgeneExceptions instance=new TgeneExceptions(); instance.setPk(new TgeneExceptionsKey()); return instance; } /**Clona la entidad TgeneExceptions @see com.fp.dto.hb.HibernateBean#cloneMe() */ public Object cloneMe() throws CloneNotSupportedException{ TgeneExceptions p=(TgeneExceptions)this.clone(); p.setPk((TgeneExceptionsKey)this.pk.cloneMe()); return p; } //Metodos manuales. /**Sentencia que devuelve la definicion de excepciones que requieren autorizacion, por subproducto moneda.*/ private static final String HQL_EXCEPTIONS = "from TgeneExceptions texception " + " where texception.pk.modulecode = :modulecode "+ " and texception.pk.productcode = :productcode "+ " and texception.pk.subproductcode = :subproductcode "+ " and texception.pk.currencycode = :currencycode "+ " order by texception.pk.exceptionorder "; /** * Entrega una lista de excepciones de solicitud definidas por subproducto moneda, con la cual * se generan excepciones a autorizar en una solicitud. * @param pModuleCode Codigo de modulo. * @param pProductCode Codigo de product. * @param pSubproductCode Codigo de subproducto. * @param pCurrencyCode Codigo de moneda. * @return List * @throws Exception */ @SuppressWarnings("unchecked") public static List find(EntityManager pEntityManager,String pModuleCode,String pProductCode, String pSubproductCode,String pCurrencyCode) throws Exception { List lObjects = null; Query qry = pEntityManager.createQuery(HQL_EXCEPTIONS); qry.setParameter("modulecode", pModuleCode); qry.setParameter("productcode", pProductCode); qry.setParameter("subproductcode", pSubproductCode); qry.setParameter("currencycode", pCurrencyCode); lObjects = qry.getResultList(); return lObjects; } }