Cadastro de clientes corporativos feat bug#AL-4275
parent
d0715013c5
commit
257d16b433
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.63.0</version>
|
||||
<version>1.64.0</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClienteCorporativo;
|
||||
|
||||
public interface ClienteCorporativoDAO extends GenericDAO<ClienteCorporativo, Integer>{
|
||||
|
||||
public List<ClienteCorporativo> buscar(Integer classe,Integer alias,Integer orgaoConcedente);
|
||||
|
||||
public ClienteCorporativo existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId);
|
||||
|
||||
}
|
|
@ -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<ClienteCorporativo, Integer>
|
||||
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<ClienteCorporativo> 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<ClienteCorporativo> 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<ClienteCorporativo> buscar(Integer classe,Integer alias,Integer orgaoConcedente);
|
||||
}
|
|
@ -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<ClienteCorporativo> 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<ClienteCorporativo> buscar(Integer classe, Integer alias, Integer orgaoConcedente) {
|
||||
return clienteCorpDAO.buscar(classe, alias, orgaoConcedente);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue