fixes bug #7448
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@56023 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5b38d13243
commit
00f5941114
|
@ -0,0 +1,11 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Secretaria;
|
||||
import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa;
|
||||
|
||||
public interface SecretariaEmpresaDAO extends GenericDAO<SecretariaEmpresa, Integer> {
|
||||
|
||||
public List<SecretariaEmpresa> buscarPorSecretaria(Secretaria secretaria);
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SecretariaEmpresaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Secretaria;
|
||||
import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa;
|
||||
|
||||
@Repository("secretariaEmpresaDAO")
|
||||
public class SecretariaEmpresaHibernateDAO extends GenericHibernateDAO<SecretariaEmpresa, Integer>
|
||||
implements SecretariaEmpresaDAO {
|
||||
|
||||
@Autowired
|
||||
public SecretariaEmpresaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
public List<SecretariaEmpresa> buscarPorSecretaria(Secretaria secretaria) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.add(Restrictions.eq("secretaria", secretaria));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
}
|
|
@ -6,8 +6,10 @@ package com.rjconsultores.ventaboletos.entidad;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
|
@ -22,6 +24,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 Administrador
|
||||
|
@ -58,10 +65,37 @@ public class Secretaria implements Serializable {
|
|||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "SECRETARIA_ID")
|
||||
private List<CuponSecretaria> lsCuponSecretaria;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "secretaria")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<SecretariaEmpresa> empresas = new ArrayList<SecretariaEmpresa>();
|
||||
|
||||
public Secretaria() {
|
||||
}
|
||||
|
||||
public SecretariaEmpresa addEmpresa(Empresa e) {
|
||||
SecretariaEmpresa se = new SecretariaEmpresa();
|
||||
se.setEmpresa(e);
|
||||
se.setSecretaria(this);
|
||||
se.setActivo(Boolean.TRUE);
|
||||
se.setFecmodif(Calendar.getInstance().getTime());
|
||||
se.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
this.empresas.add(se);
|
||||
return se;
|
||||
}
|
||||
|
||||
public void removeEmpresa(SecretariaEmpresa e) {
|
||||
this.empresas.remove(e);
|
||||
}
|
||||
|
||||
public void removeEmpresa(Empresa e) {
|
||||
for (SecretariaEmpresa se : empresas) {
|
||||
if (se.getEmpresa().equals(e)) {
|
||||
this.empresas.remove(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Secretaria(Integer secretariaId) {
|
||||
this.secretariaId = secretariaId;
|
||||
}
|
||||
|
@ -144,7 +178,22 @@ public class Secretaria implements Serializable {
|
|||
return tmp;
|
||||
}
|
||||
|
||||
public void setLsCuponSecretaria(List<CuponSecretaria> lsCuponSecretaria) {
|
||||
|
||||
public List<SecretariaEmpresa> getEmpresas() {
|
||||
List<SecretariaEmpresa> lista = new ArrayList<SecretariaEmpresa>();
|
||||
for (SecretariaEmpresa eb : empresas) {
|
||||
if (eb.getActivo()) {
|
||||
lista.add(eb);
|
||||
}
|
||||
}
|
||||
return lista;
|
||||
}
|
||||
|
||||
public void setEmpresas(List<SecretariaEmpresa> empresas) {
|
||||
this.empresas = empresas;
|
||||
}
|
||||
|
||||
public void setLsCuponSecretaria(List<CuponSecretaria> lsCuponSecretaria) {
|
||||
this.lsCuponSecretaria = lsCuponSecretaria;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
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
|
||||
@SequenceGenerator(name = "SECRETARIA_EMPRESA_SEQ", sequenceName = "SECRETARIA_EMPRESA_SEQ", allocationSize = 1)
|
||||
@Table(name = "SECRETARIA_EMPRESA")
|
||||
public class SecretariaEmpresa {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SECRETARIA_EMPRESA_SEQ")
|
||||
@Column(name = "SECRETARIAEMPRESA_ID")
|
||||
private Integer secretariaempresaId;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "SECRETARIA_ID")
|
||||
private Secretaria secretaria;
|
||||
@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 SecretariaEmpresa(){
|
||||
this.activo = true;
|
||||
}
|
||||
|
||||
public Integer getSecretariaempresaId() {
|
||||
return secretariaempresaId;
|
||||
}
|
||||
public void setSecretariaempresaId(Integer secretariaempresaId) {
|
||||
this.secretariaempresaId = secretariaempresaId;
|
||||
}
|
||||
public Secretaria getSecretaria() {
|
||||
return secretaria;
|
||||
}
|
||||
public void setSecretaria(Secretaria secretaria) {
|
||||
this.secretaria = secretaria;
|
||||
}
|
||||
public Empresa getEmpresa() {
|
||||
return empresa;
|
||||
}
|
||||
public void setEmpresa(Empresa empresa) {
|
||||
this.empresa = empresa;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (secretariaempresaId != null ? secretariaempresaId.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 SecretariaEmpresa)) {
|
||||
return false;
|
||||
}
|
||||
SecretariaEmpresa other = (SecretariaEmpresa) object;
|
||||
if ((this.secretariaempresaId == null && other.secretariaempresaId != null) || (this.secretariaempresaId != null && !this.secretariaempresaId.equals(other.secretariaempresaId))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa[secretariaempresaId=" + secretariaempresaId + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Secretaria;
|
||||
import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa;
|
||||
|
||||
public interface SecretariaEmpresaService extends GenericService<SecretariaEmpresa, Integer> {
|
||||
|
||||
public List<SecretariaEmpresa> buscarPorSecretaria(Secretaria secretaria);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
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.SecretariaEmpresaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Secretaria;
|
||||
import com.rjconsultores.ventaboletos.entidad.SecretariaEmpresa;
|
||||
import com.rjconsultores.ventaboletos.service.SecretariaEmpresaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("secretariaEmpresaService")
|
||||
public class SecretariaEmpresaServiceImpl implements SecretariaEmpresaService {
|
||||
|
||||
@Autowired
|
||||
private SecretariaEmpresaDAO secretariaEmpresaDAO;
|
||||
|
||||
public List<SecretariaEmpresa> obtenerTodos() {
|
||||
return secretariaEmpresaDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public SecretariaEmpresa obtenerID(Integer id) {
|
||||
return secretariaEmpresaDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SecretariaEmpresa suscribir(SecretariaEmpresa entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return secretariaEmpresaDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SecretariaEmpresa actualizacion(SecretariaEmpresa entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return secretariaEmpresaDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(SecretariaEmpresa entidad) {
|
||||
secretariaEmpresaDAO.borrar(entidad);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SecretariaEmpresa> buscarPorSecretaria(Secretaria secretaria){
|
||||
return secretariaEmpresaDAO.buscarPorSecretaria(secretaria);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue