maia_modificado/.svn/pristine/bb/bbb8a4dc9e298841c0d63ef6d07...

265 lines
7.4 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.safe;
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.Query;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fp.common.helper.Constant;
import com.fp.dto.hb.HibernateBean;
import com.fp.dto.hb.Log;
/** Clase que implementa la entidad de Hibernate que hace referencia a la tabla TSAFEUSERPROFILE */
@Entity(name = "TsafeUserProfile")
@Table(name = "TSAFEUSERPROFILE")
public class TsafeUserProfile extends com.fp.dto.AbstractDataTransport implements Serializable, HibernateBean, Cloneable, Log {
/**
* 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 TsafeUserProfile
*/
@EmbeddedId
private TsafeUserProfileKey pk;
@Column(name = "DATEFROM", nullable = false)
/**
* Fecha desde la cual esta vigente el registro del detalle de usuarios
*/
private Timestamp datefrom;
@Column(name = "INGRESSUSER", nullable = true)
/**
* Codigo de usuario que ingreso la informacion
*/
private String ingressuser;
@Column(name = "MODIFYUSER", nullable = true)
/**
* Codigo de usuario que modifico la informacion
*/
private String modifyuser;
/** Contructor por defecto */
public TsafeUserProfile() {
}
/**
* Contructor de TsafeUserProfile
*
* @param pPk Clave Primaria del entity
* @param pDatefrom Fecha desde la cual esta vigente el registro del detalle de usuarios
*/
public TsafeUserProfile(TsafeUserProfileKey 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 TsafeUserProfile
*/
public static TsafeUserProfile find(EntityManager pEntityManager, TsafeUserProfileKey pKey) throws Exception {
TsafeUserProfile obj = pEntityManager.find(TsafeUserProfile.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TsafeUserProfile
*
* @return El objeto que referencia a la Clave primaria de TsafeUserProfile
*/
public TsafeUserProfileKey getPk() {
return this.pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TsafeUserProfile
*
* @param pPk El objeto que referencia a la nueva Clave primaria de TsafeUserProfile
*/
public void setPk(TsafeUserProfileKey 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 ingressuser
*
* @return valor de ingressuser
*/
public String getIngressuser() {
return this.ingressuser;
}
/**
* Fija el valor de ingressuser
*
* @param pIngressuser nuevo Valor de ingressuser
*/
public void setIngressuser(String pIngressuser) {
this.ingressuser = pIngressuser;
}
/**
* Obtiene el valor de modifyuser
*
* @return valor de modifyuser
*/
public String getModifyuser() {
return this.modifyuser;
}
/**
* Fija el valor de modifyuser
*
* @param pModifyuser nuevo Valor de modifyuser
*/
public void setModifyuser(String pModifyuser) {
this.modifyuser = pModifyuser;
}
@Override
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TsafeUserProfile)) {
return false;
}
TsafeUserProfile that = (TsafeUserProfile) 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 TsafeUserProfile
*
* @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 TsafeUserProfile */
@Override
public Object createInstance() {
TsafeUserProfile instance = new TsafeUserProfile();
instance.setPk(new TsafeUserProfileKey());
return instance;
}
/**
* Clona la entidad TsafeUserProfile
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
@Override
public Object cloneMe() throws CloneNotSupportedException {
TsafeUserProfile p = (TsafeUserProfile) this.clone();
p.setPk((TsafeUserProfileKey) this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
// Metodos manuales.
/**
* Sentencia que devuelve un registro de TsafeUserProfile.
*/
private static final String JPQL_USER_PROFILE = "from TsafeUserProfile tsup " + " where tsup.pk.usercode = :usercode"
+ " and tsup.pk.dateto = :dateto";
/**
* Metodo que obtiene datos del perfil del usuario.
*
* @param pusercode Codigo de usuario.
* @return TsafeUserProfile
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static List<TsafeUserProfile> find(EntityManager pEntityManager, String pusercode) throws Exception {
Query qry = pEntityManager.createQuery(TsafeUserProfile.JPQL_USER_PROFILE);
qry.setParameter("usercode", pusercode);
qry.setParameter("dateto", Constant.getDefaultExpiryTimestamp());
return qry.getResultList();
}
}