commit e6e92b7389130ba040966c499bcb34ccf69c443a Author: Samuel Gamez Date: Fri May 10 08:41:57 2024 -0500 Version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae6dd5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/nbproject/private/ +/ProyectoInventario-war/nbproject/private/ +/ProyectoInventario-ejb/nbproject/private/ +/ProyectoInventario-ejb/build/ +/ProyectoInventario-war/build/ +/build/ +/ProyectoInventario-war/dist/ +/ProyectoInventario-ejb/dist/ +/dist/ diff --git a/Almacen.sql b/Almacen.sql new file mode 100644 index 0000000..e09026c --- /dev/null +++ b/Almacen.sql @@ -0,0 +1,190 @@ +-- MySQL Script generated by MySQL Workbench +-- Sat Apr 27 12:23:20 2024 +-- Model: New Model Version: 1.0 +-- MySQL Workbench Forward Engineering + +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; + +-- ----------------------------------------------------- +-- Schema inventarioalmacen +-- ----------------------------------------------------- + +-- ----------------------------------------------------- +-- Schema inventarioalmacen +-- ----------------------------------------------------- +CREATE SCHEMA IF NOT EXISTS `inventarioalmacen` DEFAULT CHARACTER SET utf8 ; +USE `inventarioalmacen` ; + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`marca` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`marca` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL, + `estado` INT NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`paises` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`paises` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL, + `estado` INT NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`estados` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`estados` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(45) NOT NULL, + `estado` INT NOT NULL, + `paises_id` INT NOT NULL, + PRIMARY KEY (`id`), + INDEX `fk_estados_paises1_idx` (`paises_id` ASC) VISIBLE, + CONSTRAINT `fk_estados_paises1` + FOREIGN KEY (`paises_id`) + REFERENCES `inventarioalmacen`.`paises` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`proveedor` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`proveedor` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL, + `telefono` VARCHAR(10) NOT NULL, + `email` VARCHAR(100) NOT NULL, + `estado` INT NOT NULL, + `domicilio` VARCHAR(100) NOT NULL, + `estados_id` INT NOT NULL, + `marca_id` INT NOT NULL, + PRIMARY KEY (`id`), + INDEX `fk_proveedor_estados1_idx` (`estados_id` ASC) VISIBLE, + INDEX `fk_proveedor_marca1_idx` (`marca_id` ASC) VISIBLE, + CONSTRAINT `fk_proveedor_estados1` + FOREIGN KEY (`estados_id`) + REFERENCES `inventarioalmacen`.`estados` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_proveedor_marca1` + FOREIGN KEY (`marca_id`) + REFERENCES `inventarioalmacen`.`marca` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`ubicacion` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`ubicacion` ( + `id` INT NOT NULL AUTO_INCREMENT, + `bloque` VARCHAR(1) NOT NULL, + `anaquel` INT NOT NULL, + `estado` INT NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`tipo` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`tipo` ( + `id` INT NOT NULL AUTO_INCREMENT, + `tipo` VARCHAR(45) NOT NULL, + `estado` INT NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`producto` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`producto` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL, + `codigo` INT ZEROFILL NOT NULL, + `precio` FLOAT NOT NULL, + `piezas` INT NOT NULL, + `estado` INT NOT NULL, + `fecha` DATE NOT NULL, + `proveedor_idproveedor` INT NOT NULL, + `ubicacion_id` INT NOT NULL, + `tipo_id` INT NOT NULL, + PRIMARY KEY (`id`), + INDEX `fk_producto_proveedor1_idx` (`proveedor_idproveedor` ASC) VISIBLE, + INDEX `fk_producto_ubicacion1_idx` (`ubicacion_id` ASC) VISIBLE, + INDEX `fk_producto_tipo1_idx` (`tipo_id` ASC) VISIBLE, + CONSTRAINT `fk_producto_proveedor1` + FOREIGN KEY (`proveedor_idproveedor`) + REFERENCES `inventarioalmacen`.`proveedor` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_producto_ubicacion1` + FOREIGN KEY (`ubicacion_id`) + REFERENCES `inventarioalmacen`.`ubicacion` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_producto_tipo1` + FOREIGN KEY (`tipo_id`) + REFERENCES `inventarioalmacen`.`tipo` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`roles` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`roles` ( + `id` INT NOT NULL AUTO_INCREMENT, + `rol` VARCHAR(45) NOT NULL, + `estado` INT NOT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `inventarioalmacen`.`usuarios` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`usuarios` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(50) NOT NULL, + `apellidoPaterno` VARCHAR(50) NOT NULL, + `email` VARCHAR(100) NOT NULL, + `telefono` VARCHAR(10) NOT NULL, + `estado` INT NOT NULL, + `contrasenia` VARCHAR(20) NOT NULL, + `domicilio` VARCHAR(100) NOT NULL, + `estados_id` INT NOT NULL, + `roles_id` INT NOT NULL, + PRIMARY KEY (`id`), + INDEX `fk_usuarios_roles1_idx` (`roles_id` ASC) VISIBLE, + INDEX `fk_usuarios_estados1_idx` (`estados_id` ASC) VISIBLE, + CONSTRAINT `fk_usuarios_roles1` + FOREIGN KEY (`roles_id`) + REFERENCES `inventarioalmacen`.`roles` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_usuarios_estados1` + FOREIGN KEY (`estados_id`) + REFERENCES `inventarioalmacen`.`estados` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/Miky_Inventario.mwb b/Miky_Inventario.mwb new file mode 100644 index 0000000..03f7c2a Binary files /dev/null and b/Miky_Inventario.mwb differ diff --git a/Miky_Inventario.mwb.bak b/Miky_Inventario.mwb.bak new file mode 100644 index 0000000..0eaaac8 Binary files /dev/null and b/Miky_Inventario.mwb.bak differ diff --git a/ProyectoInventario-ejb/build.xml b/ProyectoInventario-ejb/build.xml new file mode 100644 index 0000000..4864e0b --- /dev/null +++ b/ProyectoInventario-ejb/build.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + Builds, tests, and runs the project ProyectoInventario-ejb. + + + diff --git a/ProyectoInventario-ejb/nbproject/ant-deploy.xml b/ProyectoInventario-ejb/nbproject/ant-deploy.xml new file mode 100644 index 0000000..fdc06d5 --- /dev/null +++ b/ProyectoInventario-ejb/nbproject/ant-deploy.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-ejb/nbproject/build-impl.xml b/ProyectoInventario-ejb/nbproject/build-impl.xml new file mode 100644 index 0000000..bdcc503 --- /dev/null +++ b/ProyectoInventario-ejb/nbproject/build-impl.xml @@ -0,0 +1,1253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set main.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-ejb/nbproject/genfiles.properties b/ProyectoInventario-ejb/nbproject/genfiles.properties new file mode 100644 index 0000000..eceebfa --- /dev/null +++ b/ProyectoInventario-ejb/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=32277192 +build.xml.script.CRC32=79125877 +build.xml.stylesheet.CRC32=a737d6c5@1.75 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=32277192 +nbproject/build-impl.xml.script.CRC32=6effce6d +nbproject/build-impl.xml.stylesheet.CRC32=62693482@1.75 diff --git a/ProyectoInventario-ejb/nbproject/project.xml b/ProyectoInventario-ejb/nbproject/project.xml new file mode 100644 index 0000000..511a1c6 --- /dev/null +++ b/ProyectoInventario-ejb/nbproject/project.xml @@ -0,0 +1,20 @@ + + + org.netbeans.modules.j2ee.ejbjarproject + + + ProyectoInventario-ejb + 1.6.5 + + + + + + + + + + ..\.\lib\nblibraries.properties + + + diff --git a/ProyectoInventario-ejb/src/conf/MANIFEST.MF b/ProyectoInventario-ejb/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/ProyectoInventario-ejb/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/ProyectoInventario-ejb/src/conf/META-INF/glassfish-resources.xml b/ProyectoInventario-ejb/src/conf/META-INF/glassfish-resources.xml new file mode 100644 index 0000000..c3c2633 --- /dev/null +++ b/ProyectoInventario-ejb/src/conf/META-INF/glassfish-resources.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-ejb/src/conf/persistence.xml b/ProyectoInventario-ejb/src/conf/persistence.xml new file mode 100644 index 0000000..c60eaeb --- /dev/null +++ b/ProyectoInventario-ejb/src/conf/persistence.xml @@ -0,0 +1,8 @@ + + + + jdbc/almacen + false + + + diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBL.java new file mode 100644 index 0000000..2284287 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBL.java @@ -0,0 +1,153 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.EstadosDAO; +import xforce.modelo.Estados; +import xforce.modelo.Proveedor; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Stateless +public class EstadosBL implements EstadosBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Estados estados) { + System.out.println("Llegaste al metodo de agregar paises"); + EstadosDAO estadosDAO = new EstadosDAO(); + Mensaje m; + //Toda la logica + + if (estados.getNombre().isEmpty()) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + + estados.setEstado(2); + + Optional paisEncontradoOptional = estadosDAO.buscarEstado(estados); + + if (paisEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un pais + paisEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + estadosDAO.agregar(estados); + System.out.println("Agregado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Estados buscarId(Estados estados) { + EstadosDAO estadosDAO = new EstadosDAO(); + if (estadosDAO.buscarId(estados) == null) { + System.out.println("No existe el pais"); + return estadosDAO.buscarId(estados); + } else { + System.out.println("Se encontro el pais"); + return estadosDAO.buscarId(estados); + } + } + + @Override + public Mensaje eliminar(Estados estados) { + Mensaje m = null; + EstadosDAO estadosDAO = new EstadosDAO(); + + Estados estadoEnUso = estadosDAO.buscarId(estados); + + if (estadoEnUso != null) { + // Verificar si existen productos asociados a esta pais + + List referenciaUsuarios = estadosDAO.buscarPaisesReferenciadosUsuarios(estadoEnUso); + + List referenciaProveedor = estadosDAO.buscarPaisesReferenciadosProveedor(estadoEnUso); + + if (!referenciaProveedor.isEmpty() + || !referenciaUsuarios.isEmpty()) { + + System.out.println(referenciaProveedor.toString()); + System.out.println(referenciaUsuarios.toString()); + // Hay estados asociados a esta pais, no se puede eliminar + System.out.println("No se puede eliminar el estado porque esta en uso"); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "El estado esta en uso"); + m = Mensaje.ERROR_PRODUCTOS_ASOCIADOS; + + } else { + if (estadoEnUso.getEstado() == 2) { + estadoEnUso.setEstado(1); + + if (estadosDAO.eliminar(estadoEnUso)) { + System.out.println("Pais eliminado"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar pais"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Pais se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("Pais inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + + } + + @Override + public List buscarValidos(boolean estado) { + EstadosDAO estadosDAO = new EstadosDAO(); + System.out.println("pais existente"); + List l = estadosDAO.buscarValidos(estado); + System.out.println(l); + + return l; + } + + @Override + public Estados buscarNombre(Estados estados) { + EstadosDAO estadosDAO = new EstadosDAO(); + if (estadosDAO.buscarPorNombre(estados) == null) { + System.out.println("no existe el pais"); + return estadosDAO.buscarId(estados); + } else { + System.out.println("se encontro un pais"); + return estadosDAO.buscarId(estados); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajePaises", new FacesMessage(severity, summary, detail)); + } +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBLLocal.java new file mode 100644 index 0000000..1f5f94f --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/EstadosBLLocal.java @@ -0,0 +1,29 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Estados; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Local +public interface EstadosBLLocal { + + public Mensaje agregar(Estados estados); + + public Estados buscarId(Estados estados); + + public Mensaje eliminar(Estados estados); + + public List buscarValidos(boolean estado); + + public Estados buscarNombre(Estados estados); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/LoginBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/LoginBL.java new file mode 100644 index 0000000..41e7e3b --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/LoginBL.java @@ -0,0 +1,75 @@ +/* + * 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 xforce.bl; + +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import javax.persistence.NoResultException; +import xforce.dao.LoginDAO; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Stateless +public class LoginBL implements LoginBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje login(Usuarios usuarios) { + System.out.println("AAAAAAAAAAAAAAAAAAAAAAAA"); + LoginDAO loginDAO = new LoginDAO(); + Mensaje m; + //Toda la logica + + if (usuarios.getNombre().isEmpty() + || usuarios.getContrasenia().isEmpty()) { + + System.out.println("Campos incompletos"); + addMessage(FacesMessage.SEVERITY_WARN, "INFO", "Rellene todos los campos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + + usuarios.setEstado(2); + Optional loginOptional = loginDAO.login(usuarios); + + if (loginOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un usuario + m = Mensaje.SIN_ERROR; + rol(usuarios); + System.out.println(m); + } else { + m = Mensaje.NO_EXISTE; + rol(usuarios); + System.out.println(m); + } + return m; + } + + @Override + public String rol(Usuarios usuarios) { + LoginDAO loginDAO = new LoginDAO(); + String rol = "No existe"; + try { + rol = loginDAO.rol(usuarios); + return rol; + } catch (NoResultException e) { + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Usuario o contraseña incorrectos"); + return rol; + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeLogin", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/LoginBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/LoginBLLocal.java new file mode 100644 index 0000000..7226397 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/LoginBLLocal.java @@ -0,0 +1,21 @@ +/* + * 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 xforce.bl; + +import javax.ejb.Local; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Local +public interface LoginBLLocal { + + public Mensaje login(Usuarios usuarios); + + public String rol(Usuarios usuarios); +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBL.java new file mode 100644 index 0000000..9a36a44 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBL.java @@ -0,0 +1,204 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.MarcaDAO; +import xforce.modelo.Marca; +import xforce.modelo.Proveedor; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Stateless +public class MarcaBL implements MarcaBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Marca marca) { + System.out.println("Llegaste al metodo de agregar marca"); + MarcaDAO marcaDAO = new MarcaDAO(); + Mensaje m; + //Toda la logica + + if (marca.getNombre().isEmpty()) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + marca.setEstado(2); + Optional marcaEncontradoOptional = marcaDAO.buscarMarca(marca); + + if (marcaEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + marcaEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + marcaDAO.agregar(marca); + System.out.println("Agregado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Marca buscarId(Marca marca) { + MarcaDAO u = new MarcaDAO(); + if (u.buscarId(marca) == null) { + System.out.println("No existe la marca"); + return u.buscarId(marca); + } else { + System.out.println("Se encontro la marca"); + return u.buscarId(marca); + } + } + + + @Override + public Mensaje eliminar(Marca marca) { + Mensaje m = null; + MarcaDAO marcaDao = new MarcaDAO(); + + Marca mark = marcaDao.buscarId(marca); + + if (mark != null) { + // Verificar si existen productos asociados a esta marca + + List idsMarcasReferenciadas = marcaDao.buscarMarcasReferenciadas(mark); + + if (!idsMarcasReferenciadas.isEmpty()) { + + System.out.println(idsMarcasReferenciadas.toString()); + // Hay productos asociados a esta marca, no se puede eliminar + System.out.println("No se puede eliminar la marca porque existen proveedores asociados."); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "La marca esta en uso"); + m = Mensaje.ERROR_PROVEEDORES_ASOCIADOS; + + } else { + if (mark.getEstado() == 2) { + mark.setEstado(1); + + if (marcaDao.eliminar(mark)) { + System.out.println("Marca eliminada"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar marca"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Marca se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("Marca inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + + } + + @Override + public Mensaje editar(Marca marca) { + Mensaje m = null; + try { + + MarcaDAO p = new MarcaDAO(); + + if (marca.getNombre().isEmpty()) { + System.out.println("Algunos campos son erroneos"); + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + Optional marcaEncontradoOptional = p.buscarMarca(marca); + + if (marcaEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + marcaEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + // Editar el usuario solo si todas las validaciones son exitosas + Marca mark = p.buscarId(marca); + + // Editar el usuario solo si todas las validaciones son exitosas + if (mark != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + mark.setNombre(marca.getNombre()); + + // Guardar la modificación en la base de datos + if (p.editar(mark)) { + System.out.println("Editado con éxito"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Editado con exito"); + m = Mensaje.SIN_ERROR; + return m; + } else { + System.out.println("Error al editar"); + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + } else { + System.out.println("No existe el producto a editar"); + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + } + + } catch (Exception e) { + + System.out.println("Algo es erroneo"); + m = Mensaje.DATOS_INCORRECTOS; + return m; + } + return m; + } + + @Override + public List buscarValidos(boolean estado) { + MarcaDAO marca = new MarcaDAO(); + System.out.println("marcas existente"); + List l = marca.buscarValidos(estado); + System.out.println(l); + + return l; + } + + @Override + public Marca buscarNombre(Marca marca) { + MarcaDAO m = new MarcaDAO(); + if (m.buscarPorNombre(marca) == null) { + System.out.println("no existe la marca"); + return m.buscarId(marca); + } else { + System.out.println("se encontro una marca"); + return m.buscarId(marca); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeMarca", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBLLocal.java new file mode 100644 index 0000000..a4cca99 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/MarcaBLLocal.java @@ -0,0 +1,33 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Marca; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Local +public interface MarcaBLLocal { + + Mensaje agregar(Marca marca); + + Marca buscarId(Marca marca); + + Mensaje eliminar(Marca marca); + + Mensaje editar(Marca marca); + + List buscarValidos(boolean estado); + + Marca buscarNombre(Marca marca); + + + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java new file mode 100644 index 0000000..a68d528 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java @@ -0,0 +1,212 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.PaisesDAO; +import xforce.modelo.Estados; +import xforce.modelo.Paises; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Stateless +public class PaisesBL implements PaisesBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Paises paises) { + System.out.println("Llegaste al metodo de agregar paises"); + PaisesDAO paisesDao = new PaisesDAO(); + Mensaje m; + //Toda la logica + + if (paises.getNombre().isEmpty()) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + paises.setEstado(2); + Optional paisEncontradoOptional = paisesDao.buscarPaises(paises); + + if (paisEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un pais + paisEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + paisesDao.agregar(paises); + System.out.println("Agregado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Mensaje editar(Paises paises) { + Mensaje m; + try { + + PaisesDAO paisesDAO = new PaisesDAO(); + + if (paises.getNombre().isEmpty()) { + System.out.println("Algunos campos son erroneos"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Verifique los campos numericos"); + + m = Mensaje.CAMPOS_INCOMPLETOS; + + return m; + } + + Paises paisExistente = paisesDAO.buscarId(paises); + + Optional productoEncontradoActivo = paisesDAO.buscarPaises(paises); + + if (productoEncontradoActivo.isPresent()) { + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + System.out.println("Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + + if (paisExistente != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + paisExistente.setNombre(paises.getNombre()); + + // Guardar la modificación en la base de datos + if (paisesDAO.editar(paisExistente)) { + System.out.println("Editado con éxito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Editado con exito"); + + m = Mensaje.SIN_ERROR; + return m; + } else { + System.out.println("Error al editar"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Error al editar"); + + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + } else { + System.out.println("No existe el producto a editar"); + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + + } + + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Algo es erróneo"); + m = Mensaje.DATOS_INCORRECTOS; + return m; + } + return m; + } + + @Override + public Paises buscarId(Paises paises) { + PaisesDAO paisesDao = new PaisesDAO(); + if (paisesDao.buscarId(paises) == null) { + System.out.println("No existe el pais"); + return paisesDao.buscarId(paises); + } else { + System.out.println("Se encontro el pais"); + return paisesDao.buscarId(paises); + } + } + + @Override + public Mensaje eliminar(Paises paises) { + Mensaje m = null; + PaisesDAO paisesDao = new PaisesDAO(); + + Paises paisEnUso = paisesDao.buscarId(paises); + + if (paisEnUso != null) { + // Verificar si existen productos asociados a esta pais + List idsPaisesReferenciados = paisesDao.buscarPaisesReferenciados(paisEnUso); + + if (!idsPaisesReferenciados.isEmpty()) { + + System.out.println(idsPaisesReferenciados.toString()); + // Hay estados asociados a esta pais, no se puede eliminar + System.out.println("No se puede eliminar el pais porque existen estados asociados."); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "El pais esta en uso"); + m = Mensaje.ERROR_PRODUCTOS_ASOCIADOS; + + } else { + if (paisEnUso.getEstado() == 2) { + paisEnUso.setEstado(1); + + if (paisesDao.eliminar(paisEnUso)) { + System.out.println("Pais eliminado"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar pais"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Pais se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("Pais inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + + } + + @Override + public List buscarValidos(boolean estado) { + PaisesDAO paisesDao = new PaisesDAO(); + System.out.println("pais existente"); + List l = paisesDao.buscarValidos(estado); + System.out.println(l); + + return l; + } + + @Override + public Paises buscarNombre(Paises paises) { + PaisesDAO paisesDao = new PaisesDAO(); + if (paisesDao.buscarPorNombre(paises) == null) { + System.out.println("no existe el pais"); + return paisesDao.buscarId(paises); + } else { + System.out.println("se encontro un pais"); + return paisesDao.buscarId(paises); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajePaises", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBLLocal.java new file mode 100644 index 0000000..8d42704 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBLLocal.java @@ -0,0 +1,31 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Paises; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Local +public interface PaisesBLLocal { + + public Mensaje agregar(Paises paises); + + public Mensaje editar(Paises paises); + + public Paises buscarId(Paises paises); + + public Mensaje eliminar(Paises paises); + + public List buscarValidos(boolean estado); + + public Paises buscarNombre(Paises paises); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBL.java new file mode 100644 index 0000000..54049d6 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBL.java @@ -0,0 +1,262 @@ +/* + * 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 xforce.bl; + +import java.time.Instant; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.ProductoDAO; +import xforce.dao.ProveedorDAO; +import xforce.dao.UbicacionDAO; +import xforce.modelo.Producto; +import xforce.modelo.Proveedor; +import xforce.modelo.Ubicacion; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Stateless +public class ProductoBL implements ProductoBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Producto producto) { + System.out.println("Llegaste al metodo de agregar Producto"); + ProductoDAO productoDAO = new ProductoDAO(); + Mensaje m; + + ProveedorDAO proveedorDAO = new ProveedorDAO(); + UbicacionDAO ubicacionDAO = new UbicacionDAO(); + + // Verifica si las llaves foraneas existen + Proveedor proveedor = proveedorDAO.buscarPorId(producto.getProveedorIdproveedor()); + if (proveedor == null) { + System.out.println("El proveedor no existe. No se puede agregar el producto."); + return Mensaje.PROVEEDOR_ERRONEO; // Agrega un mensaje de error específico para marca no existente + } + + Ubicacion ubicacion = ubicacionDAO.buscarPorId(producto.getUbicacionId()); + if (ubicacion == null) { + System.out.println("La ubicacion no existe. No se puede agregar el producto."); + return Mensaje.UBICACION_ERRONEA; // Agrega un mensaje de error específico para marca no existente + } + + // Resto de la lógica de validación + if (producto.getNombre().isEmpty() + || producto.getCodigo() <= 0 + || producto.getPrecio() <= 0 + || producto.getPiezas() <= 0 + || producto.getProveedorIdproveedor() == null + || producto.getUbicacionId() == null + || producto.getTipoId() == null) { + System.out.println("Campos incompletos"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Verifique los campos numericos"); + + m = Mensaje.CAMPOS_INCOMPLETOS; + + return m; + } + + // Resto de la lógica para verificar duplicados y agregar el producto + producto.setEstado(2); + Optional productoEncontradoActivo = productoDAO.buscarProducto(producto); + + if (productoEncontradoActivo.isPresent()) { + System.out.println("Elemento duplicado"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + producto.setFecha(Date.from(Instant.now())); + productoDAO.agregar(producto); + System.out.println("Agregado con éxito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + + return m; + } + + @Override + public Mensaje editar(Producto producto) { + Mensaje m; + try { + + ProductoDAO productoDAO = new ProductoDAO(); + + if (producto.getNombre().isEmpty() + || producto.getCodigo() <= 0 + || producto.getPrecio() <= 0 + || producto.getPiezas() < 0 + || producto.getProveedorIdproveedor() == null + || producto.getUbicacionId() == null + || producto.getTipoId() == null) { + System.out.println("Algunos campos son erroneos"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Verifique los campos numericos"); + + m = Mensaje.CAMPOS_INCOMPLETOS; + + return m; + } + + Producto productoExistente = productoDAO.buscarId(producto); + + Optional productoEncontradoActivo = productoDAO.buscarProducto(producto); + + if (productoEncontradoActivo.isPresent()) { + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + System.out.println("Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + + if (productoExistente != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + productoExistente.setNombre(producto.getNombre()); + productoExistente.setCodigo(producto.getCodigo()); + productoExistente.setPrecio(producto.getPrecio()); + productoExistente.setPiezas(producto.getPiezas()); + productoExistente.setProveedorIdproveedor(producto.getProveedorIdproveedor()); + productoExistente.setUbicacionId(producto.getUbicacionId()); + productoExistente.setTipoId(producto.getTipoId()); + + // Guardar la modificación en la base de datos + if (productoDAO.editar(productoExistente)) { + System.out.println("Editado con éxito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Editado con exito"); + + m = Mensaje.SIN_ERROR; + return m; + } else { + System.out.println("Error al editar"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Error al editar"); + + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + } else { + System.out.println("No existe el producto a editar"); + m = Mensaje.CAMPOS_INCOMPLETOS; + return m; + } + + } + + } catch (Exception e) { + System.out.println("Algo es erróneo"); + m = Mensaje.DATOS_INCORRECTOS; + return m; + } + return m; + } + + @Override + public Producto buscarId(Producto producto) { + ProductoDAO productoDAO = new ProductoDAO(); + Producto p = productoDAO.buscarId(producto); + if (p == null) { + System.out.println("No existe el producto"); + return p; + } else { + System.out.println("Se encontro el producto"); + return p; + } + } + + @Override + public List buscarValidos(boolean estado) { + ProductoDAO productoDAO = new ProductoDAO(); + List l = productoDAO.buscarValidos(estado); + // Llama al método buscarValidos de ProductoDAO y devuelve la lista resultante + System.out.println(l); + return l; + } + + @Override + public Producto buscarNombre(Producto producto) { + ProductoDAO productoDAO = new ProductoDAO(); + Producto p = productoDAO.buscarPorNombre(producto); + if (p == null) { + System.out.println("No existe el producto"); + return p; + } else { + System.out.println("Se encontro el producto"); + return p; + } + } + + @Override + public List buscarUbicacion(int id) { + ProductoDAO productoDAO = new ProductoDAO(); + List l = productoDAO.buscarPorUbicacion(id); + System.out.println(l); + return l; + } + + @Override + public List buscarMarca(int id) { + ProductoDAO productoDAO = new ProductoDAO(); + List l = productoDAO.buscarPorMarca(id); + System.out.println(l); + return l; + } + + @Override + public Mensaje eliminar(Producto producto) { + Mensaje m; + ProductoDAO productoDAO = new ProductoDAO(); + + // Buscar el producto por id + Producto productoExistente = productoDAO.buscarId(producto); + + if (productoExistente != null) { + // Verificar que el estado actual sea 2 antes de cambiarlo a 1 + if (productoExistente.getEstado() == 2) { + // Modificar solo el atributo estado + + // Guardar la modificación en la base de datos + if (productoDAO.eliminar(productoExistente)) { + System.out.println("Producto eliminado"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Producto eliminado con exito"); + + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("El producto ya se elimino"); + m = Mensaje.NO_EXISTE; // Puedes definir este mensaje en tu enumeración Mensaje + } + } else { + System.out.println("No existe el producto"); + m = Mensaje.NO_EXISTE; + } + + return m; + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeProducto", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBLLocal.java new file mode 100644 index 0000000..989b39c --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/ProductoBLLocal.java @@ -0,0 +1,35 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Producto; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Local +public interface ProductoBLLocal { + + Mensaje agregar(Producto producto); + + Producto buscarId(Producto producto); + + List buscarValidos(boolean estado); + + Producto buscarNombre(Producto producto); + + List buscarUbicacion(int id); + + List buscarMarca(int id); + + Mensaje eliminar(Producto producto); + + Mensaje editar(Producto producto); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBL.java new file mode 100644 index 0000000..fc37bc0 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBL.java @@ -0,0 +1,206 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.ProveedorDAO; +import xforce.modelo.Producto; +import xforce.modelo.Proveedor; +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Stateless +public class ProveedorBL implements ProveedorBLLocal { +// Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + + @Override + public Mensaje agregar(Proveedor proveedor) { + + System.out.println("Llegaste al metodo de agregar proveedor"); + + ProveedorDAO pDAO = new ProveedorDAO(); + Mensaje m; + //Toda la logica + + if (proveedor.getNombre().isEmpty() + ||proveedor.getEmail().isEmpty() + ||proveedor.getTelefono().isEmpty() + ) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + proveedor.setEstado(2); + Optional pEncontradoOptional = pDAO.buscarproveedor(proveedor); + + if (pEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR,"ERROR","Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + pDAO.agregar(proveedor); + System.out.println("Agregado con exito"); + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Agregado con exito"); + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Proveedor buscarId(Proveedor proveedor) { + ProveedorDAO u = new ProveedorDAO(); + if (u.buscarPorId(proveedor) == null) { + System.out.println("No existe el proveedor"); + return u.buscarPorId(proveedor); + } else { + System.out.println("Se encontro la proveedor"); + return u.buscarPorId(proveedor); + } + + } + + @Override + public Mensaje editar(Proveedor proveedor) { + Mensaje m = null; + try { + + ProveedorDAO p = new ProveedorDAO(); + + if (proveedor.getNombre().isEmpty() || proveedor.getEmail().isEmpty() || proveedor.getTelefono().isEmpty() + ) { + System.out.println("Algunos campos son erroneos"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + Optional marcaEncontradoOptional = p.buscarproveedor(proveedor); + + if (marcaEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + marcaEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + // Editar el usuario solo si todas las validaciones son exitosas + Proveedor mark = p.buscarPorId(proveedor); +// Editar el usuario solo si todas las validaciones son exitosas + if (mark != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + mark.setNombre(proveedor.getNombre()); + // Editar el usuario solo si todas las validaciones son exitosas + if (p.editar(proveedor) == true) { + System.out.println("Editado con exito"); + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Editado con exito"); + m = m.SIN_ERROR; + return m; + }} else { + System.out.println("No existe le proveedor a editar"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + + } + }catch (Exception e) { + + System.out.println("Algo es erroneo"); + m = m.DATOS_INCORRECTOS; + return m; + } + return m; + } + + @Override + public Mensaje eliminar(Proveedor proveedor) { + Mensaje m = null; + ProveedorDAO proveedorDao = new ProveedorDAO(); + Proveedor prov = proveedorDao.buscarPorId(proveedor); + + if (prov != null) { + List idsMarcasReferenciadas = proveedorDao.buscarMarcasReferenciadas(prov); + + /*for (Producto producto : idsMarcasReferenciadas) { + if (marca.getId().equals(producto.getId())) { + marcaReferenciada = true; + break; + } + + }*/ + + if (!idsMarcasReferenciadas.isEmpty()) { + + System.out.println(idsMarcasReferenciadas.toString()); + // Hay productos asociados a esta marca, no se puede eliminar + System.out.println("No se puede eliminar la marca porque existen productos asociados."); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "El elemento esta en uso"); + m = Mensaje.ERROR_PRODUCTOS_ASOCIADOS; + System.out.println(m); + + }else{ + if (prov.getEstado() == 2) { + prov.setEstado(1); + + if (proveedorDao.eliminar(prov)) { + System.out.println("provvedor eliminado"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("erro al eliminar proveedor"); + + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("proveedor se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + + } + } else { + System.out.println("proveedor inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + } + + + @Override + public List buscarValidos(boolean estado) { + ProveedorDAO proveedor = new ProveedorDAO(); + System.out.println("Proveedor existente"); + + return proveedor.buscarValidos(estado); + } + + + @Override + public Proveedor buscarNombre(Proveedor proveedor) { + ProveedorDAO p = new ProveedorDAO(); + if (p.buscarPorNombre(proveedor) == null) { + System.out.println("no existe el proveedor"); + return p.buscarPorId(proveedor); + } else { + System.out.println("se encontro un proveedor"); + return p.buscarPorId(proveedor); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeProveedor", new FacesMessage(severity, summary, detail)); + } + + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBLLocal.java new file mode 100644 index 0000000..81fd253 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBLLocal.java @@ -0,0 +1,31 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Proveedor; +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Local +public interface ProveedorBLLocal { + + Mensaje agregar(Proveedor proveedor); + + Proveedor buscarId(Proveedor Proveedor); + + Mensaje editar(Proveedor Proveedor); + + Mensaje eliminar(Proveedor proveedor); + + List buscarValidos(boolean estado); + + Proveedor buscarNombre(Proveedor proveedor); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/RolesBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/RolesBL.java new file mode 100644 index 0000000..5e3ff56 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/RolesBL.java @@ -0,0 +1,150 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.RolesDAO; +import xforce.modelo.Roles; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Stateless +public class RolesBL implements RolesBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Roles roles) { + System.out.println("Llegaste al metodo de agregar roles"); + RolesDAO rolesDao = new RolesDAO(); + Mensaje m; + //Toda la logica + + if (roles.getRol().isEmpty()) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + + roles.setEstado(2); + + Optional rolesEncontradosOptional = rolesDao.buscarRoles(roles); + + if (rolesEncontradosOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un pais + rolesEncontradosOptional.get(); + System.out.println("Elemento duplicado"); + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + rolesDao.agregar(roles); + System.out.println("Agregado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Roles buscarId(Roles roles) { + RolesDAO rolesDao = new RolesDAO(); + if (rolesDao.buscarId(roles) == null) { + System.out.println("No existe el rol"); + return rolesDao.buscarId(roles); + } else { + System.out.println("Se encontro el rol"); + return rolesDao.buscarId(roles); + } + } + + @Override + public Mensaje eliminar(Roles roles) { + Mensaje m = null; + RolesDAO rolesDao = new RolesDAO(); + + Roles rolUsado = rolesDao.buscarId(roles); + + if (rolUsado != null) { + // Verificar si existen usuarios asociados a este rol + + + List referenciaUsuarios = rolesDao.buscarUsuariosReferenciados(rolUsado); + + if (!referenciaUsuarios.isEmpty()) { + + System.out.println(referenciaUsuarios.toString()); + System.out.println(referenciaUsuarios.toString()); + + System.out.println("No se puede eliminar el rol porque esta en uso"); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "El rol esta en uso"); + m = Mensaje.ERROR_USUARIOS_ASOCIADOS; + + } else { + if (rolUsado.getEstado() == 2) { + rolUsado.setEstado(1); + + if (rolesDao.eliminar(rolUsado)) { + System.out.println("Rol eliminado"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar rol"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Rol se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("ROl inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + } + + @Override + public List buscarValidos(boolean estado) { + RolesDAO rolesDao = new RolesDAO(); + System.out.println("roles existentes"); + List l = rolesDao.buscarValidos(estado); + System.out.println(l); + + return l; + } + + @Override + public Roles buscarNombre(Roles roles) { + RolesDAO rolesDao = new RolesDAO(); + if (rolesDao.buscarPorNombre(roles) == null) { + System.out.println("no existe el rol"); + return rolesDao.buscarId(roles); + } else { + System.out.println("se encontro un rol"); + return rolesDao.buscarId(roles); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeRoles", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/RolesBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/RolesBLLocal.java new file mode 100644 index 0000000..ddd4b1a --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/RolesBLLocal.java @@ -0,0 +1,27 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Roles; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Local +public interface RolesBLLocal { + public Mensaje agregar(Roles roles); + + public Roles buscarId(Roles roles); + + public Mensaje eliminar(Roles roles); + + public List buscarValidos(boolean estado); + + public Roles buscarNombre(Roles roles); +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/TipoBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/TipoBL.java new file mode 100644 index 0000000..f73d0b4 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/TipoBL.java @@ -0,0 +1,137 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/J2EE/EJB30/StatefulEjbClass.java to edit this template + */ +package xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateful; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.TipoDAO; +import xforce.modelo.Producto; +import xforce.modelo.Tipo; + +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Stateful +public class TipoBL implements TipoBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + + public Mensaje agregar(Tipo tipos) { + + System.out.println("Llegaste al metodo de agregar tipo"); + + TipoDAO tDAO = new TipoDAO(); + Mensaje m; + //Toda la logica + + if (tipos.getTipo().isEmpty() + + ) { + + System.out.println("Campos incompletos"); + return Mensaje.CAMPOS_INCOMPLETOS; + } + tipos.setEstado(2); + Optional tEncontradoOptional = tDAO.buscarTipo(tipos); + + if (tEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + tEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR,"ERROR","Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + tDAO.agregar(tipos); + System.out.println("Agregado con exito"); + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Agregado con exito"); + m = Mensaje.SIN_ERROR; + } + return m; + } + + public Mensaje eliminar(Tipo tipo) { + Mensaje m = null; + TipoDAO tDao = new TipoDAO(); + + Tipo tUsado = tDao.buscarId(tipo); + + if (tUsado != null) { + // Verificar si existen usuarios asociados a este rol + + + List referenciaTipo = tDao.buscarTiposReferenciados(tUsado); + + if (!referenciaTipo.isEmpty()) { + + System.out.println(referenciaTipo.toString()); + System.out.println(referenciaTipo.toString()); + + System.out.println("No se puede eliminar el tipo porque esta en uso"); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "El tipo esta en uso"); + m = Mensaje.ERROR_USUARIOS_ASOCIADOS; + + } else { + if (tUsado.getEstado() == 2) { + tUsado.setEstado(1); + + if (tDao.eliminar(tUsado)) { + System.out.println("Rol eliminado"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar el tipo"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Tipo se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("Tipo inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + } + + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("tipoM", new FacesMessage(severity, summary, detail)); + } + @Override + + public List buscarValidos(boolean estado) { + TipoDAO tipoDao = new TipoDAO(); + System.out.println("roles existentes"); + List l= tipoDao.buscarValidos(estado); + System.out.println(l); + + return l; + } + +} + + + + + + + + + + + + + diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/TipoBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/TipoBLLocal.java new file mode 100644 index 0000000..2b34bd9 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/TipoBLLocal.java @@ -0,0 +1,24 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Tipo; +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Local +public interface TipoBLLocal { + + public Mensaje agregar(Tipo tipos); + + public List buscarValidos(boolean estado); + public Mensaje eliminar(Tipo tipo); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBL.java new file mode 100644 index 0000000..2bab6c1 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBL.java @@ -0,0 +1,207 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.UbicacionDAO; +import xforce.modelo.*; +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Stateless +public class UbicacionBL implements UbicacionBLLocal { +// Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + + @Override + public Mensaje agregar(Ubicacion ubicacion) { + System.out.println("Llegaste al metodo de agregar ubicacion"); + UbicacionDAO ubicacionDAO = new UbicacionDAO(); + Mensaje m; + //Toda la logica + + if (ubicacion.getBloque().isEmpty() + || ubicacion.getAnaquel() < 0) { + + System.out.println("Campos incompletos"); + + return Mensaje.CAMPOS_INCOMPLETOS; + } + ubicacion.setEstado(2); + + Optional ubicacionEncontradoOptional = ubicacionDAO.buscaUbicacion(ubicacion); + + if (ubicacionEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos una marca + + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + ubicacionDAO.agregar(ubicacion); + System.out.println("Agregado con exito"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Agregado con exito"); + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Mensaje eliminar(Ubicacion ubicacion) { + + Mensaje m = null; + UbicacionDAO u = new UbicacionDAO(); + Ubicacion ubic = u.buscarPorId(ubicacion); + + if (ubic != null) { + + List idUbicacionr = u.buscarMarcasReferenciadas(ubic); + + if (!idUbicacionr.isEmpty()) { + + System.out.println(idUbicacionr.toString()); + // Hay productos asociados a esta marca, no se puede eliminar + System.out.println("No se puede eliminar la marca porque existen productos asociados."); + addMessage(FacesMessage.SEVERITY_WARN, "ATENCION", "La ubicacion esta en uso"); + m = Mensaje.ERROR_PRODUCTOS_ASOCIADOS; + + } else { + if (ubic.getEstado() == 2) { + ubic.setEstado(1); + + if (u.eliminar(ubic)) { + System.out.println("Marca eliminada"); + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("Error al eliminar marca"); + m = Mensaje.DATOS_INCORRECTOS; + } + } else { + System.out.println("Marca se acaba de eliminar"); + m = Mensaje.NO_EXISTE; + } + } + + } else { + System.out.println("Marca inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + + } + + @Override + public Mensaje editar(Ubicacion ubicacion) { + Mensaje m = null; + try { + + UbicacionDAO u = new UbicacionDAO(); + + if (ubicacion.getBloque().isEmpty() || ubicacion.getAnaquel() < 0) { + System.out.println("Algunos campos son erroneos"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + + Ubicacion ubicacionExistente = u.buscarPorId(ubicacion); + + Optional ubiEncontradoActivo = u.buscaUbicacion(ubicacion); + + if (ubiEncontradoActivo.isPresent()) { + + addMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Elemento duplicado"); + + System.out.println("Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + + if (ubicacionExistente != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + ubicacionExistente.setAnaquel(ubicacion.getAnaquel()); + ubicacionExistente.setBloque(ubicacion.getBloque()); + } + // Editar el usuario solo si todas las validaciones son exitosas + if (u.editar(ubicacion)) { + System.out.println("Editado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO, "INFO", "Editado con exito"); + + m = m.SIN_ERROR; + return m; + } else { + System.out.println("No existe la ubicacion a editar"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + } + } catch (Exception e) { + System.out.println("Algo es erroneo"); + m = m.DATOS_INCORRECTOS; + return m; + } + return m; + } + + @Override + public Ubicacion buscaUbicacion(Ubicacion ubicacion) { + + UbicacionDAO u = new UbicacionDAO(); + if (u.buscarPorId(ubicacion) == null) { + System.out.println("No existe la ubicacion"); + return u.buscarPorId(ubicacion); + } else { + System.out.println("Se encontro la ubicacion"); + return u.buscarPorId(ubicacion); + } + } + + @Override + public List buscarValidos(boolean estado) { + UbicacionDAO p = new UbicacionDAO(); + System.out.println("Proveedor existente"); + + return p.buscarValidos(estado); + } + + @Override + public Ubicacion buscarId(Ubicacion ubicacion) { + UbicacionDAO u = new UbicacionDAO(); + if (u.buscarPorId(ubicacion) == null) { + System.out.println("No existe el proveedor"); + return u.buscarPorId(ubicacion); + } else { + System.out.println("Se encontro la proveedor"); + return u.buscarPorId(ubicacion); + } + } + + @Override + public Ubicacion buscarNombre(Ubicacion ubicacion) { + UbicacionDAO p = new UbicacionDAO(); + if (p.buscarPorNombre(ubicacion) == null) { + System.out.println("no existe el proveedor"); + return p.buscarPorId(ubicacion); + } else { + System.out.println("se encontro un proveedor"); + return p.buscarPorId(ubicacion); + } + + } + + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeUbicacion", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBLLocal.java new file mode 100644 index 0000000..978ab01 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBLLocal.java @@ -0,0 +1,34 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Ubicacion; + +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Local +public interface UbicacionBLLocal { + + Mensaje agregar(Ubicacion ubicacion); + + Mensaje eliminar(Ubicacion Ubicacion); + + Mensaje editar(Ubicacion ubicacion); + + Ubicacion buscaUbicacion(Ubicacion ubicacion); + + List buscarValidos(boolean estado); + + Ubicacion buscarNombre(Ubicacion ubicacion); + + Ubicacion buscarId(Ubicacion ubicacion); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBL.java new file mode 100644 index 0000000..aee9675 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBL.java @@ -0,0 +1,225 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import java.util.Optional; +import javax.ejb.Stateless; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import xforce.dao.EstadosDAO; +import xforce.dao.RolesDAO; +import xforce.dao.UsuariosDAO; +import xforce.modelo.Estados; +import xforce.modelo.Roles; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Stateless +public class UsuariosBL implements UsuariosBLLocal { + + // Add business logic below. (Right-click in editor and choose + // "Insert Code > Add Business Method") + @Override + public Mensaje agregar(Usuarios usuarios) { + System.out.println("Llegaste al metodo de agregar usuario"); + UsuariosDAO usuariosDAO = new UsuariosDAO(); + Mensaje m; + + RolesDAO rolesDao = new RolesDAO(); + EstadosDAO estadosDao = new EstadosDAO(); + + // Verifica si las llaves foraneas existen + Roles rol = rolesDao.buscarId(usuarios.getRolesId()); + if (rol == null) { + System.out.println("El rol no existe. No se puede agregar el usuario."); + return Mensaje.ROL_ERRONEO; // Agrega un mensaje de error específico para marca no existente + } + + Estados estados = estadosDao.buscarId(usuarios.getEstadosId()); + if (estados == null) { + System.out.println("El estado no existe. No se puede agregar el usuario."); + return Mensaje.ESTADO_ERRONEO; // Agrega un mensaje de error específico para marca no existente + } + + if (usuarios.getNombre().isEmpty() + || usuarios.getApellidoPaterno().isEmpty() + || usuarios.getEmail().isEmpty() + || usuarios.getTelefono().isEmpty() + || usuarios.getContrasenia().isEmpty() + || usuarios.getDomicilio().isEmpty() + || usuarios.getEstadosId() == null + || usuarios.getRolesId() == null) { + + System.out.println("Campos incompletos"); + + return Mensaje.CAMPOS_INCOMPLETOS; + } + + Optional usuarioEncontradoOptional = usuariosDAO.buscarUsuario(usuarios); + + if (usuarioEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un usuario + usuarioEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR,"ERROR","Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + } else { + usuariosDAO.agregar(usuarios); + System.out.println("Agregado con exito"); + + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Agregado con exito"); + + m = Mensaje.SIN_ERROR; + } + return m; + } + + @Override + public Usuarios buscarId(Usuarios usuarios) { + UsuariosDAO u = new UsuariosDAO(); + + if (u.buscarId(usuarios) == null) { + System.out.println("No existe el usuario"); + return u.buscarId(usuarios); + } else { + System.out.println("Se encontro el usuario"); + return u.buscarId(usuarios); + } + } + + @Override + public List buscarValidos(boolean estado) { + UsuariosDAO usuario = new UsuariosDAO(); + + System.out.println("usuarios existentes"); + + return usuario.buscarValidos(estado); + } + + @Override + public Usuarios buscarNombre(Usuarios usuario) { + UsuariosDAO user = new UsuariosDAO(); + if (user.buscarPorNombre(usuario) == null) { + System.out.println("no existe el usuario"); + return user.buscarId(usuario); + } else { + System.out.println("se encontro el usuario"); + return user.buscarId(usuario); + } + + } + + @Override + public Mensaje eliminar(Usuarios usuarios) { + Mensaje m = null; + UsuariosDAO u = new UsuariosDAO(); + Usuarios user = u.buscarId(usuarios); + + if (user != null) { + if (user.getEstado() == 2) { + user.setEstado(1); + + if (u.eliminar(user)) { + System.out.println("usuario eliminado"); + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Eliminado Correctamente"); + m = Mensaje.SIN_ERROR; + } else { + System.out.println("error al eliminar usuario"); + m = Mensaje.DATOS_INCORRECTOS; + } + + } else { + System.out.println("usuario acaba de eliminarse"); + m = Mensaje.NO_EXISTE; + } + } else { + System.out.println("usuario inexistente"); + m = Mensaje.NO_EXISTE; + } + + return m; + } + + @Override + public Mensaje editar(Usuarios usuarios) { + Mensaje m = null; + try { + + UsuariosDAO p = new UsuariosDAO(); + + if (usuarios.getNombre().isEmpty() + || usuarios.getApellidoPaterno().isEmpty() + || usuarios.getEmail().isEmpty() + || usuarios.getTelefono().isEmpty() + || usuarios.getContrasenia().isEmpty() + || usuarios.getDomicilio().isEmpty() + || usuarios.getRolesId() == null + || usuarios.getEstadosId() == null) { + System.out.println("Algunos campos son erroneos"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + + Optional usuarioEncontradoOptional = p.buscarUsuario(usuarios); + + if (usuarioEncontradoOptional.isPresent()) { + // Manejar el caso en el que se encontró al menos un usuario + usuarioEncontradoOptional.get(); + System.out.println("Elemento duplicado"); + addMessage(FacesMessage.SEVERITY_ERROR,"ERROR","Elemento duplicado"); + m = Mensaje.ELEMENTO_DUPLICADO; + }else{ + Usuarios users = p.buscarId(usuarios); + + // Editar el usuario solo si todas las validaciones son exitosas + if (users != null) { + // Copiar los valores de los atributos (excepto estado) al producto existente + users.setNombre(usuarios.getNombre()); + users.setApellidoPaterno(usuarios.getApellidoPaterno()); + users.setEmail(usuarios.getEmail()); + users.setTelefono(usuarios.getTelefono()); + users.setContrasenia(usuarios.getContrasenia()); + users.setRolesId(usuarios.getRolesId()); + users.setEstadosId(usuarios.getEstadosId()); + + + // Guardar la modificación en la base de datos + if (p.editar(users)) { + System.out.println("Editado con éxito"); + addMessage(FacesMessage.SEVERITY_INFO,"INFO","Editado con exito"); + m = m.SIN_ERROR; + return m; + } else { + System.out.println("Error al editar"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + } else { + System.out.println("No existe el producto a editar"); + m = m.CAMPOS_INCOMPLETOS; + return m; + } + + } + + } catch (Exception e) { + + System.out.println("Algo es erroneo"); + m = m.DATOS_INCORRECTOS; + return m; + } + return m; + } + public void addMessage(FacesMessage.Severity severity, String summary, String detail) { + FacesContext.getCurrentInstance(). + addMessage("mensajeUsuario", new FacesMessage(severity, summary, detail)); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBLLocal.java b/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBLLocal.java new file mode 100644 index 0000000..6e5c83c --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBLLocal.java @@ -0,0 +1,31 @@ +/* + * 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 xforce.bl; + +import java.util.List; +import javax.ejb.Local; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author hugoa + */ +@Local +public interface UsuariosBLLocal { + + Mensaje agregar(Usuarios usuarios); + + Usuarios buscarId(Usuarios usuarios); + + Mensaje eliminar(Usuarios usuarios); + + Mensaje editar(Usuarios usuarios); + + List buscarValidos(boolean estado); + + Usuarios buscarNombre(Usuarios usuario); + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/EstadosDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/EstadosDAO.java new file mode 100644 index 0000000..562a74e --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/EstadosDAO.java @@ -0,0 +1,135 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Estados; +import xforce.modelo.Proveedor; +import xforce.modelo.Usuarios; + +/** + * + * @author Samuel Gamez + */ +public class EstadosDAO { + + private EntityManager em;//Manejador de entidades + + public EstadosDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Estados estados) { + em.getTransaction().begin(); + estados.setEstado(2); + em.persist(estados);//Almacenar en DB + em.getTransaction().commit(); + } + + public boolean eliminar(Estados estados) { + if (buscarId(estados) == null) { + return false; + } else { + // Iniciar transacción + em.getTransaction().begin(); + + // Obtener proveedor actualizado desde la base de datos + Estados estadosPersistente = em.find(Estados.class, estados.getId()); + + // Conservar datos existentes + estados.setNombre(estadosPersistente.getNombre()); + + // Modificar solo el estado + estados.setEstado(1); + em.merge(estados); + em.getTransaction().commit(); + + return true; + } + + } + + public Estados buscarId(Estados estados) { + Query q = em.createNamedQuery("Estados.findById"); + q.setParameter("id", estados.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Estados) q.getResultList().get(0); + } + + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Estados.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + if (s == 2) { + System.out.println("Activos"); + } else { + System.out.println("Inactivos"); + } + return q.getResultList(); + } + + public Estados buscarPorNombre(Estados estados) { + Query q = em.createNamedQuery("Estados.findByNombre"); + q.setParameter("nombre", estados.getNombre()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Estados) q.getResultList().get(0); + } + } + + public Optional buscarEstado(Estados estados) { + + Query q1 = em.createNamedQuery("Estados.findByNombre"); + q1.setParameter("nombre", estados.getNombre()); + + Query q2 = em.createNamedQuery("Estados.findByEstado"); + q2.setParameter("estado", estados.getEstado()); + + List resultadoNombre = q1.getResultList(); + List resultadoEstado = q2.getResultList(); + + // Verifica si hay resultados para todos los campos + if (!resultadoNombre.isEmpty() + && !resultadoEstado.isEmpty()) { + // Compara si el mismo autor está en los tres resultados + Estados estadosEncontrado = resultadoNombre.stream() + .filter(resultadoEstado::contains) + .findFirst() + .orElse(null); + + return Optional.ofNullable(estadosEncontrado); + } else { + // Devuelve Optional vacío para indicar ausencia de resultados + return Optional.empty(); + } + } + + public List buscarPaisesReferenciadosProveedor(Estados id) { + Query q = em.createQuery("SELECT p FROM Proveedor p WHERE p.estado = 2 and p.estadosId = :idEstados"); + q.setParameter("idEstados", id); + return q.getResultList(); + } + + public List buscarPaisesReferenciadosUsuarios(Estados id) { + Query q = em.createQuery("SELECT u FROM Usuarios u WHERE u.estado = 2 and u.estadosId = :idEstados"); + q.setParameter("idEstados", id); + return q.getResultList(); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/LoginDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/LoginDAO.java new file mode 100644 index 0000000..d455e9f --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/LoginDAO.java @@ -0,0 +1,64 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Usuarios; + +/** + * + * @author Samuel Gamez + */ +public class LoginDAO { + + private EntityManager em; + + public LoginDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public Optional login(Usuarios usuarios) { + Query q1 = em.createNamedQuery("Usuarios.findByNombre"); + q1.setParameter("nombre", usuarios.getNombre()); + + Query q2 = em.createNamedQuery("Usuarios.findByContrasenia"); + q2.setParameter("contrasenia", usuarios.getContrasenia()); + + Query q3 = em.createNamedQuery("Usuarios.findByEstado"); + q3.setParameter("estado", usuarios.getEstado()); + + List resNombre = q1.getResultList(); + List resContrasenia = q2.getResultList(); + List resEstado = q3.getResultList(); + + if (!resNombre.isEmpty() && !resContrasenia.isEmpty()) { + Usuarios usuarioEncontrado = resNombre.stream() + .filter(resContrasenia::contains) + .filter(resEstado::contains) + .findFirst() + .orElse(null); + return Optional.ofNullable(usuarioEncontrado); + } else { + return Optional.empty(); + } + } + + public String rol(Usuarios usuarios) { + + Query q = em.createQuery("SELECT u.rolesId.rol FROM Usuarios u WHERE u.nombre = :nombre AND u.contrasenia = :contrasenia AND u.estado = :estado"); + q.setParameter("nombre", usuarios.getNombre()); + q.setParameter("contrasenia", usuarios.getContrasenia()); + q.setParameter("estado", usuarios.getEstado()); + + return (String) q.getSingleResult(); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/MarcaDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/MarcaDAO.java new file mode 100644 index 0000000..f421265 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/MarcaDAO.java @@ -0,0 +1,112 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Marca; +import xforce.modelo.Proveedor; + +/** + * + * @author hugoa + */ +public class MarcaDAO { + + private EntityManager em; + + public MarcaDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Marca a) { + em.getTransaction().begin(); + a.setEstado(2); + em.persist(a);//almacena en la base de datos + em.getTransaction().commit(); + } + + public boolean editar(Marca a) { + if (buscarId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Marca a) { + if (buscarId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a); //eliminar en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public Marca buscarId(Marca a) { + Query q = em.createNamedQuery("Marca.findById"); + q.setParameter("id", a.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Marca) q.getResultList().get(0); + } + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Marca.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + return q.getResultList(); + } + + public Marca buscarPorNombre(Marca marca) { + Query q = em.createNamedQuery("Marca.findByNombre"); + q.setParameter("nombre", marca.getNombre()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Marca) q.getResultList().get(0); + } + + } + + public List buscarMarcasReferenciadas(Marca id) { + Query q = em.createQuery("SELECT p FROM Proveedor p WHERE p.estado = 2 and p.marcaId = :idMarca"); + q.setParameter("idMarca", id); + return q.getResultList(); +} + + public Optional buscarMarca(Marca a) { + Query ql = em.createNamedQuery("Marca.findByNombre"); + ql.setParameter("nombre", a.getNombre()); + Query q2 = em.createNamedQuery("Marca.findByEstado"); + q2.setParameter("estado", a.getEstado()); + List resNombre = ql.getResultList(); + List resEstado = q2.getResultList(); + + if (!resNombre.isEmpty() && !resEstado.isEmpty()) { + Marca marcaEncontrada = resNombre.stream() + .filter(resEstado::contains) + .findFirst() + .orElse(null); + return Optional.ofNullable(marcaEncontrada); + } else { + return Optional.empty(); + } + + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/PaisesDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/PaisesDAO.java new file mode 100644 index 0000000..4ddd8a7 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/PaisesDAO.java @@ -0,0 +1,139 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Estados; +import xforce.modelo.Paises; + +/** + * + * @author Samuel Gamez + */ +public class PaisesDAO { + + private EntityManager em;//Manejador de entidades + + public PaisesDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Paises paises) { + em.getTransaction().begin(); + paises.setEstado(2); + em.persist(paises);//Almacenar en DB + em.getTransaction().commit(); + } + + public boolean editar(Paises paises) { + if (buscarId(paises) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(paises);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Paises paises) { + if (buscarId(paises) == null) { + return false; + } else { + // Iniciar transacción + em.getTransaction().begin(); + + // Obtener proveedor actualizado desde la base de datos + Paises paisesPersistente = em.find(Paises.class, paises.getId()); + + // Conservar datos existentes + paises.setNombre(paisesPersistente.getNombre()); + + // Modificar solo el estado + paises.setEstado(1); + em.merge(paises); + em.getTransaction().commit(); + + return true; + } + + } + + public Paises buscarId(Paises paises) { + Query q = em.createNamedQuery("Paises.findById"); + q.setParameter("id", paises.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Paises) q.getResultList().get(0); + } + + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Paises.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + if (s == 2) { + System.out.println("Activos"); + } else { + System.out.println("Inactivos"); + } + return q.getResultList(); + } + + public Paises buscarPorNombre(Paises paises) { + Query q = em.createNamedQuery("Paises.findByNombre"); + q.setParameter("nombre", paises.getNombre()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Paises) q.getResultList().get(0); + } + } + + public Optional buscarPaises(Paises paises) { + + Query q1 = em.createNamedQuery("Paises.findByNombre"); + q1.setParameter("nombre", paises.getNombre()); + + Query q2 = em.createNamedQuery("Paises.findByEstado"); + q2.setParameter("estado", paises.getEstado()); + + List resultadoNombre = q1.getResultList(); + List resultadoEstado = q2.getResultList(); + + // Verifica si hay resultados para todos los campos + if (!resultadoNombre.isEmpty() + && !resultadoEstado.isEmpty()) { + // Compara si el mismo autor está en los tres resultados + Paises paisesEncontrado = resultadoNombre.stream() + .filter(resultadoEstado::contains) + .findFirst() + .orElse(null); + + return Optional.ofNullable(paisesEncontrado); + } else { + // Devuelve Optional vacío para indicar ausencia de resultados + return Optional.empty(); + } + } + + public List buscarPaisesReferenciados(Paises id) { + Query q = em.createQuery("SELECT e FROM Estados e WHERE e.estado = 2 and e.paisesId = :idPaises"); + q.setParameter("idPaises", id); + return q.getResultList(); + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/ProductoDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/ProductoDAO.java new file mode 100644 index 0000000..922312e --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/ProductoDAO.java @@ -0,0 +1,185 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Producto; + +/** + * + * @author Samuel Gamez + */ +public class ProductoDAO { + + private EntityManager em;//Manejador de entidades + + public ProductoDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Producto producto) { + em.getTransaction().begin(); + producto.setEstado(2); + em.persist(producto);//Almacenar en DB + em.getTransaction().commit(); + } + + public boolean editar(Producto producto) { + if (buscarId(producto) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(producto);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Producto producto) { + if (buscarId(producto) == null) { + return false; + } else { + // Iniciar transacción + em.getTransaction().begin(); + + // Obtener proveedor actualizado desde la base de datos + Producto productoPersistente = em.find(Producto.class, producto.getId()); + + // Conservar datos existentes + producto.setNombre(productoPersistente.getNombre()); + producto.setCodigo(productoPersistente.getCodigo()); + producto.setPrecio(productoPersistente.getPrecio()); + producto.setProveedorIdproveedor(productoPersistente.getProveedorIdproveedor()); + producto.setPiezas(productoPersistente.getPiezas()); + producto.setUbicacionId(productoPersistente.getUbicacionId()); + producto.setTipoId(productoPersistente.getTipoId()); + + // Modificar solo el estado + producto.setEstado(1); + em.merge(producto); + em.getTransaction().commit(); + + return true; + } + + } + + public Producto buscarId(Producto producto) { + Query q = em.createNamedQuery("Producto.findById"); + q.setParameter("id", producto.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Producto) q.getResultList().get(0); + } + + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Producto.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + if (s == 2) { + System.out.println("Activos"); + } else { + System.out.println("Inactivos"); + } + return q.getResultList(); + } + + public Producto buscarPorNombre(Producto producto) { + Query q = em.createNamedQuery("Producto.findByNombre"); + q.setParameter("nombre", producto.getNombre()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Producto) q.getResultList().get(0); + } + } + + public List buscarPorUbicacion(int id) { + Query q = em.createQuery("SELECT p FROM Producto p WHERE p.ubicacionId.id = :idUbicacion"); + q.setParameter("idUbicacion", id); + return q.getResultList(); + } + + public List buscarPorMarca(int id) { + Query q = em.createQuery("SELECT p FROM Producto p WHERE p.ubicacionId.id = :idMarca"); + q.setParameter("idMarca", id); + return q.getResultList(); + } + + public Optional buscarProducto(Producto producto) { + + Query q1 = em.createNamedQuery("Producto.findByNombre"); + q1.setParameter("nombre", producto.getNombre()); + + Query q2 = em.createNamedQuery("Producto.findByCodigo"); + q2.setParameter("codigo", producto.getCodigo()); + + Query q3 = em.createNamedQuery("Producto.findByPrecio"); + q3.setParameter("precio", producto.getPrecio()); + + Query q4 = em.createNamedQuery("Producto.findByPiezas"); + q4.setParameter("piezas", producto.getPiezas()); + + Query q5 = em.createNamedQuery("Producto.findByEstado"); + q5.setParameter("estado", producto.getEstado()); + + Query q7 = em.createQuery("SELECT p FROM Producto p WHERE p.proveedorIdproveedor = :proveedorIdproveedor"); + q7.setParameter("proveedorIdproveedor", producto.getProveedorIdproveedor()); + + Query q8 = em.createQuery("SELECT p FROM Producto p WHERE p.ubicacionId = :ubicacionId"); + q8.setParameter("ubicacionId", producto.getUbicacionId()); + + Query q9 = em.createQuery("SELECT p FROM Producto p WHERE p.tipoId = :tipoId"); + q9.setParameter("tipoId", producto.getTipoId()); + + List resultadoNombre = q1.getResultList(); + List resultadoCodigo = q2.getResultList(); + List resultadoPrecio = q3.getResultList(); + List resultadoPiezas = q4.getResultList(); + List resultadoEstado = q5.getResultList(); + List resultadoProveedor = q7.getResultList(); + List resultadoUbicacion = q8.getResultList(); + List resultadoTipo = q9.getResultList(); + + // Verifica si hay resultados para todos los campos + if (!resultadoNombre.isEmpty() + && !resultadoCodigo.isEmpty() + && !resultadoPrecio.isEmpty() + && !resultadoPiezas.isEmpty() + && !resultadoEstado.isEmpty() + && !resultadoProveedor.isEmpty() + && !resultadoUbicacion.isEmpty() + && !resultadoTipo.isEmpty()) { + // Compara si el mismo autor está en los tres resultados + Producto productoEncontrado = resultadoNombre.stream() + .filter(resultadoCodigo::contains) + .filter(resultadoPrecio::contains) + .filter(resultadoPiezas::contains) + .filter(resultadoEstado::contains) + .filter(resultadoProveedor::contains) + .filter(resultadoUbicacion::contains) + .filter(resultadoTipo::contains) + .findFirst() + .orElse(null); + + return Optional.ofNullable(productoEncontrado); + } else { + // Devuelve Optional vacío para indicar ausencia de resultados + return Optional.empty(); + } + } +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/ProveedorDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/ProveedorDAO.java new file mode 100644 index 0000000..3c5dac3 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/ProveedorDAO.java @@ -0,0 +1,134 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Marca; +import xforce.modelo.Producto; +import xforce.modelo.Proveedor; + + +/** + * + * @author oscar + */ +public class ProveedorDAO { + private EntityManager em;//Manejador de entidades + + public ProveedorDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Proveedor a) { + em.getTransaction().begin(); + + em.persist(a);//Almacenar en DB + em.getTransaction().commit(); + } + + public boolean editar(Proveedor a) { + if (buscarPorId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Proveedor a) { + if (buscarPorId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a); //eliminar en la base de datos + em.getTransaction().commit(); + return true; + } + + } + + public Proveedor buscarPorId(Proveedor a) { + Query q = em.createNamedQuery("Proveedor.findById"); + q.setParameter("id", a.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Proveedor) q.getResultList().get(0); + } + + } + public List buscarMarcasReferenciadas(Proveedor id) { + Query q = em.createQuery("SELECT p FROM Producto p WHERE p.estado = 2 and p.proveedorIdproveedor = :idProveedor"); + q.setParameter("idProveedor", id); + return q.getResultList(); +} + + public Optional buscarproveedor(Proveedor a) { + Query ql = em.createNamedQuery("Proveedor.findByNombre"); + ql.setParameter("nombre", a.getNombre()); + + Query q2 = em.createNamedQuery("Proveedor.findByTelefono"); + q2.setParameter("telefono", a.getTelefono()); + + Query q3 = em.createNamedQuery("Proveedor.findByEmail"); + q3.setParameter("email", a.getEmail()); + + Query q4 = em.createNamedQuery("Proveedor.findByEstado"); + q4.setParameter("estado", a.getEstado()); + + List resNombre = ql.getResultList(); + List resTel = q2.getResultList(); + List resMail = q3.getResultList(); + List resEstado = q4.getResultList(); + + if (!resNombre.isEmpty()&& !resTel.isEmpty()&&!resMail.isEmpty() && !resEstado.isEmpty()) { + Proveedor proveedorEncontrada = resNombre.stream() + + .filter(resMail::contains) + .filter(resNombre::contains) + .filter(resTel::contains) + .filter(resEstado::contains) + .findFirst() + .orElse(null); + return Optional.ofNullable(proveedorEncontrada); + } else { + return Optional.empty(); + } + + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Proveedor.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + return q.getResultList(); + } + + public Proveedor buscarPorNombre(Proveedor proveedor) { + Query q = em.createNamedQuery("Proveedor.findByNombre"); + q.setParameter("nombre", proveedor.getNombre()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Proveedor) q.getResultList().get(0); + } + + } + + + + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/RolesDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/RolesDAO.java new file mode 100644 index 0000000..7e8716e --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/RolesDAO.java @@ -0,0 +1,149 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Roles; +import xforce.modelo.Usuarios; + +/** + * + * @author hugoa + */ +public class RolesDAO { + + private EntityManager em; + + public RolesDAO(){ + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Roles roles){ + em.getTransaction().begin(); + roles.setEstado(2); + em.persist(roles); + em.getTransaction().commit(); + } + + public boolean eliminar(Roles rol){ + + if (buscarId(rol) == null){ + return false; + }else{ + em.getTransaction().begin(); + Roles rolesPersistentes = em.find(Roles.class, rol.getId()); + rol.setRol(rolesPersistentes.getRol()); + rol.setEstado(1); + em.merge(rol); + em.getTransaction().commit(); + + return true; + + } + } + + public Roles buscarId(Roles rol){ + Query q = em.createNamedQuery("Roles.findById"); + q.setParameter("id", rol.getId()); + if (q.getResultList().isEmpty()) { + return null; + }else{ + return (Roles) q.getResultList().get(0); + } + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Roles.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + if (s == 2) { + System.out.println("Activos"); + } else { + System.out.println("Inactivos"); + } + return q.getResultList(); + } + + public Roles buscarPorNombre(Roles rol) { + Query q = em.createNamedQuery("Roles.findByRol"); + q.setParameter("rol", rol.getRol()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Roles) q.getResultList().get(0); + } + } + + public Optional buscarRoles(Roles rol){ + Query q1 = em.createNamedQuery("Roles.findByRol"); + q1.setParameter("rol", rol.getRol()); + + Query q2 = em.createNamedQuery("Roles.findByEstado"); + q2.setParameter("estado", rol.getEstado()); + + List resRol =q1.getResultList(); + List resEstado = q2.getResultList(); + + if (!resRol.isEmpty() && !resEstado.isEmpty()) { + Roles rolesEncontrados = resRol.stream() + .filter(resEstado::contains) + .findFirst() + .orElse(null); + + return Optional.ofNullable(rolesEncontrados); + + }else{ + return Optional.empty(); + } + } + + public List buscarUsuariosReferenciados(Roles id){ + Query q = em.createQuery("SELECT u FROM Usuarios u WHERE u.estado = 2 and u.rolesId = :idRoles"); + q.setParameter("idRoles", id); + return q.getResultList(); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/TipoDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/TipoDAO.java new file mode 100644 index 0000000..d35970e --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/TipoDAO.java @@ -0,0 +1,122 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import xforce.modelo.Tipo; +import java.util.Optional; +import javax.persistence.Query; +import xforce.modelo.Producto; +import xforce.modelo.Roles; + + +/** + * + * @author oscar + */ +public class TipoDAO { + private EntityManager em;//Manejador de entidades + + public TipoDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Tipo a) { + em.getTransaction().begin(); + a.setEstado(2); + em.persist(a);//Almacenar en DB + em.getTransaction().commit(); + } + + public Tipo buscarPorNombre(Tipo tip) { + Query q = em.createNamedQuery("Roles.findByRol"); + q.setParameter("tipo", tip.getTipo()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Tipo) q.getResultList().get(0); + } + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Tipo.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + if (s == 2) { + System.out.println("Activos"); + } else { + System.out.println("Inactivos"); + } + return q.getResultList(); + } + + + + public boolean eliminar(Tipo tip){ + + if (buscarId(tip) == null){ + return false; + }else{ + em.getTransaction().begin(); + Tipo tiposPersistentes = em.find(Tipo.class, tip.getId()); + tip.setTipo(tiposPersistentes.getTipo()); + tip.setEstado(1); + em.merge(tip); + em.getTransaction().commit(); + + return true; + + } + } + + public Optional buscarTipo(Tipo t){ +Query ql = em.createNamedQuery("Tipo.findByTipo"); + ql.setParameter("tipo", t.getTipo()); + + Query q2 = em.createNamedQuery("Tipo.findByEstado"); + q2.setParameter("estado", t.getEstado()); + + + List resTipo = ql.getResultList(); + List resEstado = q2.getResultList(); + + if (!resTipo.isEmpty()&& !resEstado.isEmpty()) { + Tipo tipoEncontrado = resTipo.stream() + + .filter(resTipo::contains) + .filter(resEstado::contains) + .findFirst() + .orElse(null); + return Optional.ofNullable(tipoEncontrado); + } else { + return Optional.empty(); + } + + } + + public Tipo buscarId(Tipo tipo){ + Query q = em.createNamedQuery("Tipo.findById"); + q.setParameter("id", tipo.getId()); + if (q.getResultList().isEmpty()) { + return null; + }else{ + return (Tipo) q.getResultList().get(0); + } + } + public List buscarTiposReferenciados(Tipo id){ + Query q = em.createQuery("SELECT p FROM Producto p WHERE p.estado = 2 and p.tipoId = :idTipo"); + q.setParameter("idTipo", id); + return q.getResultList(); + } + + +} \ No newline at end of file diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/UbicacionDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/UbicacionDAO.java new file mode 100644 index 0000000..e8a0eb6 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/UbicacionDAO.java @@ -0,0 +1,127 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Producto; +import xforce.modelo.Ubicacion; + +/** + * + * @author oscar + */ +public class UbicacionDAO { + + private EntityManager em;//Manejador de entidades + + public UbicacionDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Ubicacion a) { + em.getTransaction().begin(); + a.setEstado(2); + em.persist(a);//Almacenar en DB + em.getTransaction().commit(); + } + + public boolean editar(Ubicacion a) { + if (buscarPorId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Ubicacion a) { + if (buscarPorId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a); //eliminar en la base de datos + em.getTransaction().commit(); + return true; + } + + } + + public Ubicacion buscarPorId(Ubicacion a) { + Query q = em.createNamedQuery("Ubicacion.findById"); + q.setParameter("id", a.getId()); + + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Ubicacion) q.getResultList().get(0); + } + + } + + public Optional buscaUbicacion(Ubicacion a) { + Query q1 = em.createNamedQuery("Ubicacion.findByAnaquel"); + q1.setParameter("anaquel", a.getAnaquel()); + + Query q2 = em.createNamedQuery("Ubicacion.findByBloque"); + q2.setParameter("bloque", a.getBloque()); + + Query q3 = em.createNamedQuery("Ubicacion.findByEstado"); + q3.setParameter("estado", a.getEstado()); + + List resultadoAnaquel = q1.getResultList(); + List resultadoBloque = q2.getResultList(); + List resultadoEstado = q3.getResultList(); + + // Verifica si hay resultados para todos los campos + if (!resultadoAnaquel.isEmpty() && !resultadoBloque.isEmpty() && !resultadoEstado.isEmpty()) { + // Compara si el mismo autor está en los tres resultados + Ubicacion ubicacionEncontrada = resultadoAnaquel.stream() + .filter(resultadoBloque::contains) + .filter(resultadoEstado::contains) + .filter(resultadoEstado::contains) + .findFirst() + .orElse(null); + + return Optional.ofNullable(ubicacionEncontrada); + } else { + // Devuelve Optional vacío para indicar ausencia de resultados + return Optional.empty(); + } + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Ubicacion.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + return q.getResultList(); + } + + public Ubicacion buscarPorNombre(Ubicacion ubicacion) { + Query q = em.createNamedQuery("Ubicacion.findByBloque"); + q.setParameter("bloque", ubicacion.getBloque()); + + List resultados = q.getResultList(); + + if (resultados.isEmpty()) { + return null; + } else { + return (Ubicacion) q.getResultList().get(0); + } + + } + public List buscarMarcasReferenciadas(Ubicacion id) { + Query q = em.createQuery("SELECT p FROM Producto p WHERE p.estado = 2 and p.ubicacionId = :idubi"); + q.setParameter("idubi", id); + return q.getResultList(); +} +} diff --git a/ProyectoInventario-ejb/src/java/xforce/dao/UsuariosDAO.java b/ProyectoInventario-ejb/src/java/xforce/dao/UsuariosDAO.java new file mode 100644 index 0000000..9acd2a6 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/dao/UsuariosDAO.java @@ -0,0 +1,140 @@ +/* + * 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 xforce.dao; + +import java.util.List; +import java.util.Optional; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import xforce.modelo.Usuarios; + +/** + * + * @author hugoa + */ +public class UsuariosDAO { + + private EntityManager em; + + public UsuariosDAO() { + EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProyectoInventario-ejbPU"); + em = emf.createEntityManager(); + } + + public void agregar(Usuarios a) { + em.getTransaction().begin(); + a.setEstado(2); + em.persist(a);//almacena en la base de datos + em.getTransaction().commit(); + } + + public boolean editar(Usuarios a) { + if (buscarId(a) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(a);//edita en la base de datos + em.getTransaction().commit(); + return true; + } + } + + public boolean eliminar(Usuarios usuario) { + if (buscarId(usuario) == null) { + return false; + } else { + em.getTransaction().begin(); + em.merge(usuario); + // Finalizar transacción + em.getTransaction().commit(); + + return true; + } + } + + public Usuarios buscarId(Usuarios a) { + Query q = em.createNamedQuery("Usuarios.findById"); + q.setParameter("id", a.getId()); + if (q.getResultList().isEmpty()) { + return null; + } else { + System.out.println(q.getResultList()); + return (Usuarios) q.getResultList().get(0); + } + } + + public List buscarValidos(boolean status) { + Query q = em.createNamedQuery("Usuarios.findByEstado"); + int s = status ? 2 : 1; + q.setParameter("estado", s); + return q.getResultList(); + } + + public Usuarios buscarPorNombre(Usuarios usuario) { + Query q = em.createNamedQuery("Usuarios.findByNombre"); + q.setParameter("nombre", usuario.getNombre()); + if (q.getResultList().isEmpty()) { + return null; + } else { + return (Usuarios) q.getResultList().get(0); + } + } + + public Optional buscarUsuario(Usuarios a) { + Query ql = em.createNamedQuery("Usuarios.findByNombre"); + ql.setParameter("nombre", a.getNombre()); + + Query q2 = em.createNamedQuery("Usuarios.findByApellidoPaterno"); + q2.setParameter("apellidoPaterno", a.getApellidoPaterno()); + + Query q3 = em.createNamedQuery("Usuarios.findByEmail"); + q3.setParameter("email", a.getEmail()); + + Query q4 = em.createNamedQuery("Usuarios.findByTelefono"); + q4.setParameter("telefono", a.getTelefono()); + + Query q5 = em.createNamedQuery("Usuarios.findByContrasenia"); + q5.setParameter("contrasenia", a.getContrasenia()); + + Query q6 = em.createNamedQuery("Usuarios.findByDomicilio"); + q6.setParameter("domicilio", a.getDomicilio()); + + Query q7 = em.createQuery("SELECT u FROM Usuarios u WHERE u.rolesId = :id"); + q7.setParameter("id", a.getRolesId()); + + Query q8 = em.createQuery("SELECT u FROM Usuarios u WHERE u.estadosId = :id"); + q8.setParameter("id", a.getEstadosId()); + + List resNombre = ql.getResultList(); + List resApellidoPaterno = q2.getResultList(); + List resEmail = q3.getResultList(); + List resTelefono = q4.getResultList(); + List resContrasenia = q5.getResultList(); + List resDomicilio = q6.getResultList(); + List resRol = q7.getResultList(); + List resEstados = q8.getResultList(); + + if (!resNombre.isEmpty() && !resApellidoPaterno.isEmpty() && !resEmail.isEmpty() && !resTelefono.isEmpty() && !resContrasenia.isEmpty() && !resDomicilio.isEmpty() + && !resRol.isEmpty() && !resEstados.isEmpty()) { + Usuarios usuarioEncontrado = resNombre.stream() + .filter(resApellidoPaterno::contains) + .filter(resEmail::contains) + .filter(resTelefono::contains) + .filter(resContrasenia::contains) + .filter(resDomicilio::contains) + .filter(resRol::contains) + .filter(resEstados::contains) + .findFirst() + .orElse(null); + return Optional.ofNullable(usuarioEncontrado); + } else { + return Optional.empty(); + } + + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Estados.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Estados.java new file mode 100644 index 0000000..8d3cee3 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Estados.java @@ -0,0 +1,152 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "estados", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Estados.findAll", query = "SELECT e FROM Estados e"), + @NamedQuery(name = "Estados.findById", query = "SELECT e FROM Estados e WHERE e.id = :id"), + @NamedQuery(name = "Estados.findByNombre", query = "SELECT e FROM Estados e WHERE e.nombre = :nombre"), + @NamedQuery(name = "Estados.findByEstado", query = "SELECT e FROM Estados e WHERE e.estado = :estado")}) +public class Estados 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 = 45) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "estadosId") + private List proveedorList; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "estadosId") + private List usuariosList; + @JoinColumn(name = "paises_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Paises paisesId; + + public Estados() { + } + + public Estados(Integer id) { + this.id = id; + } + + public Estados(Integer id, String nombre, int estado) { + this.id = id; + this.nombre = nombre; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getProveedorList() { + return proveedorList; + } + + public void setProveedorList(List proveedorList) { + this.proveedorList = proveedorList; + } + + @XmlTransient + public List getUsuariosList() { + return usuariosList; + } + + public void setUsuariosList(List usuariosList) { + this.usuariosList = usuariosList; + } + + public Paises getPaisesId() { + return paisesId; + } + + public void setPaisesId(Paises paisesId) { + this.paisesId = paisesId; + } + + @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 Estados)) { + return false; + } + Estados other = (Estados) 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 "xforce.modelo.Estados[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Marca.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Marca.java new file mode 100644 index 0000000..32b1ac3 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Marca.java @@ -0,0 +1,128 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "marca", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Marca.findAll", query = "SELECT m FROM Marca m"), + @NamedQuery(name = "Marca.findById", query = "SELECT m FROM Marca m WHERE m.id = :id"), + @NamedQuery(name = "Marca.findByNombre", query = "SELECT m FROM Marca m WHERE m.nombre = :nombre"), + @NamedQuery(name = "Marca.findByEstado", query = "SELECT m FROM Marca m WHERE m.estado = :estado")}) +public class Marca 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 = 100) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "marcaId") + private List proveedorList; + + public Marca() { + } + + public Marca(Integer id) { + this.id = id; + } + + public Marca(Integer id, String nombre, int estado) { + this.id = id; + this.nombre = nombre; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getProveedorList() { + return proveedorList; + } + + public void setProveedorList(List proveedorList) { + this.proveedorList = proveedorList; + } + + @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 Marca)) { + return false; + } + Marca other = (Marca) 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 "xforce.modelo.Marca[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Paises.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Paises.java new file mode 100644 index 0000000..1b44ac0 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Paises.java @@ -0,0 +1,128 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "paises", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Paises.findAll", query = "SELECT p FROM Paises p"), + @NamedQuery(name = "Paises.findById", query = "SELECT p FROM Paises p WHERE p.id = :id"), + @NamedQuery(name = "Paises.findByNombre", query = "SELECT p FROM Paises p WHERE p.nombre = :nombre"), + @NamedQuery(name = "Paises.findByEstado", query = "SELECT p FROM Paises p WHERE p.estado = :estado")}) +public class Paises 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 = 100) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "paisesId") + private List estadosList; + + public Paises() { + } + + public Paises(Integer id) { + this.id = id; + } + + public Paises(Integer id, String nombre, int estado) { + this.id = id; + this.nombre = nombre; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getEstadosList() { + return estadosList; + } + + public void setEstadosList(List estadosList) { + this.estadosList = estadosList; + } + + @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 Paises)) { + return false; + } + Paises other = (Paises) 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 "xforce.modelo.Paises[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Producto.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Producto.java new file mode 100644 index 0000000..1f2a95a --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Producto.java @@ -0,0 +1,208 @@ +/* + * 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 xforce.modelo; + +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.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 Samuel Gamez + */ +@Entity +@Table(name = "producto", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Producto.findAll", query = "SELECT p FROM Producto p"), + @NamedQuery(name = "Producto.findById", query = "SELECT p FROM Producto p WHERE p.id = :id"), + @NamedQuery(name = "Producto.findByNombre", query = "SELECT p FROM Producto p WHERE p.nombre = :nombre"), + @NamedQuery(name = "Producto.findByCodigo", query = "SELECT p FROM Producto p WHERE p.codigo = :codigo"), + @NamedQuery(name = "Producto.findByPrecio", query = "SELECT p FROM Producto p WHERE p.precio = :precio"), + @NamedQuery(name = "Producto.findByPiezas", query = "SELECT p FROM Producto p WHERE p.piezas = :piezas"), + @NamedQuery(name = "Producto.findByEstado", query = "SELECT p FROM Producto p WHERE p.estado = :estado"), + @NamedQuery(name = "Producto.findByFecha", query = "SELECT p FROM Producto p WHERE p.fecha = :fecha")}) +public class Producto 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 = 100) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Column(name = "codigo") + private int codigo; + @Basic(optional = false) + @NotNull + @Column(name = "precio") + private float precio; + @Basic(optional = false) + @NotNull + @Column(name = "piezas") + private int piezas; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @Basic(optional = false) + @NotNull + @Column(name = "fecha") + @Temporal(TemporalType.DATE) + private Date fecha; + @JoinColumn(name = "proveedor_idproveedor", referencedColumnName = "id") + @ManyToOne(optional = false) + private Proveedor proveedorIdproveedor; + @JoinColumn(name = "tipo_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Tipo tipoId; + @JoinColumn(name = "ubicacion_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Ubicacion ubicacionId; + + public Producto() { + } + + public Producto(Integer id) { + this.id = id; + } + + public Producto(Integer id, String nombre, int codigo, float precio, int piezas, int estado, Date fecha) { + this.id = id; + this.nombre = nombre; + this.codigo = codigo; + this.precio = precio; + this.piezas = piezas; + this.estado = estado; + this.fecha = fecha; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getCodigo() { + return codigo; + } + + public void setCodigo(int codigo) { + this.codigo = codigo; + } + + public float getPrecio() { + return precio; + } + + public void setPrecio(float precio) { + this.precio = precio; + } + + public int getPiezas() { + return piezas; + } + + public void setPiezas(int piezas) { + this.piezas = piezas; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + public Date getFecha() { + return fecha; + } + + public void setFecha(Date fecha) { + this.fecha = fecha; + } + + public Proveedor getProveedorIdproveedor() { + return proveedorIdproveedor; + } + + public void setProveedorIdproveedor(Proveedor proveedorIdproveedor) { + this.proveedorIdproveedor = proveedorIdproveedor; + } + + public Tipo getTipoId() { + return tipoId; + } + + public void setTipoId(Tipo tipoId) { + this.tipoId = tipoId; + } + + public Ubicacion getUbicacionId() { + return ubicacionId; + } + + public void setUbicacionId(Ubicacion ubicacionId) { + this.ubicacionId = ubicacionId; + } + + @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 Producto)) { + return false; + } + Producto other = (Producto) 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 "xforce.modelo.Producto[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Proveedor.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Proveedor.java new file mode 100644 index 0000000..31a22f3 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Proveedor.java @@ -0,0 +1,198 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "proveedor", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Proveedor.findAll", query = "SELECT p FROM Proveedor p"), + @NamedQuery(name = "Proveedor.findById", query = "SELECT p FROM Proveedor p WHERE p.id = :id"), + @NamedQuery(name = "Proveedor.findByNombre", query = "SELECT p FROM Proveedor p WHERE p.nombre = :nombre"), + @NamedQuery(name = "Proveedor.findByTelefono", query = "SELECT p FROM Proveedor p WHERE p.telefono = :telefono"), + @NamedQuery(name = "Proveedor.findByEmail", query = "SELECT p FROM Proveedor p WHERE p.email = :email"), + @NamedQuery(name = "Proveedor.findByEstado", query = "SELECT p FROM Proveedor p WHERE p.estado = :estado"), + @NamedQuery(name = "Proveedor.findByDomicilio", query = "SELECT p FROM Proveedor p WHERE p.domicilio = :domicilio")}) +public class Proveedor 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 = 100) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 10) + @Column(name = "telefono") + private String telefono; + // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 100) + @Column(name = "email") + private String email; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 100) + @Column(name = "domicilio") + private String domicilio; + @JoinColumn(name = "estados_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Estados estadosId; + @JoinColumn(name = "marca_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Marca marcaId; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "proveedorIdproveedor") + private List productoList; + + public Proveedor() { + } + + public Proveedor(Integer id) { + this.id = id; + } + + public Proveedor(Integer id, String nombre, String telefono, String email, int estado, String domicilio) { + this.id = id; + this.nombre = nombre; + this.telefono = telefono; + this.email = email; + this.estado = estado; + this.domicilio = domicilio; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getTelefono() { + return telefono; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + public String getDomicilio() { + return domicilio; + } + + public void setDomicilio(String domicilio) { + this.domicilio = domicilio; + } + + public Estados getEstadosId() { + return estadosId; + } + + public void setEstadosId(Estados estadosId) { + this.estadosId = estadosId; + } + + public Marca getMarcaId() { + return marcaId; + } + + public void setMarcaId(Marca marcaId) { + this.marcaId = marcaId; + } + + @XmlTransient + public List getProductoList() { + return productoList; + } + + public void setProductoList(List productoList) { + this.productoList = productoList; + } + + @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 Proveedor)) { + return false; + } + Proveedor other = (Proveedor) 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 "xforce.modelo.Proveedor[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Roles.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Roles.java new file mode 100644 index 0000000..e1c9df4 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Roles.java @@ -0,0 +1,128 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "roles", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Roles.findAll", query = "SELECT r FROM Roles r"), + @NamedQuery(name = "Roles.findById", query = "SELECT r FROM Roles r WHERE r.id = :id"), + @NamedQuery(name = "Roles.findByRol", query = "SELECT r FROM Roles r WHERE r.rol = :rol"), + @NamedQuery(name = "Roles.findByEstado", query = "SELECT r FROM Roles r WHERE r.estado = :estado")}) +public class Roles 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 = 45) + @Column(name = "rol") + private String rol; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "rolesId") + private List usuariosList; + + public Roles() { + } + + public Roles(Integer id) { + this.id = id; + } + + public Roles(Integer id, String rol, int estado) { + this.id = id; + this.rol = rol; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getRol() { + return rol; + } + + public void setRol(String rol) { + this.rol = rol; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getUsuariosList() { + return usuariosList; + } + + public void setUsuariosList(List usuariosList) { + this.usuariosList = usuariosList; + } + + @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 Roles)) { + return false; + } + Roles other = (Roles) 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 "xforce.modelo.Roles[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Tipo.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Tipo.java new file mode 100644 index 0000000..f5b05f6 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Tipo.java @@ -0,0 +1,128 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "tipo", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Tipo.findAll", query = "SELECT t FROM Tipo t"), + @NamedQuery(name = "Tipo.findById", query = "SELECT t FROM Tipo t WHERE t.id = :id"), + @NamedQuery(name = "Tipo.findByTipo", query = "SELECT t FROM Tipo t WHERE t.tipo = :tipo"), + @NamedQuery(name = "Tipo.findByEstado", query = "SELECT t FROM Tipo t WHERE t.estado = :estado")}) +public class Tipo 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 = 45) + @Column(name = "tipo") + private String tipo; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoId") + private List productoList; + + public Tipo() { + } + + public Tipo(Integer id) { + this.id = id; + } + + public Tipo(Integer id, String tipo, int estado) { + this.id = id; + this.tipo = tipo; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTipo() { + return tipo; + } + + public void setTipo(String tipo) { + this.tipo = tipo; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getProductoList() { + return productoList; + } + + public void setProductoList(List productoList) { + this.productoList = productoList; + } + + @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 Tipo)) { + return false; + } + Tipo other = (Tipo) 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 "xforce.modelo.Tipo[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Ubicacion.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Ubicacion.java new file mode 100644 index 0000000..b340f78 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Ubicacion.java @@ -0,0 +1,146 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +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.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 Samuel Gamez + */ +@Entity +@Table(name = "ubicacion", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Ubicacion.findAll", query = "SELECT u FROM Ubicacion u"), + @NamedQuery(name = "Ubicacion.findById", query = "SELECT u FROM Ubicacion u WHERE u.id = :id"), + @NamedQuery(name = "Ubicacion.findByBloque", query = "SELECT u FROM Ubicacion u WHERE u.bloque = :bloque"), + @NamedQuery(name = "Ubicacion.findByAnaquel", query = "SELECT u FROM Ubicacion u WHERE u.anaquel = :anaquel"), + @NamedQuery(name = "Ubicacion.findByEstado", query = "SELECT u FROM Ubicacion u WHERE u.estado = :estado")}) +public class Ubicacion 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 = 1) + @Column(name = "bloque") + private String bloque; + @Basic(optional = false) + @NotNull + @Column(name = "anaquel") + private int anaquel; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "ubicacionId") + private List productoList; + + public Ubicacion() { + } + + public Ubicacion(Integer id) { + this.id = id; + } + + public Ubicacion(Integer id, String bloque, int anaquel, int estado) { + this.id = id; + this.bloque = bloque; + this.anaquel = anaquel; + this.estado = estado; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBloque() { + return bloque; + } + + public void setBloque(String bloque) { + this.bloque = bloque; + } + + public int getAnaquel() { + return anaquel; + } + + public void setAnaquel(int anaquel) { + this.anaquel = anaquel; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + @XmlTransient + public List getProductoList() { + return productoList; + } + + public void setProductoList(List productoList) { + this.productoList = productoList; + } + + @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 Ubicacion)) { + return false; + } + Ubicacion other = (Ubicacion) 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 "xforce.modelo.Ubicacion[ id=" + id + " ]"; + } + + public String getLugar() { + return bloque + anaquel; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/modelo/Usuarios.java b/ProyectoInventario-ejb/src/java/xforce/modelo/Usuarios.java new file mode 100644 index 0000000..8428256 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/modelo/Usuarios.java @@ -0,0 +1,213 @@ +/* + * 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 xforce.modelo; + +import java.io.Serializable; +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.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author Samuel Gamez + */ +@Entity +@Table(name = "usuarios", catalog = "inventarioalmacen", schema = "") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Usuarios.findAll", query = "SELECT u FROM Usuarios u"), + @NamedQuery(name = "Usuarios.findById", query = "SELECT u FROM Usuarios u WHERE u.id = :id"), + @NamedQuery(name = "Usuarios.findByNombre", query = "SELECT u FROM Usuarios u WHERE u.nombre = :nombre"), + @NamedQuery(name = "Usuarios.findByApellidoPaterno", query = "SELECT u FROM Usuarios u WHERE u.apellidoPaterno = :apellidoPaterno"), + @NamedQuery(name = "Usuarios.findByEmail", query = "SELECT u FROM Usuarios u WHERE u.email = :email"), + @NamedQuery(name = "Usuarios.findByTelefono", query = "SELECT u FROM Usuarios u WHERE u.telefono = :telefono"), + @NamedQuery(name = "Usuarios.findByEstado", query = "SELECT u FROM Usuarios u WHERE u.estado = :estado"), + @NamedQuery(name = "Usuarios.findByContrasenia", query = "SELECT u FROM Usuarios u WHERE u.contrasenia = :contrasenia"), + @NamedQuery(name = "Usuarios.findByDomicilio", query = "SELECT u FROM Usuarios u WHERE u.domicilio = :domicilio")}) +public class Usuarios 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 = 50) + @Column(name = "nombre") + private String nombre; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 50) + @Column(name = "apellidoPaterno") + private String apellidoPaterno; + // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 100) + @Column(name = "email") + private String email; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 10) + @Column(name = "telefono") + private String telefono; + @Basic(optional = false) + @NotNull + @Column(name = "estado") + private int estado; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 20) + @Column(name = "contrasenia") + private String contrasenia; + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 100) + @Column(name = "domicilio") + private String domicilio; + @JoinColumn(name = "estados_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Estados estadosId; + @JoinColumn(name = "roles_id", referencedColumnName = "id") + @ManyToOne(optional = false) + private Roles rolesId; + + public Usuarios() { + } + + public Usuarios(Integer id) { + this.id = id; + } + + public Usuarios(Integer id, String nombre, String apellidoPaterno, String email, String telefono, int estado, String contrasenia, String domicilio) { + this.id = id; + this.nombre = nombre; + this.apellidoPaterno = apellidoPaterno; + this.email = email; + this.telefono = telefono; + this.estado = estado; + this.contrasenia = contrasenia; + this.domicilio = domicilio; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellidoPaterno() { + return apellidoPaterno; + } + + public void setApellidoPaterno(String apellidoPaterno) { + this.apellidoPaterno = apellidoPaterno; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTelefono() { + return telefono; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } + + public int getEstado() { + return estado; + } + + public void setEstado(int estado) { + this.estado = estado; + } + + public String getContrasenia() { + return contrasenia; + } + + public void setContrasenia(String contrasenia) { + this.contrasenia = contrasenia; + } + + public String getDomicilio() { + return domicilio; + } + + public void setDomicilio(String domicilio) { + this.domicilio = domicilio; + } + + public Estados getEstadosId() { + return estadosId; + } + + public void setEstadosId(Estados estadosId) { + this.estadosId = estadosId; + } + + public Roles getRolesId() { + return rolesId; + } + + public void setRolesId(Roles rolesId) { + this.rolesId = rolesId; + } + + @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 Usuarios)) { + return false; + } + Usuarios other = (Usuarios) 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 "xforce.modelo.Usuarios[ id=" + id + " ]"; + } + +} diff --git a/ProyectoInventario-ejb/src/java/xforce/msg/Mensaje.java b/ProyectoInventario-ejb/src/java/xforce/msg/Mensaje.java new file mode 100644 index 0000000..5666b16 --- /dev/null +++ b/ProyectoInventario-ejb/src/java/xforce/msg/Mensaje.java @@ -0,0 +1,34 @@ +/* + * 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 xforce.msg; + +/** + * + * @author Oscar + */ +public enum Mensaje { + + SIN_ERROR, + CAMPOS_INCOMPLETOS, + DATOS_INCORRECTOS, + ELEMENTO_DUPLICADO, + NO_EXISTE, + MARCA_ERRONEA, + PROVEEDOR_ERRONEO, + UBICACION_ERRONEA, + ROL_ERRONEO, + ESTADO_ERRONEO, + TIPO_ERRONEO, + PAIS_ERRONEO, + ERROR_PRODUCTOS_ASOCIADOS, + ERROR_ROLES_ASOCIADOS, + ERROR_ESTADOS_ASOCIADOS, + ERROR_TIPOS_ASOCIADOS, + ERROR_PAISES_ASOCIADOS, + ERROR_PROVEEDORES_ASOCIADOS, + ERROR_USUARIOS_ASOCIADOS, + + +} diff --git a/ProyectoInventario-war/build.xml b/ProyectoInventario-war/build.xml new file mode 100644 index 0000000..296e693 --- /dev/null +++ b/ProyectoInventario-war/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project ProyectoInventario-war. + + + diff --git a/ProyectoInventario-war/libs/primefaces-12.0.0.jar b/ProyectoInventario-war/libs/primefaces-12.0.0.jar new file mode 100644 index 0000000..88dab24 Binary files /dev/null and b/ProyectoInventario-war/libs/primefaces-12.0.0.jar differ diff --git a/ProyectoInventario-war/nbproject/ant-deploy.xml b/ProyectoInventario-war/nbproject/ant-deploy.xml new file mode 100644 index 0000000..fdc06d5 --- /dev/null +++ b/ProyectoInventario-war/nbproject/ant-deploy.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-war/nbproject/build-impl.xml b/ProyectoInventario-war/nbproject/build-impl.xml new file mode 100644 index 0000000..8c99d09 --- /dev/null +++ b/ProyectoInventario-war/nbproject/build-impl.xml @@ -0,0 +1,1490 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-war/nbproject/faces-config.NavData b/ProyectoInventario-war/nbproject/faces-config.NavData new file mode 100644 index 0000000..187ec92 --- /dev/null +++ b/ProyectoInventario-war/nbproject/faces-config.NavData @@ -0,0 +1,6 @@ + + + + + + diff --git a/ProyectoInventario-war/nbproject/genfiles.properties b/ProyectoInventario-war/nbproject/genfiles.properties new file mode 100644 index 0000000..fb174f9 --- /dev/null +++ b/ProyectoInventario-war/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=15a8da94 +build.xml.script.CRC32=d42f2f65 +build.xml.stylesheet.CRC32=1707db4f@1.96.0.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=15a8da94 +nbproject/build-impl.xml.script.CRC32=34c0a0b2 +nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.96.0.1 diff --git a/ProyectoInventario-war/nbproject/project.xml b/ProyectoInventario-war/nbproject/project.xml new file mode 100644 index 0000000..49ea03c --- /dev/null +++ b/ProyectoInventario-war/nbproject/project.xml @@ -0,0 +1,40 @@ + + + org.netbeans.modules.web.project + + + ProyectoInventario-war + 1.6.5 + + + + ${reference.ProyectoInventario-ejb.dist} + + + ${file.reference.primefaces-12.0.0.jar} + WEB-INF/lib + + + + + + + + + + + + ..\.\lib\nblibraries.properties + + + + ProyectoInventario-ejb + jar + + dist + clean + dist + + + + diff --git a/ProyectoInventario-war/src/conf/MANIFEST.MF b/ProyectoInventario-war/src/conf/MANIFEST.MF new file mode 100644 index 0000000..58630c0 --- /dev/null +++ b/ProyectoInventario-war/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/ProyectoInventario-war/src/java/xforce/seguridad/AutorizacionListener.java b/ProyectoInventario-war/src/java/xforce/seguridad/AutorizacionListener.java new file mode 100644 index 0000000..6b4825c --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/seguridad/AutorizacionListener.java @@ -0,0 +1,63 @@ +/* + * 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 xforce.seguridad; + +import java.io.IOException; +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import javax.faces.application.NavigationHandler; +import javax.faces.context.FacesContext; +import javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "autorizacionListener") +@SessionScoped +public class AutorizacionListener implements PhaseListener { + + /** + * Creates a new instance of AutorizacionListener + */ + public AutorizacionListener() { + } + + private static final long serialVersionUID = 1L; + + @Override + public void afterPhase(PhaseEvent event) { + try { + //Obtener la pagina actual para validar la sesion + String paginaActual = event.getFacesContext().getViewRoot().getViewId(); + + //inicializar la sesion en caso de no haber sesion + DemoBeanLogin.getSession(); + + //Revisar que no sea la pafina index y que no estes logueado + //para redireccionar + if (!paginaActual.contains("index.xhtml") && DemoBeanLogin.getEstatus() == false) { + FacesContext.getCurrentInstance().getExternalContext().redirect("faces/index.xhtml?faces-redirect=true"); + + NavigationHandler nh = event.getFacesContext().getApplication().getNavigationHandler(); + nh.handleNavigation(event.getFacesContext(), null, "index"); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void beforePhase(PhaseEvent event) { + } + + @Override + public PhaseId getPhaseId() { + return PhaseId.RESTORE_VIEW; + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/seguridad/DemoBeanLogin.java b/ProyectoInventario-war/src/java/xforce/seguridad/DemoBeanLogin.java new file mode 100644 index 0000000..cdc8ecb --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/seguridad/DemoBeanLogin.java @@ -0,0 +1,165 @@ +/* + * 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 xforce.seguridad; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import javax.ejb.EJB; +import javax.faces.application.FacesMessage; +import javax.faces.application.NavigationHandler; +import javax.faces.context.FacesContext; +import javax.servlet.http.HttpSession; +import xforce.bl.LoginBL; +import xforce.bl.LoginBLLocal; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "demoBeanLogin") +@SessionScoped +public class DemoBeanLogin implements Serializable { + + @EJB + private LoginBLLocal loginBL; + + //variable para manejar la sesion + public static HttpSession httpSession; + + /** + * Creates a new instance of DemoBeanLogin + */ + public DemoBeanLogin() { + } + + private Usuarios usuarios = new Usuarios(); + + private String rol; + private String user; + private static String http = "pinchilink"; + private boolean permisos = false; + + public Usuarios getUsuarios() { + return usuarios; + } + + public void setUsuarios(Usuarios usuarios) { + this.usuarios = usuarios; + } + + public String getRol() { + return rol; + } + + public void setRol(String rol) { + this.rol = rol; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public boolean isPermisos() { + return permisos; + } + + public void setPermisos(boolean permisos) { + this.permisos = permisos; + } + + public static void getSession() { + httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false); + } + + public String logout() { + //quitar atributo + //invalidar la session + System.out.println(http); + httpSession.removeAttribute(http); + httpSession.invalidate(); + return "index.xhtml"; + } + + public String login() { + //BL de autenticacion de usuario + //poner atributo + + Mensaje mensaje = loginBL.login(usuarios); + + switch (mensaje) { + case SIN_ERROR: + + rol = loginBL.rol(usuarios); + + user = usuarios.getNombre(); + + System.out.println(rol); + httpSession.setAttribute(http, "true"); + permiso(); + System.out.println(permisos); + usuarios = new Usuarios(); + return "productoLista.xhtml"; + case ELEMENTO_DUPLICADO: + return null;//"productoLista?faces-redirect=true"; // Redirecciona a la lista de productos + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + + public static boolean getEstatus() { + if (httpSession != null + && httpSession.getId() != null + && !httpSession.getId().isEmpty() + && httpSession.getAttribute("pinchilink") != null) { + return true; + } else { + return false; + } + } + + public void verificarAcceso(String rolesRequeridos) { + String[] roles = rolesRequeridos.split(","); + boolean accesoPermitido = false; + for (String rolRequerido : roles) { + if (rolRequerido.equals(rol)) { + accesoPermitido = true; + break; + } + } + if (!accesoPermitido) { + FacesContext context = FacesContext.getCurrentInstance(); + NavigationHandler handler = context.getApplication().getNavigationHandler(); + handler.handleNavigation(context, null, "productoLista.xhtml?faces-redirect=true"); + } + } + + public void permiso() { + switch (rol) { + case "admin": + permisos = true; + break; + case "vendedor": + permisos = false; + break; + case "gestor": + permisos = false; + break; + default: + throw new AssertionError(); + } + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanEstados.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanEstados.java new file mode 100644 index 0000000..156eed7 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanEstados.java @@ -0,0 +1,97 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import xforce.bl.EstadosBLLocal; +import xforce.modelo.Estados; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "demoBeanEstados") +@SessionScoped +public class DemoBeanEstados implements Serializable { + + @EJB + private EstadosBLLocal estadosBL; + + /** + * Creates a new instance of DemoBeanEstados + */ + public DemoBeanEstados() { + } + + private Estados estados = new Estados(); + + private String titulo; + + private boolean nuevo; + + public List getEstados() { + return estadosBL.buscarValidos(true); + } + + public Estados getEstado() { + return estados; + } + + public void setEstado(Estados estados) { + this.estados = estados; + } + + public String getTitulo() { + return titulo; + } + + public void setTitulo(String titulo) { + this.titulo = titulo; + } + + public String agregarEstados() { + + Mensaje mensaje = estadosBL.agregar(estados); + + switch (mensaje) { + case SIN_ERROR: + estados = new Estados(); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + PrimeFaces.current().ajax().update("productoTable:messages"); + return null;//"productoLista?faces-redirect=true"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public void eliminarEstados(Estados estados) { + nuevo = false; + this.estados = estados; + estadosBL.eliminar(estados); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + PrimeFaces.current().ajax().update("productoTable:messages"); + + } + + public void prepararNuevo() { + nuevo = true; + estados = new Estados(); + } +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanMarca.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanMarca.java new file mode 100644 index 0000000..e9248d7 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanMarca.java @@ -0,0 +1,184 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import java.util.Locale; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import org.primefaces.util.LangUtils; +import xforce.bl.MarcaBLLocal; +import xforce.modelo.Marca; +import xforce.msg.Mensaje; +import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS; +import static xforce.msg.Mensaje.DATOS_INCORRECTOS; +import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO; +import static xforce.msg.Mensaje.SIN_ERROR; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "demoBeanMarca") +@SessionScoped +public class DemoBeanMarca implements Serializable { + + @EJB + private MarcaBLLocal marcaBL; + + /** + * Creates a new instance of DemoBeanMarca + */ + + private Marca marca = new Marca(); + private String titulo; + private boolean nuevo; + private List marcaFilter; + + + + + public DemoBeanMarca() { + } + + public String agregar() { + Mensaje mensaje = marcaBL.agregar(marca); + switch (mensaje) { + case SIN_ERROR: + marca = new Marca(); + PrimeFaces.current().executeScript("PF('mar').hide()"); + PrimeFaces.current().ajax().update("marcaTable:messages"); + return "marcaLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + public String editarMarca(){ + Mensaje mensaje = marcaBL.editar(marca); + switch (mensaje) { + case SIN_ERROR: + marca = new Marca(); + PrimeFaces.current().executeScript("PF('mar').hide()"); + PrimeFaces.current().ajax().update("marcaTable:messages"); + return "marcaLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + + + +// public String buscar() { +// Marca marca = new Marca(); +// marca.setId(1); +// marcaBL.buscarId(marca); +// return "index.xhtml"; +// } +// +// public String buscarNombre() { +// Marca marca = new Marca(); +// marca.setNombre("patito"); +// marcaBL.buscarNombre(marca); +// return "index.xhtml"; +// } + + public String buscarValidos() { + System.out.println(marcaBL.buscarValidos(true)); + return "index.xhtml"; + } + + + + public List getMarcas(){ + return marcaBL.buscarValidos(true); + } + + + public Marca getMarca() { + return marca; + } + + public void setMarca(Marca marca) { + this.marca = marca; + } + + public boolean isNuevo() { + return nuevo; + } + + + public void rellenarEditar(Marca marca){ + nuevo = false; + titulo="Editando marca"; + this.marca=marca; + +} + + public String getTitulo() { + return titulo; + } + public void prepararNuevo(){ + nuevo = true; + titulo="Nueva marca"; + marca = new Marca(); + +} + public void prepararEliminar(Marca marca){ + titulo = "Eliminar Marca"; + this.marca = marca; + } + public String eliminarMarca(){ + Mensaje mensaje = marcaBL.eliminar(marca); + switch (mensaje) { + case SIN_ERROR: + PrimeFaces.current().executeScript("PF('dialogD').hide()"); + PrimeFaces.current().ajax().update("marcaTable:messages"); + return "marcaLista.xhtml"; // Redirecciona a la lista de productos + case ERROR_PRODUCTOS_ASOCIADOS: + return null; + + default: + return null; + + } + } + + public List getMarcaFilter() { + return marcaFilter; + } + + public void setMarcaFilter(List marcaFilter) { + this.marcaFilter = marcaFilter; + } + + public boolean globalFilterFunction(Object value, Object filter, Locale locale) { + String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); + if (LangUtils.isBlank(filterText)) { + return true; + } + + Marca m = (Marca) value; + + return m.getNombre().toLowerCase().contains(filterText); + } + + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanPaises.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanPaises.java new file mode 100644 index 0000000..c089958 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanPaises.java @@ -0,0 +1,126 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import xforce.bl.PaisesBLLocal; +import xforce.modelo.Paises; +import xforce.modelo.Producto; +import xforce.modelo.Tipo; +import xforce.msg.Mensaje; +import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS; +import static xforce.msg.Mensaje.DATOS_INCORRECTOS; +import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO; +import static xforce.msg.Mensaje.SIN_ERROR; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "demoBeanPaises") +@SessionScoped +public class DemoBeanPaises implements Serializable { + + @EJB + private PaisesBLLocal paisesBL; + + /** + * Creates a new instance of DemoBeaPaises + */ + public DemoBeanPaises() { + } + + private Paises paises = new Paises(); + + private String titulo; + + private boolean nuevo; + + public List getPaises() { + return paisesBL.buscarValidos(true); + } + + public Paises getPais() { + return paises; + } + + public void setPais(Paises paises) { + this.paises = paises; + } + + public String getTitulo() { + return titulo; + } + + public void setTitulo(String titulo) { + this.titulo = titulo; + } + + public String agregarPais() { + + Mensaje mensaje = paisesBL.agregar(paises); + + switch (mensaje) { + case SIN_ERROR: + paises = new Paises(); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + PrimeFaces.current().ajax().update("productoTable:messages"); + return null;//"productoLista?faces-redirect=true"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public String editarProducto() { + + Mensaje mensaje = paisesBL.editar(paises); + + switch (mensaje) { + case SIN_ERROR: + paises = new Paises(); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + PrimeFaces.current().ajax().update("productoTable:messages"); + return "productoLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public void eliminarPais(Paises paises) { + nuevo = false; + this.paises = paises; + paisesBL.eliminar(paises); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + PrimeFaces.current().ajax().update("productoTable:messages"); + + } + + public void prepararNuevo() { + nuevo = true; + paises = new Paises(); + } +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProducto.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProducto.java new file mode 100644 index 0000000..9a2422d --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProducto.java @@ -0,0 +1,178 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.time.Instant; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import org.primefaces.model.SortMeta; +import org.primefaces.util.LangUtils; +import xforce.bl.ProductoBLLocal; +import xforce.modelo.Producto; +import xforce.modelo.Tipo; +import xforce.msg.Mensaje; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "demoBeanProducto") +@SessionScoped +public class DemoBeanProducto implements Serializable { + + @EJB + private ProductoBLLocal productoBL; + + private Producto producto = new Producto(); + + private String titulo; + + private boolean nuevo; + + ///////////////////////////////////////// + private List productoFilter;/// + //////////////////////////////////////// + + private List sortBy; + + public List getSortBy() { + return sortBy; + } + + + /** + * Creates a new instance of DemoBeanProducto + */ + public DemoBeanProducto() { + } + + public String agregarProducto() { + + //producto.setFecha(Date.from(Instant.now())); + + Mensaje mensaje = productoBL.agregar(producto); + + switch (mensaje) { + case SIN_ERROR: + producto = new Producto(); + PrimeFaces.current().executeScript("PF('dialogProducto').hide()"); + PrimeFaces.current().ajax().update("productoTable:messages"); + return "productoLista.xhtml";//"productoLista?faces-redirect=true"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public String editarProducto() { + + Mensaje mensaje = productoBL.editar(producto); + + switch (mensaje) { + case SIN_ERROR: + producto = new Producto(); + PrimeFaces.current().executeScript("PF('dialogProducto').hide()"); + PrimeFaces.current().ajax().update("productoTable:messages"); + return "productoLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public void eliminarProducto() { + + productoBL.eliminar(producto); + + PrimeFaces.current().executeScript("PF('deleteProducto').hide()"); + PrimeFaces.current().ajax().update("productoTable:messages"); + + } + + public void prepararEditar(Producto producto) { + nuevo = false; + titulo = "Editando Producto"; + this.producto = producto; + } + + public void prepararNuevo() { + nuevo = true; + titulo = "Nuevo Producto"; + producto = new Producto(); + } + + public void prepararEliminar(Producto producto) { + this.producto = producto; + } + + public List getProductos() { + return productoBL.buscarValidos(true); + } + + ////////////////////////////////////////////////////////////////////// + public List getProductoFilter() { // + return productoFilter; // + } // + // + + public void setProductoFilter(List productoFilter) { // + this.productoFilter = productoFilter; // + } // + ////////////////////////////////////////////////////////////////////// + + public Producto getProducto() { + return producto; + } + + public void setProducto(Producto producto) { + this.producto = producto; + } + + public String getTitulo() { + return titulo; + } + + public boolean isNuevo() { + return nuevo; + } + + public boolean globalFilterFunction(Object value, Object filter, Locale locale) { + String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); + if (LangUtils.isBlank(filterText)) { + return true; + } + + Producto p = (Producto) value; + + return p.getNombre().toLowerCase().contains(filterText) + || String.valueOf(p.getCodigo()).contains(filterText) + || String.valueOf(p.getPrecio()).contains(filterText) + || String.valueOf(p.getPiezas()).contains(filterText) + || String.valueOf(p.getFecha()).contains(filterText) + || p.getProveedorIdproveedor().getMarcaId().getNombre().toLowerCase().contains(filterText) + || p.getProveedorIdproveedor().getNombre().toLowerCase().contains(filterText) + || p.getTipoId().getTipo().toLowerCase().contains(filterText) + || p.getUbicacionId().getLugar().toLowerCase().contains(filterText); + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProveedor.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProveedor.java new file mode 100644 index 0000000..316a1be --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanProveedor.java @@ -0,0 +1,212 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import java.util.Locale; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import org.primefaces.util.LangUtils; +import xforce.bl.ProveedorBLLocal; +import xforce.modelo.Proveedor; +import xforce.modelo.Ubicacion; +import xforce.msg.Mensaje; +import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS; +import static xforce.msg.Mensaje.DATOS_INCORRECTOS; +import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO; +import static xforce.msg.Mensaje.SIN_ERROR; + +/** + * + * @author oscar + */ +@Named(value = "demoBeanProveedor") +@SessionScoped +public class DemoBeanProveedor implements Serializable { + + @EJB + private ProveedorBLLocal proveedorBL; + + private Proveedor proveedor = new Proveedor(); + private String titulo; + private boolean nuevo; + private List proveedorFilter; + + /** + * Creates a new instance of DemoBeanProveedor + */ + public DemoBeanProveedor() { + } + +public String agregar() { + + Mensaje mensaje = proveedorBL.agregar(proveedor); + + switch (mensaje) { + case SIN_ERROR: + proveedor = new Proveedor(); + PrimeFaces.current().executeScript("PF('dialogproveedor').hide()"); + PrimeFaces.current().ajax().update("proveedorTabla:messages"); + return "proveedorLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } +} + + public List getProveedorFilter() { + return proveedorFilter; + } + + public void setProveedorFilter(List proveedorFilter) { + this.proveedorFilter = proveedorFilter; + } + + public boolean globalFilterFunction(Object value, Object filter, Locale locale) { + String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); + if (LangUtils.isBlank(filterText)) { + return true; + } + + Proveedor p = (Proveedor) value; + + return p.getNombre().toLowerCase().contains(filterText) + || p.getTelefono().contains(filterText) + || p.getEmail().contains(filterText); + } + + public void agregarProveedor() { + proveedorBL.agregar(proveedor); + } + + public String eliminar() { + Proveedor p = new Proveedor(); + p.setId(1); + proveedorBL.eliminar(p); + return "index.xhtml"; + } + + public String buscar() { + Proveedor p = new Proveedor(); + p.setId(1); + proveedorBL.buscarId(p); + return "index.xhtml"; + } + + public String buscarNombre() { + Proveedor p = new Proveedor(); + p.setNombre("DHL"); + proveedorBL.buscarNombre(p); + return "index.xhtml"; + } + + public String editar() { + + Proveedor p = new Proveedor(); + p.setId(1); + p.setNombre("comex"); + p.setEmail("comex@gmail.com"); + p.setTelefono("3433445577"); + p.setEstado(2); + + proveedorBL.editar(p); + + return "index.xhtml"; + } + + public String buscarValidos() { + System.out.println(proveedorBL.buscarValidos(true)); + return "index.xhtml"; + } + + public List getProveedores() { + return proveedorBL.buscarValidos(true); + } + + public Proveedor getProveedor() { + return proveedor; + } + + public void setProveedor(Proveedor proveedor) { + this.proveedor = proveedor; + } + + public void prepararEditar(Proveedor proveedor) { + nuevo = false; + titulo = "Editando Proveedor"; + this.proveedor = proveedor; + + } + + public String getTitulo() { + return titulo; + } + + public boolean isNuevo() { + return nuevo; + } + + public void prepararnuevo() { + nuevo = true; + titulo = "Agregando proveedor"; + proveedor = new Proveedor(); + } + + public String editarP() { + + Mensaje mensaje = proveedorBL.editar(proveedor); + switch (mensaje) { + case SIN_ERROR: + proveedor = new Proveedor(); + PrimeFaces.current().executeScript("PF('dialogproveedor').hide()"); + PrimeFaces.current().ajax().update("proveedorTabla:messages"); + return "proveedorLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public void prepararEliminar(Proveedor proveedor) { + titulo = "Eliminar proveedor"; + this.proveedor = proveedor; + } + + public String eliminarProveedor() { + Mensaje mensaje = proveedorBL.eliminar(proveedor); + + switch (mensaje) { + case SIN_ERROR: + PrimeFaces.current().executeScript("PF('deleteProveedor').hide()"); + PrimeFaces.current().ajax().update("proveedorTabla:messages"); + return "proveedorLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + case ERROR_PRODUCTOS_ASOCIADOS: + return null; + default: + return null; + } + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanRoles.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanRoles.java new file mode 100644 index 0000000..1dddc51 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanRoles.java @@ -0,0 +1,116 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import xforce.bl.RolesBLLocal; +import xforce.modelo.Roles; +import xforce.msg.Mensaje; + + +/** + * + * @author hugoa + */ +@Named(value = "demoBeanRoles") +@SessionScoped +public class DemoBeanRoles implements Serializable { + + @EJB + private RolesBLLocal rolesBL; + /** + * Creates a new instance of DemoBeanRoles + */ + + public DemoBeanRoles() { + } + + private Roles roles = new Roles(); + private boolean nuevo; + private String titulo; + + public String agregarRol(){ + Mensaje mensaje = rolesBL.agregar(roles); + + switch (mensaje) { + case SIN_ERROR: + roles = new Roles(); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + return null; + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + + public void prepararNuevo() { + nuevo = true; + titulo = "Roles"; + roles = new Roles(); + } + + public boolean isNuevo() { + return nuevo; + } + + public void eliminarRol(Roles roles) { + nuevo=false; + this.roles = roles; + rolesBL.eliminar(roles); + PrimeFaces.current().ajax().update("marcaTable:messages"); + PrimeFaces.current().ajax().update("userTable:messages"); + + } + public String getTitulo() { + return titulo; + } + public List getRoles() { + return rolesBL.buscarValidos(true); + } + + public Roles getRol() { + return roles; + } + + public void setRol(Roles rol) { + this.roles = rol; + } + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanTipo.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanTipo.java new file mode 100644 index 0000000..741ca0e --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanTipo.java @@ -0,0 +1,89 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import xforce.bl.TipoBLLocal; +import xforce.modelo.Tipo; +import xforce.msg.Mensaje; + +/** + * + * @author oscar + */ +@Named(value = "demoBeanTipo") +@SessionScoped +public class DemoBeanTipo implements Serializable { + + @EJB + private TipoBLLocal tipoBl; + private Tipo tipo = new Tipo(); + private String titulo; + private boolean nuevo; + private List proveedorFilter; + + /** + * Creates a new instance of DemoBeanTipo + */ + public DemoBeanTipo() { + } + + public String agregar() { + + Mensaje mensaje = tipoBl.agregar(tipo); + + switch (mensaje) { + case SIN_ERROR: + tipo = new Tipo(); + PrimeFaces.current().ajax().update("ubicacionTabla:messages"); + + return null; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + public void eliminarTipo(Tipo tipo) { + nuevo=false; + this.tipo = tipo; + tipoBl.eliminar(tipo); + PrimeFaces.current().ajax().update("tipT:messages"); + PrimeFaces.current().ajax().update("ubicacionTabla:messages"); + + } + + + public void prepararNuevo() { + nuevo = true; + + tipo = new Tipo(); + } + + public boolean isNuevo() { + return nuevo; + } + public List getTipos() { + return tipoBl.buscarValidos(true); + } + + public Tipo getTipo() { + return tipo; + } + + public void setTipo(Tipo tip) { + this.tipo = tip; + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUbicacion.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUbicacion.java new file mode 100644 index 0000000..24e6051 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUbicacion.java @@ -0,0 +1,213 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import java.util.Locale; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import org.primefaces.util.LangUtils; +import xforce.bl.UbicacionBLLocal; +import xforce.modelo.Marca; +import xforce.modelo.Ubicacion; +import xforce.msg.Mensaje; +import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS; +import static xforce.msg.Mensaje.DATOS_INCORRECTOS; +import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO; +import static xforce.msg.Mensaje.SIN_ERROR; + +/** + * + * @author oscar + */ +@Named(value = "demoBeanUbicacion") +@SessionScoped +public class DemoBeanUbicacion implements Serializable { + + @EJB + private UbicacionBLLocal ubicacionBL; + private Ubicacion ubicacion = new Ubicacion(); + private String titulo; + private boolean nuevo; + private List ubicacionFilter; + + /** + * Creates a new instance of DemoBeanUbicacion + */ + public DemoBeanUbicacion() { + } + + public String agregar() { + + Mensaje mensaje = ubicacionBL.agregar(ubicacion); + + switch (mensaje) { + case SIN_ERROR: + ubicacion = new Ubicacion(); + PrimeFaces.current().executeScript("PF('mar').hide()"); + PrimeFaces.current().ajax().update("ubicacionTabla:messages"); + return "ubicacionLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + + public String editarU() { + + Mensaje mensaje = ubicacionBL.editar(ubicacion); + switch (mensaje) { + + case SIN_ERROR: + PrimeFaces.current().executeScript("PF('mar').hide()"); + PrimeFaces.current().ajax().update("ubicacionTabla:messages"); + ubicacion = new Ubicacion(); + return "ubicacionLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public List getUbicacionFilter() { + return ubicacionFilter; + } + + public void setUbicacionFilter(List ubicacionFilter) { + this.ubicacionFilter = ubicacionFilter; + } + + public boolean globalFilterFunction(Object value, Object filter, Locale locale) { + String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); + if (LangUtils.isBlank(filterText)) { + return true; + } + + Ubicacion p = (Ubicacion) value; + + return p.getBloque().toLowerCase().contains(filterText) + || String.valueOf(p.getAnaquel()).contains(filterText); + } + + public void agregarUbicacion() { + ubicacionBL.agregar(ubicacion); + } + + public String eliminar() { + + Ubicacion ubi = new Ubicacion(); + ubi.setId(1); + ubicacionBL.eliminar(ubi); + + return "index.xhtml"; + } + + public String buscar() { + Ubicacion p = new Ubicacion(); + p.setId(2); + ubicacionBL.buscarId(p); + return "index.xhtml"; + } + + public String buscarNombre() { + Ubicacion p = new Ubicacion(); + p.setBloque(""); + ubicacionBL.buscaUbicacion(p); + return "index.xhtml"; + } + + public String editar() { + + Ubicacion p = new Ubicacion(); + p.setId(1); + p.setBloque(""); + p.setAnaquel(1); + p.setEstado(2); + + ubicacionBL.editar(p); + + return "index.xhtml"; + } + + public String buscarValidos() { + System.out.println(ubicacionBL.buscarValidos(true)); + return "index.xhtml"; + } + + public List getUbicacion() { + return ubicacionBL.buscarValidos(true); + } + + public Ubicacion getUbi() { + return ubicacion; + } + + public void setUbicacion(Ubicacion ubicacion) { + this.ubicacion = ubicacion; + } + + public void prepararEditar(Ubicacion ubicacion) { + nuevo = false; + titulo = "Editando ubicacion"; + this.ubicacion = ubicacion; + + } + + public String getTitulo() { + return titulo; + } + + public boolean isNuevo() { + return nuevo; + } + + public void prepararnuevo() { + nuevo = true; + titulo = "Agregando ubicacion"; + ubicacion = new Ubicacion(); + } + + public void prepararEliminar(Ubicacion ubicacion) { + + titulo="Eliminar ubicacion"; + + this.ubicacion = ubicacion; + } + + public String eliminarUbicacion() { + Mensaje mensaje = ubicacionBL.eliminar(ubicacion); + + switch (mensaje) { + + case SIN_ERROR: + PrimeFaces.current().executeScript("PF('deleteUbicacion').hide()"); + PrimeFaces.current().ajax().update("ubicacionTabla:messages"); + return "ubicacionLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUsuarios.java b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUsuarios.java new file mode 100644 index 0000000..386be56 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/DemoBeanUsuarios.java @@ -0,0 +1,182 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import java.util.List; +import java.util.Locale; +import javax.ejb.EJB; +import org.primefaces.PrimeFaces; +import org.primefaces.util.LangUtils; +import xforce.bl.UsuariosBLLocal; +import xforce.modelo.Estados; +import xforce.modelo.Usuarios; +import xforce.msg.Mensaje; +import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS; +import static xforce.msg.Mensaje.DATOS_INCORRECTOS; +import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO; +import static xforce.msg.Mensaje.SIN_ERROR; + +/** + * + * @author hugoa + */ +@Named(value = "demoBeanUsuarios") +@SessionScoped +public class DemoBeanUsuarios implements Serializable { + + @EJB + private UsuariosBLLocal usuariosBL; + + /** + * Creates a new instance of DemoBeanUsuarios + */ + private Usuarios usuario = new Usuarios(); + private String titulo; + private boolean nuevo; + private List usuariosFilter; + + public DemoBeanUsuarios() { + } + + public String agregar() { + + Estados estao = new Estados(); + estao.setId(3); + + usuario.setEstadosId(estao); + + Mensaje mensaje = usuariosBL.agregar(usuario); + switch (mensaje) { + case SIN_ERROR: + + usuario = new Usuarios(); + PrimeFaces.current().executeScript("PF('user').hide()"); + PrimeFaces.current().ajax().update("userTable:messages"); + return "usuariosLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + + } + + public void eliminarUsuario() { + usuariosBL.eliminar(usuario); + PrimeFaces.current().executeScript("PF('userD').hide()"); + PrimeFaces.current().ajax().update("userTable:messages"); + } + + public void prepararEliminar(Usuarios usuario) { + titulo = "Eliminar usuario"; + this.usuario = usuario; + } + + public String buscarValidos() { + System.out.println(usuariosBL.buscarValidos(true)); + + return "index.xhtml"; + } + + public List getUsuarios() { + return usuariosBL.buscarValidos(true); + } + + public String editarUsuario() { + Mensaje mensaje = usuariosBL.editar(usuario); + switch (mensaje) { + case SIN_ERROR: + usuario = new Usuarios(); + PrimeFaces.current().executeScript("PF('user').hide()"); + PrimeFaces.current().ajax().update("userTable:messages"); + return "usuariosLista.xhtml"; // Redirecciona a la lista de productos + case ELEMENTO_DUPLICADO: + return null; + case CAMPOS_INCOMPLETOS: + return null; + case DATOS_INCORRECTOS: + return null; + default: + return null; + } + } + + public void prepararNuevo() { + nuevo = true; + titulo = "Nuevo usuario"; + usuario = new Usuarios(); + } + + public boolean isNuevo() { + return nuevo; + } + + public void rellenarEditar(Usuarios usuario) { + nuevo = false; + titulo = "Editando usuario"; + this.usuario = usuario; + + } + + public String getTitulo() { + return titulo; + } + + public Usuarios getUsuario() { + return usuario; + } + + public void setUsuario(Usuarios usuario) { + this.usuario = usuario; + } + + public List getUsuariosFilter() { + return usuariosFilter; + } + + public void setUsuariosFilter(List usuariosFilter) { + this.usuariosFilter = usuariosFilter; + } + + public boolean globalFilterFunction(Object value, Object filter, Locale locale) { + String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); + if (LangUtils.isBlank(filterText)) { + return true; + } + + Usuarios u = (Usuarios) value; + + return u.getNombre().toLowerCase().contains(filterText) + || u.getApellidoPaterno().toLowerCase().contains(filterText) + || u.getEmail().toLowerCase().contains(filterText) + || u.getTelefono().toLowerCase().contains(filterText) + || u.getRolesId().getRol().toLowerCase().contains(filterText) + || u.getEstadosId().getNombre().toLowerCase().contains(filterText); + } + + // public String buscar() { +// Usuarios usuarios = new Usuarios(); +// +// usuarios.setId(4); +// +// usuariosBL.buscarId(usuarios); +// +// return "index.xhtml"; +// } +// +// public String buscarNombre(){ +// Usuarios usuario = new Usuarios(); +// usuario.setNombre("samuel"); +// usuariosBL.buscarNombre(usuario); +// return "index.xhtml"; +// } +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/SelectOneMenuConverter.java b/ProyectoInventario-war/src/java/xforce/vista/SelectOneMenuConverter.java new file mode 100644 index 0000000..ba0ac17 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/SelectOneMenuConverter.java @@ -0,0 +1,86 @@ +/* + * 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 xforce.vista; + +import java.util.List; +import javax.faces.component.UIComponent; +import javax.faces.component.UISelectItem; +import javax.faces.component.UISelectItems; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; + +/** + * + * @author Samuel Gamez + */ +@FacesConverter("selectOneMenuConverter") +public class SelectOneMenuConverter implements Converter{ + + @Override + public Object getAsObject(final FacesContext arg0, final UIComponent arg1, final String objectString) { + if (objectString == null) { + return null; + } + + return fromSelect(arg1, objectString); + } + + /** + * Serialize. + * + * @param object the object + * @return the string + */ + private String serialize(final Object object) { + if (object == null) { + return null; + } + return object.getClass() + "@" + object.hashCode(); + } + + /** + * From select. + * + * @param currentcomponent the currentcomponent + * @param objectString the object string + * @return the object + */ + private Object fromSelect(final UIComponent currentcomponent, final String objectString) { + + if (currentcomponent.getClass() == UISelectItem.class) { + final UISelectItem item = (UISelectItem) currentcomponent; + final Object value = item.getValue(); + if (objectString.equals(serialize(value))) { + return value; + } + } + + if (currentcomponent.getClass() == UISelectItems.class) { + final UISelectItems items = (UISelectItems) currentcomponent; + final List elements = (List) items.getValue(); + for (final Object element : elements) { + if (objectString.equals(serialize(element))) { + return element; + } + } + } + + if (!currentcomponent.getChildren().isEmpty()) { + for (final UIComponent component : currentcomponent.getChildren()) { + final Object result = fromSelect(component, objectString); + if (result != null) { + return result; + } + } + } + return null; + } + + @Override + public String getAsString(final FacesContext arg0, final UIComponent arg1, final Object object) { + return serialize(object); + } +} diff --git a/ProyectoInventario-war/src/java/xforce/vista/ventanas.java b/ProyectoInventario-war/src/java/xforce/vista/ventanas.java new file mode 100644 index 0000000..c609a44 --- /dev/null +++ b/ProyectoInventario-war/src/java/xforce/vista/ventanas.java @@ -0,0 +1,46 @@ +/* + * 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 xforce.vista; + +import javax.inject.Named; +import javax.enterprise.context.SessionScoped; +import java.io.Serializable; +import org.primefaces.PrimeFaces; +import org.primefaces.model.DialogFrameworkOptions; + +/** + * + * @author Samuel Gamez + */ +@Named(value = "ventanas") +@SessionScoped +public class ventanas implements Serializable { + + /** + * Creates a new instance of ventanas + */ + public ventanas() { + } + + //////////////////////////////////////////////////////////////////////////// + public void viewProductsCustomized() { + DialogFrameworkOptions options = DialogFrameworkOptions.builder() + .modal(true) + .width("640") + .height("340") + .contentHeight("100%") + .contentWidth("100%") + .headerElement("customheader") + .build(); + + System.out.println("si"); + PrimeFaces.current().dialog().openDynamic("paises1", options, null); + } + + public void close() { + PrimeFaces.current().dialog().closeDynamic(this); + } + +} diff --git a/ProyectoInventario-war/web/WEB-INF/faces-config.xml b/ProyectoInventario-war/web/WEB-INF/faces-config.xml new file mode 100644 index 0000000..dfc6614 --- /dev/null +++ b/ProyectoInventario-war/web/WEB-INF/faces-config.xml @@ -0,0 +1,42 @@ + + + + + + + xforce.seguridad.AutorizacionListener + + + + + * + + accesoDenegado + /productoLista.xhtml + + + + + diff --git a/ProyectoInventario-war/web/WEB-INF/glassfish-web.xml b/ProyectoInventario-war/web/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..584a477 --- /dev/null +++ b/ProyectoInventario-war/web/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/ProyectoInventario-war/web/WEB-INF/web.xml b/ProyectoInventario-war/web/WEB-INF/web.xml new file mode 100644 index 0000000..c270ea7 --- /dev/null +++ b/ProyectoInventario-war/web/WEB-INF/web.xml @@ -0,0 +1,28 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/productoLista.xhtml + + + javax.faces.CONFIG_FILES + /WEB-INF/faces-config.xml + + diff --git a/ProyectoInventario-war/web/estados.xhtml b/ProyectoInventario-war/web/estados.xhtml new file mode 100644 index 0000000..7fe5f64 --- /dev/null +++ b/ProyectoInventario-war/web/estados.xhtml @@ -0,0 +1,140 @@ + + + + + + + + +
Estados
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+ +
+ +
+ + + +
Nuevo Estado
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+
+ +
+ + + + + diff --git a/ProyectoInventario-war/web/index.html b/ProyectoInventario-war/web/index.html new file mode 100644 index 0000000..4cea0a0 --- /dev/null +++ b/ProyectoInventario-war/web/index.html @@ -0,0 +1,15 @@ + + + + + TODO supply a title + + + + +
TODO write content
+ + diff --git a/ProyectoInventario-war/web/index.xhtml b/ProyectoInventario-war/web/index.xhtml new file mode 100644 index 0000000..847879f --- /dev/null +++ b/ProyectoInventario-war/web/index.xhtml @@ -0,0 +1,64 @@ + + + + + + + + + Facelets Template + + +
+ + +

Inventario almacen

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ diff --git a/ProyectoInventario-war/web/marcaCrearEditar.xhtml b/ProyectoInventario-war/web/marcaCrearEditar.xhtml new file mode 100644 index 0000000..66c0da6 --- /dev/null +++ b/ProyectoInventario-war/web/marcaCrearEditar.xhtml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + diff --git a/ProyectoInventario-war/web/marcaEliminar.xhtml b/ProyectoInventario-war/web/marcaEliminar.xhtml new file mode 100644 index 0000000..4e5ef9e --- /dev/null +++ b/ProyectoInventario-war/web/marcaEliminar.xhtml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/marcaLista.xhtml b/ProyectoInventario-war/web/marcaLista.xhtml new file mode 100644 index 0000000..6fa2029 --- /dev/null +++ b/ProyectoInventario-war/web/marcaLista.xhtml @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ +
+
Marcas
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+ + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+ + + + + + +
+ +
+ +
+ + + + diff --git a/ProyectoInventario-war/web/paises.xhtml b/ProyectoInventario-war/web/paises.xhtml new file mode 100644 index 0000000..d714f25 --- /dev/null +++ b/ProyectoInventario-war/web/paises.xhtml @@ -0,0 +1,106 @@ + + + + + + + + +
Paises
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + +
+ +
+ +
+ + + +
Nuevo Pais
+ + + + + + + + + + + +
+ + + +
+ +
+
+ +
+ + + + diff --git a/ProyectoInventario-war/web/productoCrearEditar.xhtml b/ProyectoInventario-war/web/productoCrearEditar.xhtml new file mode 100644 index 0000000..a7304ed --- /dev/null +++ b/ProyectoInventario-war/web/productoCrearEditar.xhtml @@ -0,0 +1,150 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + diff --git a/ProyectoInventario-war/web/productoEliminar.xhtml b/ProyectoInventario-war/web/productoEliminar.xhtml new file mode 100644 index 0000000..c17680b --- /dev/null +++ b/ProyectoInventario-war/web/productoEliminar.xhtml @@ -0,0 +1,72 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/productoLista.xhtml b/ProyectoInventario-war/web/productoLista.xhtml new file mode 100644 index 0000000..fa7ac01 --- /dev/null +++ b/ProyectoInventario-war/web/productoLista.xhtml @@ -0,0 +1,452 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + +
+
+ +
+ +
+
Productos
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO: update below reference to list of available items + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ +
+ +
+ +
+
+ + + diff --git a/ProyectoInventario-war/web/proveedorCrearEditar.xhtml b/ProyectoInventario-war/web/proveedorCrearEditar.xhtml new file mode 100644 index 0000000..ec59c9b --- /dev/null +++ b/ProyectoInventario-war/web/proveedorCrearEditar.xhtml @@ -0,0 +1,94 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/proveedorEliminar.xhtml b/ProyectoInventario-war/web/proveedorEliminar.xhtml new file mode 100644 index 0000000..4cf6d83 --- /dev/null +++ b/ProyectoInventario-war/web/proveedorEliminar.xhtml @@ -0,0 +1,61 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + + +

+ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/proveedorLista.xhtml b/ProyectoInventario-war/web/proveedorLista.xhtml new file mode 100644 index 0000000..0fe9920 --- /dev/null +++ b/ProyectoInventario-war/web/proveedorLista.xhtml @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + +
+
+ +
+ +
+
Proveedores
+
+
+
+ + +
+
+
+
+ + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + +
+ +
+ + + + diff --git a/ProyectoInventario-war/web/resources/css/cssLayout.css b/ProyectoInventario-war/web/resources/css/cssLayout.css new file mode 100644 index 0000000..0bc28ba --- /dev/null +++ b/ProyectoInventario-war/web/resources/css/cssLayout.css @@ -0,0 +1,82 @@ + +#top { + position: relative; + background-color: #036fab; + color: white; + padding: 5px; + margin: 0px 0px 10px 0px; +} + +#bottom { + position: relative; + background-color: #c2dfef; + padding: 5px; + margin: 10px 0px 0px 0px; +} + + +#left { + float: left; + background-color: #000000; + padding: 5px; + width: 150px; +} + +#right { + float: right; + background-color: #000000; + padding: 5px; + width: 150px; +} +.abajo{ + position: absolute; + bottom: 0; +} +.center_content { + position: relative; + background-color: #dddddd; + padding: 5px; +} +.titulo { + +font-family: Arial Black; +font-weight: bold; + +font-size: 30px; +color: #fff; + +} +.negrita{ + font-family: Arial Black; +} +.centro{ + text-aling: center; +} +.izq{ + text-align: left; +} +.left_content { + background-color: #dddddd; + padding: 5px; + margin-left: 170px; +} + +.right_content { + background-color: #dddddd; + padding: 5px; + margin: 0px 170px 0px 170px; +} + +#top a:link, #top a:visited { + color: white; + font-weight : bold; + text-decoration: none; +} + +#top a:link:hover, #top a:visited:hover { + color: black; + font-weight : bold; + text-decoration : underline; +} + + diff --git a/ProyectoInventario-war/web/resources/css/default.css b/ProyectoInventario-war/web/resources/css/default.css new file mode 100644 index 0000000..3fde41e --- /dev/null +++ b/ProyectoInventario-war/web/resources/css/default.css @@ -0,0 +1,31 @@ +body { + background-color: #ffffff; + font-size: 12px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h1 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 25px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #000000; + text-aling: center; +} + + +a:link, a:visited { + color: #045491; + font-weight : bold; + text-decoration: none; +} + +a:link:hover, a:visited:hover { + color: #000000; + font-weight : bold; + text-decoration : underline; +} diff --git a/ProyectoInventario-war/web/roles.xhtml b/ProyectoInventario-war/web/roles.xhtml new file mode 100644 index 0000000..32d68b2 --- /dev/null +++ b/ProyectoInventario-war/web/roles.xhtml @@ -0,0 +1,93 @@ + + + + + + + + +
Roles
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nuevo Rol
+ + + + + + + + + + + + +
+ + + +
+ +
+
+ + + +
+ + + + diff --git a/ProyectoInventario-war/web/template/listas.xhtml b/ProyectoInventario-war/web/template/listas.xhtml new file mode 100644 index 0000000..02ab357 --- /dev/null +++ b/ProyectoInventario-war/web/template/listas.xhtml @@ -0,0 +1,48 @@ + + + + + + + + + + Gestor de inventario + + + + + +
+
+ Almacen, Bienvenido #{demoBeanLogin.user} + + + +
+
+ +
+ Content +
+ +
+
+
Derechos reservados XFORCE
+ + +
2024
+
+
+ +
+ + diff --git a/ProyectoInventario-war/web/template/principal.xhtml b/ProyectoInventario-war/web/template/principal.xhtml new file mode 100644 index 0000000..895ac3e --- /dev/null +++ b/ProyectoInventario-war/web/template/principal.xhtml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + Gestor de inventario + + + + + +
+
+ Almacen +
+
+ +
+
+ Left +
+
+ +
+ Content +
+
+
+
+ +
Derechos reservados XFORCE
+ + +
2024
+
+ +
+ + diff --git a/ProyectoInventario-war/web/tipos.xhtml b/ProyectoInventario-war/web/tipos.xhtml new file mode 100644 index 0000000..8e3509f --- /dev/null +++ b/ProyectoInventario-war/web/tipos.xhtml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + +
+
+ + + +
Nuevo tipo
+ + + + + + + + + + + + +
+ + + +
+ +
+ + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProyectoInventario-war/web/ubicacionCrearEditar.xhtml b/ProyectoInventario-war/web/ubicacionCrearEditar.xhtml new file mode 100644 index 0000000..d80963f --- /dev/null +++ b/ProyectoInventario-war/web/ubicacionCrearEditar.xhtml @@ -0,0 +1,84 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + + diff --git a/ProyectoInventario-war/web/ubicacionEliminar.xhtml b/ProyectoInventario-war/web/ubicacionEliminar.xhtml new file mode 100644 index 0000000..02029a9 --- /dev/null +++ b/ProyectoInventario-war/web/ubicacionEliminar.xhtml @@ -0,0 +1,58 @@ + + + + + + + + + + top + + + + left + + + + right + + + + + + + +

+ + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/ubicacionLista.xhtml b/ProyectoInventario-war/web/ubicacionLista.xhtml new file mode 100644 index 0000000..7c77013 --- /dev/null +++ b/ProyectoInventario-war/web/ubicacionLista.xhtml @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+ +
+
+
Ubicacion
+
+ + +
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/usuarioCrearEditar.xhtml b/ProyectoInventario-war/web/usuarioCrearEditar.xhtml new file mode 100644 index 0000000..3e1fcf4 --- /dev/null +++ b/ProyectoInventario-war/web/usuarioCrearEditar.xhtml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/usuarioEliminar.xhtml b/ProyectoInventario-war/web/usuarioEliminar.xhtml new file mode 100644 index 0000000..8676915 --- /dev/null +++ b/ProyectoInventario-war/web/usuarioEliminar.xhtml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + diff --git a/ProyectoInventario-war/web/usuariosLista.xhtml b/ProyectoInventario-war/web/usuariosLista.xhtml new file mode 100644 index 0000000..92820a3 --- /dev/null +++ b/ProyectoInventario-war/web/usuariosLista.xhtml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ +
+ +
+ +
+
Usuarios
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + +
+ +
+ +
+ + + diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..d7bf4d0 --- /dev/null +++ b/build.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + Builds, tests, and runs the project ProyectoInventario. + + + diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..b545720 Binary files /dev/null and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/EclipseLink-GlassFish-v3/javaee-doc-api.jar b/lib/EclipseLink-GlassFish-v3/javaee-doc-api.jar new file mode 100644 index 0000000..9e19d4f Binary files /dev/null and b/lib/EclipseLink-GlassFish-v3/javaee-doc-api.jar differ diff --git a/lib/javaee-endorsed-api-7.0/javaee-doc-api.jar b/lib/javaee-endorsed-api-7.0/javaee-doc-api.jar new file mode 100644 index 0000000..9e19d4f Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/javaee-doc-api.jar differ diff --git a/lib/javaee-endorsed-api-7.0/javax.annotation-api.jar b/lib/javaee-endorsed-api-7.0/javax.annotation-api.jar new file mode 100644 index 0000000..9ab39ff Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/javax.annotation-api.jar differ diff --git a/lib/javaee-endorsed-api-7.0/javax.xml.soap-api.jar b/lib/javaee-endorsed-api-7.0/javax.xml.soap-api.jar new file mode 100644 index 0000000..b9f4d5b Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/javax.xml.soap-api.jar differ diff --git a/lib/javaee-endorsed-api-7.0/jaxb-api-osgi.jar b/lib/javaee-endorsed-api-7.0/jaxb-api-osgi.jar new file mode 100644 index 0000000..8be7c66 Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/jaxb-api-osgi.jar differ diff --git a/lib/javaee-endorsed-api-7.0/jaxws-api.jar b/lib/javaee-endorsed-api-7.0/jaxws-api.jar new file mode 100644 index 0000000..c2ed58b Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/jaxws-api.jar differ diff --git a/lib/javaee-endorsed-api-7.0/jsr181-api.jar b/lib/javaee-endorsed-api-7.0/jsr181-api.jar new file mode 100644 index 0000000..91538a7 Binary files /dev/null and b/lib/javaee-endorsed-api-7.0/jsr181-api.jar differ diff --git a/lib/jpa20-persistence/jakarta.persistence-2.2.3-doc.zip b/lib/jpa20-persistence/jakarta.persistence-2.2.3-doc.zip new file mode 100644 index 0000000..6d042bc Binary files /dev/null and b/lib/jpa20-persistence/jakarta.persistence-2.2.3-doc.zip differ diff --git a/lib/jpa20-persistence/jakarta.persistence-2.2.3.jar b/lib/jpa20-persistence/jakarta.persistence-2.2.3.jar new file mode 100644 index 0000000..22fdc22 Binary files /dev/null and b/lib/jpa20-persistence/jakarta.persistence-2.2.3.jar differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties new file mode 100644 index 0000000..24ccba4 --- /dev/null +++ b/lib/nblibraries.properties @@ -0,0 +1,28 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=3.0 +libs.EclipseLink-GlassFish-v3.classpath=\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.antlr.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.asm.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.core.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.dbws.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.jpa.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.jpa.jpql.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.jpa.modelgen.processor.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.moxy.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/org.eclipse.persistence.oracle.jar;\ + ${base}/../../../../../../../../GlassFish_Server4.0/glassfish/modules/javax.persistence.jar +libs.EclipseLink-GlassFish-v3.displayName=EclipseLink from GlassFish +libs.EclipseLink-GlassFish-v3.javadoc=\ + ${base}/EclipseLink-GlassFish-v3/javaee-doc-api.jar +libs.javaee-endorsed-api-7.0.classpath=\ + ${base}/javaee-endorsed-api-7.0/javax.annotation-api.jar;\ + ${base}/javaee-endorsed-api-7.0/javax.xml.soap-api.jar;\ + ${base}/javaee-endorsed-api-7.0/jaxb-api-osgi.jar;\ + ${base}/javaee-endorsed-api-7.0/jaxws-api.jar;\ + ${base}/javaee-endorsed-api-7.0/jsr181-api.jar +libs.javaee-endorsed-api-7.0.displayName=Java EE 7 Endorsed API Library +libs.javaee-endorsed-api-7.0.javadoc=\ + ${base}/javaee-endorsed-api-7.0/javaee-doc-api.jar +libs.javaee-endorsed-api-7.0.prop-maven-dependencies=\n javax.annotation:javax.annotation-api:1.2\n javax.xml.bind:jaxb-api-osgi:2.2.7\n javax.xml.soap:javax.xml.soap-api:1.3.5\n javax.xml.ws:jaxws-api:2.2.8\n javax.jws:jsr181-api:1.0-MR1\n diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100644 index 0000000..fdc06d5 --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..fedfc77 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,660 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set build.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.excludes + Must set dist.jar + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..87198ae --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=4389f768 +build.xml.script.CRC32=02fa562d +build.xml.stylesheet.CRC32=7e2ae9c8@1.73 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=4389f768 +nbproject/build-impl.xml.script.CRC32=65862f86 +nbproject/build-impl.xml.stylesheet.CRC32=abdce74a@1.73 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..67bf9c7 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,41 @@ +build.classes.excludes=**/*.java,**/*.form,**/.nbattrs +build.dir=build +build.generated.dir=${build.dir}/generated +client.module.uri=ProyectoInventario-war +client.urlPart= +debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath} +display.browser=true +dist.dir=dist +dist.jar=${dist.dir}/${jar.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-7.0.classpath} +j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} +j2ee.compile.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.7 +j2ee.platform.classpath= +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv4ee7 +jar.compress=false +jar.content.additional=\ + ${reference.ProyectoInventario-war.dist-ear}:\ + ${reference.ProyectoInventario-ejb.dist-ear} +jar.name=ProyectoInventario.ear +javac.debug=true +javac.deprecation=false +javac.source=1.7 +javac.target=1.7 +meta.inf=src/conf +no.dependencies=false +platform.active=default_platform +project.ProyectoInventario-ejb=ProyectoInventario-ejb +project.ProyectoInventario-war=ProyectoInventario-war +reference.ProyectoInventario-ejb.dist-ear=${project.ProyectoInventario-ejb}/dist/ProyectoInventario-ejb.jar +reference.ProyectoInventario-war.dist-ear=${project.ProyectoInventario-war}/dist/ProyectoInventario-war.war +resource.dir=setup +run.classpath= +source.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..f2f990a --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,42 @@ + + + org.netbeans.modules.j2ee.earproject + + + ProyectoInventario + 1.6.5 + + + + ${reference.ProyectoInventario-war.dist-ear} + / + + + ${reference.ProyectoInventario-ejb.dist-ear} + / + + + + + .\lib\nblibraries.properties + + + + ProyectoInventario-ejb + j2ee_ear_archive + + dist-ear + clean-ear + dist-ear + + + ProyectoInventario-war + j2ee_ear_archive + + dist-ear + clean-ear + dist-ear + + + + diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +