747 lines
17 KiB
Plaintext
Executable File
747 lines
17 KiB
Plaintext
Executable File
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.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.dto.hb.HibernateBean;
|
||
import com.fp.dto.hb.Log;
|
||
import com.fp.general.exception.GeneralException;
|
||
|
||
/**
|
||
* Clase que implementa la entidad de Hibernate que hace referencia a la tabla
|
||
* TSAFEUSERDETAIL
|
||
*/
|
||
@Entity(name = "TsafeUserDetail")
|
||
@Table(name = "TSAFEUSERDETAIL")
|
||
public class TsafeUserDetail 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 TsafeUserDetail
|
||
*/
|
||
@EmbeddedId
|
||
private TsafeUserDetailKey pk;
|
||
|
||
@Version
|
||
@Column(name = "RECORDVERSION", nullable = true)
|
||
/**
|
||
* Optimistic blocking del registro
|
||
*/
|
||
private Integer recordversion;
|
||
|
||
@Column(name = "DATEFROM", nullable = false)
|
||
/**
|
||
* Fecha desde la cual esta vigente el registro del detalle de usuarios
|
||
*/
|
||
private Timestamp datefrom;
|
||
|
||
@Column(name = "USERSTATUSCATALOG", nullable = true)
|
||
/**
|
||
* Codigo de catalogo ACT, Activo, BLQ Bloqueado, RET Retirado
|
||
*/
|
||
private String userstatuscatalog;
|
||
|
||
@Column(name = "USERSTATUSCATALOGCODE", nullable = true)
|
||
/**
|
||
* Codigo de tabla de catalogo USERSTATUS del estatus del usuario
|
||
*/
|
||
private String userstatuscatalogcode;
|
||
|
||
@Column(name = "COMPANYCODE", nullable = true)
|
||
/**
|
||
* Codigo de compania a la que pertenece el departamento
|
||
*/
|
||
private Integer companycode;
|
||
|
||
@Column(name = "AREACODE", nullable = true)
|
||
/**
|
||
* Codigo de area
|
||
*/
|
||
private Integer areacode;
|
||
|
||
@Column(name = "OFFICECODE", nullable = true)
|
||
/**
|
||
* Codigo de oficina
|
||
*/
|
||
private Integer officecode;
|
||
|
||
@Column(name = "BRANCHCODE", nullable = true)
|
||
/**
|
||
* Codigo de sucursal
|
||
*/
|
||
private Integer branchcode;
|
||
|
||
@Column(name = "CHANNELCODE", nullable = true)
|
||
/**
|
||
* Codigo de canal.
|
||
*/
|
||
private String channelcode;
|
||
|
||
@Column(name = "LANGUAGECODE", nullable = true)
|
||
/**
|
||
* Codigo de idioma
|
||
*/
|
||
private String languagecode;
|
||
|
||
@Column(name = "NICKNAME", nullable = false)
|
||
/**
|
||
* Nombre corto o nombre com<6F>n del usuario.
|
||
*/
|
||
private String nickname;
|
||
|
||
@Column(name = "PASSWORD", nullable = true)
|
||
/**
|
||
* Password
|
||
*/
|
||
private String password;
|
||
|
||
@Column(name = "BRANCHFROMTERMINAL", nullable = true)
|
||
/**
|
||
* Y indica que la sucursal, oficina area toma del terminal de la maquina
|
||
*/
|
||
private String branchfromterminal;
|
||
|
||
@Column(name = "CHANGEPASSWORD", nullable = true)
|
||
/**
|
||
* Y Indica que el usuario tiene que cambiar de password al momento de logon, cuando el administrador resea el password
|
||
*/
|
||
private String changepassword;
|
||
|
||
@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;
|
||
|
||
@Column(name = "ACTIVATEUSER", nullable = true)
|
||
/**
|
||
* Codigo de usuario que pone operativo o activa al usuario.
|
||
*/
|
||
private String activateuser;
|
||
|
||
@Column(name = "TERMINALCODE", nullable = true)
|
||
/**
|
||
* null
|
||
*/
|
||
private String terminalcode;
|
||
|
||
@Column(name = "ISUSERBPM", nullable = true)
|
||
/**
|
||
* Y indica que el usuario esta habilitado para trabajar en el JBPM
|
||
*/
|
||
private String isuserbpm;
|
||
|
||
@Column(name="CCENTROCONTROL", nullable=true)
|
||
|
||
/**
|
||
* Codigo de centro de control de armas
|
||
*/
|
||
private String ccentrocontrol;
|
||
|
||
/** Contructor por defecto */
|
||
public TsafeUserDetail() {
|
||
}
|
||
|
||
/**
|
||
* Contructor de TsafeUserDetail
|
||
*
|
||
* @param pPk
|
||
* Clave Primaria del entity
|
||
* @param pDatefrom
|
||
* Fecha desde la cual esta vigente el registro del detalle de
|
||
* usuarios
|
||
* @param pNickname
|
||
* Nombre corto o nombre com<6F>n del usuario.
|
||
*/
|
||
public TsafeUserDetail(TsafeUserDetailKey pPk, Timestamp pDatefrom,
|
||
String pNickname) {
|
||
this();
|
||
pk = pPk;
|
||
datefrom = pDatefrom;
|
||
nickname = pNickname;
|
||
}
|
||
|
||
/**
|
||
* 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 TsafeUserDetail
|
||
*/
|
||
public static TsafeUserDetail find(EntityManager pEntityManager,
|
||
TsafeUserDetailKey pKey) throws Exception {
|
||
TsafeUserDetail obj = pEntityManager.find(TsafeUserDetail.class, pKey);
|
||
return obj;
|
||
}
|
||
|
||
/**
|
||
* Entrega la Clave primaria de TsafeUserDetail
|
||
*
|
||
* @return El objeto que referencia a la Clave primaria de TsafeUserDetail
|
||
*/
|
||
public TsafeUserDetailKey getPk() {
|
||
return pk;
|
||
}
|
||
|
||
/**
|
||
* Fija un nuevo valor a la Clave primaria de TsafeUserDetail
|
||
*
|
||
* @param pPk
|
||
* El objeto que referencia a la nueva Clave primaria de
|
||
* TsafeUserDetail
|
||
*/
|
||
public void setPk(TsafeUserDetailKey pPk) {
|
||
pk = pPk;
|
||
}
|
||
|
||
/**
|
||
* 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 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 userstatuscatalog
|
||
*
|
||
* @return valor de userstatuscatalog
|
||
*/
|
||
public String getUserstatuscatalog() {
|
||
return userstatuscatalog;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de userstatuscatalog
|
||
*
|
||
* @param pUserstatuscatalog
|
||
* nuevo Valor de userstatuscatalog
|
||
*/
|
||
public void setUserstatuscatalog(String pUserstatuscatalog) {
|
||
userstatuscatalog = pUserstatuscatalog;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de userstatuscatalogcode
|
||
*
|
||
* @return valor de userstatuscatalogcode
|
||
*/
|
||
public String getUserstatuscatalogcode() {
|
||
return userstatuscatalogcode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de userstatuscatalogcode
|
||
*
|
||
* @param pUserstatuscatalogcode
|
||
* nuevo Valor de userstatuscatalogcode
|
||
*/
|
||
public void setUserstatuscatalogcode(String pUserstatuscatalogcode) {
|
||
userstatuscatalogcode = pUserstatuscatalogcode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de companycode
|
||
*
|
||
* @return valor de companycode
|
||
*/
|
||
public Integer getCompanycode() {
|
||
return companycode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de companycode
|
||
*
|
||
* @param pCompanycode
|
||
* nuevo Valor de companycode
|
||
*/
|
||
public void setCompanycode(Integer pCompanycode) {
|
||
companycode = pCompanycode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de areacode
|
||
*
|
||
* @return valor de areacode
|
||
*/
|
||
public Integer getAreacode() {
|
||
return areacode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de areacode
|
||
*
|
||
* @param pAreacode
|
||
* nuevo Valor de areacode
|
||
*/
|
||
public void setAreacode(Integer pAreacode) {
|
||
areacode = pAreacode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de officecode
|
||
*
|
||
* @return valor de officecode
|
||
*/
|
||
public Integer getOfficecode() {
|
||
return officecode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de officecode
|
||
*
|
||
* @param pOfficecode
|
||
* nuevo Valor de officecode
|
||
*/
|
||
public void setOfficecode(Integer pOfficecode) {
|
||
officecode = pOfficecode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de branchcode
|
||
*
|
||
* @return valor de branchcode
|
||
*/
|
||
public Integer getBranchcode() {
|
||
return branchcode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de branchcode
|
||
*
|
||
* @param pBranchcode
|
||
* nuevo Valor de branchcode
|
||
*/
|
||
public void setBranchcode(Integer pBranchcode) {
|
||
branchcode = pBranchcode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de channelcode
|
||
*
|
||
* @return valor de channelcode
|
||
*/
|
||
public String getChannelcode() {
|
||
return channelcode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de channelcode
|
||
*
|
||
* @param pChannelcode
|
||
* nuevo Valor de channelcode
|
||
*/
|
||
public void setChannelcode(String pChannelcode) {
|
||
channelcode = pChannelcode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de languagecode
|
||
*
|
||
* @return valor de languagecode
|
||
*/
|
||
public String getLanguagecode() {
|
||
return languagecode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de languagecode
|
||
*
|
||
* @param pLanguagecode
|
||
* nuevo Valor de languagecode
|
||
*/
|
||
public void setLanguagecode(String pLanguagecode) {
|
||
languagecode = pLanguagecode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de nickname
|
||
*
|
||
* @return valor de nickname
|
||
*/
|
||
public String getNickname() {
|
||
return nickname;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de nickname
|
||
*
|
||
* @param pNickname
|
||
* nuevo Valor de nickname
|
||
*/
|
||
public void setNickname(String pNickname) {
|
||
nickname = pNickname;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de password
|
||
*
|
||
* @return valor de password
|
||
*/
|
||
public String getPassword() {
|
||
return password;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de password
|
||
*
|
||
* @param pPassword
|
||
* nuevo Valor de password
|
||
*/
|
||
public void setPassword(String pPassword) {
|
||
password = pPassword;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de branchfromterminal
|
||
*
|
||
* @return valor de branchfromterminal
|
||
*/
|
||
public String getBranchfromterminal() {
|
||
return branchfromterminal;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de branchfromterminal
|
||
*
|
||
* @param pBranchfromterminal
|
||
* nuevo Valor de branchfromterminal
|
||
*/
|
||
public void setBranchfromterminal(String pBranchfromterminal) {
|
||
branchfromterminal = pBranchfromterminal;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de changepassword
|
||
*
|
||
* @return valor de changepassword
|
||
*/
|
||
public String getChangepassword() {
|
||
return changepassword;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de changepassword
|
||
*
|
||
* @param pChangepassword
|
||
* nuevo Valor de changepassword
|
||
*/
|
||
public void setChangepassword(String pChangepassword) {
|
||
changepassword = pChangepassword;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de ingressuser
|
||
*
|
||
* @return valor de ingressuser
|
||
*/
|
||
public String getIngressuser() {
|
||
return ingressuser;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de ingressuser
|
||
*
|
||
* @param pIngressuser
|
||
* nuevo Valor de ingressuser
|
||
*/
|
||
public void setIngressuser(String pIngressuser) {
|
||
ingressuser = pIngressuser;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de modifyuser
|
||
*
|
||
* @return valor de modifyuser
|
||
*/
|
||
public String getModifyuser() {
|
||
return modifyuser;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de modifyuser
|
||
*
|
||
* @param pModifyuser
|
||
* nuevo Valor de modifyuser
|
||
*/
|
||
public void setModifyuser(String pModifyuser) {
|
||
modifyuser = pModifyuser;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de activateuser
|
||
*
|
||
* @return valor de activateuser
|
||
*/
|
||
public String getActivateuser() {
|
||
return activateuser;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de activateuser
|
||
*
|
||
* @param pActivateuser
|
||
* nuevo Valor de activateuser
|
||
*/
|
||
public void setActivateuser(String pActivateuser) {
|
||
activateuser = pActivateuser;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de terminalcode
|
||
*
|
||
* @return valor de terminalcode
|
||
*/
|
||
public String getTerminalcode() {
|
||
return terminalcode;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de terminalcode
|
||
*
|
||
* @param pTerminalcode
|
||
* nuevo Valor de terminalcode
|
||
*/
|
||
public void setTerminalcode(String pTerminalcode) {
|
||
terminalcode = pTerminalcode;
|
||
}
|
||
|
||
/**
|
||
* Obtiene el valor de isuserbpm
|
||
*
|
||
* @return valor de isuserbpm
|
||
*/
|
||
public String getIsuserbpm() {
|
||
return isuserbpm;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de isuserbpm
|
||
*
|
||
* @param pIsuserbpm
|
||
* nuevo Valor de isuserbpm
|
||
*/
|
||
public void setIsuserbpm(String pIsuserbpm) {
|
||
isuserbpm = pIsuserbpm;
|
||
}
|
||
|
||
/**Obtiene el valor de ccentrocontrol
|
||
@return valor de ccentrocontrol*/
|
||
public String getCcentrocontrol(){
|
||
return ccentrocontrol;
|
||
}
|
||
/**Fija el valor de ccentrocontrol
|
||
@param pCcentrocontrol nuevo Valor de ccentrocontrol*/
|
||
public void setCcentrocontrol(String pCcentrocontrol){
|
||
ccentrocontrol=pCcentrocontrol;
|
||
}
|
||
|
||
public boolean equals(Object rhs) {
|
||
if (rhs == null)
|
||
return false;
|
||
if (!(rhs instanceof TsafeUserDetail))
|
||
return false;
|
||
TsafeUserDetail that = (TsafeUserDetail) 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 TsafeUserDetail
|
||
*
|
||
* @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 TsafeUserDetail */
|
||
public Object createInstance() {
|
||
TsafeUserDetail instance = new TsafeUserDetail();
|
||
instance.setPk(new TsafeUserDetailKey());
|
||
return instance;
|
||
}
|
||
|
||
/**
|
||
* Clona la entidad TsafeUserDetail
|
||
*
|
||
* @see com.fp.dto.hb.HibernateBean#cloneMe()
|
||
*/
|
||
public Object cloneMe() throws CloneNotSupportedException {
|
||
TsafeUserDetail p = (TsafeUserDetail) this.clone();
|
||
p.setPk((TsafeUserDetailKey) this.pk.cloneMe());
|
||
return p;
|
||
}
|
||
|
||
public Object getId() {
|
||
return this.pk;
|
||
}
|
||
|
||
//METODOS MANUALES
|
||
/**Sentecnia que entrega lista de los ultimos n passwords del usuario ordenados en forma decendente*/
|
||
private static String SQL = "from TsafeUserDetail t where t.pk.usercode = :usercode "
|
||
+ " order by t.pk.dateto desc ";
|
||
|
||
/**
|
||
* Enterga una lista de registros asociados a un usuario de TsafeUserDetail ordenados en forma decendenete.
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param pUserCode Codigo de usuario
|
||
* @param pNumReg Numero de registros a obtener en la lista .
|
||
* @return List<TsafeUserDetail>
|
||
* @throws Exception
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
public static List<TsafeUserDetail> find(EntityManager pEntityManager, String pUserCode, Integer pNumReg) throws Exception {
|
||
List<TsafeUserDetail> ldata = null;
|
||
Query qry = pEntityManager.createQuery(SQL);
|
||
qry.setParameter("usercode", pUserCode);
|
||
qry.setMaxResults(pNumReg);
|
||
ldata = qry.getResultList();
|
||
return ldata;
|
||
}
|
||
|
||
/**Sentecnia que entrega un objeto con los datos de un usuario.*/
|
||
private static String JPQL_BY_USER = "from TsafeUserDetail t where t.pk.usercode = :usercode "
|
||
+ " and t.pk.dateto = :dateto ";
|
||
|
||
/**
|
||
* Enterga un objeto con los datos de un usuario de TsafeUserDetail.
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param pUserCode Codigo de usuario
|
||
* @return TsafeUserDetail
|
||
* @throws Exception
|
||
*/
|
||
public static TsafeUserDetail find(EntityManager pEntityManager, String pUserCode) throws Exception {
|
||
TsafeUserDetail obj = null;
|
||
Query qry = pEntityManager.createQuery(JPQL_BY_USER);
|
||
qry.setParameter("usercode", pUserCode);
|
||
qry.setParameter("dateto",Constant.getDefaultExpiryDate());
|
||
try {
|
||
obj = (TsafeUserDetail)qry.getSingleResult();
|
||
} catch (NoResultException e) {
|
||
throw new GeneralException("GENE-0035", "USUARIO: {0} NO DEFINIDO EN TSAFEUSERDETAIL", pUserCode);
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
|
||
/**
|
||
* Sentencia que devuelve un registro de TgeneSubProduct.
|
||
*/
|
||
private static final String JPQL_NAME_USER = "from TsafeUserDetail tsu " + " where tsu.pk.usercode = :usercode "
|
||
+ " and tsu.pk.dateto = :dateto ";
|
||
/**
|
||
* Metodo que obtiene datos de un registro del subproducto.
|
||
*
|
||
* @param pEntityManager Session de la base de datos.
|
||
* @param pModulecode Codigo de modulo a obtener datos de la base.
|
||
* @param pProductcode Codigo de producto a obtener datos de la base.
|
||
* @param pSubproductcode Codigo de subproducto a obtener datos de la base.
|
||
* @return TgeneSubProduct
|
||
* @throws Exception
|
||
*/
|
||
public static TsafeUserDetail findByUserCode(EntityManager pEntityManager, String usercode) throws Exception {
|
||
Query qry = pEntityManager.createQuery(TsafeUserDetail.JPQL_NAME_USER);
|
||
qry.setParameter("usercode", usercode);
|
||
qry.setParameter("dateto", Constant.getDefaultExpiryDate());
|
||
try {
|
||
return (TsafeUserDetail) qry.getSingleResult();
|
||
} catch (NoResultException e) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
}
|