maia_modificado/.svn/pristine/6d/6d7fcc07829e8acf36fdaaf790e...

289 lines
8.5 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.safe;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import java.io.Serializable;
import javax.persistence.Table;
import com.fp.dto.hb.HibernateBean;
import com.fp.dto.hb.Log;
import com.fp.general.exception.GeneralException;
import javax.persistence.Version;
import java.lang.reflect.Field;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.Transient;
/**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TSAFETERMINAL*/
@Entity(name = "TsafeTerminal")
@Table(name = "TSAFETERMINAL")
public class TsafeTerminal 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 TsafeTerminal
*/
@EmbeddedId
private TsafeTerminalKey pk;
@Version
@Column(name = "RECORDVERSION", nullable = true)
/**
* Optimistic blocking del registro
*/
private Integer recordversion;
@Column(name = "OFFICECODE", nullable = true)
/**
* Codigo de oficina
*/
private Integer officecode;
@Column(name = "BRANCHCODE", nullable = true)
/**
* Codigo de sucursal
*/
private Integer branchcode;
@Column(name = "AREACODE", nullable = true)
/**
* Codigo de area
*/
private Integer areacode;
@Column(name = "IPADDRESS", nullable = true)
/**
* Ip de la maquina
*/
private String ipaddress;
@Column(name = "MACADDRESS", nullable = true)
/**
* Mac de la maquina
*/
private String macaddress;
@Column(name = "SLIPTPRINTER", nullable = true)
/**
* Nombre de la impresora en la que se imprime el slipt de validacion de caja
*/
private String sliptprinter;
/**Contructor por defecto*/
public TsafeTerminal() {
}
/**Contructor de TsafeTerminal
@param pPk Clave Primaria del entity
*/
public TsafeTerminal(TsafeTerminalKey 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 TsafeTerminal
*/
public static TsafeTerminal find(EntityManager pEntityManager, TsafeTerminalKey pKey) throws Exception {
TsafeTerminal obj = pEntityManager.find(TsafeTerminal.class, pKey);
return obj;
}
/**Entrega la Clave primaria de TsafeTerminal
@return El objeto que referencia a la Clave primaria de TsafeTerminal
*/
public TsafeTerminalKey getPk() {
return pk;
}
/**Fija un nuevo valor a la Clave primaria de TsafeTerminal
@param pPk El objeto que referencia a la nueva Clave primaria de TsafeTerminal
*/
public void setPk(TsafeTerminalKey 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 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 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 ipaddress
@return valor de ipaddress*/
public String getIpaddress() {
return ipaddress;
}
/**Fija el valor de ipaddress
@param pIpaddress nuevo Valor de ipaddress*/
public void setIpaddress(String pIpaddress) {
ipaddress = pIpaddress;
}
/**Obtiene el valor de macaddress
@return valor de macaddress*/
public String getMacaddress() {
return macaddress;
}
/**Fija el valor de macaddress
@param pMacaddress nuevo Valor de macaddress*/
public void setMacaddress(String pMacaddress) {
macaddress = pMacaddress;
}
/**Obtiene el valor de sliptprinter
@return valor de sliptprinter*/
public String getSliptprinter() {
return sliptprinter;
}
/**Fija el valor de sliptprinter
@param pSliptprinter nuevo Valor de sliptprinter*/
public void setSliptprinter(String pSliptprinter) {
sliptprinter = pSliptprinter;
}
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TsafeTerminal)) {
return false;
}
TsafeTerminal that = (TsafeTerminal) 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 TsafeTerminal
@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 TsafeTerminal
*/
public Object createInstance() {
TsafeTerminal instance = new TsafeTerminal();
instance.setPk(new TsafeTerminalKey());
return instance;
}
/**Clona la entidad TsafeTerminal
@see com.fp.dto.hb.HibernateBean#cloneMe()
*/
public Object cloneMe() throws CloneNotSupportedException {
TsafeTerminal p = (TsafeTerminal) this.clone();
p.setPk((TsafeTerminalKey) this.pk.cloneMe());
return p;
}
private static final String HQL_TERMINAL = "from TsafeTerminal t where t.pk.companycode = :company and ipaddress = :ip";
/**
* Metodo que devuelve un objeto de tipo TsafeTerminal
* @param pEntityManager
* @param company
* @param ip
* @return
* @throws Exception
*/
public static TsafeTerminal find(EntityManager pEntityManager, Integer company, String ip) throws Exception {
TsafeTerminal tsafeTerminal = null;
Query qry = (Query) pEntityManager.createQuery(HQL_TERMINAL);
qry.setParameter("company", company);
qry.setParameter("ip", ip);
try {
tsafeTerminal = (TsafeTerminal) qry.getSingleResult();
} catch (NoResultException e) {
return null;
}
return tsafeTerminal;
}
}