leonardo 2016-05-13 20:52:52 +00:00
parent a37a5c7f1f
commit d83a9f94fe
5 changed files with 120 additions and 27 deletions

View File

@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.entidad;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -26,6 +27,11 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
/** /**
* *
* @author Rafius * @author Rafius
@ -89,21 +95,27 @@ public class TipoEventoExtra implements Serializable {
@Column(name = "NATUREZA") @Column(name = "NATUREZA")
private String natureza; private String natureza;
@Column(name = "CONTACONTABIL") @Column(name = "CONTACONTABIL")
private String contaContabil; private String contaContabil;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoeventoextra")
@JoinColumn(name = "TIPOEVENTOEXTRA_ID", referencedColumnName = "TIPOEVENTOEXTRA_ID") @LazyCollection(LazyCollectionOption.FALSE)
private List<TipoEventoExtraEmpresa> empresas; private List<TipoEventoExtraEmpresa> empresas;
@Column(name = "INDCONFERENCIAFISICACOMISSAO") @Column(name = "INDCONFERENCIAFISICACOMISSAO")
private Boolean indconferenciafisicacomissao; private Boolean indconferenciafisicacomissao;
// @Column(name = "FORMAPAGO_ID") public TipoEventoExtraEmpresa addEmpresa(Empresa e) {
// private Integer formapagoId; TipoEventoExtraEmpresa t = new TipoEventoExtraEmpresa();
// @Column(name = "PARAMARTICULO2_ID") t.setEmpresa(e);
// private Integer paramarticulo2Id; t.setTipoeventoextra(this);
// @Column(name = "FORMAPAGO2_ID") t.setActivo(Boolean.TRUE);
// private Integer formapago2Id; t.setFecmodif(Calendar.getInstance().getTime());
// @Column(name = "PARAMARTICULO_ID") t.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
// private Integer paramarticuloId; this.empresas.add(t);
return t;
}
public void removeEmpresa(TipoEventoExtraEmpresa t) {
this.empresas.remove(t);
}
public String getDescTipoEvento() { public String getDescTipoEvento() {
return descTipoEvento; return descTipoEvento;
@ -129,16 +141,6 @@ public class TipoEventoExtra implements Serializable {
private ParamArticulo paramArticulo2; private ParamArticulo paramArticulo2;
public TipoEventoExtra() { public TipoEventoExtra() {
empresas = new ArrayList<TipoEventoExtraEmpresa>();
}
public void addTipoEventoExtraEmpresa(TipoEventoExtraEmpresa tipoEventoExtraEmpresa){
tipoEventoExtraEmpresa.setTipoeventoextra(this);
empresas.add(tipoEventoExtraEmpresa);
}
public void removeTipoEventoExtraEmpresa(TipoEventoExtraEmpresa tipoEventoExtraEmpresa){
empresas.remove(tipoEventoExtraEmpresa);
} }
public TipoEventoExtra(Integer tipoeventoextraId) { public TipoEventoExtra(Integer tipoeventoextraId) {
@ -358,7 +360,13 @@ public class TipoEventoExtra implements Serializable {
} }
public List<TipoEventoExtraEmpresa> getEmpresas() { public List<TipoEventoExtraEmpresa> getEmpresas() {
return empresas; List<TipoEventoExtraEmpresa> lista = new ArrayList<TipoEventoExtraEmpresa>();
for (TipoEventoExtraEmpresa t : empresas) {
if (t.getActivo()) {
lista.add(t);
}
}
return lista;
} }
public void setEmpresas(List<TipoEventoExtraEmpresa> empresas) { public void setEmpresas(List<TipoEventoExtraEmpresa> empresas) {

View File

@ -1,5 +1,7 @@
package com.rjconsultores.ventaboletos.entidad; package com.rjconsultores.ventaboletos.entidad;
import java.util.Date;
import javax.persistence.Basic; import javax.persistence.Basic;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@ -10,6 +12,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity @Entity
@Table(name = "TIPO_EVENTO_EXTRA_EMPRESA") @Table(name = "TIPO_EVENTO_EXTRA_EMPRESA")
@ -19,14 +23,22 @@ public class TipoEventoExtraEmpresa {
@Basic(optional = false) @Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_EVENTO_EXTRA_EMPRESA_SEQ") @GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_EVENTO_EXTRA_EMPRESA_SEQ")
@Column(name = "TIPOEVENTOEXTRAEMPRESA_ID") @Column(name = "TIPOEVENTOEXTRAEMPRESA_ID")
private Integer tipoeventoextraempresaId; private Integer tipoeventoextraempresaId;
@JoinColumn(name = "TIPOEVENTOEXTRA_ID")
@ManyToOne @ManyToOne
@JoinColumn(name = "TIPOEVENTOEXTRA_ID")
private TipoEventoExtra tipoeventoextra; private TipoEventoExtra tipoeventoextra;
@ManyToOne @ManyToOne
@JoinColumn(name = "EMPRESA_ID") @JoinColumn(name = "EMPRESA_ID")
private Empresa empresa; 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() { public Integer getTipoeventoextraempresaId() {
return tipoeventoextraempresaId; return tipoeventoextraempresaId;
} }
@ -50,4 +62,43 @@ public class TipoEventoExtraEmpresa {
public String toString() { public String toString() {
return empresa.getNombempresa(); 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;
}
} }

View File

@ -57,4 +57,5 @@ public interface EmpresaService {
public void removerComissaoTipoEventoExtra(ComEmpTipoEventoExtra comEmpTipoEventoExtra); public void removerComissaoTipoEventoExtra(ComEmpTipoEventoExtra comEmpTipoEventoExtra);
public List<Empresa> obtenerTodosIncluindoEmpresaTodas();
} }

View File

@ -2,11 +2,12 @@ package com.rjconsultores.ventaboletos.service;
import java.util.List; import java.util.List;
import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa;
import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra;
import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa;
import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; import com.rjconsultores.ventaboletos.exception.ValidacionCampoException;
public interface TipoEventoExtraEmpresaService { public interface TipoEventoExtraEmpresaService extends GenericService<TipoEventoExtraEmpresa, Integer> {
public List<TipoEventoExtraEmpresa> buscarPorTipoEventoExtra(TipoEventoExtra tipoeventoextra); public List<TipoEventoExtraEmpresa> buscarPorTipoEventoExtra(TipoEventoExtra tipoeventoextra);
public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad); public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad);
} }

View File

@ -1,14 +1,17 @@
package com.rjconsultores.ventaboletos.service.impl; package com.rjconsultores.ventaboletos.service.impl;
import java.util.Calendar;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.TipoEventoExtraEmpresaDAO; import com.rjconsultores.ventaboletos.dao.TipoEventoExtraEmpresaDAO;
import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra;
import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtraEmpresa;
import com.rjconsultores.ventaboletos.service.TipoEventoExtraEmpresaService; import com.rjconsultores.ventaboletos.service.TipoEventoExtraEmpresaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("tipoEventoExtraEmpresaService") @Service("tipoEventoExtraEmpresaService")
public class TipoEventoExtraEmpresaServiceImpl implements TipoEventoExtraEmpresaService { public class TipoEventoExtraEmpresaServiceImpl implements TipoEventoExtraEmpresaService {
@ -20,11 +23,40 @@ public class TipoEventoExtraEmpresaServiceImpl implements TipoEventoExtraEmpresa
return tipoEventoExtraEmpresaDAO.buscarPorTipoEventoExtra(tipoeventoextra); return tipoEventoExtraEmpresaDAO.buscarPorTipoEventoExtra(tipoeventoextra);
} }
@Override @Transactional
public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad) { public TipoEventoExtraEmpresa suscribir(TipoEventoExtraEmpresa entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return tipoEventoExtraEmpresaDAO.suscribir(entidad); return tipoEventoExtraEmpresaDAO.suscribir(entidad);
} }
@Override
public List<TipoEventoExtraEmpresa> 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);
}
} }