diff --git a/src/com/rjconsultores/ventaboletos/dao/MensagemRecusaDAO.java b/src/com/rjconsultores/ventaboletos/dao/MensagemRecusaDAO.java new file mode 100644 index 000000000..eda1019af --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/MensagemRecusaDAO.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.MensagemRecusa; + +public interface MensagemRecusaDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/MensagemRecusaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/MensagemRecusaHibernateDAO.java new file mode 100644 index 000000000..0bb83ca23 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/MensagemRecusaHibernateDAO.java @@ -0,0 +1,35 @@ +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.MensagemRecusaDAO; +import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder; +import com.rjconsultores.ventaboletos.entidad.MensagemRecusa; + +@Repository("MensagemRecusaDAO") +public class MensagemRecusaHibernateDAO extends GenericHibernateDAO implements MensagemRecusaDAO { + + @Autowired + private SQLBuilder sqlBuilder; + + @Autowired + public MensagemRecusaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + return c.list(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/MensagemRecusa.java b/src/com/rjconsultores/ventaboletos/entidad/MensagemRecusa.java new file mode 100644 index 000000000..ff73e6a49 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/MensagemRecusa.java @@ -0,0 +1,123 @@ +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.ManyToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "MENSAGEM_RECUSA_SEQ", sequenceName = "MENSAGEM_RECUSA_SEQ", allocationSize = 1) +@Table(name = "MENSAGEM_RECUSA") +public class MensagemRecusa implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "MENSAGEM_RECUSA_SEQ") + @Column(name = "MENSAGEMRECUSA_ID") + private Integer mensagemRecusaId; + + @Column(name = "TIPO_MENSAGEM") + private String tipoMensagem; + + @Column(name = "DESCRICAO") + private String descricao; + + @JoinColumn(name = "CATEGORIA_ID", referencedColumnName = "CATEGORIA_ID") + @ManyToOne + private Categoria categoria; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Basic(optional = false) + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + @Column(name= "TIPO_RELATORIO") + private Short tipoRelatorio; + + public MensagemRecusa() { + } + + public Integer getMensagemRecusaId() { + return mensagemRecusaId; + } + + public void setMensagemRecusaId(Integer mensagemRecusaId) { + this.mensagemRecusaId = mensagemRecusaId; + } + + public String getTipoMensagem() { + return tipoMensagem; + } + + public void setTipoMensagem(String tipoMensagem) { + this.tipoMensagem = tipoMensagem; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public Categoria getCategoria() { + return categoria; + } + + public void setCategoria(Categoria categoria) { + this.categoria = categoria; + } + + 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; + } + + public Short getTipoRelatorio() { + return tipoRelatorio; + } + + public void setTipoRelatorio(Short tipoRelatorio) { + this.tipoRelatorio = tipoRelatorio; + } + +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/service/MensagemRecusaService.java b/src/com/rjconsultores/ventaboletos/service/MensagemRecusaService.java new file mode 100644 index 000000000..6ba1202a7 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/MensagemRecusaService.java @@ -0,0 +1,18 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.MensagemRecusa; +import com.rjconsultores.ventaboletos.exception.BusinessException; + +public interface MensagemRecusaService { + + public List obtenerTodos(); + + public MensagemRecusa obtenerID(Integer id); + + public void borrar(MensagemRecusa entidad); + + public MensagemRecusa suscribirActualizar(MensagemRecusa entidad) throws BusinessException; + +} \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/service/impl/MensagemRecusaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/MensagemRecusaServiceImpl.java new file mode 100644 index 000000000..9907a9ac5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/MensagemRecusaServiceImpl.java @@ -0,0 +1,47 @@ +package com.rjconsultores.ventaboletos.service.impl; + +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.MensagemRecusaDAO; +import com.rjconsultores.ventaboletos.entidad.MensagemRecusa; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.service.MensagemRecusaService; + +@Service("mensagemRecusaService") +public class MensagemRecusaServiceImpl implements MensagemRecusaService { + + @Autowired + private MensagemRecusaDAO mensagemRecusaDAO; + + @Override + public List obtenerTodos() { + return mensagemRecusaDAO.obtenerTodos(); + } + + @Override + public MensagemRecusa obtenerID(Integer id) { + return mensagemRecusaDAO.obtenerID(id); + } + + @Override + @Transactional(rollbackFor = BusinessException.class) + public void borrar(MensagemRecusa entidad) { + entidad.setActivo(Boolean.FALSE); + mensagemRecusaDAO.actualizacion(entidad); + } + + @Override + @Transactional(rollbackFor = BusinessException.class) + public MensagemRecusa suscribirActualizar(MensagemRecusa entidad) throws BusinessException { + if (entidad.getMensagemRecusaId() == null) { + return mensagemRecusaDAO.suscribir(entidad); + } else { + return mensagemRecusaDAO.actualizacion(entidad); + } + } + +}