Adição do cadastro de Alias de classe bug#AL-3857
parent
4d457fb662
commit
822d062465
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>br.com.rjconsultores</groupId>
|
<groupId>br.com.rjconsultores</groupId>
|
||||||
<artifactId>ModelWeb</artifactId>
|
<artifactId>ModelWeb</artifactId>
|
||||||
<version>1.58.3</version>
|
<version>1.59.0</version>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AliasClasse;
|
||||||
|
|
||||||
|
public interface AliasClasseDAO extends GenericDAO<AliasClasse, Integer>{
|
||||||
|
|
||||||
|
public List<AliasClasse> buscar(Integer classe,Integer alias,Integer orgaoConcedente);
|
||||||
|
|
||||||
|
public AliasClasse 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.AliasClasseDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AliasClasse;
|
||||||
|
|
||||||
|
@Repository("aliasClasseDAO")
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public class AliasClasseHibernateDAO extends GenericHibernateDAO<AliasClasse, Integer>
|
||||||
|
implements AliasClasseDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AliasClasseHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AliasClasse 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 (AliasClasse) c.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AliasClasse> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
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.OneToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "ALIAS_CLASSE_SEQ", sequenceName = "ALIAS_CLASSE_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "ALIAS_CLASSE_SERVICO")
|
||||||
|
public class AliasClasse implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "ALIAS_CLASSE_SEQ")
|
||||||
|
@Column(name = "ALIASCLASSE_ID")
|
||||||
|
private Integer aliasClasseId;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "CLASSE_ID")
|
||||||
|
private ClaseServicio classe;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "ALIAS_ID")
|
||||||
|
private ClaseServicio alias;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "ORGAOCONCEDENTE_ID")
|
||||||
|
private OrgaoConcedente orgaoConcedente;
|
||||||
|
|
||||||
|
@Column(name = "MENSAGEM")
|
||||||
|
private String mensagem;
|
||||||
|
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecmodif;
|
||||||
|
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
|
||||||
|
public AliasClasse() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((aliasClasseId == null) ? 0 : aliasClasseId.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
AliasClasse other = (AliasClasse) obj;
|
||||||
|
if (aliasClasseId == null) {
|
||||||
|
if (other.aliasClasseId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!aliasClasseId.equals(other.aliasClasseId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAliasClasseId() {
|
||||||
|
return aliasClasseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliasClasseId(Integer aliasClasseId) {
|
||||||
|
this.aliasClasseId = aliasClasseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClaseServicio getClasse() {
|
||||||
|
return classe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClasse(ClaseServicio classe) {
|
||||||
|
this.classe = classe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClaseServicio getAlias() {
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlias(ClaseServicio alias) {
|
||||||
|
this.alias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrgaoConcedente getOrgaoConcedente() {
|
||||||
|
return orgaoConcedente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrgaoConcedente(OrgaoConcedente orgaoConcedente) {
|
||||||
|
this.orgaoConcedente = orgaoConcedente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMensagem() {
|
||||||
|
return mensagem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMensagem(String mensagem) {
|
||||||
|
this.mensagem = mensagem;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Integer getUsuarioId() {
|
||||||
|
return usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsuarioId(Integer usuarioId) {
|
||||||
|
this.usuarioId = usuarioId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AliasClasse;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
|
public interface AliasClasseService{
|
||||||
|
|
||||||
|
public List<AliasClasse> obtenerTodos();
|
||||||
|
|
||||||
|
public AliasClasse obtenerID(Integer id);
|
||||||
|
|
||||||
|
public AliasClasse suscribirActualizar(AliasClasse entidad) throws BusinessException;
|
||||||
|
|
||||||
|
public void borrar(AliasClasse entidad);
|
||||||
|
|
||||||
|
public AliasClasse existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId);
|
||||||
|
|
||||||
|
public List<AliasClasse> buscar(Integer classe,Integer alias,Integer orgaoConcedente);
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
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.AliasClasseDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AliasClasse;
|
||||||
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AliasClasseService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("aliasClasseService")
|
||||||
|
public class AliasClasseServiceImpl implements AliasClasseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliasClasseDAO aliasClasseDAO;
|
||||||
|
|
||||||
|
public List<AliasClasse> obtenerTodos() {
|
||||||
|
return aliasClasseDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AliasClasse obtenerID(Integer id) {
|
||||||
|
return aliasClasseDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public AliasClasse suscribirActualizar(AliasClasse entidad) throws BusinessException {
|
||||||
|
|
||||||
|
if ( (entidad.getClasse() == null) || (entidad.getAlias() == null) || (entidad.getOrgaoConcedente() == null) ){
|
||||||
|
throw new BusinessException("MSG.camposObrigatorios");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AliasClasse> lsBusca = aliasClasseDAO.buscar(entidad.getClasse().getClaseservicioId(), null, entidad.getOrgaoConcedente().getOrgaoConcedenteId());
|
||||||
|
|
||||||
|
if (!lsBusca.isEmpty()){
|
||||||
|
|
||||||
|
for(AliasClasse as : lsBusca){
|
||||||
|
if(!as.equals(entidad)){
|
||||||
|
throw new BusinessException("MSG.registroYaExiste");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
if (entidad.getAliasClasseId() == null){
|
||||||
|
return aliasClasseDAO.suscribir(entidad);
|
||||||
|
}else{
|
||||||
|
return aliasClasseDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void borrar(AliasClasse entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
|
aliasClasseDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AliasClasse existe(Integer classe, Integer alias, Integer orgaoConcedente, Integer aliasClasseId) {
|
||||||
|
return aliasClasseDAO.existe(classe, alias, orgaoConcedente, aliasClasseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AliasClasse> buscar(Integer classe, Integer alias, Integer orgaoConcedente) {
|
||||||
|
return aliasClasseDAO.buscar(classe, alias, orgaoConcedente);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue