ADM_20121217_1RC90
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@23218 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
ff42d2b4fb
commit
7d700e00a9
|
@ -5,16 +5,21 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
|
@ -70,13 +75,12 @@ public class Estacion implements Serializable {
|
|||
private String nomeArquivoLayout;
|
||||
@Column(name = "NOMEIMPRESSORARELATORIO")
|
||||
private String nomeImpressoraRelatorio;
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
|
||||
private List<EstacionSitef> estacionSitefList;
|
||||
|
||||
@JoinColumn(name = "ESTACIONSITEF_ID")
|
||||
@ManyToOne(cascade=CascadeType.ALL)
|
||||
private EstacionSitef estacionSitefId;
|
||||
|
||||
public Estacion() {
|
||||
this.estacionSitefId = new EstacionSitef();
|
||||
|
||||
}
|
||||
|
||||
public Estacion(Integer estacionId) {
|
||||
|
@ -197,14 +201,6 @@ public class Estacion implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public EstacionSitef getEstacionSitefId() {
|
||||
return estacionSitefId;
|
||||
}
|
||||
|
||||
public void setEstacionSitefId(EstacionSitef estacionSitefId) {
|
||||
this.estacionSitefId = estacionSitefId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
|
@ -228,4 +224,21 @@ public class Estacion implements Serializable {
|
|||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.Estacion[estacionId=" + estacionId + "]";
|
||||
}
|
||||
|
||||
public List<EstacionSitef> getEstacionSitefList() {
|
||||
List<EstacionSitef> tmp = new ArrayList<EstacionSitef>();
|
||||
|
||||
if(estacionSitefList != null){
|
||||
for(EstacionSitef es:estacionSitefList){
|
||||
if (es.getActivo()){
|
||||
tmp.add(es);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void setEstacionSitefList(List<EstacionSitef> estacionSitefList) {
|
||||
this.estacionSitefList = estacionSitefList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,20 +9,18 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,6 +43,12 @@ public class EstacionSitef implements Serializable {
|
|||
private Integer numfilial;
|
||||
@Column(name = "NUMPDV")
|
||||
private Integer numpdv;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "EMPRESA_ID")
|
||||
private Empresa empresa;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ESTACION_ID", referencedColumnName = "ESTACION_ID")
|
||||
private Estacion estacion;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
@Column(name = "ACTIVO")
|
||||
|
@ -53,8 +57,6 @@ public class EstacionSitef implements Serializable {
|
|||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "estacionSitefId")
|
||||
private List<Estacion> estacionList;
|
||||
|
||||
public EstacionSitef() {
|
||||
}
|
||||
|
@ -120,14 +122,6 @@ public class EstacionSitef implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public List<Estacion> getEstacionList() {
|
||||
return estacionList;
|
||||
}
|
||||
|
||||
public void setEstacionList(List<Estacion> estacionList) {
|
||||
this.estacionList = estacionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
|
@ -153,4 +147,20 @@ public class EstacionSitef implements Serializable {
|
|||
return "com.rjconsultores.ventaboletos.entidad.EstacionSitef[ estacionsitefId=" + estacionsitefId + " ]";
|
||||
}
|
||||
|
||||
public Empresa getEmpresa() {
|
||||
return empresa;
|
||||
}
|
||||
|
||||
public void setEmpresa(Empresa empresa) {
|
||||
this.empresa = empresa;
|
||||
}
|
||||
|
||||
public Estacion getEstacion() {
|
||||
return estacion;
|
||||
}
|
||||
|
||||
public void setEstacion(Estacion estacion) {
|
||||
this.estacion = estacion;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.EstacionDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
import com.rjconsultores.ventaboletos.entidad.EstacionSitef;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.service.EstacionService;
|
||||
|
@ -39,19 +40,6 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
@Transactional(rollbackFor = BusinessException.class)
|
||||
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
||||
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getDescmac());
|
||||
boolean esDuplicado = false;
|
||||
|
||||
if (!lsEstacion.isEmpty()) {
|
||||
if (estacion.getEstacionId() == null) {
|
||||
esDuplicado = true;
|
||||
} else {
|
||||
esDuplicado = !lsEstacion.get(0).getEstacionId().equals(estacion.getEstacionId());
|
||||
}
|
||||
}
|
||||
|
||||
if (esDuplicado) {
|
||||
throw new BusinessException("MSG.Registro.Existe");
|
||||
}
|
||||
|
||||
boolean esCajaDuplicado = false;
|
||||
lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
||||
|
@ -64,7 +52,6 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (esCajaDuplicado) {
|
||||
throw new BusinessException("estacionServiceImpl.msg.cajaDuplicado");
|
||||
}
|
||||
|
@ -87,10 +74,12 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
if(entidad.getEstacionSitefId() != null){
|
||||
entidad.getEstacionSitefId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.getEstacionSitefId().setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.getEstacionSitefId().setActivo(Boolean.FALSE);
|
||||
if (entidad.getEstacionSitefList() != null) {
|
||||
for (EstacionSitef es : entidad.getEstacionSitefList()) {
|
||||
es.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
es.setFecmodif(Calendar.getInstance().getTime());
|
||||
es.setActivo(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
estacionDAO.actualizacion(entidad);
|
||||
|
|
Loading…
Reference in New Issue