Guest User

Untitled

a guest
Dec 11th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package domain;
  2.  
  3. import data.TableGateway;
  4. import data.ProfesorGateway;
  5.  
  6. import java.util.Map;
  7. import java.util.List;
  8. import java.io.IOException;
  9. import javax.servlet.ServletException;
  10.  
  11. public class ProfesorModule {
  12.  
  13. private ProfesorGateway gateway;
  14.  
  15. public void setGateway(TableGateway gateway) {
  16. this.gateway = (ProfesorGateway)gateway;
  17. }
  18.  
  19. public void actualizar(int id, String cedula, String nombre, String titulo,
  20. String area, String telefono) throws Exception {
  21. if (id <= 0)
  22. throw new Exception("Identificador de profesor incorrecto");
  23. if (titulo.toLowerCase().equals("bachiller") ||
  24. titulo.toLowerCase().equals("licenciado") ||
  25. titulo.toLowerCase().equals("master") ||
  26. titulo.toLowerCase().equals("doctor"))
  27. gateway.update(id,cedula,nombre,titulo,area,telefono);
  28. else
  29. throw new Exception("Error en título de profesor");
  30. }
  31.  
  32. public void ingresar(int id, String cedula, String nombre, String titulo,
  33. String area, String telefono) throws Exception {
  34. if (id <= 0)
  35. throw new Exception("Identificador de profesor incorrecto");
  36. if (titulo.toLowerCase().equals("bachiller") ||
  37. titulo.toLowerCase().equals("licenciado") ||
  38. titulo.toLowerCase().equals("master") ||
  39. titulo.toLowerCase().equals("doctor"))
  40. gateway.insert(id,cedula,nombre,titulo,area,telefono);
  41. else
  42. throw new Exception("Error en título de profesor");
  43. }
  44.  
  45. public void eliminar(int id) throws Exception {
  46. if (id <= 0)
  47. throw new Exception("Identificador de profesor incorrecto");
  48. gateway.delete(id+"");
  49. }
  50.  
  51. public Map<String,Object> buscar(int id) throws Exception {
  52. if (id <= 0)
  53. throw new Exception("Identificador de profesor incorrecto");
  54. Map<String,Object> prof = gateway.find(id+"");
  55. return prof;
  56. }
  57.  
  58. public List<Map<String,Object>> listado() throws Exception {
  59. List<Map<String,Object>> profs = gateway.findAll();
  60. return profs;
  61. }
  62. }
Add Comment
Please, Sign In to add comment