diff --git a/src/com/rjconsultores/ventaboletos/dao/ConductorDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConductorDAO.java index ab3521d40..356c29f7d 100644 --- a/src/com/rjconsultores/ventaboletos/dao/ConductorDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/ConductorDAO.java @@ -13,4 +13,5 @@ import com.rjconsultores.ventaboletos.entidad.Conductor; public interface ConductorDAO extends GenericDAO { public Conductor buscar(String claveConductor, String contraSenha); + public Conductor buscarPorEmpleado(int empleadoId); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConductorHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConductorHibernateDAO.java index 2c4c30d3b..e488facb4 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConductorHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConductorHibernateDAO.java @@ -5,6 +5,7 @@ package com.rjconsultores.ventaboletos.dao.hibernate; import com.rjconsultores.ventaboletos.dao.ConductorDAO; +import com.rjconsultores.ventaboletos.entidad.Cliente; import com.rjconsultores.ventaboletos.entidad.Conductor; import java.util.List; import org.hibernate.Criteria; @@ -42,4 +43,12 @@ public class ConductorHibernateDAO extends GenericHibernateDAO +@Repository("empleadoDAO") +public class EmpleadoHibernateDAO extends GenericHibernateDAO implements EmpleadoDAO { @Autowired - public EmpladoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + public EmpleadoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { setSessionFactory(factory); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEmpleadoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEmpleadoHibernateDAO.java index 4141388f3..955acce24 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEmpleadoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TipoEmpleadoHibernateDAO.java @@ -5,10 +5,8 @@ package com.rjconsultores.ventaboletos.dao.hibernate; -import com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO; -import com.rjconsultores.ventaboletos.entidad.TipoEmpleado; -import java.io.Serializable; import java.util.List; + import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; @@ -16,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; +import com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO; +import com.rjconsultores.ventaboletos.entidad.TipoEmpleado; + /** * * @author Shiro diff --git a/src/com/rjconsultores/ventaboletos/entidad/Conductor.java b/src/com/rjconsultores/ventaboletos/entidad/Conductor.java index 37a5e1196..5313cba59 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Conductor.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Conductor.java @@ -55,8 +55,18 @@ public class Conductor implements Serializable { private Empleado empleado; @Column(name = "NOMBPATERNO") private String nomPaterno; + @Column(name = "NOMBMATERNO") + private String nomMaterno; + + public String getNomMaterno() { + return nomMaterno; + } - public String getNomPaterno() { + public void setNomMaterno(String nomMaterno) { + this.nomMaterno = nomMaterno; + } + + public String getNomPaterno() { return nomPaterno; } diff --git a/src/com/rjconsultores/ventaboletos/entidad/Empleado.java b/src/com/rjconsultores/ventaboletos/entidad/Empleado.java index 984307c93..998234aae 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Empleado.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Empleado.java @@ -58,6 +58,12 @@ public class Empleado implements Serializable { private Date fecmodif; @Column(name = "USUARIO_ID") private Integer usuarioId; + @Column(name = "DESCCALLE") + private String descCalle; + @Column(name = "NUMEXTINT") + private String numExtInt; + @Column(name = "CODPOSTAL") + private String codPostal; @JoinColumn(name = "TIPOEMPLEADO_ID", referencedColumnName = "TIPOEMPLEADO_ID") @ManyToOne @@ -168,9 +174,33 @@ public class Empleado implements Serializable { public void setUsuarioId(Integer usuarioId) { this.usuarioId = usuarioId; - } + } - @Override + public String getDescCalle() { + return descCalle; + } + + public void setDescCalle(String descCalle) { + this.descCalle = descCalle; + } + + public String getNumExtInt() { + return numExtInt; + } + + public void setNumExtInt(String numExtInt) { + this.numExtInt = numExtInt; + } + + public String getCodPostal() { + return codPostal; + } + + public void setCodPostal(String codPostal) { + this.codPostal = codPostal; + } + + @Override public int hashCode() { int hash = 0; hash += (empleadoId != null ? empleadoId.hashCode() : 0); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConductorServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConductorServiceImpl.java index 2f1555055..9e8dcb04c 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ConductorServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConductorServiceImpl.java @@ -48,4 +48,8 @@ public class ConductorServiceImpl implements ConductorService { public Conductor buscar(String claveConductor, String contraSenha) { return conductorDAO.buscar(claveConductor, contraSenha); } + + public Conductor buscarPorEmpleado(int empleadoId){ + return conductorDAO.buscarPorEmpleado(empleadoId); + } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpleadoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpleadoServiceImpl.java index 1af66d645..8575e3f63 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EmpleadoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpleadoServiceImpl.java @@ -4,7 +4,9 @@ */ package com.rjconsultores.ventaboletos.service.impl; +import com.rjconsultores.ventaboletos.dao.ConductorDAO; import com.rjconsultores.ventaboletos.dao.EmpleadoDAO; +import com.rjconsultores.ventaboletos.entidad.Conductor; import com.rjconsultores.ventaboletos.entidad.Empleado; import com.rjconsultores.ventaboletos.service.EmpleadoService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -12,6 +14,7 @@ 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; /** * @@ -19,9 +22,13 @@ import org.springframework.stereotype.Service; */ @Service("empleadoService") public class EmpleadoServiceImpl implements EmpleadoService { + + private static int CONDUCTOR = 1; @Autowired private EmpleadoDAO empleadoDAO; + @Autowired + private ConductorDAO conductorDAO; public List obtenerTodos() { return empleadoDAO.obtenerTodos(); @@ -31,27 +38,66 @@ public class EmpleadoServiceImpl implements EmpleadoService { return empleadoDAO.obtenerID(id); } + @Transactional public Empleado suscribir(Empleado entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); - return empleadoDAO.suscribir(entidad); + Empleado result = empleadoDAO.suscribir(entidad); + + if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){ + Conductor cond = new Conductor(); + cond.setActivo(Boolean.TRUE); + cond.setEmpleado(result); + cond.setFecmodif(Calendar.getInstance().getTime()); + cond.setNombconductor(entidad.getNombEmpleado()); + cond.setNomPaterno(entidad.getNombPaterno()); + cond.setNomMaterno(entidad.getNombMaterno()); + cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + conductorDAO.suscribir(cond); + } + + return result; } + @Transactional public Empleado actualizacion(Empleado entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); + if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){ + Conductor cond = conductorDAO.buscarPorEmpleado(entidad.getEmpleadoId()); + cond.setActivo(Boolean.TRUE); + cond.setEmpleado(entidad); + cond.setFecmodif(Calendar.getInstance().getTime()); + cond.setNombconductor(entidad.getNombEmpleado()); + cond.setNomPaterno(entidad.getNombPaterno()); + cond.setNomMaterno(entidad.getNombMaterno()); + cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + conductorDAO.actualizacion(cond); + } + return empleadoDAO.actualizacion(entidad); } + @Transactional public void borrar(Empleado entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.FALSE); + if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){ + Conductor cond = conductorDAO.buscarPorEmpleado(entidad.getEmpleadoId()); + cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + cond.setFecmodif(Calendar.getInstance().getTime()); + cond.setActivo(Boolean.FALSE); + conductorDAO.actualizacion(cond); + } + empleadoDAO.actualizacion(entidad); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TipoEmpleadoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TipoEmpleadoServiceImpl.java new file mode 100644 index 000000000..91433f7a0 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/TipoEmpleadoServiceImpl.java @@ -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 com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO; +import com.rjconsultores.ventaboletos.entidad.TipoEmpleado; +import com.rjconsultores.ventaboletos.service.TipoEmpleadoService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("tipoEmpleadoService") +public class TipoEmpleadoServiceImpl implements TipoEmpleadoService { + + @Autowired + private TipoEmpleadoDAO tipoEmpleadoDAO; + + @Override + public List obtenerTodos() { + return tipoEmpleadoDAO.obtenerTodos(); + } + + @Override + public TipoEmpleado obtenerID(Integer id) { + return tipoEmpleadoDAO.obtenerID(id); + } + + @Override + public TipoEmpleado suscribir(TipoEmpleado entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoEmpleadoDAO.suscribir(entidad); + } + + @Override + public TipoEmpleado actualizacion(TipoEmpleado entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoEmpleadoDAO.actualizacion(entidad); + } + + @Override + public void borrar(TipoEmpleado entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + tipoEmpleadoDAO.actualizacion(entidad); + } + + +}