diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBL.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBL.java index 70060ab..1f711a7 100644 --- a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBL.java +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBL.java @@ -75,6 +75,15 @@ public class RolBL implements RolBLLocal { return a.buscarPorId(rol); } + + @Override + public Rol buscarPorRol(Rol rol) { + + RolDAO a = new RolDAO(); + //Aqui le movi + return a.buscarPorRolName(rol); + + } diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBLLocal.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBLLocal.java index 19e2d59..a983de5 100644 --- a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBLLocal.java +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/RolBLLocal.java @@ -28,6 +28,8 @@ public interface RolBLLocal { Mensaje editar(Rol rol); public List buscarTodos(); + + public Rol buscarPorRol(Rol rol); diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBL.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBL.java new file mode 100644 index 0000000..e6f9186 --- /dev/null +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBL.java @@ -0,0 +1,180 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/J2EE/EJB30/StatelessEjbClass.java to edit this template + */ +package mx.edu.tsj.chapala.sistemas.inventario.modelo.bl; + +import java.util.List; +import javax.ejb.Stateless; +import mx.edu.tsj.chapala.sistemas.inventario.modelo.dao.TokenDAO; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; +import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; +/** + * + * @author Ivan Alejandro PC + */ +@Stateless +public class TokenBL implements TokenBLLocal { + + @Override + public Mensaje agregar(Token token) { + System.out.println("Llegaste al metodo de agregar!!"); + TokenDAO tokenDAO = new TokenDAO(); + + + if(token== null){ + return Mensaje.CAMPOS_INCOMPLETOS; + } + + Token existeToken = tokenDAO.buscarPorId(token); + //TO DO: agregar la logica + + //Test de validaciones + if(token.getToken().isEmpty() | token.getServicio().isEmpty()){ + return Mensaje.CAMPOS_INCOMPLETOS; + } + + if(token.getToken().length()>50 | token.getServicio().length()>255 ){ + return Mensaje.DATOS_INCORRECTOS; + } + + if (existeToken != null) { + return Mensaje.ELEMENTO_DUPLICADO; + }else{ + tokenDAO.agregar(token); + return Mensaje.SIN_ERROR; + + } + } + + + + @Override + public Mensaje buscarId(Token token) { + TokenDAO tokenDAO = new TokenDAO(); + Token existeToken = tokenDAO.buscarPorId(token); + + if(token== null){ + return Mensaje.CAMPOS_INCOMPLETOS; + } + + if (existeToken == null) { + return Mensaje.ELEMENTO_NO_ENCONTRADO; + }else{ + tokenDAO.buscarPorId(token); + return Mensaje.SIN_ERROR; + + } + } + + @Override + public Token buscarIdLi(Token token) { + + TokenDAO a = new TokenDAO(); + //Aqui le movi + return a.buscarPorId(token); + + } + + + + @Override + public Mensaje eliminar(Token token) { + TokenDAO a = new TokenDAO(); + Token existe = a.buscarPorId(token); + + if(existe==null){ + return Mensaje.ELEMENTO_NO_ENCONTRADO; + + }else if(token==null){ + return Mensaje.ELEMENTO_NO_ENCONTRADO; + }else{ + a.eliminar(token); + return Mensaje.SIN_ERROR; + + } + + + + } + + + @Override + public List buscarTodos() { + TokenDAO rolDAO = new TokenDAO(); + return rolDAO.buscarTodos(); +} + @Override + public Mensaje buscarRol(Token token) { + TokenDAO tokenDAO = new TokenDAO(); + Token rE = tokenDAO.buscarPorTokenName(token); + + if (rE == null) { + return Mensaje.ELEMENTO_NO_ENCONTRADO; + } else { + return Mensaje.SIN_ERROR; + } + + } + + //Test de Token + @Override +public Mensaje buscarToken(Token token) { + TokenDAO tokenDAO = new TokenDAO(); + Token rE = tokenDAO.buscarPorTokenName1(token); + + if (rE == null) { + return Mensaje.ELEMENTO_NO_ENCONTRADO; + } else { + return Mensaje.SIN_ERROR; + } +} + + + @Override + public Mensaje editar(Token token) { + System.out.println("Llegaste al metodo de editar"); + TokenDAO a = new TokenDAO(); + //Rol existeRol = a.buscarPorId(rol); + if(token== null){ + return Mensaje.CAMPOS_INCOMPLETOS; + } + //Test de validaciones + if(token.getToken().isEmpty() | token.getServicio().isEmpty()){ + return Mensaje.CAMPOS_INCOMPLETOS; + } + + if(token.getToken().length()>50 | token.getServicio().length()>255 ){ + return Mensaje.DATOS_INCORRECTOS; + } + + if(token.getId()==null){ + return Mensaje.ELEMENTO_NO_ENCONTRADO; + }else{ + a.editar(token); + return Mensaje.SIN_ERROR; + + } + + } + + @Override + public void editar(String string) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + + + + + + + + + + + + +} + + diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBLLocal.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBLLocal.java new file mode 100644 index 0000000..189a5b9 --- /dev/null +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/bl/TokenBLLocal.java @@ -0,0 +1,45 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/J2EE/EJB30/SessionLocal.java to edit this template + */ +package mx.edu.tsj.chapala.sistemas.inventario.modelo.bl; + +import java.util.List; +import javax.ejb.Local; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; +import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; +/** + * + * @author Ivan Alejandro PC + */ +@Local +public interface TokenBLLocal { + + Mensaje agregar(Token token); + + Mensaje buscarRol(Token token); + + Mensaje buscarId(Token token); + + Token buscarIdLi(Token token); + + Mensaje eliminar(Token token); + + Mensaje editar(Token token); + + public List buscarTodos(); + + public Mensaje buscarToken(Token token); + + public void editar(String editar); + + // public void editar(String editar); + + + + + + + + +} diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/dao/TokenDAO.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/dao/TokenDAO.java new file mode 100644 index 0000000..94a8eb9 --- /dev/null +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo/dao/TokenDAO.java @@ -0,0 +1,111 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package mx.edu.tsj.chapala.sistemas.inventario.modelo.dao; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; + +/** + * + * @author Ivan Alejandro PC + */ +public class TokenDAO { + + private EntityManager em; //Manejadro de identidades + + public TokenDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("Inventario-ejbPU"); + em = emf.createEntityManager(); + } + /* + Este es un prueba de actualizar + */ + + public void agregar(Token a){ + em.getTransaction().begin();//Empezar + em.persist(a);//Almacenar en la BD + em.getTransaction().commit();// terminar + + } + + public void editar(Token a){ + + em.getTransaction().begin();//Empezar + em.merge(a);//Actualizar en la BD + em.getTransaction().commit();// terminar + + + + + } + public void eliminar(Token a){ + em.getTransaction().begin();//Empezar + em.remove(em.merge(a));//Eliminar en la BD + em.getTransaction().commit();// terminar + + } + + + public Token buscarPorTokenName(Token a){ + /*if(a.getStatus()==0){ + return null; + }*/ + if (a.getToken()== null) { + return null; + } + Query q = em.createNamedQuery("Token.findByServicio"); + q.setParameter("servicio", a.getToken()); + List resultList = q.getResultList(); + if(resultList.isEmpty()){ + return null; + } else { + return resultList.get(0); + } +} + public Token buscarPorTokenName1(Token a) { + if (a.getToken() == null) { + return null; + } + Query q = em.createNamedQuery("Token.findByToken"); + q.setParameter("token", a.getToken()); + List resultList = q.getResultList(); + if (resultList.isEmpty()) { + return null; + } else { + return resultList.get(0); + } +} + + + + + public Token buscarPorId(Token a){ + if (a == null || a.getId()== null) { + return null; + } + Query q = em.createNamedQuery("Token.findById"); + q.setParameter("id", a.getId()); + if(q.getResultList().isEmpty()){ + return null; + } else { + return (Token) q.getResultList().get(0); + } +} + + + + public List buscarTodos(){ + Query q = em.createNamedQuery("Token.findAll"); + return q.getResultList(); +} + + + + +} diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Proveedores.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Proveedores.java index 667d41b..4646531 100644 --- a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Proveedores.java +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Proveedores.java @@ -5,7 +5,9 @@ package mx.edu.tsj.chapala.sistemas.inventario.modelo1; import java.io.Serializable; +import java.util.Collection; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -15,12 +17,17 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; - +/** + * + * @author Ivan Alejandro PC + */ @Entity @Table(name = "proveedores") @XmlRootElement @@ -85,6 +92,8 @@ public class Proveedores implements Serializable { @JoinColumn(name = "Categoria_id", referencedColumnName = "id") @ManyToOne(optional = false) private Categoria categoriaid; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "proveedoresid") + private Collection productosCollection; public Proveedores() { } @@ -185,6 +194,15 @@ public class Proveedores implements Serializable { this.categoriaid = categoriaid; } + @XmlTransient + public Collection getProductosCollection() { + return productosCollection; + } + + public void setProductosCollection(Collection productosCollection) { + this.productosCollection = productosCollection; + } + @Override public int hashCode() { int hash = 0; diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Token.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Token.java new file mode 100644 index 0000000..b703c99 --- /dev/null +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Token.java @@ -0,0 +1,132 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package mx.edu.tsj.chapala.sistemas.inventario.modelo1; + +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.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author Ivan Alejandro PC + */ +@Entity +@Table(name = "token") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Token.findAll", query = "SELECT t FROM Token t"), + @NamedQuery(name = "Token.findById", query = "SELECT t FROM Token t WHERE t.id = :id"), + @NamedQuery(name = "Token.findByServicio", query = "SELECT t FROM Token t WHERE t.servicio = :servicio"), + @NamedQuery(name = "Token.findByToken", query = "SELECT t FROM Token t WHERE t.token = :token"), + @NamedQuery(name = "Token.findByFecha", query = "SELECT t FROM Token t WHERE t.fecha = :fecha")}) +public class Token implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic(optional = false) + @Column(name = "id") + private Integer id; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 255) + @Column(name = "servicio") + private String servicio; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 50) + @Column(name = "token") + private String token; + @Basic(optional = false) + @NotNull + @Column(name = "fecha") + @Temporal(TemporalType.DATE) + private Date fecha; + + public Token() { + } + + public Token(Integer id) { + this.id = id; + } + + public Token(Integer id, String servicio, String token, Date fecha) { + this.id = id; + this.servicio = servicio; + this.token = token; + this.fecha = fecha; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getServicio() { + return servicio; + } + + public void setServicio(String servicio) { + this.servicio = servicio; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public Date getFecha() { + return fecha; + } + + public void setFecha(Date fecha) { + this.fecha = fecha; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Token)) { + return false; + } + Token other = (Token) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token[ id=" + id + " ]"; + } + +} diff --git a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Usuarios.java b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Usuarios.java index cc4afc5..206be8e 100644 --- a/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Usuarios.java +++ b/Inventario-ejb/src/java/mx/edu/tsj/chapala/sistemas/inventario/modelo1/Usuarios.java @@ -40,7 +40,6 @@ import javax.xml.bind.annotation.XmlRootElement; @NamedQuery(name = "Usuarios.findByStatus", query = "SELECT u FROM Usuarios u WHERE u.status = :status"), @NamedQuery(name = "Usuarios.validar", query = "SELECT u FROM Usuarios u WHERE u.status = :status and u.usuario = :usuario and u.password = :password"), @NamedQuery(name = "Usuarios.login", query = "SELECT u FROM Usuarios u WHERE u.usuario = :usuario and u.password = :password")}) - public class Usuarios implements Serializable { private static final long serialVersionUID = 1L; diff --git a/Inventario-war/src/java/mx/edu/itsj/servicios/RolesEndpoint.java b/Inventario-war/src/java/mx/edu/itsj/servicios/RolesEndpoint.java new file mode 100644 index 0000000..9f1bb01 --- /dev/null +++ b/Inventario-war/src/java/mx/edu/itsj/servicios/RolesEndpoint.java @@ -0,0 +1,162 @@ +package mx.edu.itsj.servicios; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.ejb.EJB; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.RolBLLocal; +import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.TokenBLLocal; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Rol; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; +import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; + +@WebServlet(name = "RolesEndpoint", urlPatterns = {"/RolesEndpoint"}) +public class RolesEndpoint extends HttpServlet { + + @EJB + private TokenBLLocal tokenBL; + + @EJB + private RolBLLocal rolBL; + + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + String rolOpcion = request.getParameter("rolOpcion"); + String valor = request.getParameter("valor"); + String tokenParam = request.getParameter("token"); + String buscar = request.getParameter("buscar"); + + if (areParamsInvalid(rolOpcion, tokenParam)) { + out.print("Parametros invalidos"); + return; + } + + Token token = new Token(); + token.setToken(tokenParam); + + Mensaje tokenValidationResult = tokenBL.buscarToken(token); + if (tokenValidationResult == Mensaje.ELEMENTO_NO_ENCONTRADO) { + out.print("Token invalido"); + return; + } + + switch (rolOpcion) { + case "0": + mostrarTodos(out); + break; + case "1": + if (isParamInvalid(valor)) { + out.print("Parametros invalidos Agregar"); + } else { + agregarRol(valor, out); + } + break; + case "2": + if (isParamInvalid(buscar) || isParamInvalid(valor)) { + out.print("Parametros invalidos Editar"); + } else { + editarRol(buscar, valor, out); + } + break; + case "3": + if (isParamInvalid(buscar)) { + out.print("Parametros invalidos Eliminar"); + } else { + eliminarRol(buscar, out); + } + break; + case "4": + if (isParamInvalid(buscar)) { + out.print("Parametros invalidos Buscar"); + } else { + buscarRol(buscar, out); + } + break; + default: + out.print("Opcion invalida"); + break; + } + } + } + + private boolean areParamsInvalid(String rolOpcion, String tokenParam) { + return rolOpcion == null || rolOpcion.trim().isEmpty() || + tokenParam == null || tokenParam.trim().isEmpty(); + } + + private boolean isParamInvalid(String param) { + return param == null || param.trim().isEmpty(); + } + + private void mostrarTodos(PrintWriter out) { + out.print(""); + out.print(""); + out.print(""); + + for (Rol r : rolBL.buscarTodos()) { + out.print(""); + } + + out.print("
Roles de Usuario
Rol Usuario
" + r.getRolUsuario() + "
"); + } + + private void agregarRol(String valor, PrintWriter out) { + Rol a = new Rol(); + a.setRolUsuario(valor); + rolBL.agregar(a); + out.print("Rol agregado"); + } + + private void editarRol(String buscar, String valor, PrintWriter out) { + Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); + if (a == null) { + out.print("Rol no encontrado"); + return; + } + a.setRolUsuario(valor); + rolBL.editar(a); + out.print("Rol editado"); + } + + private void eliminarRol(String buscar, PrintWriter out) { + Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); + if (a == null) { + out.print("Rol no encontrado"); + return; + } + rolBL.eliminar(a); + out.print("Rol eliminado"); + } + + private void buscarRol(String buscar, PrintWriter out) { + Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); + if (a == null) { + out.print("Rol no encontrado"); + return; + } + out.print("Rol encontrado: " + a.getRolUsuario()); + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + @Override + public String getServletInfo() { + return "Roles Endpoint Servlet"; + } +} diff --git a/Inventario-war/src/java/mx/edu/tsj/chapala/sistemas/inventario/vista/DemoBeanToken.java b/Inventario-war/src/java/mx/edu/tsj/chapala/sistemas/inventario/vista/DemoBeanToken.java new file mode 100644 index 0000000..14a8971 --- /dev/null +++ b/Inventario-war/src/java/mx/edu/tsj/chapala/sistemas/inventario/vista/DemoBeanToken.java @@ -0,0 +1,241 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template + */ +package mx.edu.tsj.chapala.sistemas.inventario.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.ejb.EJB; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; +import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; +import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.TokenBLLocal; + +/** + * + * @author Ivan Alejandro PC + */ +@Named(value = "demoBeanToken") +@SessionScoped +public class DemoBeanToken implements Serializable { + + + @EJB + private TokenBLLocal tokenBL; + + private Token token = new Token(); + private String titulo; + private boolean nuevo; + + + + + /** + * Creates a new instance of DemoBean + */ + public DemoBeanToken() { + } + + //Aqui empieza lo de la clase pasada + //Metodo para eliminar + + public void eliminarToken(){ + tokenBL.eliminar(token); + } + + public void prepararEliminar(Token token){ + this.token=token; + } + + //Metodo de editar + + public String getTitulo() { + return titulo; + } + + public boolean isNuevo() { + return nuevo; + } + + + public void editarRoles(){ + tokenBL.editar(token); + } + + + public void prepararEditar(Token token){ + nuevo = false; + titulo="Editando Token"; + this.token=token; + } + + public void prepararNuevo(){ + nuevo =true; + titulo="Agregando Token"; + token = new Token(); + } + + + public String agregarToken(){ + + tokenBL.agregar(token); + + token = new Token(); + + return "tokenLista.xhtml"; + } + + //Aqui esta para crear token + + private String tokenInput; + + public String getTokenInput() { + return tokenInput; + } + + public void setTokenInput(String tokenInput) { + this.tokenInput = tokenInput; + } + + public void crearToken() { + String cad = "rdfgfiodgionergnio345nio3in"; + StringBuilder tokenBuilder = new StringBuilder(); + for (int x = 0; x < 48; x++) { + tokenBuilder.append(cad.charAt((int) (Math.random() * (cad.length() - 1)))); + } + + String tokenValue = tokenBuilder.toString(); + + token.setToken(tokenValue); + + // Generar la fecha de registro automáticamente + // Obtener la fecha actual + Date fechaActual = new Date(); + + // Convertir la fecha actual a String y asignarla al campo fecha + token.setFecha(fechaActual); + + System.out.println("Token generado: " + token.getToken()); + + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Token generado", "El token ha sido generado correctamente.")); +} + + //------------------------- + + public Token getToken() { + return token; + } + + public void setToken(Token token) { + this.token = token; + } + + public List getListToken(){ + return tokenBL.buscarTodos(); + } + + + /* public String metodo(){ + Token a = new Token(); + //Para que te marque como id duplicaod tienes que asignarlo + //a.setId(1); + a.setToken("Administrador"); + + + Mensaje m = rolBL.agregar(a); + System.out.println(m); + if(m.compareTo(Mensaje.SIN_ERROR)==0){ + System.out.println("SE AGREGRO"); + }else{ + System.out.println("NO SE PUDO"); + } + return "index.xhtml"; + }*/ + + /*public String buscar(){ + Rol a = new Rol(); + a.setId(31); + Mensaje m = rolBL.buscarId(a); + System.out.println(m); + if(m.compareTo(Mensaje.SIN_ERROR)==0){ + System.out.println("Encontre el Rol: " + a.getId()); + System.out.println(rolBL.buscarId(a)); + }else{ + System.out.println("NO SE ENCONTRO"); + } + //System.out.println("Encontre el Autor: "); + //System.out.println(autorBL.buscarId(a)); + return "index.xhtml"; + } + public String buscarPorNombre(){ + Rol a = new Rol(); + a.setRolUsuario("Ivan Alejandro"); + Mensaje m = rolBL.buscarRol(a); + System.out.println(m); + if(m.compareTo(Mensaje.SIN_ERROR)==0){ + System.out.println("Encontre el Rol: " + a.getRolUsuario()); + }else{ + System.out.println("NO SE ENCONTRO"); + } + + return "index.xhtml"; +} + */ + /*public String buscarALLRol() { + //short status = 1; + List usuariosStatus1 = rolBL.buscarTodos(); + if (!usuariosStatus1.isEmpty()) { + System.out.println("Busqueda All: "); + for (Rol rol : usuariosStatus1) { + + System.out.println("Encontre los roles de usuario: "+ "ID: " + rol.getId() +" Rol: " + rol.getRolUsuario() ); + } + + } else { + System.out.println("No se encontraron roles de usuarios"); + } + return "index.xhtml"; + }*/ + + + /*public String eliminar(){ + Rol a = rolBL.buscarIdLi(new Rol(33)); + System.out.println("Autor eliminado: "); + Mensaje m = rolBL.eliminar(a); + System.out.println(m); + if(m.compareTo(Mensaje.SIN_ERROR)==0){ + System.out.println("SE AGREGRO"); + }else{ + System.out.println("NO SE PUDO"); + } + //System.out.println(autorBL.eliminar(a)); + return "index.xhtml"; + } + */ + /*public String editar() { + try{ + Rol a = rolBL.buscarIdLi(new Rol(35)); + a.setRolUsuario("Trabajador"); + + Mensaje m = rolBL.editar(a); + System.out.println(m); + if(m.compareTo(Mensaje.SIN_ERROR)==0){ + System.out.println("SE AGREGRO"); + }else{ + System.out.println("NO SE PUDO"); + } + }catch(Exception e){ + System.out.println("Ha ocurrido un error: " + Mensaje.ELEMENTO_NO_ENCONTRADO); + } + //autorBL.editar(a); + return "index.xhtml"; +}*/ + +} diff --git a/Inventario-war/web/GeneroEliminar.xhtml b/Inventario-war/web/GeneroEliminar.xhtml index 2f2d379..b05a8d7 100644 --- a/Inventario-war/web/GeneroEliminar.xhtml +++ b/Inventario-war/web/GeneroEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/categoriaCrear.xhtml b/Inventario-war/web/categoriaCrear.xhtml index ac8c4a2..0a6d67c 100644 --- a/Inventario-war/web/categoriaCrear.xhtml +++ b/Inventario-war/web/categoriaCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/categoriaEliminar.xhtml b/Inventario-war/web/categoriaEliminar.xhtml index bc7f0aa..bd9942f 100644 --- a/Inventario-war/web/categoriaEliminar.xhtml +++ b/Inventario-war/web/categoriaEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/categoriaLista.xhtml b/Inventario-war/web/categoriaLista.xhtml index 50aba8c..6de0ca6 100644 --- a/Inventario-war/web/categoriaLista.xhtml +++ b/Inventario-war/web/categoriaLista.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/colorCrear.xhtml b/Inventario-war/web/colorCrear.xhtml index 905d6e6..079eff7 100644 --- a/Inventario-war/web/colorCrear.xhtml +++ b/Inventario-war/web/colorCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/colorEliminar.xhtml b/Inventario-war/web/colorEliminar.xhtml index 5d1cd2c..4e08d9b 100644 --- a/Inventario-war/web/colorEliminar.xhtml +++ b/Inventario-war/web/colorEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/colorLista.xhtml b/Inventario-war/web/colorLista.xhtml index e4e8a7d..6d63b42 100644 --- a/Inventario-war/web/colorLista.xhtml +++ b/Inventario-war/web/colorLista.xhtml @@ -49,6 +49,7 @@ + diff --git a/Inventario-war/web/generoCrear.xhtml b/Inventario-war/web/generoCrear.xhtml index c993b6c..3d19864 100644 --- a/Inventario-war/web/generoCrear.xhtml +++ b/Inventario-war/web/generoCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/marcaCrear.xhtml b/Inventario-war/web/marcaCrear.xhtml index 49d25a8..f253e13 100644 --- a/Inventario-war/web/marcaCrear.xhtml +++ b/Inventario-war/web/marcaCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/marcaEliminar.xhtml b/Inventario-war/web/marcaEliminar.xhtml index d25ec8b..e545d5b 100644 --- a/Inventario-war/web/marcaEliminar.xhtml +++ b/Inventario-war/web/marcaEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/marcaLista.xhtml b/Inventario-war/web/marcaLista.xhtml index 3f0d607..596b23c 100644 --- a/Inventario-war/web/marcaLista.xhtml +++ b/Inventario-war/web/marcaLista.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/marcaLista3.xhtml b/Inventario-war/web/marcaLista3.xhtml index da839a7..bad8ef3 100644 --- a/Inventario-war/web/marcaLista3.xhtml +++ b/Inventario-war/web/marcaLista3.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/productosCrear.xhtml b/Inventario-war/web/productosCrear.xhtml index c413936..c4bc8c6 100644 --- a/Inventario-war/web/productosCrear.xhtml +++ b/Inventario-war/web/productosCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/productosEliminar.xhtml b/Inventario-war/web/productosEliminar.xhtml index d2c053d..58348ef 100644 --- a/Inventario-war/web/productosEliminar.xhtml +++ b/Inventario-war/web/productosEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/productosLista.xhtml b/Inventario-war/web/productosLista.xhtml index 2c28de7..7f6d7b8 100644 --- a/Inventario-war/web/productosLista.xhtml +++ b/Inventario-war/web/productosLista.xhtml @@ -53,6 +53,7 @@ + diff --git a/Inventario-war/web/proveedorCrear.xhtml b/Inventario-war/web/proveedorCrear.xhtml index ae7952b..3583f82 100644 --- a/Inventario-war/web/proveedorCrear.xhtml +++ b/Inventario-war/web/proveedorCrear.xhtml @@ -49,6 +49,7 @@ + diff --git a/Inventario-war/web/proveedorEliminar.xhtml b/Inventario-war/web/proveedorEliminar.xhtml index 283c361..7df7f2e 100644 --- a/Inventario-war/web/proveedorEliminar.xhtml +++ b/Inventario-war/web/proveedorEliminar.xhtml @@ -46,6 +46,7 @@ + diff --git a/Inventario-war/web/rolCrear.xhtml b/Inventario-war/web/rolCrear.xhtml index b896ecc..0133f7d 100644 --- a/Inventario-war/web/rolCrear.xhtml +++ b/Inventario-war/web/rolCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/rolEliminar.xhtml b/Inventario-war/web/rolEliminar.xhtml index 4390e2d..71e1e3b 100644 --- a/Inventario-war/web/rolEliminar.xhtml +++ b/Inventario-war/web/rolEliminar.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/rolLista.xhtml b/Inventario-war/web/rolLista.xhtml index b2b3430..877585e 100644 --- a/Inventario-war/web/rolLista.xhtml +++ b/Inventario-war/web/rolLista.xhtml @@ -49,6 +49,7 @@ + diff --git a/Inventario-war/web/tallaCrear.xhtml b/Inventario-war/web/tallaCrear.xhtml index 580790a..f797c25 100644 --- a/Inventario-war/web/tallaCrear.xhtml +++ b/Inventario-war/web/tallaCrear.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/tallaEliminar.xhtml b/Inventario-war/web/tallaEliminar.xhtml index 828006f..a28c7b6 100644 --- a/Inventario-war/web/tallaEliminar.xhtml +++ b/Inventario-war/web/tallaEliminar.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/tallaLista.xhtml b/Inventario-war/web/tallaLista.xhtml index 15b3361..4479651 100644 --- a/Inventario-war/web/tallaLista.xhtml +++ b/Inventario-war/web/tallaLista.xhtml @@ -46,6 +46,7 @@ + diff --git a/Inventario-war/web/tokenCrear.xhtml b/Inventario-war/web/tokenCrear.xhtml new file mode 100644 index 0000000..e1c626a --- /dev/null +++ b/Inventario-war/web/tokenCrear.xhtml @@ -0,0 +1,71 @@ + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +

+ +
+ + +
+
+ + +
+
+ + +
+ + +
+
+
+
+
+ + diff --git a/Inventario-war/web/tokenEliminar.xhtml b/Inventario-war/web/tokenEliminar.xhtml new file mode 100644 index 0000000..9899b63 --- /dev/null +++ b/Inventario-war/web/tokenEliminar.xhtml @@ -0,0 +1,103 @@ + + + + + + + + + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ +

+ +
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + + +
+
+
+ +
+ +
+ + + diff --git a/Inventario-war/web/tokenLista.xhtml b/Inventario-war/web/tokenLista.xhtml new file mode 100644 index 0000000..ac0c56f --- /dev/null +++ b/Inventario-war/web/tokenLista.xhtml @@ -0,0 +1,135 @@ + + + + + + + + + + + + top + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + right + + + + + + + + + Lista de Token +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ + + bottom + + + + +
+ + + + + diff --git a/Inventario-war/web/ubicacionCrear.xhtml b/Inventario-war/web/ubicacionCrear.xhtml index 733135e..561f588 100644 --- a/Inventario-war/web/ubicacionCrear.xhtml +++ b/Inventario-war/web/ubicacionCrear.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/ubicacionEliminar.xhtml b/Inventario-war/web/ubicacionEliminar.xhtml index a81a8e4..9015635 100644 --- a/Inventario-war/web/ubicacionEliminar.xhtml +++ b/Inventario-war/web/ubicacionEliminar.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/ubicacionLista.xhtml b/Inventario-war/web/ubicacionLista.xhtml index 66c6797..eb06d21 100644 --- a/Inventario-war/web/ubicacionLista.xhtml +++ b/Inventario-war/web/ubicacionLista.xhtml @@ -49,6 +49,7 @@ + diff --git a/Inventario-war/web/usuarioCrear.xhtml b/Inventario-war/web/usuarioCrear.xhtml index ba61ac6..7967e3a 100644 --- a/Inventario-war/web/usuarioCrear.xhtml +++ b/Inventario-war/web/usuarioCrear.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/usuariosEliminar.xhtml b/Inventario-war/web/usuariosEliminar.xhtml index 510040d..e74838e 100644 --- a/Inventario-war/web/usuariosEliminar.xhtml +++ b/Inventario-war/web/usuariosEliminar.xhtml @@ -47,6 +47,7 @@ + diff --git a/Inventario-war/web/vistaGenero.xhtml b/Inventario-war/web/vistaGenero.xhtml index b634d19..e2d0f67 100644 --- a/Inventario-war/web/vistaGenero.xhtml +++ b/Inventario-war/web/vistaGenero.xhtml @@ -48,6 +48,7 @@ + diff --git a/Inventario-war/web/vistaProveedores.xhtml b/Inventario-war/web/vistaProveedores.xhtml index 81323d6..f5b1ccd 100644 --- a/Inventario-war/web/vistaProveedores.xhtml +++ b/Inventario-war/web/vistaProveedores.xhtml @@ -48,6 +48,7 @@ +