Browse Source

Version

master
Samuel Gamez 4 months ago
commit
e6e92b7389
  1. 9
      .gitignore
  2. 190
      Almacen.sql
  3. BIN
      Miky_Inventario.mwb
  4. BIN
      Miky_Inventario.mwb.bak
  5. 68
      ProyectoInventario-ejb/build.xml
  6. 131
      ProyectoInventario-ejb/nbproject/ant-deploy.xml
  7. 1253
      ProyectoInventario-ejb/nbproject/build-impl.xml
  8. 8
      ProyectoInventario-ejb/nbproject/genfiles.properties
  9. 20
      ProyectoInventario-ejb/nbproject/project.xml
  10. 2
      ProyectoInventario-ejb/src/conf/MANIFEST.MF
  11. 15
      ProyectoInventario-ejb/src/conf/META-INF/glassfish-resources.xml
  12. 8
      ProyectoInventario-ejb/src/conf/persistence.xml
  13. 153
      ProyectoInventario-ejb/src/java/xforce/bl/EstadosBL.java
  14. 29
      ProyectoInventario-ejb/src/java/xforce/bl/EstadosBLLocal.java
  15. 75
      ProyectoInventario-ejb/src/java/xforce/bl/LoginBL.java
  16. 21
      ProyectoInventario-ejb/src/java/xforce/bl/LoginBLLocal.java
  17. 204
      ProyectoInventario-ejb/src/java/xforce/bl/MarcaBL.java
  18. 33
      ProyectoInventario-ejb/src/java/xforce/bl/MarcaBLLocal.java
  19. 212
      ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java
  20. 31
      ProyectoInventario-ejb/src/java/xforce/bl/PaisesBLLocal.java
  21. 262
      ProyectoInventario-ejb/src/java/xforce/bl/ProductoBL.java
  22. 35
      ProyectoInventario-ejb/src/java/xforce/bl/ProductoBLLocal.java
  23. 206
      ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBL.java
  24. 31
      ProyectoInventario-ejb/src/java/xforce/bl/ProveedorBLLocal.java
  25. 150
      ProyectoInventario-ejb/src/java/xforce/bl/RolesBL.java
  26. 27
      ProyectoInventario-ejb/src/java/xforce/bl/RolesBLLocal.java
  27. 137
      ProyectoInventario-ejb/src/java/xforce/bl/TipoBL.java
  28. 24
      ProyectoInventario-ejb/src/java/xforce/bl/TipoBLLocal.java
  29. 207
      ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBL.java
  30. 34
      ProyectoInventario-ejb/src/java/xforce/bl/UbicacionBLLocal.java
  31. 225
      ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBL.java
  32. 31
      ProyectoInventario-ejb/src/java/xforce/bl/UsuariosBLLocal.java
  33. 135
      ProyectoInventario-ejb/src/java/xforce/dao/EstadosDAO.java
  34. 64
      ProyectoInventario-ejb/src/java/xforce/dao/LoginDAO.java
  35. 112
      ProyectoInventario-ejb/src/java/xforce/dao/MarcaDAO.java
  36. 139
      ProyectoInventario-ejb/src/java/xforce/dao/PaisesDAO.java
  37. 185
      ProyectoInventario-ejb/src/java/xforce/dao/ProductoDAO.java
  38. 134
      ProyectoInventario-ejb/src/java/xforce/dao/ProveedorDAO.java
  39. 149
      ProyectoInventario-ejb/src/java/xforce/dao/RolesDAO.java
  40. 122
      ProyectoInventario-ejb/src/java/xforce/dao/TipoDAO.java
  41. 127
      ProyectoInventario-ejb/src/java/xforce/dao/UbicacionDAO.java
  42. 140
      ProyectoInventario-ejb/src/java/xforce/dao/UsuariosDAO.java
  43. 152
      ProyectoInventario-ejb/src/java/xforce/modelo/Estados.java
  44. 128
      ProyectoInventario-ejb/src/java/xforce/modelo/Marca.java
  45. 128
      ProyectoInventario-ejb/src/java/xforce/modelo/Paises.java
  46. 208
      ProyectoInventario-ejb/src/java/xforce/modelo/Producto.java
  47. 198
      ProyectoInventario-ejb/src/java/xforce/modelo/Proveedor.java
  48. 128
      ProyectoInventario-ejb/src/java/xforce/modelo/Roles.java
  49. 128
      ProyectoInventario-ejb/src/java/xforce/modelo/Tipo.java
  50. 146
      ProyectoInventario-ejb/src/java/xforce/modelo/Ubicacion.java
  51. 213
      ProyectoInventario-ejb/src/java/xforce/modelo/Usuarios.java
  52. 34
      ProyectoInventario-ejb/src/java/xforce/msg/Mensaje.java
  53. 71
      ProyectoInventario-war/build.xml
  54. BIN
      ProyectoInventario-war/libs/primefaces-12.0.0.jar
  55. 131
      ProyectoInventario-war/nbproject/ant-deploy.xml
  56. 1490
      ProyectoInventario-war/nbproject/build-impl.xml
  57. 6
      ProyectoInventario-war/nbproject/faces-config.NavData
  58. 8
      ProyectoInventario-war/nbproject/genfiles.properties
  59. 40
      ProyectoInventario-war/nbproject/project.xml
  60. 2
      ProyectoInventario-war/src/conf/MANIFEST.MF
  61. 63
      ProyectoInventario-war/src/java/xforce/seguridad/AutorizacionListener.java
  62. 165
      ProyectoInventario-war/src/java/xforce/seguridad/DemoBeanLogin.java
  63. 97
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanEstados.java
  64. 184
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanMarca.java
  65. 126
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanPaises.java
  66. 178
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanProducto.java
  67. 212
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanProveedor.java
  68. 116
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanRoles.java
  69. 89
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanTipo.java
  70. 213
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanUbicacion.java
  71. 182
      ProyectoInventario-war/src/java/xforce/vista/DemoBeanUsuarios.java
  72. 86
      ProyectoInventario-war/src/java/xforce/vista/SelectOneMenuConverter.java
  73. 46
      ProyectoInventario-war/src/java/xforce/vista/ventanas.java
  74. 42
      ProyectoInventario-war/web/WEB-INF/faces-config.xml
  75. 25
      ProyectoInventario-war/web/WEB-INF/glassfish-web.xml
  76. 28
      ProyectoInventario-war/web/WEB-INF/web.xml
  77. 140
      ProyectoInventario-war/web/estados.xhtml
  78. 15
      ProyectoInventario-war/web/index.html
  79. 64
      ProyectoInventario-war/web/index.xhtml
  80. 64
      ProyectoInventario-war/web/marcaCrearEditar.xhtml
  81. 60
      ProyectoInventario-war/web/marcaEliminar.xhtml
  82. 231
      ProyectoInventario-war/web/marcaLista.xhtml
  83. 106
      ProyectoInventario-war/web/paises.xhtml
  84. 150
      ProyectoInventario-war/web/productoCrearEditar.xhtml
  85. 72
      ProyectoInventario-war/web/productoEliminar.xhtml
  86. 452
      ProyectoInventario-war/web/productoLista.xhtml
  87. 94
      ProyectoInventario-war/web/proveedorCrearEditar.xhtml
  88. 61
      ProyectoInventario-war/web/proveedorEliminar.xhtml
  89. 427
      ProyectoInventario-war/web/proveedorLista.xhtml
  90. 82
      ProyectoInventario-war/web/resources/css/cssLayout.css
  91. 31
      ProyectoInventario-war/web/resources/css/default.css
  92. 93
      ProyectoInventario-war/web/roles.xhtml
  93. 48
      ProyectoInventario-war/web/template/listas.xhtml
  94. 57
      ProyectoInventario-war/web/template/principal.xhtml
  95. 167
      ProyectoInventario-war/web/tipos.xhtml
  96. 84
      ProyectoInventario-war/web/ubicacionCrearEditar.xhtml
  97. 58
      ProyectoInventario-war/web/ubicacionEliminar.xhtml
  98. 306
      ProyectoInventario-war/web/ubicacionLista.xhtml
  99. 68
      ProyectoInventario-war/web/usuarioCrearEditar.xhtml
  100. 63
      ProyectoInventario-war/web/usuarioEliminar.xhtml

9
.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/

190
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;

BIN
Miky_Inventario.mwb

Binary file not shown.

BIN
Miky_Inventario.mwb.bak

Binary file not shown.

68
ProyectoInventario-ejb/build.xml

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="ProyectoInventario-ejb" default="default" basedir="." xmlns:ejbjarproject="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
<description>Builds, tests, and runs the project ProyectoInventario-ejb.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying
(Targets beginning with '-' are not intended to be called on their own.)
Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets.
The target of interest are:
init-macrodef-javac: defines macro for javac compilation
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation
Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.
-->
</project>

131
ProyectoInventario-ejb/nbproject/ant-deploy.xml

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project default="-deploy-ant" basedir=".">
<target name="-init-cl-deployment-env" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}" />
<available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
<available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
<available file="${deploy.ant.resource.dir}" property="has.setup"/>
<tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
</target>
<target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
<tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<sun-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.sun.web}" validate="false">
</xmlproperty>
<delete file="${temp.sun.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&amp;contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
</target>
<target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
<tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.gf.web}" validate="false">
</xmlproperty>
<delete file="${temp.gf.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&amp;contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
</target>
<target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
<property name="deploy.context.root.argument" value=""/>
</target>
<target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
<tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
<mkdir dir="${gfv3.resources.dir}"/>
<mkdir dir="${gfv3.resources.dir}/META-INF"/>
<copy todir="${gfv3.resources.dir}/META-INF">
<fileset dir="${deploy.ant.resource.dir}"/>
</copy>
<jar destfile="${deploy.ant.archive}" update="true">
<fileset dir="${gfv3.resources.dir}"/>
</jar>
<delete dir="${gfv3.resources.dir}"/>
</target>
<target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
<antcall target="-deploy-without-pw"/>
<antcall target="-deploy-with-pw"/>
</target>
<target name="-deploy-without-pw" unless="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-deploy-with-pw" if="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
<antcall target="-undeploy-without-pw"/>
<antcall target="-undeploy-with-pw"/>
</target>
<target name="-undeploy-without-pw" unless="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-with-pw" if="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
</project>

1253
ProyectoInventario-ejb/nbproject/build-impl.xml

File diff suppressed because it is too large

8
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

20
ProyectoInventario-ejb/nbproject/project.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.j2ee.ejbjarproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
<name>ProyectoInventario-ejb</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<explicit-platform explicit-source-supported="true"/>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>..\.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>

2
ProyectoInventario-ejb/src/conf/MANIFEST.MF

@ -0,0 +1,2 @@
Manifest-Version: 1.0

15
ProyectoInventario-ejb/src/conf/META-INF/glassfish-resources.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_inventarioalmacen_rootPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="inventarioalmacen"/>
<property name="User" value="root"/>
<property name="Password" value="root"/>
<property name="URL" value="jdbc:mysql://localhost:3306/inventarioalmacen"/>
<property name="driverClass" value="org.gjt.mm.mysql.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="java:module/almacen" object-type="user" pool-name="mysql_inventarioalmacen_rootPool"/>
<jdbc-resource enabled="true" jndi-name="java:module/si" object-type="user" pool-name="mysql_inventarioalmacen_rootPool"/>
</resources>

8
ProyectoInventario-ejb/src/conf/persistence.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ProyectoInventario-ejbPU" transaction-type="JTA">
<jta-data-source>jdbc/almacen</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

153
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<Estados> 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<Usuarios> referenciaUsuarios = estadosDAO.buscarPaisesReferenciadosUsuarios(estadoEnUso);
List<Proveedor> 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<Estados> 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));
}
}

29
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<Estados> buscarValidos(boolean estado);
public Estados buscarNombre(Estados estados);
}

75
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<Usuarios> 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));
}
}

21
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);
}

204
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<Marca> 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<Proveedor> 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<Marca> 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<Marca> 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));
}
}

33
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<Marca> buscarValidos(boolean estado);
Marca buscarNombre(Marca marca);
}

212
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<Paises> 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<Paises> 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<Estados> 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<Paises> 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));
}
}

31
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<Paises> buscarValidos(boolean estado);
public Paises buscarNombre(Paises paises);
}

262
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<Producto> 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<Producto> 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<Producto> 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<Producto> buscarUbicacion(int id) {
ProductoDAO productoDAO = new ProductoDAO();
List l = productoDAO.buscarPorUbicacion(id);
System.out.println(l);
return l;
}
@Override
public List<Producto> 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));
}
}

35
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<Producto> buscarValidos(boolean estado);
Producto buscarNombre(Producto producto);
List<Producto> buscarUbicacion(int id);
List<Producto> buscarMarca(int id);
Mensaje eliminar(Producto producto);
Mensaje editar(Producto producto);
}

206
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<Proveedor> 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<Proveedor> 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<Producto> 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<Proveedor> 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));
}
}

31
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 <Proveedor> buscarValidos(boolean estado);
Proveedor buscarNombre(Proveedor proveedor);
}

150
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<Roles> 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<Usuarios> 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<Roles> 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));
}
}

27
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<Roles> buscarValidos(boolean estado);
public Roles buscarNombre(Roles roles);
}

137
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<Tipo> 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<Producto> 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<Tipo> buscarValidos(boolean estado) {
TipoDAO tipoDao = new TipoDAO();
System.out.println("roles existentes");
List l= tipoDao.buscarValidos(estado);
System.out.println(l);
return l;
}
}

24
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<Tipo> buscarValidos(boolean estado);
public Mensaje eliminar(Tipo tipo);
}

207
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<Ubicacion> 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<Producto> 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<Ubicacion> 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<Ubicacion> 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));
}
}

34
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<Ubicacion> buscarValidos(boolean estado);
Ubicacion buscarNombre(Ubicacion ubicacion);
Ubicacion buscarId(Ubicacion ubicacion);
}

225
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<Usuarios> 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<Usuarios> 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<Usuarios> 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));
}
}

31
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 <Usuarios> buscarValidos(boolean estado);
Usuarios buscarNombre(Usuarios usuario);
}

135
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<Estados> 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<Estados> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Estados) q.getResultList().get(0);
}
}
public Optional<Estados> 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<Estados> resultadoNombre = q1.getResultList();
List<Estados> 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<Proveedor> 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<Usuarios> 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();
}
}

64
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<Usuarios> 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<Usuarios> resNombre = q1.getResultList();
List<Usuarios> resContrasenia = q2.getResultList();
List<Usuarios> 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();
}
}

112
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<Marca> 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<Proveedor> 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<Marca> 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<Marca> resNombre = ql.getResultList();
List<Marca> 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();
}
}
}

139
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<Paises> 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<Paises> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Paises) q.getResultList().get(0);
}
}
public Optional<Paises> 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<Paises> resultadoNombre = q1.getResultList();
List<Paises> 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<Estados> 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();
}
}

185
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<Producto> 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<Producto> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Producto) q.getResultList().get(0);
}
}
public List<Producto> 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<Producto> 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<Producto> 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<Producto> resultadoNombre = q1.getResultList();
List<Producto> resultadoCodigo = q2.getResultList();
List<Producto> resultadoPrecio = q3.getResultList();
List<Producto> resultadoPiezas = q4.getResultList();
List<Producto> resultadoEstado = q5.getResultList();
List<Producto> resultadoProveedor = q7.getResultList();
List<Producto> resultadoUbicacion = q8.getResultList();
List<Producto> 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();
}
}
}

134
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<Producto> 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<Proveedor> 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<Proveedor> resNombre = ql.getResultList();
List<Proveedor> resTel = q2.getResultList();
List<Proveedor> resMail = q3.getResultList();
List<Proveedor> 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<Proveedor> 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<Proveedor> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Proveedor) q.getResultList().get(0);
}
}
}

149
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<Roles> 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<Roles> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Roles) q.getResultList().get(0);
}
}
public Optional<Roles> 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<Roles> resRol =q1.getResultList();
List<Roles> 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<Usuarios> 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();
}
}

122
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<Tipo> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Tipo) q.getResultList().get(0);
}
}
public List<Tipo > 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<Tipo> 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<Tipo> resTipo = ql.getResultList();
List<Tipo> 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<Producto> 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();
}
}

127
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<Ubicacion> 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<Ubicacion> resultadoAnaquel = q1.getResultList();
List<Ubicacion> resultadoBloque = q2.getResultList();
List<Ubicacion> 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<Ubicacion> 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<Ubicacion> resultados = q.getResultList();
if (resultados.isEmpty()) {
return null;
} else {
return (Ubicacion) q.getResultList().get(0);
}
}
public List<Producto> 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();
}
}

140
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<Usuarios> 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<Usuarios> 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<Usuarios> resNombre = ql.getResultList();
List<Usuarios> resApellidoPaterno = q2.getResultList();
List<Usuarios> resEmail = q3.getResultList();
List<Usuarios> resTelefono = q4.getResultList();
List<Usuarios> resContrasenia = q5.getResultList();
List<Usuarios> resDomicilio = q6.getResultList();
List<Usuarios> resRol = q7.getResultList();
List<Usuarios> 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();
}
}
}

152
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<Proveedor> proveedorList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "estadosId")
private List<Usuarios> 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<Proveedor> getProveedorList() {
return proveedorList;
}
public void setProveedorList(List<Proveedor> proveedorList) {
this.proveedorList = proveedorList;
}
@XmlTransient
public List<Usuarios> getUsuariosList() {
return usuariosList;
}
public void setUsuariosList(List<Usuarios> 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 + " ]";
}
}

128
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<Proveedor> 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<Proveedor> getProveedorList() {
return proveedorList;
}
public void setProveedorList(List<Proveedor> 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 + " ]";
}
}

128
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<Estados> 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<Estados> getEstadosList() {
return estadosList;
}
public void setEstadosList(List<Estados> 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 + " ]";
}
}

208
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 + " ]";
}
}

198
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<Producto> 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<Producto> getProductoList() {
return productoList;
}
public void setProductoList(List<Producto> 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 + " ]";
}
}

128
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<Usuarios> 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<Usuarios> getUsuariosList() {
return usuariosList;
}
public void setUsuariosList(List<Usuarios> 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 + " ]";
}
}

128
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<Producto> 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<Producto> getProductoList() {
return productoList;
}
public void setProductoList(List<Producto> 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 + " ]";
}
}

146
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<Producto> 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<Producto> getProductoList() {
return productoList;
}
public void setProductoList(List<Producto> 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;
}
}

213
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 + " ]";
}
}

34
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,
}

71
ProyectoInventario-war/build.xml

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="ProyectoInventario-war" default="default" basedir=".">
<description>Builds, tests, and runs the project ProyectoInventario-war.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets.
The target of interest are:
init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation
Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.
-->
</project>

BIN
ProyectoInventario-war/libs/primefaces-12.0.0.jar

Binary file not shown.

131
ProyectoInventario-war/nbproject/ant-deploy.xml

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project default="-deploy-ant" basedir=".">
<target name="-init-cl-deployment-env" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}" />
<available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
<available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
<available file="${deploy.ant.resource.dir}" property="has.setup"/>
<tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
</target>
<target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
<tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<sun-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.sun.web}" validate="false">
</xmlproperty>
<delete file="${temp.sun.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&amp;contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
</target>
<target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
<tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.gf.web}" validate="false">
</xmlproperty>
<delete file="${temp.gf.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&amp;contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
</target>
<target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
<property name="deploy.context.root.argument" value=""/>
</target>
<target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
<tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
<mkdir dir="${gfv3.resources.dir}"/>
<mkdir dir="${gfv3.resources.dir}/META-INF"/>
<copy todir="${gfv3.resources.dir}/META-INF">
<fileset dir="${deploy.ant.resource.dir}"/>
</copy>
<jar destfile="${deploy.ant.archive}" update="true">
<fileset dir="${gfv3.resources.dir}"/>
</jar>
<delete dir="${gfv3.resources.dir}"/>
</target>
<target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
<antcall target="-deploy-without-pw"/>
<antcall target="-deploy-with-pw"/>
</target>
<target name="-deploy-without-pw" unless="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-deploy-with-pw" if="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
<antcall target="-undeploy-without-pw"/>
<antcall target="-undeploy-with-pw"/>
</target>
<target name="-undeploy-without-pw" unless="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-with-pw" if="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
</project>

1490
ProyectoInventario-war/nbproject/build-impl.xml

File diff suppressed because it is too large

6
ProyectoInventario-war/nbproject/faces-config.NavData

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project"/>
<Scope Scope="All Faces Configurations"/>
</Scene>

8
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

40
ProyectoInventario-war/nbproject/project.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/web-project/3">
<name>ProyectoInventario-war</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<explicit-platform explicit-source-supported="true"/>
<web-module-libraries>
<library dirs="100">
<file>${reference.ProyectoInventario-ejb.dist}</file>
</library>
<library dirs="200">
<file>${file.reference.primefaces-12.0.0.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
</web-module-libraries>
<web-module-additional-libraries/>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>..\.\lib\nblibraries.properties</definitions>
</libraries>
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
<reference>
<foreign-project>ProyectoInventario-ejb</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>dist</target>
<clean-target>clean</clean-target>
<id>dist</id>
</reference>
</references>
</configuration>
</project>

2
ProyectoInventario-war/src/conf/MANIFEST.MF

@ -0,0 +1,2 @@
Manifest-Version: 1.0

63
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;
}
}

165
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();
}
}
}

97
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<Estados> 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();
}
}

184
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<Marca> 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<Marca> 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<Marca> getMarcaFilter() {
return marcaFilter;
}
public void setMarcaFilter(List<Marca> 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);
}
}

126
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<Paises> 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();
}
}

178
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<Producto> productoFilter;///
////////////////////////////////////////
private List<SortMeta> sortBy;
public List<SortMeta> 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<Producto> getProductos() {
return productoBL.buscarValidos(true);
}
//////////////////////////////////////////////////////////////////////
public List<Producto> getProductoFilter() { //
return productoFilter; //
} //
//
public void setProductoFilter(List<Producto> 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);
}
}

212
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<Proveedor> 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<Proveedor> getProveedorFilter() {
return proveedorFilter;
}
public void setProveedorFilter(List<Proveedor> 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<Proveedor> 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;
}
}
}

116
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<Roles> getRoles() {
return rolesBL.buscarValidos(true);
}
public Roles getRol() {
return roles;
}
public void setRol(Roles rol) {
this.roles = rol;
}
}

89
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<Tipo> 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<Tipo> getTipos() {
return tipoBl.buscarValidos(true);
}
public Tipo getTipo() {
return tipo;
}
public void setTipo(Tipo tip) {
this.tipo = tip;
}
}

213
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<Ubicacion> 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<Ubicacion> getUbicacionFilter() {
return ubicacionFilter;
}
public void setUbicacionFilter(List<Ubicacion> 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<Ubicacion> 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;
}
}
}

182
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<Usuarios> 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<Usuarios> 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<Usuarios> getUsuariosFilter() {
return usuariosFilter;
}
public void setUsuariosFilter(List<Usuarios> 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";
// }
}

86
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<Object> elements = (List<Object>) 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);
}
}

46
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);
}
}

42
ProyectoInventario-war/web/WEB-INF/faces-config.xml

@ -0,0 +1,42 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<faces-config version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
<lifecycle>
<phase-listener>
xforce.seguridad.AutorizacionListener
</phase-listener>
</lifecycle>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>accesoDenegado</from-outcome>
<to-view-id>/productoLista.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

25
ProyectoInventario-war/web/WEB-INF/glassfish-web.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<!--
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>

28
ProyectoInventario-war/web/WEB-INF/web.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/productoLista.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
</web-app>

140
ProyectoInventario-war/web/estados.xhtml

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<f:view>
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Estados</strong></header>
<p:divider/>
<main style="display: flex; justify-content: space-between; gap: 10px;">
<h:form id="formEstados">
<p:growl id="growl" showDetail="true" for="mensajePaises"/>
<p:dataTable id="tableEstados"
value="#{demoBeanEstados.estados}"
var="item"
style="width: 600px"
paginator="true"
rows="5"
rowSelectMode="add"
paginatorPosition="bottom" >
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre"/>
</f:facet>
<h:outputText value="#{item.nombre}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado == 2 ? 'Activo':'Inactivo'}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Pais"/>
</f:facet>
<h:outputText value="#{item.paisesId.nombre}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<center>
<h:outputText value="Opciones"/>
</center>
</f:facet>
<p:commandButton action="#{demoBeanEstados.eliminarEstados(item)}"
ajax="true"
icon="pi pi-trash"
styleClass="ui-button-warning"
style="margin-top: 5px; width: 50px;"
update="formPais" />
</p:column>
</p:dataTable>
</h:form>
<h:form style="margin-left: 20px; margin-top: 20px;">
<header style="display: flex; justify-content: center;">Nuevo Estado</header>
<p:divider/>
<h:panelGrid columns="2">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre" value="#{demoBeanEstados.estado.nombre}"
title="Nombre"
required="true"
validatorMessage="Verifique el nombre"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-Za-zÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,})*\b"
for="nombre" />
</p:inputText>
<p:outputLabel></p:outputLabel>
<p:message id="alertNombre" for="nombre"/>
<p:outputLabel value="Pais:" for="paisesId" />
<p:selectOneMenu id="paisesId"
value="#{demoBeanEstados.estado.paisesId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un pais"
filter="true"
filterMatchMode="startsWith" >
<!-- Arriba esta lo del filtro, jsjsjsjs -->
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanPaises.paises}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:outputLabel></p:outputLabel>
<p:message id="alertPais" for="paisesId"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 280px; justify-content: flex-end;">
<p:commandButton action="#{demoBeanEstados.agregarEstados()}"
ajax="true"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-check"
update="formEstados:tableEstados, nombre, paisesId,
alertNombre, alertPais, formEstados:growl" />
<p:commandButton oncomplete="PF('estado').close()"
immediate="true"
ajax="false"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</footer>
</h:form>
</main>
</f:view>
</body>
</html>

15
ProyectoInventario-war/web/index.html

@ -0,0 +1,15 @@
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Html.html to edit this template
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
</body>
</html>

64
ProyectoInventario-war/web/index.xhtml

@ -0,0 +1,64 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="./css/default.css"/>
<h:outputStylesheet name="./css/cssLayout.css"/>
<title>Facelets Template</title>
<style>
</style>
</h:head>
<center>
<h:body style="text-align: center">
<h2> Inventario almacen </h2>
<h:form id="formLogin">
<p:growl id="growl" showDetail="true" for="mensajeLogin"/>
<p:panel header="Login" style="width:300px">
<h:panelGrid columns="1" cellpadding="5">
<p:inputText id="usuario"
value="#{demoBeanLogin.usuarios.nombre}"
title='nombre'
required="true"
requiredMessage="Este campo no puede estar vacio"
placeholder="Ingrese el usuario">
</p:inputText>
<p:password id="contrasenia"
value="#{demoBeanLogin.usuarios.contrasenia}"
title="contraseña"
redisplay="true"
required="true"
requiredMessage="Este campo no puede estar vacio"
placeholder="Ingrse la contraseña"
style="width: 223px">
</p:password>
<p:commandButton value="Login"
action="#{demoBeanLogin.login()}"
ajax="false"
update=":formLogin"/>
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
</center>
</html>

64
ProyectoInventario-war/web/marcaCrearEditar.xhtml

@ -0,0 +1,64 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="left">
</ui:define>
<ui:define name="right">
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<p:messages id="messages" showDetail="true" closable="true">
<p:autoUpdate/>
</p:messages>
<h1><h:outputText value="#{demoBeanMarca.titulo}"/></h1>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre" value="#{demoBeanMarca.marca.nombre}" title="Nombre" required="true">
</p:inputText>
<p:message for="nombre" display="tooltip"/>
</h:panelGrid>
<p:commandButton action="#{demoBeanMarca.agregar()}" update="messages" rendered="#{demoBeanMarca.nuevo}" styleClass="ui-button-success" style="width: 50px;" icon="pi pi-save" ajax="false"/>
<p:commandButton action="#{demoBeanMarca.editarMarca()}" update="messages" rendered="#{!demoBeanMarca.nuevo}" icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"
ajax="false"/>
<p:commandButton action="marcaLista.xhtml" immediate="true" style="margin-left: 5px; width: 50px; " icon="pi pi-times" styleClass="ui-button-danger"
ajax="false"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

60
ProyectoInventario-war/web/marcaEliminar.xhtml

@ -0,0 +1,60 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="left">
</ui:define>
<ui:define name="right">
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<p:growl id="messages" showDetail="true"/>
<h1><h:outputText value="Eliminar"/></h1>
<p:panelGrid columns="2">
<h:outputText value="Id:"/>
<h:outputText value="#{demoBeanMarca.marca.id}" title="Id"/>
<h:outputText value="Nombre:"/>
<h:outputText value="#{demoBeanMarca.marca.nombre}" title="Nombre"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanMarca.marca.estado == 2 ? 'Activo':'Inactivo'}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="#{demoBeanMarca.eliminarMarca()}" ajax="false"
icon="pi pi-trash"
styleClass="ui-button-warning"
style=" width: 50px; "
/>
<p:commandButton action="marcaLista.xhtml" immediate="true"
icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false"
style="margin-left: 5px; width: 50px;"
/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

231
ProyectoInventario-war/web/marcaLista.xhtml

@ -0,0 +1,231 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<ui:composition template="./template/listas.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="content">
<f:view>
<div>
<h:form>
<p:menubar >
<p:menuitem value="Productos" action="productoLista.xhtml" ajax="false"/>
<p:menuitem value="Marcas" action="marcaLista.xhtml" disabled="true" ajax="false"/>
<p:menuitem value="Proveedores" action="proveedorLista.xhtml" ajax="false"/>
<p:menuitem value="Ubicaciones" action="ubicacionLista.xhtml" ajax="false"/>
<p:menuitem value="Usuarios" action="usuariosLista.xhtml" ajax="false"/>
<p:submenu label="Opciones" icon="pi pi-fw pi-list">
<p:menuitem value="Roles"
icon="pi pi-fw pi-users"
oncomplete="PF('rol').show()"
update=":rolD"
actionListener="#{demoBeanRoles.prepararNuevo()}"/>
<p:menuitem value="Paises"
icon="pi pi-globe"
oncomplete="PF('pais').show()"
update="paisDialog"
actionListener="#{demoBeanPaises.prepararNuevo()}"/>
<p:menuitem value="Estados"
icon="pi pi-map"
oncomplete="PF('estado').show()"
update="estadosDialog"
actionListener="#{demoBeanEstados.prepararNuevo()}"/>
<p:menuitem value="Tipos" icon="pi pi-tags"/>
<!-- <p:divider />-->
</p:submenu>
</p:menubar>
</h:form>
<p:dialog id="rolD" widgetVar="rol" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="roles.xhtml"/>
</p:dialog>
<p:dialog id="paisDialog" widgetVar="pais" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="paises.xhtml"/>
</p:dialog>
<p:dialog id="estadosDialog" widgetVar="estado" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="estados.xhtml"/>
</p:dialog>
</div>
<!-- agregar id para el formulario -->
<h:form id="marcaTable">
<p:growl id="messages" showDetail="true" />
<!-- agregar accionador de dialogo("oncomplete") y actualizar el mismo dialogo ("update") -->
<!-- agregar id a la tabla para actualizarla -->
<p:dataTable id="table" value="#{demoBeanMarca.marcas}" var="item" filteredValue="#{demoBeanMarca.marcaFilter}"
globalFilterFunction="#{demoBeanMarca.globalFilterFunction}"
widgetVar="filter"
paginator="true" rows="10" rowSelectMode="add" paginatorPosition="bottom"
resizableColumns="true"
showGridlines="true">
<f:facet name="header" >
<div style="display: flex; align-items: center;">
<div style="flex: 1;">
<p:commandButton style="margin-top: 5px;" actionListener="#{demoBeanMarca.prepararNuevo()}" oncomplete="PF('mar').show()"
value="Nuevo" update=":dialogForm"
icon="pi pi-plus" ajax="true"/>
</div>
<div style="flex: 1; text-align: center;">
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Marcas</strong></header>
</div>
<div style="flex: 1; text-align: right;">
<div class="ui-input-icon-left mr-2" >
<i class="pi pi-fw pi-search" />
<p:inputText id="globalFilter" onkeyup="PF('filter').filter()"
placeholder="Buscar marca"
/>
</div>
</div>
</div>
</f:facet>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre"/>
</f:facet>
<h:outputText value="#{item.nombre}"/>
</p:column>
<p:column responsivePriority="2" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado == 2 ? 'Activo':'Inactivo'}"/>
</p:column>
<p:column responsivePriority="3" style="text-align: center;" >
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<div style="text-align: center;">
<p:commandButton actionListener="#{demoBeanMarca.rellenarEditar(item)}" oncomplete="PF('mar').show()" update=":dialogForm" icon="pi pi-fw pi-pencil" styleClass="ui-button-secondary" ajax="true"/>
<p:commandButton actionListener="#{demoBeanMarca.prepararEliminar(item)}" icon="pi pi-trash" style="margin-left: 5px" styleClass="ui-button-danger"
oncomplete="PF('dialogD').show()" update=":dialogDel"
ajax="true"/>
</div>
</p:column>
</p:dataTable>
</h:form>
<!-- agregar dialog modal -->
<p:dialog id="dialogForm" header="#{demoBeanMarca.titulo}" widgetVar="mar" responsive="true" showEffect="fade" modal="true" resizable="false">
<p:growl id="growl" showDetail="true" for="mensajeMarca"/>
<h:form>
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre" value="#{demoBeanMarca.marca.nombre}" title="Nombre" required="true" validatorMessage="nombre no valido"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,})*\b"
for="nombre" />
</p:inputText>
<p:outputLabel></p:outputLabel>
<p:message id="name" for="nombre"/>
</h:panelGrid>
<!-- botones en ajax true (excepto el cancelar) y updates referenciando a ids del dialog
(sobretodo a los id de los inputTxt) y tabla para actualizarla. continua en el bean -->
<footer style="display: flex; margin-top: 20px; justify-content: flex-end;">
<p:commandButton action="#{demoBeanMarca.agregar()}" update="growl,marcaTable:table, nombre, name" rendered="#{demoBeanMarca.nuevo}"
styleClass="ui-button-success" style="width: 50px;"
icon="pi pi-save" ajax="true"
/>
<p:commandButton action="#{demoBeanMarca.editarMarca()}" update="growl,marcaTable:table, nombre, name" rendered="#{!demoBeanMarca.nuevo}"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"
ajax="true"/>
<p:commandButton action="marcaLista.xhtml" immediate="true" style="margin-left: 5px; width: 50px; " icon="pi pi-times" styleClass="ui-button-danger"
ajax="false"/>
</footer>
</h:form>
</p:dialog>
<p:dialog id="dialogDel" widgetVar="dialogD" header="#{demoBeanMarca.titulo}" responsive="true" showEffect="fade" modal="true" resizable="false">
<h:form>
<p:growl id="messages" showDetail="true" for="mensajeMarca"/>
<h:panelGrid columns="2" cellpadding="7">
<h:outputText value="Nombre:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanMarca.marca.nombre}" title="Nombre"/>
<h:outputText value="Estatus:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanMarca.marca.estado == 2 ? 'Activo':'Inactivo'}" title="Estatus"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 20px; justify-content: flex-end;">
<p:commandButton action="#{demoBeanMarca.eliminarMarca()}" ajax="true"
update="marcaTable:table, messages"
icon="pi pi-trash"
styleClass="ui-button-warning"
style=" width: 50px; "
/>
<p:commandButton action="marcaLista.xhtml" immediate="true"
icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false"
style="margin-left: 5px; width: 50px;"
/>
</footer>
</h:form>
</p:dialog>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

106
ProyectoInventario-war/web/paises.xhtml

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<f:view>
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Paises</strong></header>
<p:divider/>
<main style="display: flex; justify-content: space-between; gap: 10px;">
<h:form id="formPais">
<p:growl id="growl" showDetail="true" for="mensajePaises"/>
<p:dataTable id="tablePais"
value="#{demoBeanPaises.paises}"
var="item"
style="width: 600px"
paginator="true"
rows="4"
rowSelectMode="add"
paginatorPosition="bottom" >
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre"/>
</f:facet>
<h:outputText value="#{item.nombre}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado == 2 ? 'Activo':'Inactivo'}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<center>
<h:outputText value="Opciones"/>
</center>
</f:facet>
<p:commandButton action="#{demoBeanPaises.eliminarPais(item)}"
ajax="true"
icon="pi pi-trash"
styleClass="ui-button-warning"
style="margin-top: 5px; width: 50px;"
update="formPais" />
</p:column>
</p:dataTable>
</h:form>
<h:form style="margin-left: 20px; margin-top: 20px;">
<header style="display: flex; justify-content: center;">Nuevo Pais</header>
<p:divider/>
<h:panelGrid columns="2">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre"
value="#{demoBeanPaises.pais.nombre}"
title="Nombre"
required="true"
requiredMessage="The Nombre field is required."/>
<p:outputLabel></p:outputLabel>
<p:message id="alertNombre" for="nombre"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 280px; justify-content: flex-end;">
<p:commandButton action="#{demoBeanPaises.agregarPais()}"
ajax="true"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-check"
update="formPais:tablePais, nombre, alertNombre, formPais:growl" />
<p:commandButton oncomplete="PF('pais').close()"
immediate="true"
ajax="false"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</footer>
</h:form>
</main>
</f:view>
</body>
</html>

150
ProyectoInventario-war/web/productoCrearEditar.xhtml

@ -0,0 +1,150 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="#{demoBeanProducto.titulo}"/></h1>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre"
value="#{demoBeanProducto.producto.nombre}"
title="Nombre"
required="true"
validatorMessage="El nombre no es valido"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="\b[A-Za-zÁáÉéÍíÓóÚúÜüÑñ]{3,}(?:\s+[A-Za-zÁáÉéÍíÓóÚúÜüÑñ]{3,})*\b"
for="nombre" />
</p:inputText>
<p:message for="nombre" />
<p:outputLabel value="Codigo:" for="codigo" />
<p:inputText id="codigo"
value="#{demoBeanProducto.producto.codigo}"
title="Codigo"
required="true"
converterMessage="Solo se aceptan digitos"
requiredMessage="Este campo no puede estar vacio"/>
<p:message for="codigo" />
<p:outputLabel value="Precio:" for="precio" />
<p:inputText id="precio"
value="#{demoBeanProducto.producto.precio}"
title="Precio"
required="true"
converterMessage="Solo se aceptan digitos"
requiredMessage="Este campo no puede estar vacio"/>
<p:message for="precio" />
<p:outputLabel value="Piezas:" for="piezas" />
<p:inputText id="piezas"
value="#{demoBeanProducto.producto.piezas}"
title="Piezas"
required="true"
converterMessage="Solo se aceptan digitos"
requiredMessage="Este campo no puede estar vacio"/>
<p:message for="piezas" />
<p:outputLabel value="Marca:"
for="marcaId"/>
<p:selectOneMenu id="marcaId"
value="#{demoBeanProducto.producto.marcaIdmarca}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita una marca" >
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanMarca.marcas}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:message for="marcaId" />
<p:outputLabel value="Proveedor:"
for="proveedorIdproveedor" />
<p:selectOneMenu id="proveedorIdproveedor"
value="#{demoBeanProducto.producto.proveedorIdproveedor}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un proveedor" >
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanProveedor.proveedores}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:message for="proveedorIdproveedor" />
<p:outputLabel value="Ubicacion"
for="ubicacionId" />
<p:selectOneMenu id="ubicacionId"
value="#{demoBeanProducto.producto.ubicacionId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita una ubicacion">
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanUbicacion.ubicacion}"
var="item"
itemLabel="#{item.bloque}#{item.anaquel}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:message for="ubicacionId" />
</h:panelGrid>
<p:commandButton action="#{demoBeanProducto.agregarProducto()}"
update="messages"
rendered="#{demoBeanProducto.nuevo}"
ajax="false"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-check"/>
<p:commandButton action="#{demoBeanProducto.editarProducto()}"
update="messages"
rendered="#{!demoBeanProducto.nuevo}"
ajax="false"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"/>
<p:commandButton action="productoLista.xhtml"
immediate="true"
ajax="false"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

72
ProyectoInventario-war/web/productoEliminar.xhtml

@ -0,0 +1,72 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="Eliminar producto"/></h1>
<p:panelGrid columns="2">
<h:outputText value="Nombre:"/>
<h:outputText value="#{demoBeanProducto.producto.nombre}" title="Nombre"/>
<h:outputText value="Codigo:"/>
<h:outputText value="#{demoBeanProducto.producto.codigo}" title="Codigo"/>
<h:outputText value="Precio:"/>
<h:outputText value="#{demoBeanProducto.producto.precio}" title="Precio"/>
<h:outputText value="Piezas:"/>
<h:outputText value="#{demoBeanProducto.producto.piezas}" title="Piezas"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanProducto.producto.estado == 2 ? 'Activo':'Inactivo'}" title="Estado"/>
<h:outputText value="Marca:"/>
<h:outputText value="#{demoBeanProducto.producto.marcaIdmarca.nombre}" title="MarcaIdmarca"/>
<h:outputText value="Proveedor:"/>
<h:outputText value="#{demoBeanProducto.producto.proveedorIdproveedor.nombre}" title="ProveedorIdproveedor"/>
<h:outputText value="Ubicacion:"/>
<h:outputText value="#{demoBeanProducto.producto.ubicacionId.bloque}#{demoBeanProducto.producto.ubicacionId.anaquel}" title="UbicacionId"/>
</p:panelGrid>
<p:commandButton action="productoLista.xhtml"
actionListener="#{demoBeanProducto.eliminarProducto()}"
ajax="false"
icon="pi pi-trash"
styleClass="ui-button-warning"
style="margin-top: 5px; width: 50px;"/>
<p:commandButton action="productoLista.xhtml"
immediate="true"
ajax="false"
style="margin-top: 5px; margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

452
ProyectoInventario-war/web/productoLista.xhtml

@ -0,0 +1,452 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<body>
<ui:composition template="./template/listas.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="content">
<f:view>
<div>
<h:form>
<p:menubar >
<p:menuitem value="Productos" action="productoLista.xhtml" disabled="true" ajax="false"/>
<p:menuitem value="Marcas" action="marcaLista.xhtml" ajax="false"/>
<p:menuitem value="Proveedores" action="proveedorLista.xhtml" ajax="false"/>
<p:menuitem value="Ubicaciones" action="ubicacionLista.xhtml" ajax="false"/>
<p:menuitem value="Usuarios" action="usuariosLista.xhtml" ajax="false"/>
<p:submenu label="Opciones" icon="pi pi-fw pi-list">
<p:menuitem value="Roles"
icon="pi pi-fw pi-users"
oncomplete="PF('rol').show()"
update=":rolD"
actionListener="#{demoBeanRoles.prepararNuevo()}"/>
<p:menuitem value="Paises"
icon="pi pi-globe"
oncomplete="PF('pais').show()"
update="paisDialog"
actionListener="#{demoBeanPaises.prepararNuevo()}"/>
<p:menuitem value="Estados"
icon="pi pi-map"
oncomplete="PF('estado').show()"
update="estadosDialog"
actionListener="#{demoBeanEstados.prepararNuevo()}"/>
<p:menuitem value="Tipos"
icon="pi pi-tags"
oncomplete="PF('tipo').show()"
update="tip"
actionListener="#{demoBeanTipo.prepararNuevo()}"/>
<!-- <p:divider />-->
</p:submenu>
</p:menubar>
</h:form>
<p:dialog id="rolD" widgetVar="rol" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="roles.xhtml"/>
</p:dialog>
<p:dialog id="paisDialog" widgetVar="pais" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="paises.xhtml"/>
</p:dialog>
<p:dialog id="estadosDialog" widgetVar="estado" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="estados.xhtml"/>
</p:dialog>
<p:dialog id="tip" widgetVar="tipo" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="tipos.xhtml"/>
</p:dialog>
</div>
<h:form id="productoTable">
<p:commandButton value="PDF" styleClass="mr-2 mb-2">
<p:dataExporter type="pdf" target="table" fileName="products"/>
</p:commandButton>
<p:growl id="messages" showDetail="true"/>
<!-- Por aqui checa en el datatable y el facet -->
<!-- Es lo del buscador ese pedo, y se vincula al demo bean -->
<div class="card">
<p:dataTable id="table"
value="#{demoBeanProducto.productos}"
var="item"
filteredValue="#{demoBeanProducto.productoFilter}"
globalFilterFunction="#{demoBeanProducto.globalFilterFunction}"
widgetVar="filtro"
paginator="true"
rows="10"
rowSelectMode="add"
paginatorPosition="bottom"
resizableColumns="true"
showGridlines="true" >
<f:facet name="header">
<div style="display: flex; align-items: center;">
<div style="flex: 1;"> <!-- Div para el botón a la izquierda -->
<p:commandButton actionListener="#{demoBeanProducto.prepararNuevo()}"
style="margin-top: 5px;"
value="Nuevo"
icon="pi pi-plus"
ajax="true"
oncomplete="PF('dialogProducto').show()"
update=":dialogForm"/>
</div>
<div style="flex: 1; text-align: center;"> <!-- Div para el texto centrado -->
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Productos</strong></header>
</div>
<div style="flex: 1; text-align: right;"> <!-- Div para el div a la derecha -->
<div class="ui-input-icon-left mr-2">
<i class="pi pi-fw pi-search" />
<p:inputText id="globalFilter"
onkeyup="PF('filtro').filter()"
placeholder="Buscador de productos" />
</div>
</div>
</div>
</f:facet>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre"/>
</f:facet>
<h:outputText value="#{item.nombre}"/>
</p:column>
<p:column responsivePriority="2" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Codigo"/>
</f:facet>
<h:outputText value="#{item.codigo}"/>
</p:column>
<p:column responsivePriority="3" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Precio"/>
</f:facet>
<h:outputText value="#{item.precio}"/>
</p:column>
<p:column responsivePriority="3" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Piezas"/>
</f:facet>
<h:outputText value="#{item.piezas}"/>
</p:column>
<p:column responsivePriority="4" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado == 2 ? 'Activo':'Inactivo'}"/>
</p:column>
<p:column responsivePriority="4" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Fecha"/>
</f:facet>
<h:outputText value="#{item.fecha}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column responsivePriority="5" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Marca"/>
</f:facet>
<h:outputText value="#{item.proveedorIdproveedor.marcaId.nombre}"/>
</p:column>
<p:column responsivePriority="5" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Proveedor"/>
</f:facet>
<h:outputText value="#{item.proveedorIdproveedor.nombre}"/>
</p:column>
<p:column responsivePriority="6" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Tipo"/>
</f:facet>
<h:outputText value="#{item.tipoId.tipo}"/>
</p:column>
<p:column responsivePriority="6" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Ubicacion"/>
</f:facet>
<h:outputText value="#{item.ubicacionId.lugar}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<div style="text-align: center;">
<p:commandButton styleClass="ui-button-secondary"
actionListener="#{demoBeanProducto.prepararEditar(item)}"
icon="pi pi-fw pi-pencil"
ajax="true"
oncomplete="PF('dialogProducto').show()"
update=":dialogForm"
disabled="#{!demoBeanLogin.permisos}"/>
<p:commandButton styleClass="ui-button-danger"
actionListener="#{demoBeanProducto.prepararEliminar(item)}"
icon="pi pi-trash"
ajax="true"
oncomplete="PF('deleteProducto').show()"
update=":dialogDel"
style="margin-left: 1px"
/>
</div>
</p:column>
</p:dataTable>
</div>
</h:form>
<!-- agregar dialog modal -->
<p:dialog id="dialogForm"
header="#{demoBeanProducto.titulo}"
widgetVar="dialogProducto"
responsive="true"
showEffect="fade"
modal="true"
resizable="false"
width="auto"
height="auto">
<h:form>
<p:growl id="growl" showDetail="true" for="mensajeProducto"/>
<h:panelGrid columns="6" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre"
value="#{demoBeanProducto.producto.nombre}"
title="Nombre"
required="true"
validatorMessage="Verifique el nombre"
requiredMessage="Este campo no puede estar vacio" >
<f:validateRegex pattern="\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-Za-zÁÉÍÓÚÜÑ][a-záéíóúüñ]{0,})*\b"
for="nombre" />
</p:inputText>
<p:outputLabel value="Codigo:" for="codigo" />
<p:inputText id="codigo"
value="#{demoBeanProducto.producto.codigo}"
title="Codigo"
required="true"
converterMessage="Solo se aceptan numeros"
requiredMessage="Este campo no puede estar vacio"/>
<p:outputLabel value="Precio:" for="precio" />
<p:inputText id="precio"
value="#{demoBeanProducto.producto.precio}"
title="Precio"
required="true"
converterMessage="Solo se aceptan numeros"
requiredMessage="Este campo no puede estar vacio"/>
<p:outputLabel></p:outputLabel>
<p:message id="alertNombre" for="nombre" />
<p:outputLabel></p:outputLabel>
<p:message id="alertCodigo" for="codigo" />
<p:outputLabel></p:outputLabel>
<p:message id="alertPrecio" for="precio" />
<p:outputLabel value="Piezas:" for="piezas" />
<p:inputText id="piezas"
value="#{demoBeanProducto.producto.piezas}"
title="Piezas"
required="true"
converterMessage="Solo se aceptan numeros"
requiredMessage="Este campo no puede estar vacio"/>
<p:outputLabel value="Proveedor:"
for="proveedorId" />
<p:selectOneMenu id="proveedorId"
value="#{demoBeanProducto.producto.proveedorIdproveedor}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un proveedor" >
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanProveedor.proveedores}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:outputLabel value="Ubicacion"
for="ubicacionId" />
<p:selectOneMenu id="ubicacionId"
value="#{demoBeanProducto.producto.ubicacionId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita una ubicacion">
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanUbicacion.ubicacion}"
var="item"
itemLabel="#{item.bloque}#{item.anaquel}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:outputLabel></p:outputLabel>
<p:message id="alertPiezas" for="piezas" />
<p:outputLabel></p:outputLabel>
<p:message id="alertProveedorId" for="proveedorId" />
<p:outputLabel></p:outputLabel>
<p:message id="alertUbicacionId" for="ubicacionId" />
<p:outputLabel value="Tipo:"
for="tipoId" />
<p:selectOneMenu id="tipoId"
value="#{demoBeanProducto.producto.tipoId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un tipo">
TODO: update below reference to list of available items
<f:selectItems value="#{demoBeanTipo.tipos}"
var="item"
itemLabel="#{item.tipo}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:outputLabel></p:outputLabel>
<p:outputLabel></p:outputLabel>
<p:outputLabel></p:outputLabel>
<p:outputLabel></p:outputLabel>
<p:outputLabel></p:outputLabel>
<p:outputLabel></p:outputLabel>
<p:message id="alertTipo" for="tipoId" />
</h:panelGrid>
<p:commandButton action="#{demoBeanProducto.agregarProducto()}"
update="growl, productoTable:table,
nombre, codigo, precio, piezas, proveedorId, ubicacionId,
alertNombre, alertCodigo, alertPrecio, alertPiezas, alertProveedorId, alertUbicacionId, alertTipo"
rendered="#{demoBeanProducto.nuevo}"
ajax="true"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-save"/>
<p:commandButton action="#{demoBeanProducto.editarProducto()}"
update="growl, productoTable:table,
nombre, codigo, precio, piezas, proveedorId, ubicacionId,
alertNombre, alertCodigo, alertPrecio, alertPiezas, alertProveedorId, alertUbicacionId, alertTipo"
rendered="#{!demoBeanProducto.nuevo}"
ajax="true"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"/>
<p:commandButton action="productoLista.xhtml"
immediate="true"
ajax="false"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</h:form>
</p:dialog>
<p:dialog id="dialogDel"
header="Eliminar producto"
widgetVar="deleteProducto"
responsive="true"
showEffect="fade"
modal="true"
resizable="false" >
<h:form>
<h:panelGrid columns="6" cellpadding="7">
<h:outputText value="Nombre:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.nombre}" title="Nombre"/>
<h:outputText value="Codigo:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.codigo}" title="Codigo"/>
<h:outputText value="Precio:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.precio}" title="Precio"/>
<h:outputText value="Piezas:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.piezas}" title="Piezas"/>
<h:outputText value="Estado:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.estado == 2 ? 'Activo':'Inactivo'}" title="Estado"/>
<h:outputText value="Fecha:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.fecha}" title="Fecha">
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:outputText>
<h:outputText value="Proveedor:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.proveedorIdproveedor.nombre}" title="ProveedorIdproveedor"/>
<h:outputText value="Marca:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.proveedorIdproveedor.marcaId.nombre}" title="ProveedorIdproveedor"/>
<h:outputText value="Tipo:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.tipoId.tipo}" title="TipoId"/>
<h:outputText value="Ubicacion:" style="font-weight: bold;"/>
<h:outputText value="#{demoBeanProducto.producto.ubicacionId.bloque}#{demoBeanProducto.producto.ubicacionId.anaquel}" title="UbicacionId"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 20px; justify-content: flex-end;">
<p:commandButton action="#{demoBeanProducto.eliminarProducto()}"
ajax="true"
icon="pi pi-trash"
styleClass="ui-button-warning"
style="margin-top: 5px; width: 50px;"
update="productoTable:table"/>
<p:commandButton action="productoLista.xhtml"
immediate="true"
ajax="false"
style="margin-top: 5px; margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</footer>
</h:form>
</p:dialog>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

94
ProyectoInventario-war/web/proveedorCrearEditar.xhtml

@ -0,0 +1,94 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="#{demoBeanProveedor.titulo}"/></h1>
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre"
value="#{demoBeanProveedor.proveedor.nombre}"
title="Nombre"
required="true"
validatorMessage="El nombre no es valido"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,})*\b"
for="nombre"/>
</p:inputText>
<p:outputLabel value="Telefono:" for="telefono" />
<p:inputText id="telefono"
value="#{demoBeanProveedor.proveedor.telefono}"
title="Telefono"
required="true" validatorMessage="El numero de telefono no es valido"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="^\d{10}$"
for="telefono"/>
</p:inputText>
<p:outputLabel value="Email:" for="email" />
<p:inputText id="email"
value="#{demoBeanProveedor.proveedor.email}"
title="Email"required="true" validatorMessage="El email no es valido"
requiredMessage="Este campo no puede estar vacio">
<f:validateRegex pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
for="email"/>
</p:inputText>
<p:commandButton action="#{demoBeanProveedor.agregar()}"
rendered="#{demoBeanProveedor.nuevo}"
styleClass="ui-button-success" style="width: 50px;" icon="pi pi-check"
update="messages" ajax="false"/>
<p:commandButton action="proveedorLista.xhtml"
actionListener="#{demoBeanProveedor.editarP()}"
rendered="#{!demoBeanProveedor.nuevo}"
styleClass="ui-button-secondary"
icon="pi pi-pencil"
value="Editar" ajax="false"/>
<p:commandButton action="proveedorLista.xhtml" style="margin-left: 5px; width: 50px; " icon="pi pi-times" styleClass="ui-button-danger" ajax="false" immediate="true"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

61
ProyectoInventario-war/web/proveedorEliminar.xhtml

@ -0,0 +1,61 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="Eliminar"/></h1>
<p:panelGrid columns="2">
<h:outputText value="Id:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.id}" title="Id"/>
<h:outputText value="Nombre:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.nombre}" title="Nombre"/>
<h:outputText value="Telefono:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.telefono}" title="Telefono"/>
<h:outputText value="Email:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.email}" title="Email"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.estado}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="proveedorLista.xhtml" actionListener="#{demoBeanProveedor.eliminarProveedor()}"
icon="pi pi-trash"
styleClass="ui-button-warning"
style=" width: 50px; " ajax="false"/>
<p:commandButton action="proveedorLista.xhtml" icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false"
style="margin-left: 5px; width: 50px;" immediate="true"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

427
ProyectoInventario-war/web/proveedorLista.xhtml

@ -0,0 +1,427 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<ui:composition template="./template/listas.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="content">
<f:view>
<div>
<h:form>
<p:menubar>
<p:menuitem value="Productos" action="productoLista.xhtml" ajax="false"/>
<p:menuitem value="Marcas" action="marcaLista.xhtml" ajax="false"/>
<p:menuitem value="Proveedores" action="proveedorLista.xhtml" disabled="true" ajax="false"/>
<p:menuitem value="Ubicaciones" action="ubicacionLista.xhtml" ajax="false"/>
<p:menuitem value="Usuarios" action="usuariosLista.xhtml" ajax="false"/>
<p:submenu label="Opciones" icon="pi pi-fw pi-list">
<p:menuitem value="Roles"
icon="pi pi-fw pi-users"
oncomplete="PF('rol').show()"
update=":rolD"
actionListener="#{demoBeanRoles.prepararNuevo()}"/>
<p:menuitem value="Paises"
icon="pi pi-globe"
oncomplete="PF('pais').show()"
update="paisDialog"
actionListener="#{demoBeanPaises.prepararNuevo()}"/>
<p:menuitem value="Estados"
icon="pi pi-map"
oncomplete="PF('estado').show()"
update="estadosDialog"
actionListener="#{demoBeanEstados.prepararNuevo()}"/>
<p:menuitem value="Tipos"
icon="pi pi-tags"
oncomplete="PF('tipo').show()"
update=":tip"
actionListener="#{demoBeanTipo.prepararNuevo()}"/>
<!-- <p:divider />-->
</p:submenu>
</p:menubar>
</h:form>
<p:dialog id="rolD" widgetVar="rol"
header="#{demoBeanRoles.titulo}"
responsive="true"
showEffect="fade" modal="true" resizable="false">
<ui:include src="roles.xhtml"/>
</p:dialog>
<p:dialog id="tip" widgetVar="tipo" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="tipos.xhtml"/>
</p:dialog>
<p:dialog id="paisDialog" widgetVar="pais" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="paises.xhtml"/>
</p:dialog>
<p:dialog id="estadosDialog" widgetVar="estado" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="estados.xhtml"/>
</p:dialog>
</div>
<h:form id="proveedorTabla">
<p:growl id="messages" showDetail="true" for="mensajeProveedor"/>
<div class="card">
<p:dataTable id="table"
value="#{demoBeanProveedor.proveedores}"
var="item"
filteredValue="#{demoBeanProveedor.proveedorFilter}"
globalFilterFunction="#{demoBeanProveedor.globalFilterFunction}"
widgetVar="filtro"
resizableColumns="true"
showGridlines="true"
paginator="true"
paginatorPosition="bottom"
rows="10"
rowSelectMode="add">
<f:facet name="header">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="flex: 1;">
<p:commandButton actionListener="#{demoBeanProveedor.prepararnuevo()}"
icon="pi pi-plus"
oncomplete="PF('dialogproveedor').show()"
update=":dialogForm"
style="margin-top: 5px"
value="Nuevo"
ajax="true"/>
</div>
<div style="flex: 1; text-align: center;"> <!-- Div para el texto centrado -->
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Proveedores</strong></header>
</div>
<div style="flex: 1; text-align: right;">
<div class="ui-input-icon-left mr-2" >
<i class="pi pi-fw pi-search" />
<p:inputText id="globalFilter" onkeyup="PF('filtro').filter()"
style="width:300px"
placeholder="Buscador de proveedores" />
</div>
</div>
</div>
</f:facet>
<h1><h:outputText value=""/></h1>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre"/>
</f:facet>
<h:outputText value="#{item.nombre}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Telefono"/>
</f:facet>
<h:outputText value="#{item.telefono}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Email"/>
</f:facet>
<h:outputText value="#{item.email}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="Domicilio"/>
</f:facet>
<h:outputText value="#{item.domicilio}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="EstadosId"/>
</f:facet>
<h:outputText value="#{item.estadosId}"/>
</p:column>
<p:column responsivePriority="1" style="text-align: center;">
<f:facet name="header">
<h:outputText value="MarcaId"/>
</f:facet>
<h:outputText value="#{item.marcaId}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<div style="text-align: center">
<p:commandButton action="#{demoBeanProveedor.prepararEditar(item)}"
styleClass="ui-button-secondary"
oncomplete="PF('dialogproveedor').show()"
update=":dialogForm"
icon="pi pi-pencil"
ajax="true"/>
<p:commandButton actionListener="#{demoBeanProveedor.prepararEliminar(item)}"
icon="pi pi-trash"
oncomplete="PF('deleteProveedor').show()"
update=":dialogForm1"
style="margin-left: 5px"
styleClass="ui-button-danger"
ajax="true"/>
</div>
</p:column>
</p:dataTable>
</div>
</h:form>
<!-- agregar dialog modal -->
<p:dialog id="dialogForm"
header="#{demoBeanProveedor.titulo}"
widgetVar="dialogproveedor"
responsive="true"
showEffect="fade"
modal="true"
resizable="false">
<h:form>
<p:growl id="messages" showDetail="true" for="mensajeProveedor"/>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Nombre" for="nombre" />
<p:inputText id="nombre"
value="#{demoBeanProveedor.proveedor.nombre}"
title="Nombre"
required="true"
validatorMessage="Nombre no valido"
requiredMessage="Este campo no puede estar vacio" >
<f:validateRegex pattern="\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,})*\b"
for="nombre" />
</p:inputText>
<p:message id="n" for="nombre"/>
<p:outputLabel value="Telefono" for="telefono" />
<p:inputText id="telefono"
value="#{demoBeanProveedor.proveedor.telefono}"
title="Telefono"
required="true"
validatorMessage="Numero de telefono no valido"
requiredMessage="Este campo no puede estar vacio" >
<f:validateRegex pattern="^\d{10}$"
for="telefono" />
</p:inputText>
<p:message id="t" for="telefono"/>
<p:outputLabel value="Email" for="email" />
<p:inputText id="email"
value="#{demoBeanProveedor.proveedor.email}"
title="Email"
required="true"
validatorMessage="Email no valido"
requiredMessage="Este campo no puede estar vacio" >
<f:validateRegex pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
for="email" />
</p:inputText>
<p:message id="e" for="email"/>
<p:outputLabel value="Domicilio:" for="domicilio" />
<p:inputText id="domicilio"
value="#{demoBeanProveedor.proveedor.domicilio}"
title="Domicilio"
required="true"
requiredMessage="The Domicilio field is required."/>
<p:message id="d" for="domicilio"/>
<p:outputLabel value="EstadosId:" for="estadosId" />
<p:selectOneMenu id="estadosId"
value="#{demoBeanProveedor.proveedor.estadosId}"
required="true"
requiredMessage="The EstadosId field is required." filter="true"
filterMatchMode="startsWith" >
<!-- Arriba esta lo del filtro, jsjsjsjs -->
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanEstados.estados}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:message id="eid" for="estadosId"/>
<p:outputLabel value="Marca:" for="marcaId" />
<p:selectOneMenu id="marcaId"
value="#{demoBeanProveedor.proveedor.marcaId}"
required="true"
requiredMessage="The MarcaId field is required."
filter="true"
filterMatchMode="startsWith" >
<!-- Arriba esta lo del filtro, jsjsjsjs -->
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{demoBeanMarca.marcas}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
</p:selectOneMenu>
<p:message id="m" for="marcaId"/>
</h:panelGrid>
<!-- botones en ajax true (excepto el cancelar) y updates referenciando a ids del dialog
(sobretodo a los id de los inputTxt) y tabla para actualizarla. continua en el bean -->
<p:commandButton action="#{demoBeanProveedor.agregar()}"
update="messages, proveedorTabla:table,email,e, nombre,n, telefono, t, "
rendered="#{demoBeanProveedor.nuevo}"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-save" ajax="true"
/>
<p:commandButton action="#{demoBeanProveedor.editarP()}"
update="messages, proveedorTabla:table,email,e, nombre,n, telefono, t, "
rendered="#{!demoBeanProveedor.nuevo}"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"
ajax="true"/>
<p:commandButton action="proveedorLista.xhtml" immediate="true"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times" styleClass="ui-button-danger"
ajax="false"/>
</h:form>
</p:dialog>
<p:dialog id="dialogForm1"
header="#{demoBeanProveedor.titulo} "
widgetVar="deleteProveedor"
responsive="true"
showEffect="fade"
modal="true"
resizable="true"
width="auto"
height="200">
<h:form>
<p:growl id="messages" showDetail="true" for="mensajeProveedor"/>
<h1><h:outputText value=""/></h1>
<p:panelGrid columns="2">
<h:outputText value="Nombre:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.nombre}" title="Nombre"/>
<h:outputText value="Telefono:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.telefono}" title="Telefono"/>
<h:outputText value="Email:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.email}" title="Email"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanProveedor.proveedor.estado}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="#{demoBeanProveedor.eliminarProveedor()}"
update="proveedorTabla:table, messages"
icon="pi pi-trash"
styleClass="ui-button-warning"
style=" width: 50px; " ajax="true"/>
<p:commandButton action="proveedorLista.xhtml" icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false"
style="margin-left: 5px; width: 50px;" immediate="true"/>
</h:form>
</p:dialog>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

82
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;
}

31
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;
}

93
ProyectoInventario-war/web/roles.xhtml

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<f:view>
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Roles</strong></header>
<p:divider/>
<main style="display: flex; justify-content: space-between; gap: 10px;">
<h:form id="rolForm">
<p:growl id="messages" showDetail="true" for="mensajeRoles"/>
<p:dataTable id="table" value="#{demoBeanRoles.roles}" var="item" style="width: 600px"
paginator="true" rows="5" rowSelectMode="add" paginatorPosition="bottom">
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Id"/>
</f:facet>
<h:outputText value="#{item.id}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Rol"/>
</f:facet>
<h:outputText value="#{item.rol}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Estado"/>
</f:facet>
<h:outputText value="#{item.estado == 2 ? 'Activo':'Inactivo'}"/>
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<p:commandButton action="#{demoBeanRoles.eliminarRol(item)}" icon="pi pi-trash" style="margin-left: 5px" styleClass="ui-button-warning"
update="table"
ajax="true"/>
</p:column>
</p:dataTable>
</h:form>
<h:form style="margin-top: 20px;">
<header style="display: flex; justify-content: center;">Nuevo Rol</header>
<p:divider/>
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel value="Rol:" for="rol" />
<p:inputText id="rol" value="#{demoBeanRoles.rol.rol}" title="Rol" required="true"
requiredMessage="Este campo no puede estar vacio"
validatorMessage="entrada no valida"
>
<f:validateRegex pattern="^\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}\b$"
for="apellidoPaterno" />
</p:inputText>
<p:outputLabel></p:outputLabel>
<p:message id="rols" for="rol"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 280px; justify-content: flex-end;"> <!-- alinear a derecha -->
<p:commandButton action="#{demoBeanRoles.agregarRol()}" update="rolForm:table,rol,rols,rolForm:messages" rendered="#{demoBeanRoles.nuevo}"
styleClass="ui-button-success" style="width: 50px;"
icon="pi pi-save" ajax="true"
/>
<p:commandButton oncomplete="PF('rol').close()" immediate="true" style="margin-left: 5px; width: 50px; " icon="pi pi-times" styleClass="ui-button-danger"
ajax="false"/>
</footer>
</h:form>
</main>
</f:view>
</body>
</html>

48
ProyectoInventario-war/web/template/listas.xhtml

@ -0,0 +1,48 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="./css/default.css"/>
<h:outputStylesheet name="./css/cssLayout.css"/>
<title>Gestor de inventario</title>
</h:head>
<h:body>
<div class="titulo" id="top">
<center>
<h class="centro">Almacen, Bienvenido #{demoBeanLogin.user}</h>
<h:form>
<p:commandButton action="#{demoBeanLogin.logout()}"
immediate="true"
ajax="false"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"/>
</h:form>
</center>
</div>
<div id="content" class="center_content">
<ui:insert name="content">Content</ui:insert>
</div>
<div id="bottom">
<center>
<h5>Derechos reservados XFORCE</h5>
<!-- <ui:insert name="bottom">Bottom</ui:insert>-->
<h5>2024</h5>
</center>
</div>
</h:body>
</html>

57
ProyectoInventario-war/web/template/principal.xhtml

@ -0,0 +1,57 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="./css/default.css"/>
<h:outputStylesheet name="./css/cssLayout.css"/>
<!-- <script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<link href="https://cdn.datatables.net/v/dt/dt-2.0.2/datatables.min.css" rel="stylesheet"/>
<script src="https://cdn.datatables.net/v/dt/dt-2.0.2/datatables.min.js"></script>-->
<title>Gestor de inventario</title>
<style>
</style>
</h:head>
<h:body>
<div class="titulo" id="top">
<center>
<h class="centro">Almacen</h>
</center>
</div>
<div>
<div id="left">
<ui:insert name="left">Left</ui:insert>
</div>
<div>
<div id="right">
<ui:insert name="right">Right</ui:insert>
</div>
<div id="content" class="right_content">
<ui:insert name="content">Content</ui:insert>
</div>
</div>
</div>
<div id="bottom">
<h5>Derechos reservados XFORCE</h5>
<!-- <ui:insert name="bottom">Bottom</ui:insert>-->
<h5>2024</h5>
</div>
</h:body>
</html>

167
ProyectoInventario-war/web/tipos.xhtml

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body>
<f:view>
<main style="display: flex; justify-content: space-between;">
<h:form id="tipT">
<p:growl id="messages" showDetail="true" for="tipoM"/>
<p:dataTable id="table" value="#{demoBeanTipo.tipos}" var="item" style="width: 600px"
paginator="true" rows="5" rowSelectMode="add" paginatorPosition="bottom">
<h1><h:outputText value="List"/></h1>
<p:column>
<f:facet name="header">
<h:outputText value="Id"/>
</f:facet>
<h:outputText value="#{item.id}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Tipo"/>
</f:facet>
<h:outputText value="#{item.tipo}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<p:commandButton action="#{demoBeanTipo.eliminarTipo(item)}"
icon="pi pi-trash"
style="margin-left: 5px"
styleClass="ui-button-danger"
oncomplete="PF('tipo').show()"
update="table"
ajax="true"/>
</p:column>
</p:dataTable>
</h:form>
<h:form style="margin-left: 20px; margin-top: 20px;">
<header style="display: flex; justify-content: center;">Nuevo tipo</header>
<p:divider/>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Tipo" for="tipo" />
<p:inputText id="tipo"
value="#{demoBeanTipo.tipo.tipo}"
title="Tipo"
required="true"
requiredMessage="este campo no puede estar vacio"
validatorMessage="entrada no valida"
>
<f:validateRegex pattern="^\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}\b$"
for="apellidoPaterno" />
</p:inputText>
<p:message id="tipos" for="tipo"/>
</h:panelGrid>
<footer style="display: flex; margin-top: 340px; justify-content: flex-end;"> <!-- alinear a derecha -->
<p:commandButton action="#{demoBeanTipo.agregar()}"
update="tipT:table,tipo,tipos,tipT:messages"
rendered="#{demoBeanTipo.nuevo}"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-save" ajax="true"
/>
<p:commandButton oncomplete="pf('tipo').close()"
immediate="true"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false"/>
</footer>
</h:form>
</main>
</f:view>
</body>
</html>

84
ProyectoInventario-war/web/ubicacionCrearEditar.xhtml

@ -0,0 +1,84 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<p:messages id="messages" showDetail="true" closable="true">
</p:messages>
<h1><h:outputText value="#{demoBeanUbicacion.titulo}"/></h1>
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel value="Bloque:" for="bloque" />
<p:inputText converter="" id="bloque"
value="#{demoBeanUbicacion.ubi.bloque}"
title="Bloque"
required="true"
validatorMessage="Asignación no valida"
requiredMessage="Asignación no valida">
</p:inputText>
<p:outputLabel value="Anaquel:" for="anaquel" />
<p:inputText id="anaquel" value="#{demoBeanUbicacion.ubi.anaquel}" title="Anaquel" />
</h:panelGrid>
<p:commandButton action="#{demoBeanUbicacion.agregar()}"
update="messages"
styleClass="ui-button-success"
style="width: 50px;" icon="pi pi-check"
rendered="#{demoBeanUbicacion.nuevo}"
ajax="false"/>
<p:commandButton
action="#{demoBeanUbicacion.editarU()}"
rendered="#{!demoBeanUbicacion.nuevo}"
update="messages"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;" ajax="false"/>
<p:commandButton action="ubicacionLista.xhtml" style="margin-left: 5px; width: 50px; "
icon="pi pi-times"
styleClass="ui-button-danger"
ajax="false" immediate="true"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

58
ProyectoInventario-war/web/ubicacionEliminar.xhtml

@ -0,0 +1,58 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="right">
right
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="Eliminar"/></h1>
<p:panelGrid columns="2">
<h:outputText value="Id:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.id}" title="Id"/>
<h:outputText value="Bloque:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.bloque}" title="Bloque"/>
<h:outputText value="Anaquel:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.anaquel}" title="Anaquel"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.estado}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="ubicacionLista.xhtml" actionListener="#{demoBeanUbicacion.eliminarUbicacion()}"
icon="pi pi-trash"
style=" width: 50px; "
styleClass="ui-button-warning" ajax="false"/>
<p:commandButton action="ubicacionLista.xhtml" icon="pi pi-times"
styleClass="ui-button-danger"
style="margin-left: 5px; width: 50px;"
immediate="true" ajax="false"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

306
ProyectoInventario-war/web/ubicacionLista.xhtml

@ -0,0 +1,306 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/listas.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="content">
<f:view>
<div>
<h:form>
<p:menubar>
<p:menuitem value="Productos" action="productoLista.xhtml" ajax="false"/>
<p:menuitem value="Marcas" action="marcaLista.xhtml" ajax="false"/>
<p:menuitem value="Proveedores" action="proveedorLista.xhtml" ajax="false"/>
<p:menuitem value="Ubicaciones" action="ubicacionLista.xhtml" disabled="true" ajax="false"/>
<p:menuitem value="Usuarios" action="usuariosLista.xhtml" ajax="false"/>
<p:submenu label="Opciones" icon="pi pi-fw pi-list">
<p:menuitem value="Roles"
icon="pi pi-fw pi-users"
oncomplete="PF('rol').show()"
update=":rolD"
actionListener="#{demoBeanRoles.prepararNuevo()}"/>
<p:menuitem value="Paises"
icon="pi pi-globe"
oncomplete="PF('pais').show()"
update="paisDialog"
actionListener="#{demoBeanPaises.prepararNuevo()}"/>
<p:menuitem value="Estados"
icon="pi pi-map"
oncomplete="PF('estado').show()"
update="estadosDialog"
actionListener="#{demoBeanEstados.prepararNuevo()}"/>
<p:menuitem value="Tipos"
icon="pi pi-tags"
oncomplete="PF('tipo').show()"
update=":tip"
actionListener="#{demoBeanTipo.prepararNuevo()}"/>
<!-- <p:divider />-->
</p:submenu>
</p:menubar>
</h:form>
<p:dialog id="rolD" widgetVar="rol" header="#{demoBeanRoles.titulo}" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="roles.xhtml"/>
</p:dialog>
<p:dialog id="tip" widgetVar="tipo" responsive="true" showEffect="fade" modal="true" resizable="false">
<ui:include src="tipos.xhtml"/>
</p:dialog>
<p:dialog id="paisDialog" widgetVar="pais" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="paises.xhtml"/>
</p:dialog>
<p:dialog id="estadosDialog" widgetVar="estado" responsive="true"
showEffect="fade" modal="true" resizable="false" style="height: auto">
<ui:include src="estados.xhtml"/>
</p:dialog>
</div>
<!--id para el formulario -->
<h:form id="ubicacionTabla" >
<p:growl id="messages" showDetail="true" />
<!-- agregar accionador de dialogo("oncomplete") y actualizar el mismo dialogo ("update") -->
<p:dataTable id="table" value="#{demoBeanUbicacion.ubicacion}"
var="item"
filteredValue="#{demoBeanUbicacion.ubicacionFilter}"
globalFilterFunction="#{demoBeanUbicacion.globalFilterFunction}"
widgetVar="filter"
paginator="true"
resizableColumns="true"
showGridlines="true"
paginatorPosition="bottom"
rows="10"
rowSelectMode="add" >
<f:facet name="header">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="flex: 1;">
<p:commandButton style="margin-top: 5px;"
actionListener="#{demoBeanUbicacion.prepararnuevo()}"
oncomplete="PF('mar').show()"
value="Nuevo"
update=":dialogForm"
icon="pi pi-plus"
ajax="true"/>
</div>
<div style="flex: 1; text-align: center;"> <!-- Div para el texto centrado -->
<header style="display: flex; justify-content: center; font-size: 30px;"><strong>Ubicacion</strong></header>
</div>
<div style="flex: 1; text-align: right;">
<div class="flex justify-content-end">
<p:inputText id="globalFilter"
onkeyup="PF('filter').filter()"
style="width:300px"
placeholder="Buscador general" />
</div>
</div>
</div>
</f:facet>
<p:column responsivePriority="3">
<f:facet name="header">
<h:outputText value="Bloque"/>
</f:facet>
<h:outputText value="#{item.bloque}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Anaquel"/>
</f:facet>
<h:outputText value="#{item.anaquel}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Opciones"/>
</f:facet>
<p:column>
<div style="text-align: center">
<p:commandButton actionListener="#{demoBeanUbicacion.prepararEditar(item)}"
oncomplete="PF('mar').show()"
update=":dialogForm"
icon="pi pi-fw pi-pencil"
styleClass="ui-button-secondary" ajax="true"
/>
<p:commandButton actionListener="#{demoBeanUbicacion.prepararEliminar(item)}"
ajax="true"
oncomplete="PF('deleteUbicacion').show()"
update=":dialogForm1"
icon="pi pi-trash"
style="margin-left: 5px"
styleClass="ui-button-danger"/>
</div>
</p:column>
</p:column>
</p:dataTable>
</h:form>
<!-- agregar dialog modal -->
<p:dialog id="dialogForm"
header="#{demoBeanUbicacion.titulo}"
widgetVar="mar"
responsive="true"
showEffect="fade"
modal="true"
resizable="true"
width="auto"
height="120">
<h:form>
<p:growl id="messages" showDetail="true" for="mensajeUbicacion"/>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Bloque" for="bloque" />
<p:inputText id="bloque"
value="#{demoBeanUbicacion.ubi.bloque}"
title="Bloque"
required="true"
requiredMessage="El campo no debe estar vacio"
validatorMessage="Asignación no valida" >
<f:validateRegex pattern="^[A-Z]$"
for="bloque"/>
</p:inputText>
<p:message id="block" for="bloque"/>
<p:outputLabel value="Anaquel:" for="anaquel" />
<p:inputText id="anaquel"
value="#{demoBeanUbicacion.ubi.anaquel}"
title="Anaquel"
required="true"
requiredMessage="Asignación no valida"
>
</p:inputText>
<p:message id="y" for="bloque"/>
</h:panelGrid>
<!-- botones en ajax true (excepto el cancelar) y updates referenciando a ids del dialog
(sobretodo a los id de los inputTxt) y tabla para actualizarla. continua en el bean -->
<p:commandButton action="#{demoBeanUbicacion.agregar()}"
update="messages, ubicacionTabla:table, bloque,block"
rendered="#{demoBeanUbicacion.nuevo}"
styleClass="ui-button-success"
style="width: 50px;"
icon="pi pi-save"
ajax="true"
/>
<p:commandButton action="#{demoBeanUbicacion.editarU()}"
update="messages, ubicacionTabla:table, bloque,block"
rendered="#{!demoBeanUbicacion.nuevo}"
icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;"
ajax="true"/>
<p:commandButton action="ubicacionLista.xhtml" immediate="true"
style="margin-left: 5px; width: 50px; "
icon="pi pi-times" styleClass="ui-button-danger"
ajax="false"/>
</h:form>
</p:dialog>
<p:dialog id="dialogForm1"
header="#{demoBeanUbicacion.titulo}"
widgetVar="deleteUbicacion"
responsive="true"
showEffect="fade"
modal="true"
resizable="true"
width="auto"
height="200">
<h:form>
<p:growl id="messages" showDetail="true" for="mensajeUbicacion"/>
<p:panelGrid columns="2">
<h:outputText value="Bloque:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.bloque}" title="Bloque"/>
<h:outputText value="Anaquel:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.anaquel}" title="Anaquel"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanUbicacion.ubi.estado}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="#{demoBeanUbicacion.eliminarUbicacion()}"
update="ubicacionTabla:table,messages"
icon="pi pi-trash"
style=" width: 50px; "
styleClass="ui-button-warning" ajax="true"/>
<p:commandButton action="ubicacionLista.xhtml" icon="pi pi-times"
styleClass="ui-button-danger"
style="margin-left: 5px; width: 50px;"
immediate="true" ajax="false"/>
</h:form>
</p:dialog>
</f:view>
</ui:define>
</ui:composition>
<script>
       </script>
</body>
</html>

68
ProyectoInventario-war/web/usuarioCrearEditar.xhtml

@ -0,0 +1,68 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="left">
</ui:define>
<ui:define name="right">
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<p:messages id="messages" showDetail="true" closable="true">
<p:autoUpdate/>
</p:messages>
<h1><h:outputText value="#{demoBeanUsuarios.titulo}"/></h1>
<h:panelGrid columns="3" cellpadding="7">
<p:outputLabel value="Nombre:" for="nombre" />
<p:inputText id="nombre" value="#{demoBeanUsuarios.usuario.nombre}" title="Nombre" required="true" />
<p:message for="nombre" display="tooltip"/>
<p:outputLabel value="Apellido P:" for="apellidoPaterno" />
<p:inputText id="apellidoPaterno" value="#{demoBeanUsuarios.usuario.apellidoPaterno}" title="ApellidoPaterno" required="true"/>
<p:message for="apellidoPaterno" display="tooltip"/>
<p:outputLabel value="Email:" for="email" />
<p:inputText id="email" value="#{demoBeanUsuarios.usuario.email}" title="Email" required="true"/>
<p:message for="email" display="tooltip"/>
<p:outputLabel value="Telefono:" for="telefono" />
<p:inputText id="telefono" value="#{demoBeanUsuarios.usuario.telefono}" title="Telefono" required="true"/>
<p:message for="telefono" display="tooltip"/>
</h:panelGrid>
<p:commandButton action="#{demoBeanUsuarios.agregar()}" rendered="#{demoBeanUsuarios.nuevo}" styleClass="ui-button-success" style="width: 50px;" icon="pi pi-save" ajax="false"/>
<p:commandButton action="#{demoBeanUsuarios.editarUsuario()}" icon="pi pi-save"
styleClass="ui-button-success"
style="width: 50px;" rendered="#{!demoBeanUsuarios.nuevo}" ajax="false"/>
<p:commandButton action="usuariosLista.xhtml" style="margin-left: 5px; width: 50px; " immediate="true" icon="pi pi-times" ajax="false" styleClass="ui-button-danger"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

63
ProyectoInventario-war/web/usuarioEliminar.xhtml

@ -0,0 +1,63 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="./template/principal.xhtml">
<ui:define name="top">
</ui:define>
<ui:define name="left">
</ui:define>
<ui:define name="right">
</ui:define>
<ui:define name="content">
<f:view>
<h:form>
<h1><h:outputText value="Eliminar"/></h1>
<p:panelGrid columns="2">
<h:outputText value="Id:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.id}" title="Id"/>
<h:outputText value="Nombre:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.nombre}" title="Nombre"/>
<h:outputText value="ApellidoPaterno:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.apellidoPaterno}" title="ApellidoPaterno"/>
<h:outputText value="Email:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.email}" title="Email"/>
<h:outputText value="Telefono:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.telefono}" title="Telefono"/>
<h:outputText value="Estado:"/>
<h:outputText value="#{demoBeanUsuarios.usuario.estado == 2 ? 'Activo':'Inactivo'}" title="Estado"/>
</p:panelGrid>
<p:commandButton action="usuariosLista.xhtml" actionListener="#{demoBeanUsuarios.eliminarUsuario()}" ajax="false"
icon="pi pi-trash"
styleClass="ui-button-warning"
style=" width: 50px; "
/>
<p:commandButton action="usuariosLista.xhtml" immediate="true" ajax="false"
icon="pi pi-times"
styleClass="ui-button-danger"
style="margin-left: 5px; width: 50px;"
/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save