diff --git a/pom.xml b/pom.xml index 8d9509bc4..1c9d11fdd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.63.0 + 1.64.0 diff --git a/src/com/rjconsultores/ventaboletos/dao/ClienteCorporativoDAO.java b/src/com/rjconsultores/ventaboletos/dao/ClienteCorporativoDAO.java new file mode 100644 index 000000000..315d46004 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/ClienteCorporativoDAO.java @@ -0,0 +1,13 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ClienteCorporativo; + + public interface ClienteCorporativoDAO extends GenericDAO{ + + public List buscar(Integer classe,Integer alias,Integer orgaoConcedente); + + public ClienteCorporativo existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ClienteCorporativoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ClienteCorporativoHibernateDAO.java new file mode 100644 index 000000000..aed316458 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ClienteCorporativoHibernateDAO.java @@ -0,0 +1,69 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + + +import java.util.List; + +import org.hibernate.Criteria; +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.ClienteCorporativoDAO; +import com.rjconsultores.ventaboletos.entidad.ClienteCorporativo; + +@Repository("clienteCorporativoDAO") +@SuppressWarnings("unchecked") +public class ClienteCorporativoHibernateDAO extends GenericHibernateDAO + implements ClienteCorporativoDAO { + + @Autowired + public ClienteCorporativoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public ClienteCorporativo existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId) { + Criteria c = makeCriteria(); + + c.add(Restrictions.eq("activo", Boolean.TRUE)); + if( classe != null ) { + c.add(Restrictions.eq("classe.claseservicioId",classe)); + } + + if ( alias != null ) { + c.add(Restrictions.eq("alias.claseservicioId",alias)); + } + + if( orgaoConcedente != null ) { + c.add(Restrictions.eq("orgaoConcedente.orgaoConcedenteId", orgaoConcedente)); + } + + if( aliasClasseId != null ) { + c.add(Restrictions.eq("aliasClasseId",aliasClasseId)); + } + + return (ClienteCorporativo) c.uniqueResult(); + } + + @Override + public List buscar(Integer classe, Integer alias, Integer orgaoConcedente) { + Criteria c = makeCriteria(); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + if( classe != null ) { + c.add(Restrictions.eq("classe.claseservicioId",classe)); + } + + if ( alias != null ) { + c.add(Restrictions.eq("alias.claseservicioId",alias)); + } + + if( orgaoConcedente != null ) { + c.add(Restrictions.eq("orgaoConcedente.orgaoConcedenteId", orgaoConcedente)); + } + + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/LogDespesaReceitaDivHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/LogDespesaReceitaDivHibernateDAO.java index 8bf9c8fd3..219c7ef03 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/LogDespesaReceitaDivHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/LogDespesaReceitaDivHibernateDAO.java @@ -5,7 +5,6 @@ import java.util.List; import javax.sql.DataSource; -import org.apache.xmlbeans.impl.xb.xsdschema.RestrictionDocument.Restriction; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.criterion.Order; diff --git a/src/com/rjconsultores/ventaboletos/entidad/ClienteCorporativo.java b/src/com/rjconsultores/ventaboletos/entidad/ClienteCorporativo.java new file mode 100644 index 000000000..0943dea16 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/ClienteCorporativo.java @@ -0,0 +1,211 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "CLIENTE_CORPORATIVO") +@SequenceGenerator(name = "CLIENTE_CORPORATIVO_SEQ", sequenceName = "CLIENTE_CORPORATIVO_SEQ", allocationSize = 1) +public class ClienteCorporativo implements Serializable { + + private static final long serialVersionUID = -5338880268814582448L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CLIENTE_CORPORATIVO_SEQ") + @Column(name = "CLIENTECORPORATIVO_ID") + private Long clienteCorporativoId; + + @Column(name = "EMPRESA_ID", nullable = false) + private Integer empresaId; + + @Column(name = "IDENTIFICACAO") + private Long identificacao; + + @Column(name = "NOMCLIENTECORP", length = 255) + private String nomeClienteCorp; + + @Column(name = "DATA_CRIACAO") + private Date dataCriacao; + + @Column(name = "LOGRADOURO", length = 255) + private String logradouro; + + @Column(name = "NUMERO", length = 6) + private String numero; + + @Column(name = "BAIRRO", length = 255) + private String bairro; + + @Column(name = "COMPLEMENTO", length = 100) + private String complemento; + + @Column(name = "CEP", length = 20) + private String cep; + + @Column(name = "TELEFONE", length = 20) + private String telefone; + + @Column(name = "EMAIL", length = 150) + private String email; + + @Column(name = "CIUDAD_ID") + private Integer ciudadId; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + @Column(name = "ACTIVO") + private boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecModif; + + private transient String nombEmpresa; + + public Long getClienteCorporativoId() { + return clienteCorporativoId; + } + + public void setClienteCorporativoId(Long clienteCorporativoId) { + this.clienteCorporativoId = clienteCorporativoId; + } + + public Integer getEmpresaId() { + return empresaId; + } + + public void setEmpresaId(Integer empresaId) { + this.empresaId = empresaId; + } + + public Long getIdentificacao() { + return identificacao; + } + + public void setIdentificacao(Long identificacao) { + this.identificacao = identificacao; + } + + public String getNomeClienteCorp() { + return nomeClienteCorp; + } + + public void setNomeClienteCorp(String nomeClienteCorp) { + this.nomeClienteCorp = nomeClienteCorp; + } + + public String getLogradouro() { + return logradouro; + } + + public void setLogradouro(String logradouro) { + this.logradouro = logradouro; + } + + public String getNumero() { + return numero; + } + + public void setNumero(String numero) { + this.numero = numero; + } + + public String getBairro() { + return bairro; + } + + public void setBairro(String bairro) { + this.bairro = bairro; + } + + public String getComplemento() { + return complemento; + } + + public void setComplemento(String complemento) { + this.complemento = complemento; + } + + public String getCep() { + return cep; + } + + public void setCep(String cep) { + this.cep = cep; + } + + public String getTelefone() { + return telefone; + } + + public void setTelefone(String telefone) { + this.telefone = telefone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getCiudadId() { + return ciudadId; + } + + public void setCiudadId(Integer ciudadId) { + this.ciudadId = ciudadId; + } + + 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; + } + + public Date getFecModif() { + return fecModif; + } + + public void setFecModif(Date fecModif) { + this.fecModif = fecModif; + } + + public Date getDataCriacao() { + return dataCriacao; + } + + public void setDataCriacao(Date dataCriacao) { + this.dataCriacao = dataCriacao; + } + + public String getNombEmpresa() { + return nombEmpresa; + } + + public void setNombEmpresa(String nombEmpresa) { + this.nombEmpresa = nombEmpresa; + } +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/service/ClienteCorporativoService.java b/src/com/rjconsultores/ventaboletos/service/ClienteCorporativoService.java new file mode 100644 index 000000000..a36cb6266 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ClienteCorporativoService.java @@ -0,0 +1,21 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.ClienteCorporativo; +import com.rjconsultores.ventaboletos.exception.BusinessException; + +public interface ClienteCorporativoService{ + + public List obtenerTodos(); + + public ClienteCorporativo obtenerID(Integer id); + + public ClienteCorporativo suscribirActualizar(ClienteCorporativo entidad) throws BusinessException; + + public void borrar(ClienteCorporativo entidad); + + public ClienteCorporativo existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId); + + public List buscar(Integer classe,Integer alias,Integer orgaoConcedente); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ClienteCorporativoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ClienteCorporativoServiceImpl.java new file mode 100644 index 000000000..f73219872 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ClienteCorporativoServiceImpl.java @@ -0,0 +1,69 @@ +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.ClienteCorporativoDAO; +import com.rjconsultores.ventaboletos.entidad.ClienteCorporativo; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.service.ClienteCorporativoService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("clienteCorpService") +public class ClienteCorporativoServiceImpl implements ClienteCorporativoService { + + @Autowired + private ClienteCorporativoDAO clienteCorpDAO; + + public List obtenerTodos() { + return clienteCorpDAO.obtenerTodos(); + } + + public ClienteCorporativo obtenerID(Integer id) { + return clienteCorpDAO.obtenerID(id); + } + + @Transactional + public ClienteCorporativo suscribirActualizar(ClienteCorporativo entidad) throws BusinessException { + + if ( entidad.getEmpresaId() == null || + entidad.getNomeClienteCorp() == null || + entidad.getIdentificacao() == null || + entidad.getDataCriacao() == null ){ + throw new BusinessException("MSG.camposObrigatorios"); + } + + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecModif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + if (entidad.getClienteCorporativoId() == null){ + return clienteCorpDAO.suscribir(entidad); + }else{ + return clienteCorpDAO.actualizacion(entidad); + } + } + + @Transactional + public void borrar(ClienteCorporativo entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecModif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + clienteCorpDAO.actualizacion(entidad); + } + + @Override + public ClienteCorporativo existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer clienteCorpId) { + return clienteCorpDAO.existe(classe, alias, orgaoConcedente, clienteCorpId); + } + + @Override + public List buscar(Integer classe, Integer alias, Integer orgaoConcedente) { + return clienteCorpDAO.buscar(classe, alias, orgaoConcedente); + } +}