maia_modificado/.svn/pristine/60/6008253ef26ab9b33f94b217a9c...

439 lines
12 KiB
Plaintext
Executable File

package com.fp.persistence.pcustomer.company;
import com.fp.common.helper.Constant;
import java.sql.Timestamp;
import com.fp.dto.hb.Log;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Table;
import com.fp.dto.hb.HibernateBean;
import javax.persistence.Version;
import javax.persistence.Entity;
import javax.persistence.EmbeddedId;
import javax.persistence.EntityManager;
import javax.persistence.Column;
import java.lang.reflect.Field;
import javax.persistence.Transient;
import java.sql.Date;
import java.util.List;
import javax.persistence.Query;
/**
* Clase que implementa la entidad de Hibernate que hace referencia a la tabla TCUSTCOMPANYMANAGERS
*/
@Entity(name = "TcustCompanyManagers")
@Table(name = "TCUSTCOMPANYMANAGERS")
public class TcustCompanyManagers 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 TcustCompanyManagers
*/
@EmbeddedId
private TcustCompanyManagersKey pk;
@Column(name = "DATEFROM", nullable = true)
/**
* Fecha desde la cual esta vigente el registro
*/
private Timestamp datefrom;
@Version
@Column(name = "RECORDVERSION", nullable = true)
/**
* Optimistic locking del registro
*/
private Integer recordversion;
@Column(name = "DESIGNATIONDATE", nullable = true)
/**
* Fecha de nombramiento
*/
private Date designationdate;
@Column(name = "EXPIRATIONDATE", nullable = true)
/**
* Fecha de vencimiento del nombramiento
*/
private Date expirationdate;
@Column(name = "REGISTERDATE", nullable = true)
/**
* Fecha en la que se incribe el nombramiento en los organismos de control, ejemoplo registro mercail,
* superintendencia de companias
*/
private Date registerdate;
@Column(name = "REMARK", nullable = true)
/**
* Comentario
*/
private String remark;
@Column(name = "INGRESSUSER", nullable = true)
/**
* Codigo de usuario que crea el cliente
*/
private String ingressuser;
@Column(name = "MODIFYUSER", nullable = true)
/**
* Codigo de usuario que modifica datos del cliente
*/
private String modifyuser;
@Column(name = "ISREPRESENTLEGAL", nullable = true)
/**
* I dentifica si el directivo es el representante legal de la empresa
*/
private String isrepresentlegal;
@Column(name = "PARTICIPATION", nullable = true)
/**
* Porcentaje de particicion del socio dentro de la empresa.
*/
private BigDecimal participation;
/**
* Contructor por defecto
*/
public TcustCompanyManagers() {
}
/**
* Contructor de TcustCompanyManagers
*
* @param pPk Clave Primaria del entity
*/
public TcustCompanyManagers(TcustCompanyManagersKey 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 TcustCompanyManagers
*/
public static TcustCompanyManagers find(EntityManager pEntityManager, TcustCompanyManagersKey pKey) throws Exception {
TcustCompanyManagers obj = pEntityManager.find(TcustCompanyManagers.class, pKey);
return obj;
}
/**
* Entrega la Clave primaria de TcustCompanyManagers
*
* @return El objeto que referencia a la Clave primaria de TcustCompanyManagers
*/
public TcustCompanyManagersKey getPk() {
return pk;
}
/**
* Fija un nuevo valor a la Clave primaria de TcustCompanyManagers
*
* @param pPk El objeto que referencia a la nueva Clave primaria de TcustCompanyManagers
*/
public void setPk(TcustCompanyManagersKey pPk) {
pk = pPk;
}
/**
* 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 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 designationdate
*
* @return valor de designationdate
*/
public Date getDesignationdate() {
return designationdate;
}
/**
* Fija el valor de designationdate
*
* @param pDesignationdate nuevo Valor de designationdate
*/
public void setDesignationdate(Date pDesignationdate) {
designationdate = pDesignationdate;
}
/**
* Obtiene el valor de expirationdate
*
* @return valor de expirationdate
*/
public Date getExpirationdate() {
return expirationdate;
}
/**
* Fija el valor de expirationdate
*
* @param pExpirationdate nuevo Valor de expirationdate
*/
public void setExpirationdate(Date pExpirationdate) {
expirationdate = pExpirationdate;
}
/**
* Obtiene el valor de registerdate
*
* @return valor de registerdate
*/
public Date getRegisterdate() {
return registerdate;
}
/**
* Fija el valor de registerdate
*
* @param pRegisterdate nuevo Valor de registerdate
*/
public void setRegisterdate(Date pRegisterdate) {
registerdate = pRegisterdate;
}
/**
* Obtiene el valor de remark
*
* @return valor de remark
*/
public String getRemark() {
return remark;
}
/**
* Fija el valor de remark
*
* @param pRemark nuevo Valor de remark
*/
public void setRemark(String pRemark) {
remark = pRemark;
}
/**
* 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 isrepresentlegal
*
* @return valor de isrepresentlegal
*/
public String getIsrepresentlegal() {
return isrepresentlegal;
}
/**
* Fija el valor de isrepresentlegal
*
* @param pIsrepresentlegal nuevo Valor de isrepresentlegal
*/
public void setIsrepresentlegal(String pIsrepresentlegal) {
isrepresentlegal = pIsrepresentlegal;
}
/**
* Obtiene el valor de participation
*
* @return valor de participation
*/
public BigDecimal getParticipation() {
return participation;
}
/**
* Fija el valor de participation
*
* @param pParticipation nuevo Valor de participation
*/
public void setParticipation(BigDecimal pParticipation) {
participation = pParticipation;
}
public boolean equals(Object rhs) {
if (rhs == null) {
return false;
}
if (!(rhs instanceof TcustCompanyManagers)) {
return false;
}
TcustCompanyManagers that = (TcustCompanyManagers) rhs;
if (this.getPk() == null || that.getPk() == null) {
return false;
}
return (this.getPk().equals(that.getPk()));
}
/**
* Implementacion del metodo hashCode de la la entidad TcustCompanyManagers
*
* @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;
}
/**
* Implementacion 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;
}
/**
* Implementacion de la creacion de un bean en blanco TcustCompanyManagers
*/
public Object createInstance() {
TcustCompanyManagers instance = new TcustCompanyManagers();
instance.setPk(new TcustCompanyManagersKey());
return instance;
}
/**
* Clona la entidad TcustCompanyManagers
*
* @see com.fp.dto.hb.HibernateBean#cloneMe()
*/
public Object cloneMe() throws CloneNotSupportedException {
TcustCompanyManagers p = (TcustCompanyManagers) this.clone();
p.setPk((TcustCompanyManagersKey) this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
//METODOS MANUALES.
private static final String JPQL_MANAGERS = "from TcustCompanyManagers c" + " where c.pk.personcode = :personcode "
+ " and c.pk.dateto = :dateto ";
/**
* Metodo que devuelve una lista de objetos TcustCompanyManagers dado el codigo de persona
*
* @param pEntityManager
* @param personcode codigo de persona
* @return List<TcustCompanyManagers>
* @throws Exception
*/
public static List<TcustCompanyManagers> find(EntityManager pEntityManager, Integer personcode) throws Exception {
List<TcustCompanyManagers> lcomManagers = null;
Query qry = pEntityManager.createQuery(TcustCompanyManagers.JPQL_MANAGERS);
qry.setParameter("personcode", personcode);
qry.setParameter("dateto", Constant.getDefaultExpiryDate());
lcomManagers = qry.getResultList();
return lcomManagers;
}
//METODOS MANUALES
/**
* Sentencia que devuelve las excepciones de una solicitud.
*/
private static final String JPQL_SOL_TCUSTCOMPANYMANAGERS = "from TcustCompanyManagers tcustCompanyManagers "
+ " where tcustCompanyManagers.pk.personcode = :personcode " + "and tcustCompanyManagers.pk.dateto = :dateto";
@SuppressWarnings(com.fp.common.helper.Constant.VUNCHECKED)
public static List<TcustCompanyManagers> findByPersonCode(EntityManager pEntityManager, Integer pPersonCode) throws Exception {
List<TcustCompanyManagers> lObjects = null;
Query qry = pEntityManager.createQuery(TcustCompanyManagers.JPQL_SOL_TCUSTCOMPANYMANAGERS);
qry.setParameter("personcode", pPersonCode);
qry.setParameter("dateto", Constant.getDefaultExpiryTimestamp());
lObjects = qry.getResultList();
return lObjects;
}
}