From d83a9f94fe91bdae1325d3ee28cc10cc3ad4dacb Mon Sep 17 00:00:00 2001 From: leonardo Date: Fri, 13 May 2016 20:52:52 +0000 Subject: [PATCH] bug #7438 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@55984 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/entidad/TipoEventoExtra.java | 52 ++++++++++-------- .../entidad/TipoEventoExtraEmpresa.java | 55 ++++++++++++++++++- .../ventaboletos/service/EmpresaService.java | 1 + .../TipoEventoExtraEmpresaService.java | 3 +- .../TipoEventoExtraEmpresaServiceImpl.java | 36 +++++++++++- 5 files changed, 120 insertions(+), 27 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java index 8a2d3b8d5..b438dc9a2 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtra.java @@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.entidad; import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.List; @@ -26,6 +27,11 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; + +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + /** * * @author Rafius @@ -89,21 +95,27 @@ public class TipoEventoExtra implements Serializable { @Column(name = "NATUREZA") private String natureza; @Column(name = "CONTACONTABIL") - private String contaContabil; - @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) - @JoinColumn(name = "TIPOEVENTOEXTRA_ID", referencedColumnName = "TIPOEVENTOEXTRA_ID") + private String contaContabil; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoeventoextra") + @LazyCollection(LazyCollectionOption.FALSE) private List empresas; @Column(name = "INDCONFERENCIAFISICACOMISSAO") private Boolean indconferenciafisicacomissao; - // @Column(name = "FORMAPAGO_ID") - // private Integer formapagoId; - // @Column(name = "PARAMARTICULO2_ID") - // private Integer paramarticulo2Id; - // @Column(name = "FORMAPAGO2_ID") - // private Integer formapago2Id; - // @Column(name = "PARAMARTICULO_ID") - // private Integer paramarticuloId; + public TipoEventoExtraEmpresa addEmpresa(Empresa e) { + TipoEventoExtraEmpresa t = new TipoEventoExtraEmpresa(); + t.setEmpresa(e); + t.setTipoeventoextra(this); + t.setActivo(Boolean.TRUE); + t.setFecmodif(Calendar.getInstance().getTime()); + t.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + this.empresas.add(t); + return t; + } + + public void removeEmpresa(TipoEventoExtraEmpresa t) { + this.empresas.remove(t); + } public String getDescTipoEvento() { return descTipoEvento; @@ -129,16 +141,6 @@ public class TipoEventoExtra implements Serializable { private ParamArticulo paramArticulo2; public TipoEventoExtra() { - empresas = new ArrayList(); - } - - public void addTipoEventoExtraEmpresa(TipoEventoExtraEmpresa tipoEventoExtraEmpresa){ - tipoEventoExtraEmpresa.setTipoeventoextra(this); - empresas.add(tipoEventoExtraEmpresa); - } - - public void removeTipoEventoExtraEmpresa(TipoEventoExtraEmpresa tipoEventoExtraEmpresa){ - empresas.remove(tipoEventoExtraEmpresa); } public TipoEventoExtra(Integer tipoeventoextraId) { @@ -358,7 +360,13 @@ public class TipoEventoExtra implements Serializable { } public List getEmpresas() { - return empresas; + List lista = new ArrayList(); + for (TipoEventoExtraEmpresa t : empresas) { + if (t.getActivo()) { + lista.add(t); + } + } + return lista; } public void setEmpresas(List empresas) { diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraEmpresa.java b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraEmpresa.java index 9ff267ba6..caef649f0 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraEmpresa.java +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoEventoExtraEmpresa.java @@ -1,5 +1,7 @@ package com.rjconsultores.ventaboletos.entidad; +import java.util.Date; + import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,6 +12,8 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.SequenceGenerator; import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; @Entity @Table(name = "TIPO_EVENTO_EXTRA_EMPRESA") @@ -19,14 +23,22 @@ public class TipoEventoExtraEmpresa { @Basic(optional = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_EVENTO_EXTRA_EMPRESA_SEQ") @Column(name = "TIPOEVENTOEXTRAEMPRESA_ID") - private Integer tipoeventoextraempresaId; - @JoinColumn(name = "TIPOEVENTOEXTRA_ID") + private Integer tipoeventoextraempresaId; @ManyToOne + @JoinColumn(name = "TIPOEVENTOEXTRA_ID") private TipoEventoExtra tipoeventoextra; @ManyToOne @JoinColumn(name = "EMPRESA_ID") private Empresa empresa; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "ACTIVO") + private Boolean activo; + public Integer getTipoeventoextraempresaId() { return tipoeventoextraempresaId; } @@ -50,4 +62,43 @@ public class TipoEventoExtraEmpresa { public String toString() { return empresa.getNombempresa(); } + + @Override + public int hashCode() { + int hash = 0; + hash += (tipoeventoextraempresaId != null ? tipoeventoextraempresaId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof TipoEventoExtraEmpresa)) { + return false; + } + TipoEventoExtraEmpresa other = (TipoEventoExtraEmpresa) object; + if ((this.tipoeventoextraempresaId == null && other.tipoeventoextraempresaId != null) || (this.tipoeventoextraempresaId != null && !this.tipoeventoextraempresaId.equals(other.tipoeventoextraempresaId))) { + return false; + } + return true; + } + public Date getFecmodif() { + return fecmodif; + } + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + public Integer getUsuarioId() { + return usuarioId; + } + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + public Boolean getActivo() { + return activo; + } + public void setActivo(Boolean activo) { + this.activo = activo; + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java index e6e734ed1..89c2f3d9e 100644 --- a/src/com/rjconsultores/ventaboletos/service/EmpresaService.java +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaService.java @@ -57,4 +57,5 @@ public interface EmpresaService { public void removerComissaoTipoEventoExtra(ComEmpTipoEventoExtra comEmpTipoEventoExtra); + public List obtenerTodosIncluindoEmpresaTodas(); } diff --git a/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraEmpresaService.java b/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraEmpresaService.java index b7ccde94a..ca5d9792a 100644 --- a/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraEmpresaService.java +++ b/src/com/rjconsultores/ventaboletos/service/TipoEventoExtraEmpresaService.java @@ -2,11 +2,12 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; +import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa; import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; -public interface TipoEventoExtraEmpresaService { +public interface TipoEventoExtraEmpresaService extends GenericService { public List buscarPorTipoEventoExtra(TipoEventoExtra tipoeventoextra); public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraEmpresaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraEmpresaServiceImpl.java index 3ba8299a5..93488b354 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraEmpresaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TipoEventoExtraEmpresaServiceImpl.java @@ -1,14 +1,17 @@ package com.rjconsultores.ventaboletos.service.impl; +import java.util.Calendar; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.TipoEventoExtraEmpresaDAO; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa; import com.rjconsultores.ventaboletos.service.TipoEventoExtraEmpresaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @Service("tipoEventoExtraEmpresaService") public class TipoEventoExtraEmpresaServiceImpl implements TipoEventoExtraEmpresaService { @@ -20,11 +23,40 @@ public class TipoEventoExtraEmpresaServiceImpl implements TipoEventoExtraEmpresa return tipoEventoExtraEmpresaDAO.buscarPorTipoEventoExtra(tipoeventoextra); } - @Override + @Transactional public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + return tipoEventoExtraEmpresaDAO.suscribir(entidad); } - + @Override + public List obtenerTodos() { + return tipoEventoExtraEmpresaDAO.obtenerTodos(); + } + @Override + public TipoEventoExtraEmpresa obtenerID(Integer id) { + return tipoEventoExtraEmpresaDAO.obtenerID(id); + } + + @Transactional + public TipoEventoExtraEmpresa actualizacion(TipoEventoExtraEmpresa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoEventoExtraEmpresaDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(TipoEventoExtraEmpresa entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + tipoEventoExtraEmpresaDAO.actualizacion(entidad); + } }