Download PROYECTO FINAL DE MÁSTER Junio 2013
Document related concepts
no text concepts found
Transcript
“OPTIMIZACION Y AUTOMATIZACION DEL PROCESO DE COMPRA PARA TIENDAS DE COSUMO MASIVO A TRAVES DE TECNOLOGIA MOVIL Y JEE” PROYECTO FINAL DE MÁSTER Junio 2013 Gabriel Alejandro León Paredes Carlos Efrain IñiguezJarrín 1 INDICE 1 OBJETIVO..................................................................................................................................... 14 2 ALCANCE ..................................................................................................................................... 14 3 INTRODUCCIÓN ........................................................................................................................... 14 4 IDENTIFICACIÓN DE REQUISITOS ................................................................................................. 16 4.1 5 MODELO DE DOMINIO .................................................................................................................... 16 FLUJO DE TRABAJO: REQUISITOS ................................................................................................. 16 5.1 GLOSARIO DE TÉRMINOS ................................................................................................................. 16 5.2 IDENTIFICACIÓN DE CASOS DE USO .................................................................................................... 17 5.2.1 Identificar Actores................................................................................................................. 17 5.2.2 Identificar Casos de Uso........................................................................................................ 17 5.3 PRIORIZAR CASOS DE USO ............................................................................................................... 17 5.4 DIAGRAMA GENERAL DE CASOS DE USO ............................................................................................. 18 5.5 DETALLAR CASOS DE USO ................................................................................................................ 19 5.5.1 Paquete Gestión: Acceso ...................................................................................................... 20 5.5.1.1 5.5.2 Paquete Gestión: Marca ....................................................................................................... 22 5.5.2.1 5.5.1 Prototipos de Interfaz ................................................................................................................ 38 Paquete Gestión: Medios de Pago ........................................................................................ 39 5.5.8.1 5.5.9 Prototipos de Interfaz ................................................................................................................ 36 Paquete Gestión: Usuarios.................................................................................................... 37 5.5.7.1 5.5.8 Prototipos de Interfaz ................................................................................................................ 34 Paquete Gestión: Roles ......................................................................................................... 35 5.5.6.1 5.5.7 Prototipos de Interfaz ................................................................................................................ 32 Paquete Gestión: Descuentos ............................................................................................... 33 5.5.5.1 5.5.6 Prototipos de Interfaz ................................................................................................................ 30 Paquete Gestión: Productos ................................................................................................. 31 5.5.4.1 5.5.5 Prototipos de Interfaz ................................................................................................................ 28 Paquete Gestión: Bodegas .................................................................................................... 29 5.5.3.1 5.5.4 Prototipos de Interfaz ................................................................................................................ 26 Paquete Gestión: Agencias ................................................................................................... 27 5.5.2.1 5.5.3 Prototipos de Interfaz ................................................................................................................ 24 Paquete Gestión: Empresa.................................................................................................... 25 5.5.1.1 5.5.2 Prototipos de Interfaz ................................................................................................................ 21 Prototipos de Interfaz ................................................................................................................ 40 Paquete Gestión: Categorías ................................................................................................ 40 5.5.9.1 5.5.10 5.5.10.1 5.5.11 5.5.11.1 5.5.12 5.5.12.1 Prototipos de Interfaz ................................................................................................................ 41 Paquete Gestión: Reportes ............................................................................................... 42 Prototipo de Interfaz .................................................................................................................. 42 Paquete Gestión: Facturas ............................................................................................... 44 Prototipo de Interfaz .................................................................................................................. 45 Paquete Gestión: Descuento por Producto ...................................................................... 47 Prototipos de Interfaz ................................................................................................................ 48 2 5.5.13 Paquete Gestión: Empleados por Agencia ....................................................................... 48 5.5.13.1 5.5.14 5.5.14.1 5.5.15 6 Prototipos de Interfaz ................................................................................................................ 52 Paquete Gestión: Compras ............................................................................................... 52 5.5.15.1 5.6 Prototipos de Interfaz ................................................................................................................ 50 Paquete Gestión: Detalle en Bodega ................................................................................ 51 Prototipo de Interfaz .................................................................................................................. 54 DIAGRAMA DE CONTEXTO ............................................................................................................... 55 FLUJO DE TRABAJO: ANALISIS ...................................................................................................... 57 6.1 ANÁLISIS DE LA ARQUITECTURA ........................................................................................................ 57 6.2 ANÁLISIS DE CASOS DE USO ............................................................................................................. 58 6.2.1 Paquete: Agencia .................................................................................................................. 59 6.2.1.1 6.2.1.2 6.2.1.3 6.2.1.4 6.2.1.5 6.2.2 Paquete: Marca .................................................................................................................... 61 6.2.2.1 6.2.2.2 6.2.2.3 6.2.2.4 6.2.2.5 6.2.3 Caso de Uso: Alta Producto ........................................................................................................ 68 Caso de Uso: Baja Producto ....................................................................................................... 69 Caso de Uso: Crear Producto...................................................................................................... 69 Caso de Uso: Listar Producto...................................................................................................... 70 Caso de Uso: Modificar Producto ............................................................................................... 70 Paquete: Descuento .............................................................................................................. 71 6.2.6.1 6.2.6.2 6.2.6.3 6.2.6.4 6.2.6.5 6.2.7 Caso de Uso: Alta Bodega........................................................................................................... 66 Caso de Uso: Baja Bodega .......................................................................................................... 66 Caso de Uso: Crear Bodega ........................................................................................................ 67 Caso de Uso: Listar Bodega ........................................................................................................ 67 Caso de Uso: Modificar Bodega ................................................................................................. 68 Paquete: Producto ................................................................................................................ 68 6.2.5.1 6.2.5.2 6.2.5.3 6.2.5.4 6.2.5.5 6.2.6 Caso de Uso: Alta Empresa ......................................................................................................... 63 Caso de Uso: Baja Empresa ........................................................................................................ 64 Caso de Uso: Crear Empresa ...................................................................................................... 64 Caso de Uso: Listar Empresa ...................................................................................................... 65 Caso de Uso: Modificar Empresa................................................................................................ 65 Paquete: Bodega .................................................................................................................. 66 6.2.4.1 6.2.4.2 6.2.4.3 6.2.4.4 6.2.4.5 6.2.5 Caso de Uso: Alta Marca ............................................................................................................ 61 Caso de Uso: BajaMarca ............................................................................................................. 61 Caso de Uso: Crear Marca .......................................................................................................... 62 Caso de Uso: Listar Marca .......................................................................................................... 62 Caso de Uso: Modificar Marca ................................................................................................... 63 Paquete: Empresa ................................................................................................................. 63 6.2.3.1 6.2.3.2 6.2.3.3 6.2.3.4 6.2.3.5 6.2.4 Caso de Uso: Alta Agencia .......................................................................................................... 59 Caso de Uso: Baja Agencia ......................................................................................................... 59 Caso de Uso: Crear Agencia ........................................................................................................ 59 Caso de Uso: Listar Agencia ........................................................................................................ 60 Caso de Uso: Modificar Agencia ................................................................................................. 60 Caso de Uso: Alta Descuento ..................................................................................................... 71 Caso de Uso: Baja Descuento ..................................................................................................... 71 Caso de Uso: Crear Descuento ................................................................................................... 72 Caso de Uso: Listar Descuento ................................................................................................... 72 Caso de Uso: Modificar Descuento ............................................................................................ 73 Paquete: Rol.......................................................................................................................... 73 6.2.7.1 6.2.7.2 6.2.7.3 Caso de Uso: Alta Rol ................................................................................................................. 73 Caso de Uso: Baja Rol ................................................................................................................. 74 Caso de Uso: Crear Rol ............................................................................................................... 74 3 6.2.7.4 6.2.7.5 6.2.8 Paquete: Usuario .................................................................................................................. 76 6.2.8.1 6.2.8.2 6.2.8.3 6.2.8.4 6.2.8.5 6.2.9 Caso de Uso: Alta Usuario .......................................................................................................... 76 Caso de Uso: Baja Usuario .......................................................................................................... 76 Caso de Uso: Crear Usuario ........................................................................................................ 77 Caso de Uso: Listar Usuario ........................................................................................................ 77 Caso de Uso: Modificar Usuario ................................................................................................. 78 Paquete: Medio Pago ........................................................................................................... 79 6.2.9.1 6.2.9.2 6.2.9.3 6.2.9.4 6.2.9.5 6.2.10 6.2.10.1 6.2.10.2 6.2.10.3 6.2.10.4 6.2.10.5 6.2.11 6.2.11.1 6.2.11.2 6.2.11.3 6.2.12 6.2.12.1 6.2.12.2 6.2.12.3 6.2.12.4 6.2.12.5 6.2.13 6.2.13.1 6.2.13.2 6.2.14 6.2.14.1 6.2.14.2 6.2.14.3 6.2.14.4 6.2.14.5 6.2.15 6.2.15.1 6.2.15.2 6.2.15.3 6.2.15.4 6.2.15.5 6.2.16 6.2.16.1 6.2.16.2 6.2.16.3 6.2.16.4 6.2.16.5 6.2.17 Caso de Uso: Listar Rol ............................................................................................................... 75 Caso de Uso: Modificar Rol ........................................................................................................ 75 Caso de Uso: Alta Medio Pago ................................................................................................... 79 Caso de Uso: Baja Medio Pago ................................................................................................... 79 Caso de Uso: Crear Medio Pago ................................................................................................. 80 Caso de Uso: Listar Medio Pago ................................................................................................. 80 Caso de Uso: Modificar Medio Pago .......................................................................................... 80 Paquete: Categoria........................................................................................................... 81 Caso de Uso: Alta Categoria ....................................................................................................... 81 Caso de Uso: Baja Categoria ....................................................................................................... 81 Caso de Uso: Crear Categoria ..................................................................................................... 82 Caso de Uso: Listar Categoria ..................................................................................................... 82 Caso de Uso: Modificar Categoria .............................................................................................. 83 Paquete: Reportes ............................................................................................................ 83 Caso de Uso: Generar Reporte Cierre Caja................................................................................. 83 Caso de Uso: Generar Reporte Stock ......................................................................................... 84 Caso de Uso: Generar Reporte Ventas ....................................................................................... 84 Paquete: Factura .............................................................................................................. 85 Caso de Uso: Dar Alta Factura .................................................................................................... 85 Caso de Uso: Dar Baja Factura ................................................................................................... 85 Caso de Uso: Generar Factura .................................................................................................... 86 Caso de Uso: Listar Facturas Generadas..................................................................................... 86 Caso de Uso: Listar Facturas Pendientes .................................................................................... 87 Paquete: login (beans)...................................................................................................... 88 Caso de Uso: Entrar Entorno Web .............................................................................................. 88 Caso de Uso: Salir Entorno Web ................................................................................................. 88 Paquete: Bodega Detalle .................................................................................................. 89 Caso de Uso: Alta Bodega Detalle .............................................................................................. 89 Caso de Uso: Baja Bodega Detalle .............................................................................................. 89 Caso de Uso: Crear Bodega Detalle ............................................................................................ 89 Caso de Uso: Listar Bodega Detalle ............................................................................................ 90 Caso de Uso: Modificar Bodega Detalle ..................................................................................... 90 Paquete: Descuento Producto .......................................................................................... 91 Caso de Uso: Alta Descuento Producto ...................................................................................... 91 Caso de Uso: Baja Descuento Producto ..................................................................................... 91 Caso de Uso: Crear Descuento Producto.................................................................................... 92 Caso de Uso: Listar Descuento Producto.................................................................................... 92 Caso de Uso: Modificar Descuento Producto ............................................................................. 93 Paquete: Empleado Agencia............................................................................................. 93 Caso de Uso: Alta Empleado Agencia ......................................................................................... 93 Caso de Uso: Baja Empleado Agencia......................................................................................... 94 Caso de Uso: Crear Empleado Agencia ....................................................................................... 94 Caso de Uso: Listar Empleado Agencia ....................................................................................... 95 Caso de Uso: Modificar Empleado Agencia ................................................................................ 95 Paquete: compra (android) .............................................................................................. 96 4 6.2.17.1 6.2.17.2 6.2.17.3 6.2.17.4 6.2.17.5 6.2.18 Caso de Uso: Agregar Producto .................................................................................................. 96 Caso de Uso: Confirmar Carro Compras ..................................................................................... 96 Caso de Uso: Editar Producto ..................................................................................................... 97 Caso de Uso: Listar Carros Compras ........................................................................................... 97 Caso de Uso: Listar Productos Carro Compras ........................................................................... 98 Paquete: login (android)................................................................................................... 98 6.2.18.1 6.2.18.2 6.2.18.3 Caso de Uso: Entrar Aplicativo Movil ......................................................................................... 98 Caso de Uso: Salir Aplicativo Movil ............................................................................................ 99 Caso de Uso: Registrar Usuario .................................................................................................. 99 6.3 ANÁLISIS DE CLASES ..................................................................................................................... 100 6.3.1 Atributos de la Clase Agencia ............................................................................................. 100 6.3.2 Atributos de la clase Bodega .............................................................................................. 100 6.3.3 Atributos de la Clase BodegaDetalle .................................................................................. 101 6.3.4 Atributos de la clase Categoria ........................................................................................... 101 6.3.5 Atributos de la clases Descuento ........................................................................................ 101 6.3.6 Atributos de la clase DescuentoProducto .......................................................................... 101 6.3.7 Atributos de la clase EmpleadoAgencia.............................................................................. 101 6.3.8 Atributos de la clase Empresa............................................................................................. 102 6.3.9 Atributos de la clase Factura .............................................................................................. 102 6.3.10 Atributos de la clase FacturaDetalle .............................................................................. 102 6.3.11 Atributos de la clase Marca ............................................................................................ 102 6.3.12 Atributos de la clase MedioDePago ............................................................................... 103 6.3.13 Atributos de la clase Producto........................................................................................ 103 6.3.14 Atributos de la clase Rol ................................................................................................. 103 6.3.15 Atributos de la clase Usuario .......................................................................................... 103 7 FLUJO DE TRABAJO: DISEÑO ...................................................................................................... 105 7.1 DISEÑO DE LA ARQUITECTURA ........................................................................................................ 105 7.1.1 Sección Controlador ............................................................................................................ 106 7.1.2 Sección Vistas ..................................................................................................................... 107 7.1.3 Sección Modelo ................................................................................................................... 107 7.2 DISEÑO DE CASOS DE USO ............................................................................................................. 108 7.2.1 Paquete Agencia ................................................................................................................. 108 7.2.1.1 7.2.1.2 7.2.1.3 7.2.1.4 7.2.1.5 7.2.2 Paquete: Bodega ................................................................................................................ 111 7.2.2.1 7.2.2.2 7.2.2.3 7.2.2.4 7.2.2.5 7.2.3 Caso de Uso: Alta Agencia ........................................................................................................ 108 Caso de Uso: Baja Agencia ....................................................................................................... 109 Caso de Uso: Crear Agencia ...................................................................................................... 109 Caso de Uso: Listar Agencia ...................................................................................................... 110 Caso de Uso: Modificar Agencia ............................................................................................... 110 Caso de Uso: Alta Bodega......................................................................................................... 111 Caso de Uso: Baja Bodega ........................................................................................................ 111 Caso de Uso: Crear Bodega ...................................................................................................... 112 Caso de Uso: Listar Bodega ...................................................................................................... 112 Caso de Uso: Modificar Bodega ............................................................................................... 113 Paquete: Bodega Detalle .................................................................................................... 113 7.2.3.1 7.2.3.2 7.2.3.3 7.2.3.4 7.2.3.5 Caso de Uso: Alta Bodega Detalle ............................................................................................ 113 Caso de Uso: Baja Bodega Detalle ............................................................................................ 114 Caso de Uso: Crear Bodega Detalle .......................................................................................... 114 Caso de Uso: Listar Bodega Detalle .......................................................................................... 114 Caso de Uso: Modificar Bodega Detalle ................................................................................... 115 5 7.2.4 Paquete: Categoria ............................................................................................................. 115 7.2.4.1 7.2.4.2 7.2.4.3 7.2.4.4 7.2.4.5 7.2.5 Paquete: Descuento ............................................................................................................ 118 7.2.5.1 7.2.5.2 7.2.5.3 7.2.5.4 7.2.5.5 7.2.6 Caso de Uso: Alta Empleado Agencia ....................................................................................... 122 Caso de Uso: Baja Empleado Agencia....................................................................................... 122 Caso de Uso: Crear Empleado Agencia ..................................................................................... 122 Caso de Uso: Listar Empleado Agencia ..................................................................................... 123 Caso de Uso: Modificar Empleado Agencia .............................................................................. 123 Paquete: Empresa ............................................................................................................... 123 7.2.8.1 7.2.8.2 7.2.8.3 7.2.8.4 7.2.8.5 7.2.9 Caso de Uso: Alta Descuento Producto .................................................................................... 120 Caso de Uso: Baja Descuento Producto ................................................................................... 121 Caso de Uso: Crear Descuento Producto.................................................................................. 121 Caso de Uso: Listar Descuento Producto.................................................................................. 121 Caso de Uso: Modificar Descuento Producto ........................................................................... 121 Paquete: Empleado Agencia ............................................................................................... 122 7.2.7.1 7.2.7.2 7.2.7.3 7.2.7.4 7.2.7.5 7.2.8 Caso de Uso: Alta Descuento ................................................................................................... 118 Caso de Uso: Baja Descuento ................................................................................................... 118 Caso de Uso: Crear Descuento ................................................................................................. 119 Caso de Uso: Listar Descuento ................................................................................................. 119 Caso de Uso: Modificar Descuento .......................................................................................... 120 Paquete: Descuento Producto ............................................................................................ 120 7.2.6.1 7.2.6.2 7.2.6.3 7.2.6.4 7.2.6.5 7.2.7 Caso de Uso: Alta Categoria ..................................................................................................... 115 Caso de Uso: Baja Categoria ..................................................................................................... 116 Caso de Uso: Crear Categoria ................................................................................................... 116 Caso de Uso: Listar Categoria ................................................................................................... 117 Caso de Uso: Modificar Categoria ............................................................................................ 117 Caso de Uso: Alta Empresa ....................................................................................................... 123 Caso de Uso: Baja Empresa ...................................................................................................... 124 Caso de Uso: Crear Empresa .................................................................................................... 124 Caso de Uso: Listar Empresa .................................................................................................... 125 Caso de Uso: Modificar Empresa.............................................................................................. 125 Paquete: Factura ................................................................................................................ 126 7.2.9.1 7.2.9.2 7.2.9.3 7.2.9.4 7.2.9.5 7.2.9.6 7.2.10 7.2.10.1 7.2.10.2 7.2.11 7.2.11.1 7.2.11.2 7.2.11.3 7.2.11.4 7.2.11.5 7.2.12 7.2.12.1 7.2.12.2 7.2.12.3 7.2.12.4 7.2.12.5 Caso de Uso: Alta Factura......................................................................................................... 126 Caso de Uso: Baja Factura ........................................................................................................ 126 Caso de Uso: Generar Factura .................................................................................................. 127 Caso de Uso: Imprimir Factura ................................................................................................. 127 Caso de Uso: Listar Facturas Generadas................................................................................... 128 Caso de Uso: Listar Facturas Pendientes .................................................................................. 128 Paquete: login (from beans) ........................................................................................... 129 Caso de Uso: loginUsuario ........................................................................................................ 129 Caso de Uso: logOut ................................................................................................................. 129 Paquete: Marca .............................................................................................................. 130 Caso de Uso: Alta Marca .......................................................................................................... 130 Caso de Uso: Baja Marca .......................................................................................................... 130 Caso de Uso: Crear Marca ........................................................................................................ 131 Caso de Uso: Listar Marca ........................................................................................................ 131 Caso de Uso: Modificar Marca ................................................................................................. 132 Paquete: Medio Pago ..................................................................................................... 132 Caso de Uso: Alta Medio Pago ................................................................................................. 132 Caso de Uso: Baja Medio Pago ................................................................................................. 133 Caso de Uso: Crear Medio Pago ............................................................................................... 133 Caso de Uso: Listar Medio Pago ............................................................................................... 134 Caso de Uso: Modificar Medio Pago ........................................................................................ 134 6 7.2.13 7.2.13.1 7.2.13.2 7.2.13.3 7.2.13.4 7.2.13.5 7.2.14 7.2.14.1 7.2.14.2 7.2.14.3 7.2.14.4 7.2.14.5 7.2.15 7.2.15.1 7.2.15.2 7.2.15.3 7.2.15.4 7.2.15.5 7.2.16 7.2.16.1 7.2.16.2 7.2.16.3 7.2.17 7.2.17.1 7.2.17.2 7.2.17.3 7.2.17.4 7.2.17.5 7.2.18 7.2.18.1 7.2.18.2 7.2.18.3 Paquete: Producto .......................................................................................................... 134 Caso de Uso: Alta Producto ...................................................................................................... 134 Caso de Uso: Baja Producto ..................................................................................................... 135 Caso de Uso: Crear Producto.................................................................................................... 135 Caso de Uso: Listar Producto.................................................................................................... 136 Caso de Uso: Modificar Producto ............................................................................................. 136 Paquete: Rol ................................................................................................................... 136 Caso de Uso: Alta Rol ............................................................................................................... 136 Caso de Uso: Baja Rol ............................................................................................................... 137 Caso de Uso: Crear Rol ............................................................................................................. 137 Caso de Uso: Listar Rol ............................................................................................................. 138 Caso de Uso: Modificar Rol ...................................................................................................... 138 Paquete: Usuario ............................................................................................................ 139 Caso de Uso: Alta Usuario ........................................................................................................ 139 Caso de Uso: Baja Usuario ........................................................................................................ 139 Caso de Uso: Crear Usuario ...................................................................................................... 140 Caso de Uso: Listar Usuario ...................................................................................................... 140 Caso de Uso: Modificar Usuario ............................................................................................... 141 Paquete: Reportes .......................................................................................................... 141 Caso de Uso: Reporte Cierre Caja ............................................................................................. 141 Caso de Uso: Reporte Consolidado Ventas .............................................................................. 142 Caso de Uso: Reporte Stock Productos .................................................................................... 142 Paquete: compras........................................................................................................... 143 Caso de Uso: Agregar Producto ................................................................................................ 143 Caso de Uso: Confirmar Carro Compras ................................................................................... 143 Caso de Uso: Editar Producto ................................................................................................... 144 Caso de Uso: Listar Carros Compras ......................................................................................... 144 Caso de Uso: Listar Producto Carro Compra ............................................................................ 145 Paquete: login (from android) ........................................................................................ 145 Caso de Uso: Entrar Aplicacion Movil....................................................................................... 145 Caso de Uso: Registro Usuario ................................................................................................. 146 Caso de Uso: Salir Aplicativo Movil .......................................................................................... 146 7.3 DISEÑO DE CLASES ....................................................................................................................... 147 7.3.1 Caso de Uso: ALTA Factura ................................................................................................. 147 7.3.2 Caso de Uso: BAJA Factura ................................................................................................. 149 7.3.3 Caso de Uso: GENERAR Factura .......................................................................................... 150 7.3.4 Caso de Uso: IMPRIMIR Factura ......................................................................................... 151 7.3.5 Caso de Uso: LISTAR Facturas Generadas........................................................................... 152 7.3.6 Caso de Uso: LISTAR Facturas Pagadas .............................................................................. 153 7.3.7 Caso de Uso: ALTA Agencia ................................................................................................ 154 7.3.8 Caso de Uso: BAJA Agencia ................................................................................................. 155 7.3.9 Caso de Uso: CREAR Agencia .............................................................................................. 156 7.3.10 Caso de Uso: LISTAR Agencia ......................................................................................... 157 7.3.11 Caso de Uso: MODIFICAR Agencia.................................................................................. 158 7.3.12 Caso de Uso: ALTA Bodega ............................................................................................. 159 7.3.13 Caso de Uso: BAJA Bodega ............................................................................................. 160 7.3.14 Caso de Uso: CREAR Bodega .......................................................................................... 161 7.3.15 Caso de Uso: LISTAR Bodega .......................................................................................... 162 7.3.16 Caso de Uso: MODIFICAR Bodega .................................................................................. 163 7.3.17 Caso de Uso: ALTA Bodega Detalle ................................................................................ 164 7 7.3.18 7.3.19 7.3.20 7.3.21 7.3.22 7.3.23 7.3.24 7.3.25 7.3.26 7.3.27 7.3.28 7.3.29 7.3.30 7.3.31 7.3.32 7.3.33 7.3.34 7.3.35 7.3.36 7.3.37 7.3.38 7.3.39 7.3.40 7.3.41 7.3.42 7.3.43 7.3.44 7.3.45 7.3.46 7.3.47 7.3.48 7.3.49 7.3.50 7.3.51 7.3.52 7.3.53 7.3.54 7.3.55 7.3.56 7.3.57 7.3.58 7.3.59 7.3.60 7.3.61 7.3.62 7.3.63 7.3.64 Caso de Uso: BAJA Bodega Detalle................................................................................. 165 Caso de Uso: CREAR Bodega Detalle .............................................................................. 166 Caso de Uso: LISTAR Bodega Detalle .............................................................................. 167 Caso de Uso: MODIFICAR Bodega Detalle ...................................................................... 168 Caso de Uso: ALTA Categoria ......................................................................................... 169 Caso de Uso: BAJA Categoria ......................................................................................... 170 Caso de Uso: CREAR Categoria ....................................................................................... 171 Caso de Uso: LISTAR Categoria....................................................................................... 172 Caso de Uso: MODIFICAR Categoria ............................................................................... 173 Caso de Uso: ALTA Descuento ........................................................................................ 174 Caso de Uso: BAJA Descuento ........................................................................................ 175 Caso de Uso: CREAR Descuento ...................................................................................... 176 Caso de Uso: LISTAR Descuento ..................................................................................... 177 Caso de Uso: MODIFICAR Descuento.............................................................................. 178 Caso de Uso: ALTA Descuento Producto......................................................................... 179 Caso de Uso: BAJA Descuento Producto ......................................................................... 180 Caso de Uso: CREAR Descuento Producto ...................................................................... 181 Caso de Uso: LISTAR Descuento Producto ...................................................................... 182 Caso de Uso: MODIFICAR Descuento Producto .............................................................. 183 Caso de Uso: ALTA Empleado Agencia ........................................................................... 184 Caso de Uso: BAJA Empleado Agencia ........................................................................... 185 Caso de Uso: LISTAR Empleado Agencia......................................................................... 186 Caso de Uso: MODIFICAREMPLEADOAGENCIA .............................................................. 187 Caso de Uso: ALTA Empresa ........................................................................................... 188 Caso de Uso: BAJA Empresa ........................................................................................... 189 Caso de Uso: CREAR Empresa......................................................................................... 190 Caso de Uso: LISTAR Empresa ........................................................................................ 191 Caso de Uso: MODIFICAR Empresa ................................................................................ 192 Caso de Uso: LOGINUSUARIO ......................................................................................... 193 Caso de Uso: LOGOUT .................................................................................................... 194 Caso de Uso: ALTA Marca .............................................................................................. 195 Caso de Uso: BAJA Marca ............................................................................................... 196 Caso de Uso: CREAR Marca ............................................................................................ 197 Caso de Uso: LISTAR Marca ............................................................................................ 198 Caso de Uso: MODIFICAR Marca .................................................................................... 199 Caso de Uso: ALTA Producto .......................................................................................... 200 Caso de Uso: BAJA Producto........................................................................................... 201 Caso de Uso: CREAR Producto ........................................................................................ 202 Caso de Uso: LISTAR Producto ........................................................................................ 203 Caso de Uso: MODIFICAR Producto ................................................................................ 204 Caso de Uso: ALTA Rol .................................................................................................... 205 Caso de Uso: BAJA Rol .................................................................................................... 206 Caso de Uso: CREAR Rol ................................................................................................. 207 Caso de Uso: LISTAR Rol ................................................................................................. 208 Caso de Uso: MODIFICAR Rol ......................................................................................... 209 Caso de Uso: ALTA Usuario ............................................................................................ 210 Caso de Uso: BAJA Usuario ............................................................................................. 211 8 7.3.65 Caso de Uso: CREAR Usuario .......................................................................................... 212 7.3.66 Caso de Uso: LISTA Usuario ............................................................................................ 213 7.3.67 Caso de Uso: MODIFICAR Usuario .................................................................................. 214 7.3.68 Caso de Uso: ALTA Medio Pago...................................................................................... 215 7.3.69 Caso de Uso: BAJA Medio Pago ...................................................................................... 216 7.3.70 Caso de Uso: CREAR Medio Pago ................................................................................... 217 7.3.71 Caso de Uso: LISTAR Medio Pago ................................................................................... 218 7.3.72 Caso de Uso: MODIFICAR Medio Pago ........................................................................... 219 7.3.73 Caso de Uso: ENTRAR Aplicativo Movil .......................................................................... 220 7.3.74 Caso de Uso: REGISTRO Usuario..................................................................................... 221 7.3.75 Caso de Uso: SALIR Aplicativo Movil .............................................................................. 222 7.3.76 Caso de Uso: AGREGAR Producto ................................................................................... 223 7.3.77 Caso de Uso: CONFIRMAR Carro Compras ..................................................................... 224 7.3.78 Caso de Uso: EDITAR Producto ....................................................................................... 225 7.3.79 Caso de Uso: LISTAR Carro Compras .............................................................................. 226 7.3.80 Caso de Uso: LISTAR Producto Carro Compra ................................................................ 227 7.3.81 Caso de Uso: REPORTE Cierre Caja ................................................................................. 228 7.3.82 Caso de Uso: REPORTE Consolidado Ventas ................................................................... 229 7.3.83 Caso de Uso: REPORTE Stock Productos ......................................................................... 230 7.4 DIAGRAMADE DESPLIEGUE............................................................................................................. 230 7.4.1 Cliente Web......................................................................................................................... 231 7.4.2 Servidor BDD ....................................................................................................................... 231 7.4.3 Servidor Web ...................................................................................................................... 232 7.4.4 Dispositivo Mobil ................................................................................................................ 232 7.5 DISEÑO DE DATOS ....................................................................................................................... 233 8 CONCLUSIONES ......................................................................................................................... 234 9 BIBLIOGRAFÍA ............................................................................................................................ 234 10 APENDICE: CODIGO FUENTE APLICACIÓN WEB .......................................................................... 235 10.1 BEANS (CONTROLADORES) ............................................................................................................. 235 10.1.1 Agencia ........................................................................................................................... 235 10.1.1.1 10.1.1.2 10.1.1.3 10.1.1.4 10.1.1.5 10.1.2 10.1.2.1 10.1.2.2 10.1.2.3 10.1.2.4 10.1.2.5 10.1.3 10.1.3.1 10.1.3.2 10.1.3.3 10.1.3.4 10.1.3.5 AltaAgencia.java ....................................................................................................................... 235 BajaAgencia.java ...................................................................................................................... 236 CrearAgencia.java..................................................................................................................... 237 ListarAgencia.java..................................................................................................................... 238 ModificarAgencia.java .............................................................................................................. 241 BodegaDetalle ................................................................................................................ 242 ModificarBodegaDetalle.java ................................................................................................... 242 AltaBodegaDetalle.java ............................................................................................................ 243 BajaBodegaDetalle.java ............................................................................................................ 244 CrearBodegaDetalle.java .......................................................................................................... 245 ListarBodegaDetalle.java .......................................................................................................... 247 Bodega ........................................................................................................................... 250 ListarBodega.java ..................................................................................................................... 250 CrearBodega.java ..................................................................................................................... 253 BajaBodega.java ....................................................................................................................... 254 AltaBodega.java ....................................................................................................................... 255 ModificarBodega.java .............................................................................................................. 256 9 10.1.4 Categoria ........................................................................................................................ 257 10.1.4.1 10.1.4.2 10.1.4.3 10.1.4.4 10.1.4.5 10.1.5 ListarCategoria.java .................................................................................................................. 257 CrearCategoria.java .................................................................................................................. 259 BajaCategoria.java.................................................................................................................... 260 AltaCategoria.java .................................................................................................................... 261 ModificarCategoria.java ........................................................................................................... 261 Descuento ....................................................................................................................... 262 10.1.5.1 10.1.5.2 10.1.5.3 10.1.5.4 10.1.5.5 10.1.6 ListarDescuento.java ................................................................................................................ 262 CrearDescuento.java ................................................................................................................ 265 BajaDescuento.java .................................................................................................................. 266 AltaDescuento.java .................................................................................................................. 266 ModificarDescuento.java ......................................................................................................... 267 DescuentoProducto ........................................................................................................ 268 10.1.6.1 10.1.6.2 10.1.6.3 10.1.6.4 10.1.6.5 10.1.7 ListarDescuentoProducto.java ................................................................................................. 268 CrearDescuentoProducto.java ................................................................................................. 272 BajaDescuentoProducto.java ................................................................................................... 274 AltaDescuentoProducto.java .................................................................................................... 275 ModificarDescuentoProducto.java........................................................................................... 276 EmpleadoAgencia........................................................................................................... 277 10.1.7.1 10.1.7.2 10.1.7.3 10.1.7.4 10.1.7.5 10.1.8 ListarEmpleadoAgencia.java .................................................................................................... 277 CrearEmpleadoAgencia.java .................................................................................................... 281 BajaEmpleadoAgencia.java ...................................................................................................... 283 AltaEmpleadoAgencia.java ....................................................................................................... 284 ModificarEmpleadoAgencia.java .............................................................................................. 285 Empresa.......................................................................................................................... 286 10.1.8.1 10.1.8.2 10.1.8.3 10.1.8.4 10.1.8.5 10.1.9 ListarEmpresa.java ................................................................................................................... 286 CrearEmpresa.java ................................................................................................................... 288 BajaEmpresa.java ..................................................................................................................... 289 AltaEmpresa.java...................................................................................................................... 290 ModificarEmpresa.java............................................................................................................. 291 Factura ........................................................................................................................... 291 10.1.9.1 10.1.9.2 10.1.9.3 10.1.9.4 10.1.9.5 10.1.9.6 10.1.9.7 10.1.10 ListarFacturaGenerada.java ..................................................................................................... 291 ImprimirFactura.java ................................................................................................................ 294 rptFactura.jxrml........................................................................................................................ 295 GenerarFactura.java ................................................................................................................. 303 BajaFactura.java ....................................................................................................................... 304 AltaFactura.java ....................................................................................................................... 305 ListarFacturasPendientes.java .................................................................................................. 306 Filter ............................................................................................................................... 310 10.1.10.1 10.1.11 Login ............................................................................................................................... 311 10.1.11.1 10.1.11.2 10.1.12 LoginUsuario.java ................................................................................................................ 311 LogoutUsuario.java.............................................................................................................. 313 Marca ............................................................................................................................. 313 10.1.12.1 10.1.12.2 10.1.12.3 10.1.12.4 10.1.12.5 10.1.13 ForzarLoginFilter.java .......................................................................................................... 310 ListarMarca.java .................................................................................................................. 313 CrearMarca.java .................................................................................................................. 315 BajaMarca.java .................................................................................................................... 316 AltaMarca.java..................................................................................................................... 317 ModificarMarca.java ........................................................................................................... 318 MedioPago ..................................................................................................................... 319 10.1.13.1 10.1.13.2 ListarMedioPago.java .......................................................................................................... 319 CrearMedioPago.java .......................................................................................................... 321 10 10.1.13.3 10.1.13.4 10.1.13.5 10.1.14 Menu .............................................................................................................................. 324 10.1.14.1 10.1.15 FacturaResource.java .......................................................................................................... 362 FacturaDetalleResource.java ............................................................................................... 364 DescuentoResource.java ..................................................................................................... 368 BodegaDetalleResource.java ............................................................................................... 369 AutenticacionResource.java ................................................................................................ 369 AgenciaResource.java .......................................................................................................... 370 MedioDePagoResource.java ................................................................................................ 371 Rol .................................................................................................................................. 372 10.1.18.1 10.1.18.2 10.1.18.3 10.1.18.4 10.1.18.5 10.1.19 ConsolidadoVentas.java ...................................................................................................... 333 rptVentas.jrxml .................................................................................................................... 336 CierreDeCaja.java ................................................................................................................ 343 rptVentaCaja.jrxml .............................................................................................................. 346 StockProductos.java ............................................................................................................ 352 rptStockProductos.jrxml ...................................................................................................... 355 Rest ................................................................................................................................. 362 10.1.17.1 10.1.17.2 10.1.17.3 10.1.17.4 10.1.17.5 10.1.17.6 10.1.17.7 10.1.18 ListarProducto.java .............................................................................................................. 325 CrearProducto.java .............................................................................................................. 328 BajaProducto.java................................................................................................................ 331 AltaProducto.java ................................................................................................................ 332 ModificarProducto.java ....................................................................................................... 332 Reportes ......................................................................................................................... 333 10.1.16.1 10.1.16.2 10.1.16.3 10.1.16.4 10.1.16.5 10.1.16.6 10.1.17 Menu.java ............................................................................................................................ 324 Producto ......................................................................................................................... 325 10.1.15.1 10.1.15.2 10.1.15.3 10.1.15.4 10.1.15.5 10.1.16 BajaMedioPago.java ............................................................................................................ 322 AltaMedioPago .................................................................................................................... 323 ModificarMedioPago.java ................................................................................................... 323 ListarRol.java ....................................................................................................................... 372 CrearRol.java ....................................................................................................................... 374 BajaRol.java ......................................................................................................................... 375 AltaRol.java.......................................................................................................................... 376 ModificarRol.java................................................................................................................. 377 Usuario ........................................................................................................................... 377 10.1.19.1 10.1.19.2 10.1.19.3 10.1.19.4 10.1.19.5 ListarUsuario.java ................................................................................................................ 377 CrearUsuario.java ................................................................................................................ 380 BajaUsuario.java .................................................................................................................. 382 AltaUsuario.java .................................................................................................................. 383 ModificarUsuario.java ......................................................................................................... 384 10.2 DAO .......................................................................................................................................... 384 10.2.1 UsuarioDAO.java ............................................................................................................ 384 10.2.2 AgenciaDAO.java............................................................................................................ 385 10.2.3 BodegaDAO.java ............................................................................................................ 385 10.2.4 BodegaDetalleDAO.java ................................................................................................. 385 10.2.5 CategoriaDAO.java ......................................................................................................... 385 10.2.6 DAOFactory.java ............................................................................................................ 385 10.2.7 DescuentoDAO.java........................................................................................................ 386 10.2.8 DescuentoProductoDAO.java ......................................................................................... 386 10.2.9 EmpleadoAgenciaDAO.java............................................................................................ 386 10.2.10 EmpresaDAO.java .......................................................................................................... 387 10.2.11 FacturaDAO.java ............................................................................................................ 387 10.2.12 FacturaDetalleDAO.java ................................................................................................. 387 11 10.2.13 GenericDAO.java ............................................................................................................ 388 10.2.14 MarcaDAO.java .............................................................................................................. 388 10.2.15 MedioPAgoDAO.java ...................................................................................................... 388 10.2.16 ProductoDAO.java .......................................................................................................... 388 10.2.17 RolDAO.java ................................................................................................................... 388 10.3 ENTIDADES ................................................................................................................................. 389 10.3.1 Usuario.java ................................................................................................................... 389 10.3.2 Agencia.java ................................................................................................................... 392 10.3.3 Bodega.java.................................................................................................................... 395 10.3.4 BodegaDetalle.java ........................................................................................................ 397 10.3.5 Categoria.java ................................................................................................................ 400 10.3.6 Descuento.java ............................................................................................................... 401 10.3.7 DescuentoProducto.java ................................................................................................ 404 10.3.8 EmpleadoAgencia.java ................................................................................................... 406 10.3.9 Empresa.java .................................................................................................................. 407 10.3.10 Factura.java ................................................................................................................... 410 10.3.11 FacturaDetalle.java ........................................................................................................ 414 10.3.12 Marca.java ..................................................................................................................... 418 10.3.13 MedioDePago.java ......................................................................................................... 419 10.3.14 Producto.java ................................................................................................................. 421 10.3.15 Rol.java ........................................................................................................................... 423 10.4 JPA............................................................................................................................................ 425 10.4.1 JPAUsuarioDAO.java ...................................................................................................... 425 10.4.2 JPAAgenciaDAO.java ...................................................................................................... 425 10.4.3 JPABodegaDAO.java ....................................................................................................... 425 10.4.4 JPABodegaDetalleDAO.java ........................................................................................... 426 10.4.5 JPACategoriaDAO.java ................................................................................................... 426 10.4.6 JPADAOFactory.java ....................................................................................................... 426 10.4.7 JPADescuentoDAO.java .................................................................................................. 428 10.4.8 JPADescuentoProductoDAO.java ................................................................................... 428 10.4.9 JPAEmpleadoAgenciaDAO.java ...................................................................................... 429 10.4.10 JPAEmpresaDAO.java ..................................................................................................... 429 10.4.11 JPAFacturaDAO.java....................................................................................................... 430 10.4.12 JPAFacturaDetalleDAO.java ........................................................................................... 431 10.4.13 JPAGenericDAO.java....................................................................................................... 433 10.4.14 JPAMarcaDAO.java ........................................................................................................ 435 10.4.15 JPAMedioPagoDAO.java ................................................................................................ 435 10.4.16 JPAProductoDAO.java .................................................................................................... 435 10.4.17 JPARolDAO.java .............................................................................................................. 435 10.5 ARCHIVOS DE CONFIGURACION ....................................................................................................... 436 10.5.1 Faces-config.xml ............................................................................................................. 436 10.5.2 Web.xml ......................................................................................................................... 436 10.5.3 Persistence.xml ............................................................................................................... 438 11 APENDICE: CODIGO FUENTE APLICACION ANDROID .................................................................. 439 11.1 COMPRAS ................................................................................................................................... 439 11.1.1 ConfirmarComprasActivity.java ..................................................................................... 439 11.1.2 ComprasActivity.java...................................................................................................... 442 12 11.1.3 CarrosComprasActivity.java ........................................................................................... 447 11.1.4 AddProductoActivity.java ............................................................................................... 450 11.1.5 AdaptadorListaProductos.java ....................................................................................... 454 11.1.6 AdaptadorListaCarros.java ............................................................................................. 455 11.1.7 EditProductoActivity.java ............................................................................................... 456 11.2 LOGIN ........................................................................................................................................ 461 11.2.1 logoutActivity.java ......................................................................................................... 461 11.2.2 LoginActivity.java ........................................................................................................... 462 11.2.3 NuevoUsuarioActivity.java ............................................................................................. 466 11.3 REST.......................................................................................................................................... 468 11.3.1 UsuarioREST.java ........................................................................................................... 468 11.3.2 AgenciaREST.java ........................................................................................................... 469 11.3.3 BodegaDetalleREST.java ................................................................................................ 471 11.3.4 DescuentoREST.java ....................................................................................................... 473 11.3.5 FacturaDetalleREST.java ................................................................................................ 473 11.3.6 MedioPagoREST.java...................................................................................................... 477 11.3.7 GenericREST.java ............................................................................................................ 478 11.3.8 FacturaREST.java ............................................................................................................ 478 11.3.9 RESTFactory.java ............................................................................................................ 481 11.4 CAPTUREACTIVITY.JAVA (ZXING) ................................................................................................... 481 11.5 ARCHIVOS DE CONFIGURACION ....................................................................................................... 487 11.5.1 AndroidManifest.xml ...................................................................................................... 487 13 1 OBJETIVO Optimizar y automatizar el proceso de compra de productos en tiendas de consumo masivo, mediante la implementación de tecnología JEE y Android que permite a los clientes agilitar la compra de productos, siendo necesario para esto: • La implementación de un sistema en plataforma JEE basado en Web para la gestión de una tienda y facturación de los pedidos los cuales se realizaran desde un dispositivo móvil, la aplicación web presentará las siguientes características: o Marco de trabajo en Java Server Faces. o Componentes visuales PrimeFaces para las interfaces de usuario o EclipseLink como implementación de la API de persistencia de JAVA. o JAX-RS como implementación de la API para REST Web Services. • La implementación de una aplicación móvil para ser ejecutada en teléfonos con sistema operativo Android que permita al cliente iniciar sesión, consultar y confirmar en línea los productos solicitados, implementando las siguientes características: o Librería Z-Xing como implementación para lectura de códigos QR. o HTTP como recurso para el acceso a los servicios web de la aplicación JEE. 2 ALCANCE El proyecto contempla la implementación de dos aplicaciones: • La primera en entorno web que permitirá al Administrador realizar la gestión de la tienda y al Empleado realizar la facturación de los pedidos. • La segunda como aplicación móvil para ser instalada en teléfonos con sistema operativo Android que permitirá al cliente realizar los pedidos en línea y la respectiva confirmación. Es preciso aclarar que el proyecto no considera: • Pasarela de pagos para transacciones monetarias en línea, siendo esta opción la estipulada a implementar en un proyecto futuro. • La gestión contable de agencias ni bodegas de la tienda. 3 INTRODUCCIÓN El proyecto de Gestión de Compras Masivas se compone de dos aplicaciones; una para ser instalada y ejecutada en teléfonos móviles con plataforma Android y otra basada en web, desarrollada en plataforma JEE que es en sí la administración de la solución completa. La solución está diseñada para optimizar y automatizar el proceso de compra en una tienda normal, para lo cual se plantea un nuevo escenario en el que la tienda expondrá en sus estanterías, la presentación de los productos con su respectivo precio y un código QR como identificador del producto. 14 Los clientes, utilizarán la aplicación móvil instalada previamente en su teléfono personal, como un Carro de Compras virtual que almacena los productos solicitados. Para agregar un producto, utilizará la cámara del teléfono para capturar el código QR del producto expuesto, así la aplicación obtendrá la referencia del producto. Luego el cliente indicará la cantidad solicitada del producto. Una vez que el cliente añadauno o varios productos a su “Carro de compras”, el cliente procederá a confirmar su solicitud, proceso en el cual el cliente indicará el medio de pagoy finalmente enviará el pedido en línea a la facturación. Los empleados de la tienda, a cargo de la facturación, utilizarán la plataforma Web para visualizar los pedidos realizados y posteriormente facturarlos generando la respectiva factura que describe el detalle de compra. Finalmente el Cliente se acercará a realizar el pago y retirar sus productos, Para la realización de este proyecto se utilizará la metodología PUD (Proceso de Desarrollo Unificado). Sin embargo, del PUD se realizarán únicamente los Flujos de Requisitos, Análisis y Diseño debido al tiempo propuesto para el desarrollo de este proyecto. Los flujos propuestos y desarrollados en el presente trabajo son los que hemos considerado necesarios para la realización del presente proyecto. Este proyecto es el resultado de la aplicación y adaptación de conceptos recibidos en el Máster de Ingeniería Web de la Universidad politécnica de Madrid, y se presenta como proyecto final del curso. 15 4 IDENTIFICACIÓN DE REQUISITOS 4.1 MODELO DE DOMINIO El Modelo de Dominio es una vista que se usa para capturar los objetos significativos dentro de un sistema, organización o cualquier dominio de destino, por lo cual identificamos estos objetos y sus relaciones mediante un Diagrama de Clases. 5 FLUJO DE TRABAJO: REQUISITOS 5.1 GLOSARIO DE TÉRMINOS Término Dispositivo Móvil Descuento Agencia Empresa /tienda Bodega Código QR Significado Teléfono inteligente o Tableta con conexión a internet basado en sistema operativo Android. Rebaja en el coste de un producto en un rango de fechas. Sucursal o delegación subordinada de una empresa.(Diccionario de la lengua española) Unidad de organización dedicada a actividades de venta de productos con fines lucrativos.(Diccionario de la lengua española) Cantidad de mercancías que se tienen en depósito. (Diccionario de la lengua española) Código de respuesta rápida, es un módulo útil para almacenar información en una matriz de puntos o un código de barras bidimensional creado por la compañía japonesa Denso Wave, subsidiaria de Toyot,, en 1994 16 Producto (http://es.wikipedia.org/wiki/C%C3%B3digo_QR) Bien del cual se obtiene rédito económico al venderlo. 5.2 IDENTIFICACIÓN DE CASOS DE USO 5.2.1 IDENTIFICAR ACTORES Administrador Persona que está a cargo de la administración de la tienda, gestión de productos y el control de flujo de dinero producto de las ventas realizadas. Cliente Persona que realiza las compras en la tienda. Persona que trabaja en la tienda y está encargada de facturar los pedidos realizados por los clientes. Empleado 5.2.2 IDENTIFICAR CASOS DE USO Basados en el Modelo de Dominio, se han identificado los siguientes casos de uso: Alta Agencia Crear Categoría Baja de Marca Alta Usuario Listar Categorías Modificar Empleado por Agencia Alta Empresa Baja Agencia Crear Marca Baja Usuario Crear Agencia Modificar Categoría Baja Empresa Listar Marca Crear Usuario Listar Agencias Alta Descuento Crear Empresa Modificar Marca Listar Usuarios Modificar Agencia Alta Bodega Baja Descuento Listar Empresas Alta Producto Modificar Usuario Crear Descuento Modificar Empresa Baja Producto Registrar usuario Baja Bodega Listar Descuentos Alta Factura Crear Producto Alta Medio Pago Crear Bodega Modificar Descuento Baja Factura Listar Productos Baja Medio Pago Listar Bodegas Alta Descuento Producto Baja descuento Producto Crear Descuento Producto Listar Descuento por Producto Modificar Descuento por Producto Alta Empleado por Agencia Baja Empleado Agencia Crear Empleado por Agencia Listar Empleados por Agencia Generar Factura Modificar Producto Crear Medio Pago Imprimir Factura Listar Medios de Pago Listar Facturas Generadas Listar Facturas Pendientes Entrar Aplicativo Móvil Generar Reporte Cierre Caja Generar Reporte Stock Productos Generar Reporte Ventas Alta Rol Entrar entorno Web Baja Rol Salir Aplicativo Móvil Crear Rol Salir Entorno Web Listar Roles Alta Marca Modificar Rol Modificar Bodega Alta Bodega Detalle Baja Bodega Detalle Crear Bodega Detalle Listar Bodega Detalle Modificar Bodega Detalle Alta Categoría Baja Categoría Modificar Medio Pago Agregar Producto Confirmar Carro Compras Editar Producto Listar Carros de Compras Listar Productos de Carro Compras TOTAL: 84 Casos de Uso 5.3 PRIORIZAR CASOS DE USO Hemos establecido 3 escalas de dificultad en la implementación de los casos de uso: Fácil, Medio, Difícil. A continuación se muestran los casos de uso calificados de complejidad de implementación Difícil y Media (se entiende que los casos de uso no listados corresponden a la complejidad “Fácil”). 17 Caso de Uso Complejidad Motivo de complejidad Agregar Producto Difícil Incluye la captura del Código QR con el dispositivo Móvil Confirmar Carro Compras Difícil Asegurar la transacción total de la compra. Generar Factura Difícil Incluye la generación del archivo PDF con la estructura de la Factura Registrar Usuario Media Creación de cuenta del usuario en el sistema (validación de datos) Salir Media Controlar el término de sesión de usuario. Visualizar Factura Media Construir una vista con la estructura de factura. 5.4 DIAGRAMA GENERAL DE CASOS DE USO Una vez identificados los casos de uso, se ha decidido distribuirlos según su ámbito, esto es por ejemplo para los casos de uso, Alta Agencia, Crear Agencia, Actualizar Agencia y Modificar Agencia se los ha agrupado en el paquete Gestión de Agencia. Esto facilita la organización para establecer las relaciones entre casos de uso y actores. 18 uc Casos de Uso Gestión de Productos Gestión de Categorías Gestion de Empresas + Alta Categoria + Alta Empresa + Baja Categoria + Baja Empresa + Crear Categoria + Crear Empresa + Listar Categorias + Listar Empresas + Modificar Categoria + Modificar Empresa + Alta Producto + Baja Producto Gestión de Roles + Alta Rol + Baja Rol + Crear Producto + Listar Productos + Modificar Producto Gestion Empleados por Agencia + Alta Empleado por Agencia + Baja Empleado Agencia + Crear Empleado por Agencia + Listar Empleados por Agencia + Modificar Empleado por Agencia + Crear Rol + Listar Roles + Modificar Rol Gestion de Detalle en Bodega Gestión de Descuentos + Alta Bodega Detalle + Alta Descuento «use» + Baja Descuento «use» + Baja Bodega Detalle «use» + Crear Descuento + Crear Bodega Deatlle + Listar Bodega Detalle «use» + Listar Descuentos + Modificar Bodega Detalle + Modificar Descuento Gestion de Bodegas Gestion de Descuentos por Productos «use» + Alta Bodega + Alta Descuento Producto + Baja Bodega + Baja descuento Producto + Crear Bodega «use» + Crear Descuento Producto + Listar Bodegas + Listar Descuento por Producto + Modificar Bodega Administrador + Modificar Descuento por Producto «use» Gestion de Marca «use» + Alta Marca Gestión de Usuarios + Baja de Marca «use» + Crear Marca + Alta Usuario «use» + Listar Marca + Baja Usuario + Modificar Marca + Crear Usuario + Listar Usuarios «use» + Modificar Usuario Gestion de Agencias + Registrar usuario Gestión de Facturas + Alta Agencia + Alta Factura + Baja Agencia + Baja Factura + Crear Agencia «use» + Listar Agencias + Generar Factura + Imprimir Factura + Modificar Agencia + Listar Facturas Generadas + Listar Facturas Pendientes Gestión de Medios de Pago + Alta Medio Pago + Baja Medio Pago + Crear Medio Pago + Listar Medios de Pago + Modificar Medio Pago Empledo Cliente Gestión de Reportes + Generar Reporte Cierre Caja + Generar Reporte Stock Productos + Generar Reporte Ventas Persona Gestion de Compras + Agregar Producto Gestion de Acceso + Confirmar Carro Compras + Entrar Aplicativo Movil + Editar Producto + Entrar entorno Web + Listar Carros de Compras + Salir Aplicativo Movil + Listar Productos de Carro Compras + Salir Entorno Web 5.5 DETALLAR CASOS DE USO En esta sección, detallamos cada caso de uso mediante diagramas de estados y adicionalmente se mostrará el respectivo prototipo de interfaz. Hemos agrupado los gráficos por cada paquete expuesto en el diagrama General de Casos de Uso a fin de facilitar su relación. En cuanto a los prototipos de interfaz por cada caso de uso, a fin de establecer un estándar en el prototipo de interfaz para la plataforma Web y tomando en consideración la similitud de 19 funcionalidades que hace el usuario en la mayoría de los paquetes, se ha establecido tener dos interfaces plantilla: La primera interfaz cumplirá con los casos “genéricos” a continuación: Caso de Uso Listar Alta Para lo cual … Se presenta una tabla con los elementos. Se provee en la izquierda de cada registro de la tabla, un control del tipo “selección” para seleccionar el registro, a continuación se procederá a presionar el botón Dar Alta, lo que generará el cambio de estado en el registro. Baja Se provee en la izquierda de cada registro de la tabla, un control del tipo “selección” para seleccionar el registro, a continuación se procederá a presionar el botón Dar Baja, lo que generará el cambio de estado en el registro. Modificar A la derecha de cada registro se proveerá de un ícono en forma de lápiz , que permitirá poner al registro en estado de edición. Una vez en edición, se podrá ver dos iconos, uno para cancelar la operación y otro para guardar los cambios realizados . La segunda interfaz cumplirá con los caso de uso “Crear”, para lo cual se presenta un formulario con los atributos necesarios para la creación del elemento. Para los casos de uso que salen del estándar Listar, Crear, Alta, Modificar y Baja, se establecerá su propia interfaz. 5.5.1 PAQUETE GESTIÓN: ACCESO Paquete Gestión de Acceso 20 stm Salir Entrar entorno Web stm Salir Inicial Inicial Solicita Salir /Salir Solicita Salir /Salir Final Final Salir Entorno Web Salir Aplicativo Movil Entrar Aplicativo Movil 5.5.1.1 PROTOTIPOS DE INTERFAZ INTERF Para el prototipo de interfaz del caso de uso “Entrar” se ha tomado en cuenta el rol de los usuarios es así que habrá una interfaz para el acceso a la plataforma web por parte del administrador y el Empleado y otra otra interfaz para el acceso a la aplicación móvil por parte del cliente. 21 Prototipo de Interfaz: Entrar entorno Web Prototipo de Interfaz (Teléfono móbil): Entrar Aplicativo Movil Prototipo de Interfaz (Teléfono móvil): Registrar Usuario. Para el caso de uso Salir, se puede representar el Salir en el menú general de la aplicación, que permitirá ejecutar la salida de la aplicación. Prototipo de Interfaz: Salir Entorno Web Prototipo de Interfaz: Salir Aplicativo Móvil (se desplegará como parte del menú de opciones de la Aplicación) Al hacer click sobre “Cierre de Sesion” se presentará las opciones para Aceptar o Cancelar la salida. 5.5.2 PAQUETE GESTIÓN: MARCA MAR 22 Paquete Gestión Marca ListarMarca Dar Alta Marca Dar Baja Marca Crear Marca Modificar Marca 23 5.5.2.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Dar Alta Marca Prototipo de Interfaz para Modificar Marca. Prototipo de Interfaz para Crear Marca. 24 5.5.1 PAQUETE GESTIÓN: EMPRESA Paquete Gestión Empresa ListarEmpresa Dar Alta Empresa Dar Baja Empresa Crear Empresa Modificar Empresa 25 5.5.1.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Empresa Prototipo de Interfaz para Modificar Empresa Prototipo de Interfaz para Crear Empresa 26 5.5.2 PAQUETE GESTIÓN: AGENCIAS Paquete Gestión Agencias ListarAgencias Dar Alta Agencia Dar Baja Agencia Crear Agencia Modificar Agencia 27 5.5.2.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Agencias Prototipo de Interfaz para Modificar Agencia Prototipo de Interfaz para Crear Agencia. 28 5.5.3 PAQUETE GESTIÓN: BODEGAS Paquete Gestión Bodegas ListarBodegas Dar Alta Bodega Dar Baja Bodega Crear Bodega Modificar Bodega 29 5.5.3.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Bodegas Prototipo de Interfaz para Modificar Bodega Prototipo de Interfaz para Crear Bodega 30 5.5.4 PAQUETE GESTIÓN: PRODUCTOS Paquete Gestión Productos ListarProductos Dar Alta Producto Dar Baja Producto Crear Producto Modificar Producto 31 5.5.4.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Productos Prototipo de Interfaz para Modificar Producto Prototipo de Interfaz para Crear Producto 32 5.5.5 PAQUETE GESTIÓN: DESCUENTOS Paquete Gestión Descuentos ListarDescuentos Dar Alta Descuento Dar Baja Descuento Crear Descuento Modificar Descuento 33 5.5.5.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Descuentos Prototipo de Interfaz para Modificar Descuento Prototipo de Interfaz para Crear Descuento 34 5.5.6 PAQUETE GESTIÓN: ROLES Paquete Gestión Rol ListarRoles Dar Alta Rol Dar Baja Rol Crear Rol Modificar Rol 35 5.5.6.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Rol Prototipo de Interfaz para Modificar Rol Prototipo de Interfaz para Crear Rol 36 5.5.7 PAQUETE GESTIÓN: USUARIOS Paquete Gestión Usuarios ListarUsuarios Dar Alta Usuario Dar Baja Usuario Crear Usuario Modificar Usuario 37 Registrar Usuario 5.5.7.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Usuario Prototipo de Interfaz para Modificar Usuario Prototipo de Interfaz para Crear Usuario 38 ESTA PANTALLA SE ENCUENTRA EN EL PAQUETE DE GESTION DE ACCESO, POR LO QUE SE REPITE EN AMBOS LADOS, CREO Q ESTARIA BIEN DEJARLO EN EL PAQUETE DE ACCESO 5.5.8 PAQUETE GESTIÓN: MEDIOS DE PAGO Paquete Gestión Medios de Pago ListarMedios de Pago Dar Alta Medio de Pago Dar Baja Medio de Pago Crear Medio de Pago Modificar Medio de Pago 39 5.5.8.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Medio de Pago Prototipo de Interfaz para Modificar Medio de Pago Prototipo de Interfaz para Crear Medio de pago 5.5.9 PAQUETE GESTIÓN: CATEGORÍAS CAT Paquete Gestión de Categorías 40 ListarCategorías Dar Alta Categoría Dar Baja Categoría Crear Categoría Modificar Categoría 5.5.9.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Categoría Prototipo de Interfaz para Modificar Categoría 41 Prototipo de Interfaz para Crear Categoría 5.5.10 PAQUETE GESTIÓN: REPORTES REP Paquete Gestión Reportes CU: Generar Reporte Cierre Caja CU: Generar Reporte Stock Productos CU: Generar Reporte Ventas 5.5.10.1 PROTOTIPO DE INTERFAZ INTERFA 42 Prototipo de Interfaz para Generar Reporte Stock de Productos Prototipo de Interfaz para Generar Reporte Cierre de Caja 43 Prototipo de Interfaz para Generar Reporte Ventas 5.5.11 PAQUETE GESTIÓN: FACTURAS FAC Paquete Gestión de Facturas ListarFacturas Generadas 44 Listar Facturas Pendientes Dar Alta Factura Dar Baja factura Generar Factura 5.5.11.1 PROTOTIPO DE INTERFAZ INTERFA Prototipo de Interfaz para Listar Facturas Pendientes, Dar Alta y Dar Baja. Prototipo de Interfaz para Listar Facturas Pagadas 45 Prototipo de Interfaz para Visualizar Factura Prototipo de Interfaz para Generar Factura 46 5.5.12 PAQUETE GESTIÓN: DESCUENTO POR PRODUCTO Paquete Gestión de Descuento por Producto Listar Descuento por Producto Alta Descuento por Producto Baja Descuento por Producto Crear Descuento por Producto Modificar Descuento por Producto 47 5.5.12.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Descuento por Producto Prototipo de Interfaz para Modificar Descuento por Producto Prototipo de Interfaz para Crear Descuento por Producto 5.5.13 PAQUETE GESTIÓN: EMPLEADOS EMP POR AGENCIA 48 Paquete Gestión de Empleados por Agencia Listar Empleados por Agencia Alta Empleado por Agencia Baja Empleado por Agencia Crear Empleado por Agencia Modificar Empleado por Agencia 49 5.5.13.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Empelados por Agencia Prototipo de Interfaz para Modificar Empleado por Agencia Prototipo de Interfaz para Crear Empleado por Agencia 50 5.5.14 PAQUETE GESTIÓN: DETALLE EN BODEGA Paquete Gestión de Detalle en Bodega Listar Bodega Detalle Alta Bodega Detalle Baja Bodega Detalle Crear Bodega Detalle Modificar Bodega Detalle 51 5.5.14.1 PROTOTIPOS DE INTERFAZ INTERF Prototipo de Interfaz para Listar, Dar Baja y Alta de Bodega Detalle Prototipo de Interfaz para Modificar Bodega Detalle Prototipo de Interfaz para Crear Bodega Detalle 5.5.15 PAQUETE GESTIÓN: COMPRAS Este paquete debería estar al ultimo, ya q es de la aplicación movil 52 Paquete Gestión de Compras Agregar producto Listar Productos Productos de Carro Compras Listar Carros Compras 53 Confirmar Carro Compras Editar Producto 5.5.15.1 PROTOTIPO DE INTERFAZ Las interfaces de este paquete se presentan como interfaces para el dispositivo móvil ya que la gestión de la compra realizada por el cliente se la realizará desde su teléfono personal previamente instalada la aplicación móvil. Prototipo de Interfaz para Listar Productos de Carro Compras Prototipo de Interfaz para Listar Productos de Carro Compras 54 Prototipo de Interfaz para Agregar Producto Prototipo de Interfaz para Confirmar Carro Compras Prototipo de Interfaz para Editar Producto ( incluye la eliminación) 5.6 DIAGRAMA DE CONTEXTO Por cuestiones de espacio en el documento, se ha realizado dos diagramas de contexto, el primero relacionado con los casos de uso realizados por el cliente: 55 stm Cliente Inicial Entrar Aplicativo Movil [Entrar Aplicativo Movil] Listar Productos Carro Compras Eliminar Carro Compras Agregar Producto cancelar/producto agregado cancelar/guardar/eliminar Editar Producto Listar Carro Compras cancelar Confirmar Carro Compras listar Carros Compras Eliminar Producto Salir Salir salir Final Y el segundo, que tiene que ver con el perfil Administrador y Empleado: 56 stm Diagrama de Contexto Dar Al ta Usuario Dar Baja Usuario Dar Alta Marca Inicial Modifi car Usuario Dar Baj a Marca Salir Crear Usuari o Listar Marcas Listar Usuarios entrar [Es Adminsitrador] Modificar Marca entrar [es Empleado] Salir Crear Marca Modifi car Empresa Imprimir Venta de Caja Dar Alta Empresa Sali r Lsi tar Empresas Listar Facturas Pagadas Listar Facturas Pendientes Visual izar Factura Vi sualizar Factura Crear Empresa Modifi car Agencia Imprimi r Factura Dar Baja Empresa Sali r Dar Alta Agencia Listar Agenci as Modificar Categori a Dar Baja Categoria Crear Agenci a Dar Baja Agenci a Sali r Listar Categorias Crear Categoría Salir Listar Bodegas Dar Baja Categori a Crear Bodega Salir Modifi car Medio Pago Dar Alta Bodega Modi ficar Bodega Dar Baja Medi o Pago Dar Baja Bodega Salir Listar Medi os Pago Modi ficar Producto Dar Baja Producto Li star Productos Sal ir Dar Alta Medio Pago Modificar Rol Crear Medio Pago Dar Alta Producto Dar Baja Rol Crear Producto Modi ficar Descuento Salir Listar Roles Dar Baja Descuento Salir Listar Descuentos Sali r Dar Alta Rol Crear Rol Salir Dar Alta Descuento Crear Bodega Salir Final 6 FLUJO DE TRABAJO: ANALISIS 6.1 ANÁLISIS DE LA ARQUITECTURA A fin de facilitar la reutilización de código, el mantenimiento y el proceso de desarrollo, la arquitectura de la aplicación propuesta se basa en el patrón de arquitectura de software MCV (Modelo, Vista, Controlador), separando de esta manera los datos (modelo), la lógica operacional del negocio (controlador) y la lógica de presentación (vista). El patrón MVC como el resto de los patrones, no es exclusivo de la plataforma, por lo cual en las primeras iteraciones del análisis se ha abstraído por completo la tecnología de programación de la arquitectura. 57 class Analisis de Arquitectura class controladores class beans class android agencia bodega empresa login + AltaAgencia + AltaBodega + AltaEmpresa + EntrarAplicativoMovil + BajaAgencia + BajaBodega + BajaEmpresa + RegistrarUsuario + CrearAgencia + CrearBodega + CrearEmpresa + SalirAplicativoMovil + ListarAgencia + ListarBodega + ListarEmpresa + Modifi carAgenci a + ModificarBodega + ModificarEmpresa descuentoProducto compra + AgregarProducto factura empleadoAgencia + CapturarProducto + AltaDescuentoProducto + AltaEmpleadoAgencia + AltaFactura + BajaDescuentoProducto + BajaEmpleadoAgencia + BajaFactura + CrearDescuentoProducto + CrearEmpleadoAgencia + GenerarFactura + ListarDescuentoProducto + ListarEmpleadoAgencia + ImprimirFactura + Modifi carDescuentoProducto + ModificarEmpleadoAgencia + ListarFacturasGeneradas + ConfirmarCarroCompras + EditarProducto + ListarCarrosCompras + ListarProudctosCarroCompras + ListarFacturasPendientes usuario marca producto login + AltaUsuario + AltaMarca + AltaProducto + BajaUsuario + BajaMarca + BajaProducto + loginUsuario + CrearUsuario + CrearMarca + CrearProducto + logOut + ListarUsuario + ListarMarca + ListarProducto + Modifi carUsuario + ModificarMarca + ModificarProducto bodegaDetalle descuento rol + AltaBodegaDetalle + Al taDescuento + Al taRol + BajaBodegaDetalle + BajaDescuento + BajaRol + CrearBodegaDetalle + CrearDescuento + CrearRol + ListarBodegaDetalle + ListarDescuento + ListarRol + Modifi carBodegaDetalle + ModificarDescuento + ModificarRol reporte medioPago categoria + CierreCaja + AltaMedioPago + AltaCategoria + ConsolidadoVentas + BajaMedioPago + BajaCategoria + GenerarReporteStock + CrearMedioPago + CrearCategoria + ListarMedioPago + ListarCategoria + ModificarMedioPago + ModificarCategoria class v istas Vistas Android + UI Generica Androide Vistas Web + UI Generica WEB class modelo Entidades + Agencia + Bodega + BodegaDetalle + Categoria + Descuento + DescuentoProducto + EmpleadoAgencia + Empresa + Factura + FacturaDetalle + Marca + MedioPago + Producto + Rol + Usuario 6.2 ANÁLISIS DE CASOS DE USO El análisis de cada caso de uso se presenta a mediante diagramas de Colaboración, con lo cual se identifica las responsabilidades entre las clases de análisis que conforman cada caso de uso. 58 6.2.1 PAQUETE: AGENCIA 6.2.1.1 CASO DE USO: ALTA AGENCIA sd Alta Agencia 1: solicita dar alta() 1.1: alta() ListarAgencia AltaAgencia 1.3: mostrar listado() 1.2: actualizar estado() Agencia UI Generica WEB 6.2.1.2 CASO DE USO: BAJA AGENCIA sd Alta Agencia 1: solicita dar alta() 1.1: alta() ListarAgencia AltaAgencia 1.3: mostrar listado() 1.2: actualizar estado() UI Generica WEB Agencia 6.2.1.3 CASO DE USO: CREAR AGENCIA 59 sd Crear Agencia 2: guardar() 1: solicita crear() 3: cancelar() 1.1: crear() 3.1: listar() ListarAgencia CrearAgencia 3.2: mostrar listado() 1.2: obtener listado() 1.3: mostrar() 2.1: crear agencia() UI Generica WEB Agencia Empresa 6.2.1.4 CASO DE USO: LISTAR AGENCIA sd Listar Agencia 1: solicita Listar() ListarAgencia 1.2: presentar listado() 1.1: obtener listado() UI Generica WEB Agencia 6.2.1.5 CASO DE USO: MODIFICAR AGENCIA 60 sd Modificar Agencia 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarAgencia ModificarAgencia 1.1: habiliar edicion() 3.1: deshabilitar edicion() 2.2: update() UI Generica WEB Agencia 6.2.2 PAQUETE: MARCA 6.2.2.1 CASO DE USO: ALTA MARCA sd Alta Marca 1: solicita alta() 1.1: alta() ListarMarca AltaMarca 1.3: mostrar listado() 1.2: actualiza estado() UI Generica WEB Marca 6.2.2.2 CASO DE USO: BAJAMARCA 61 sd Baj aMarca 1: solicita baja() 1.1: baja() BajaMarca ListarMarca 1.3: mostrar listado() 1.2: modificar estado() UI Generica WEB Marca 6.2.2.3 CASO DE USO: CREAR MARCA sd Crear Marca 1: solicita crear() 3: cancelar() 2: guardar() 1.1: onCrear() 3.1: listar() CrearMarca ListarMarca 1.2: mostrar() 3.2: mostrar listado() 2.1: crear() UI Generica WEB Marca 6.2.2.4 CASO DE USO: LISTAR MARCA 62 sd Listar Marca 1: solicita listar() ListarMarca 1.2: presentar listado() 1.1: listar() Marca UI Generica WEB 6.2.2.5 CASO DE USO: MODIFICAR MARCA sd Modificar Marca 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarMarca ModificarMarca 1.1: habilita edicion() 3.1: deshabilita edicion() 2.2: update() Marca UI Generica WEB 6.2.3 PAQUETE: EMPRESA 6.2.3.1 CASO DE USO: ALTA EMPRESA 63 sd Alta Empresa 1: solicita alta() 1.1: alta() ListarEmpresa AltaEmpresa 1.3: mostrar listado() 1.2: actualiza estado() UI Generica WEB Empresa 6.2.3.2 CASO DE USO: BAJA EMPRESA sd Baj a Empresa 1: solicita baja() 1.1: baja() BajaEmpresa ListarEmpresa 1.3: mostrar listado() 1.2: modificar estado() UI Generica WEB Empresa 6.2.3.3 CASO DE USO: CREAR EMPRESA 64 sd Crear Empresa 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCrear() 3.1: listar() ListarEmpresa CrearEmpresa 3.2: mostrar listado() 1.2: mostrar() 2.1: crear() UI Generica WEB Empresa 6.2.3.4 CASO DE USO: LISTAR EMPRESA sd Listar Empresa 1: solicita listar() ListarEmpresa 1.2: listarEmpresa() 1.1: listar() UI Generica WEB Empresa 6.2.3.5 CASO DE USO: MODIFICAR EMPRESA 65 sd Modificar Empresa 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarEmpresa ModificarEmpresa 3.1: deshabilitar edicion() 1.1: habilita edicion() 2.2: update() UI Generica WEB Empresa 6.2.4 PAQUETE: BODEGA 6.2.4.1 CASO DE USO: ALTA BODEGA sd Alta Bodega 1: solicita alta() 1.1: alta() ListarBodega 1.3: mostrar listado() UI Generica WEB AltaBodega 1.2: actualiza estado() Bodega 6.2.4.2 CASO DE USO: BAJA BODEGA 66 sd Baj a Bodega 1: solicita baja() 1.1: baja() BajaBodega ListarBodega 1.2: actualiza estado() 1.3: mostrar listado() Bodega UI Generica WEB 6.2.4.3 CASO DE USO: CREAR BODEGA sd Crear Bodega 1: solicita crear() 3: cancelar() 2: guardar() 1.1: onCrear() ListarBodega 3.1: listar() CrearBodega 3.2: mostrar listado() 1.3: mostrar() 2.1: create() 1.2: obtener listado() UI Generica WEB Agencia Bodega 6.2.4.4 CASO DE USO: LISTAR BODEGA 67 sd Listar Bodega 1: solicita listar() ListarBodega 1.1: obtener listado() 1.2: presentar listado() Bodega UI Generica WEB 6.2.4.5 CASO DE USO: MODIFICAR BODEGA sd Modificar Bodega 3: cancelar() 1: solicita modificar() 2: guardar() 2.1: modificar() ListarBodega ModificarBodega 1.2: habilita edicion() 1.1: obtener listado() 2.2: update() 3.1: deshabilita edicion() UI Generica WEB Agencia Bodega 6.2.5 PAQUETE: PRODUCTO 6.2.5.1 CASO DE USO: ALTA PRODUCTO 68 sd Alta Producto 1: solicita alta() 1.1: alta() ListarProducto 1.3: mostrar listado() AltaProducto 1.2: actualiza estado() UI Generica WEB Producto 6.2.5.2 CASO DE USO: BAJA PRODUCTO sd Baj a Producto 1: solicita baja() 1.1: baja() ListarProducto 1.3: mostrar listado() UI Generica WEB BajaProducto 1.2: actualiza estado() Producto 6.2.5.3 CASO DE USO: CREAR PRODUCTO 69 sd Crear Producto 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCreate() 3.1: listar() ListarProducto 3.2: mostrar listado() CrearProducto 2.1: create() 1.4: mostrar() 1.2: obtener listado() 1.3: obtener listado() UI Generica WEB Marca Producto Categoria 6.2.5.4 CASO DE USO: LISTAR PRODUCTO sd Listar Producto 1: solicita listar() ListarProducto 1.2: presentar listado() 1.1: obtener listado() UI Generica WEB Producto 6.2.5.5 CASO DE USO: MODIFICAR PRODUCTO 70 sd Modificar Producto 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() 3.1: deshabilitar edicion() ListarProducto ModificarProducto 1.2: obtener listado() 1.3: habilitar edicion() 2.2: update() Producto Marca 1.1: obtener listado() UI Generica WEB Categoria 6.2.6 PAQUETE: DESCUENTO 6.2.6.1 CASO DE USO: ALTA DESCUENTO sd Alta Descuento 1: solicita alta() 1.1: alta() ListarDescuento 1.3: mostrar listado() AltaDescuento 1.2: modificar estado() UI Generica WEB Descuento 6.2.6.2 CASO DE USO: BAJA DESCUENTO 71 sd Baj a Descuento 1: solicita baja() 1.1: baja() ListarDescuento BajaDescuento 1.3: mostrar listado() 1.2: modificar estado() UI Generica WEB Descuento 6.2.6.3 CASO DE USO: CREAR DESCUENTO sd Crear Descuento 1: solicita crear() 3: cancelar() 2: guardar() 1.1: onCrear() 3.1: listar() ListarDescuento CrearDescuento 3.2: mostrar listado() 1.2: mostrar() UI Generica WEB 2.1: crear() Descuento 6.2.6.4 CASO DE USO: LISTAR DESCUENTO 72 sd Listar Descuento 1: solicita listar() ListarDescuento 1.2: listarDescuento() 1.1: find() UI Generica WEB Descuento 6.2.6.5 CASO DE USO: MODIFICAR DESCUENTO sd Modificar Descuento 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarDescuento ModificarDescuento 1.1: habilitar edicion() 3.1: deshabilitar edicion() UI Generica WEB 2.2: update() Descuento 6.2.7 PAQUETE: ROL 6.2.7.1 CASO DE USO: ALTA ROL 73 sd Alta Rol 1: solicita alta() 1.1: alta() AltaRol ListarRol 1.3: mostrar listado() 1.2: modificar estado() Rol UI Generica WEB 6.2.7.2 CASO DE USO: BAJA ROL sd Baj a Rol 1: solicita baja() 1.1: baja() ListarRol 1.3: mostrar listado() BajaRol 1.2: modificar estado() UI Generica WEB Rol 6.2.7.3 CASO DE USO: CREAR ROL 74 sd Crear Rol 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCrear() ListarRol 3.1: listar() CrearRol 3.2: mostrar listado() 1.2: mostrar() 2.1: create() UI Generica WEB Rol 6.2.7.4 CASO DE USO: LISTAR ROL sd Listar Rol 1: solicita listar() ListarRol 1.2: presentar listado() 1.1: obtener listado() UI Generica WEB Rol 6.2.7.5 CASO DE USO: MODIFICAR ROL 75 sd Modificar Rol 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarRol ModificarRol 1.1: habilitar edicion() 3.1: deshabilitar edicion() 2.2: update() UI Generica WEB Rol 6.2.8 PAQUETE: USUARIO 6.2.8.1 CASO DE USO: ALTA USUARIO sd Alta Usuario 1: solicita alta() 1.1: alta() ListarUsuario 1.3: mostrar listado() UI Generica WEB AltaUsuario 1.2: actualiza estado() Usuario 6.2.8.2 CASO DE USO: BAJA USUARIO 76 sd Baj a Usuario 1: solicita baja() 1.1: baja() BajaUsuario ListarUsuario 1.2: actualizar estado() 1.3: mostrar listado() Usuario UI Generica WEB 6.2.8.3 CASO DE USO: CREAR USUARIO sd Crear Usuario 3: cancelar() 1: solicita crear() 2: guardar() 3.1: listar() 1.1: onCreate() ListarUsuario CrearUsuario 1.3: mostrar() 3.2: mostrar listado() 2.1: create() 1.2: obtener listado() UI Generica WEB Rol Usuario 6.2.8.4 CASO DE USO: LISTAR USUARIO 77 sd Listar Usuario 1: solicita listar() ListarUsuario 1.2: presentar listado() 1.1: obtener listado() Usuario UI Generica WEB 6.2.8.5 CASO DE USO: MODIFICAR USUARIO sd Modificar Usuario 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ModificarUsuario ListarUsuario 1.2: habilitar edicion() 3.1: deshabilitar edicion() UI Generica WEB 1.1: obtener listado() 2.2: update() Rol Usuario 78 6.2.9 PAQUETE: MEDIO PAGO 6.2.9.1 CASO DE USO: ALTA MEDIO PAGO sd Alta Medio Pago 1: solicita alta() 1.1: alta() ListarMedioPago AltaMedioPago 1.3: mostrar listado() 1.2: modificar estado() MedioPago UI Generica WEB 6.2.9.2 CASO DE USO: BAJA MEDIO PAGO sd Baj a Medio Pago 1: solicita baja() 1.1: baja() ListarMedioPago BajaMedioPago 1.3: mostrar listado() 1.2: modificar estado() UI Generica WEB MedioPago 79 6.2.9.3 CASO DE USO: CREAR MEDIO PAGO sd Crear Medio Pago 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCrear() 3.1: listar() ListarMedioPago CrearMedioPago 3.2: mostrar listado() 1.2: mostrar() 2.1: crear() MedioPago UI Generica WEB 6.2.9.4 CASO DE USO: LISTAR MEDIO PAGO sd Listar Medio Pago 1: solicita listar() ListarMedioPago 1.2: presentar listado() UI Generica WEB 1.1: obtener listado() MedioPago 6.2.9.5 CASO DE USO: MODIFICAR MEDIO PAGO 80 sd Modificar Medio Pago 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarMedioPago ModificarMedioPago 1.1: habilitar edicion() 3.1: deshabilitar edicion() 2.2: update() UI Generica WEB MedioPago 6.2.10 PAQUETE: CATEGORIA 6.2.10.1 CASO DE USO: ALTA CATEGORIA sd Alta Categoria 1: solicita alta() 1.1: alta() ListarCategoria AltaCategoria 1.3: mostrar listado() 1.2: actualiza estado() UI Generica WEB Categoria 6.2.10.2 CASO DE USO: BAJA CATEGORIA 81 sd Baj a Categoria 1: solicita baja() 1.1: baja() ListarCategoria BajaCategoria 1.3: mostrar listado() 1.2: modificar estado() Categoria UI Generica WEB 6.2.10.3 CASO DE USO: CREAR CATEGORIA sd Crear Categoria 3: cancelar() 1: solicita listar() 2: guardar() 1.1: onCrear() 3.1: listar() ListarCategoria 3.2: mostrar listado() CrearCategoria 1.2: mostrar() 2.1: crear() UI Generica WEB Categoria 6.2.10.4 CASO DE USO: LISTAR CATEGORIA 82 sd Listar Categoria 1: solicita listar() ListarCategoria 1.2: listarCategoria() 1.1: find() UI Generica WEB Categoria 6.2.10.5 CASO DE USO: MODIFICAR CATEGORIA sd Modificar Categoria 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarCategoria ModificarCategoria 1.1: habilita edicion() 3.1: deshabilita edicion() UI Generica WEB 2.2: update() Categoria 6.2.11 PAQUETE: REPORTES 6.2.11.1 CASO DE USO: GENERAR REPORTE CIERRE CAJA 83 sd Generar Reporte Cierre Caj a 1: solicita reporte() CierreCaja 1.2: presenta reporte() 1.1: generar() UI Generica WEB Factura EmpleadoAgencia FacturaDetalle 6.2.11.2 CASO DE USO: GENERAR REPORTE STOCK sd Generar Reporte Stock 1: solicita reporte() GenerarReporteStock 1.1: generar() 1.2: presentar reporte() UI Generica WEB BodegaDetalle Agencia Empresa Producto 6.2.11.3 CASO DE USO: GENERAR REPORTE VENTAS 84 sd Generar Reporte Ventas 1: solicita reporte() ConsolidadoVentas 1.2: mostrar reporte() 1.1: obtener datos() UI Generica WEB Factura EmpleadoAgencia FacturaDetalle 6.2.12 PAQUETE: FACTURA 6.2.12.1 CASO DE USO: DAR ALTA FACTURA sd Dar Alta Factura 1: solicita alta() 1.1: alta() ListarFacturasPendientes AltaFactura 1.2: mostrar listado() 1.3: actualiza estado() UI Generica WEB Factura 6.2.12.2 CASO DE USO: DAR BAJA FACTURA 85 sd Dar Baj a Factura 1: solicita baja() 1.1: baja() BajaFactura ListarFacturasPendientes 1.3: mostrar listado() 1.2: actualizar estado() UI Generica WEB Factura 6.2.12.3 CASO DE USO: GENERAR FACTURA sd Generar Factura 1: solicita generar() 1.1: generar() ListarFacturasPendientes 1.3: mostrar() UI Generica WEB GenerarFactura 1.2: update() Factura 6.2.12.4 CASO DE USO: LISTAR FACTURAS GENERADAS 86 sd Listar Facturas Generadas 1: solicita listar() ListarFacturasGeneradas 1.1: obtener listado() 1.2: mostrar listado() UI Generica WEB Factura 6.2.12.5 CASO DE USO: LISTAR FACTURAS PENDIENTES sd Listar Facturas Pendientes 1: solicita listar() ListarFacturasPendientes 1.2: mostrar listado() UI Generica WEB 1.1: obtener listado() Factura 87 6.2.13 PAQUETE: LOGIN (BEANS) 6.2.13.1 CASO DE USO: ENTRAR ENTORNO WEB sd Entrar Entorno Web 1: solicita ingresar() loginUsuario 1.2: mostrar() 1.1: obtener() UI Generica WEB Usuario 6.2.13.2 CASO DE USO: SALIR ENTORNO WEB sd Salir Entorno Web 1: solicita salir() logOut 1.1: loginUsuario() UI Generica WEB 88 6.2.14 PAQUETE: BODEGA DETALLE 6.2.14.1 CASO DE USO: ALTA BODEGA DETALLE sd Alta Bodega Detalle 1: solicita alta() 1.1: alta() ListarBodegaDetalle AltaBodegaDetalle 1.3: listarBodegaDetalle() 1.2: update() UI Generica WEB BodegaDetalle 6.2.14.2 CASO DE USO: BAJA BODEGA DETALLE sd Baj a Bodega Detalle 1: solicita baja() 1.1: baja() ListarBodegaDetalle 1.3: listarBodegaDetalle() UI Generica WEB BajaBodegaDetalle 1.2: update() BodegaDetalle 6.2.14.3 CASO DE USO: CREAR BODEGA DETALLE 89 sd Crear Bodega Detalle 3: cancelar() 1: solicita crear() 2: guardar() 1.1: crear() ListarBodegaDetalle 3.1: listar() CrearBodegaDetalle 1.3: mostrar() 2.1: create() 3.2: mostrar() 1.2: obtener lista() UI Generica WEB Bodega 1.4: obtener lista() Producto BodegaDetalle 6.2.14.4 CASO DE USO: LISTAR BODEGA DETALLE sd Listar Bodega Detalle 1: solicita listar() ListarBodegaDetalle 1.2: listarBodegaDetalle() 1.1: find() UI Generica WEB BodegaDetalle 6.2.14.5 CASO DE USO: MODIFICAR BODEGA DETALLE 90 sd Modificar Bodega Detalle 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarBodegaDetalle ModificarBodegaDetalle 1.3: habilita edicion() 1.1: listar Productos() 3.1: deshabilita edicion() 2.2: update() 1.2: listar bodegas() UI Generica WEB Bodega Producto BodegaDetalle 6.2.15 PAQUETE: DESCUENTO PRODUCTO 6.2.15.1 CASO DE USO: ALTA DESCUENTO PRODUCTO sd Alta Descuento Producto 1: solicita alta() 1.1: alta() ListarDescuentoProducto 1.3: mostrar listado() UI Generica WEB AltaDescuentoProducto 1.2: actualizar estado() DescuentoProducto 6.2.15.2 CASO DE USO: BAJA DESCUENTO PRODUCTO 91 sd Baj a Descuento Producto 1: solicita baja() 1.1: baja() ListarDescuentoProducto 1.3: mostrar listado() BajaDescuentoProducto 1.2: actualiza estado() UI Generica WEB DescuentoProducto 6.2.15.3 CASO DE USO: CREAR DESCUENTO PRODUCTO sd Crear Descuento Producto 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCreate() ListarDescuentoProducto 3.2: mostrar listado() 3.1: listar() CrearDescuentoProducto 1.4: mostrar() 2.1: create() 1.2: obtener listado() 1.3: obtener listado() UI Generica WEB Descuento Producto DescuentoProducto 6.2.15.4 CASO DE USO: LISTAR DESCUENTO PRODUCTO 92 sd Listar Descuento Producto 1: solicita listar() ListarDescuentoProducto 1.2: presenta listado() 1.1: obtener listado() UI Generica WEB DescuentoProducto 6.2.15.5 CASO DE USO: MODIFICAR DESCUENTO PRODUCTO sd Modificar Descuento Producto 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ListarDescuentoProducto ModificarDescuentoProducto 1.3: habilita edicion() 2.2: update() 3.1: deshabilita edicion() 1.2: obtener listado() UI Generica WEB 1.1: obtener listado() Producto Descuento DescuentoProducto 6.2.16 PAQUETE: EMPLEADO AGENCIA 6.2.16.1 CASO DE USO: ALTA EMPLEADO AGENCIA 93 sd Alta Empleado Agencia 1: solicita alta() 1.1: alta() ListarEmpleadoAgencia AltaEmpleadoAgencia 1.3: mostrar listado() 1.2: actualiza estado() UI Generica WEB EmpleadoAgencia 6.2.16.2 CASO DE USO: BAJA EMPLEADO AGENCIA sd Baj a Empleado Agencia 1: solicita baja() 1.1: baja() ListarEmpleadoAgencia 1.3: mostrar listado() BajaEmpleadoAgencia 1.2: actualiza estado() UI Generica WEB EmpleadoAgencia 6.2.16.3 CASO DE USO: CREAR EMPLEADO AGENCIA 94 sd Crear Empleado Agencia 3: cancelar() 1: solicita crear() 2: guardar() 1.1: onCreate() 3.1: listar() ListarEmpleadoAgencia 3.2: mostrar listado() CrearEmpleadoAgencia 1.4: mostrar() 2.1: create() 1.2: obtener listado() 1.3: obtener litado() UI Generica WEB Agencia Usuario EmpleadoAgencia 6.2.16.4 CASO DE USO: LISTAR EMPLEADO AGENCIA sd Listar Empleado Agencia 1: solicita listar() ListarEmpleadoAgencia 1.2: presentar listado() 1.1: obtener listado() UI Generica WEB EmpleadoAgencia 6.2.16.5 CASO DE USO: MODIFICAR EMPLEADO AGENCIA 95 sd Modificar Empleado Agencia 3: cancelar() 2: guardar() 1: solicita modificar() 2.1: modificar() ModificarEmpleadoAgencia ListarEmpleadoAgencia 1.3: habilitar edicion() 1.2: obtener lista() 2.2: update() 3.1: deshabilitar edicion() 1.1: obtener lista() Agencia UI Generica WEB Usuario EmpleadoAgencia 6.2.17 PAQUETE: COMPRA (ANDROID) 6.2.17.1 CASO DE USO: AGREGAR PRODUCTO sd Agregar Producto 2.1: persentar informacion() CapturarProducto 1.1: presentarCapturador() AgregarProducto 3.1: add() 1.2: mostrar() ListarProudctosCarroCompras 3: agregar() 2: capturar() 1: solicita agregar producto() Producto UI Generica Androide 6.2.17.2 CASO DE USO: CONFIRMAR CARRO COMPRAS 96 sd Confirmar Carro Compras 1.1: presentarConfirmar() ConfirmarCarroCompras ListarProudctosCarroCompras 1.3: mostrar() 2.1: update() 1: solicita confirmar() 2: confirmar() 1.2: obtener listado() MedioPago Factura UI Generica Androide 6.2.17.3 CASO DE USO: EDITAR PRODUCTO sd Editar Producto 1.1: presentarEdicion() ListarProudctosCarroCompras 2.1: update() 3.1: eliminar() EditarProducto Producto 1.2: mostrar() 1: solicita editar() 3: eliminar() 2: guardar() UI Generica Androide 6.2.17.4 CASO DE USO: LISTAR CARROS COMPRAS 97 sd Listar Carros Compras 1.1: presentarListado() ListarProudctosCarroCompras ListarCarrosCompras 1.2: obtener listado() 1: solicita listar() 1.3: mostrar() UI Generica Androide Factura 6.2.17.5 CASO DE USO: LISTAR PRODUCTOS CARRO COMPRAS sd Listar Productos Carro Compras ListarProudctosCarroCompras 1.3: lista productos() 1.2: obtener lista() 1: solicita listar() 1.1: obtener() UI Generica Androide FacturaDetalle Factura 6.2.18 PAQUETE: LOGIN (ANDROID) 6.2.18.1 CASO DE USO: ENTRAR APLICATIVO MOVIL 98 sd Entrar Aplicativ o Mov il 2.1: login() Usuario 1.2: muestra ingreso() 1: abrir aplicacion() UI Generica Androide EntrarAplicativoMovil 2: solicita ingresar() 1.1: obtener lista() Agencia 6.2.18.2 CASO DE USO: SALIR APLICATIVO MOVIL sd Salir Aplicativ o Mov il SalirAplicativoMovil 1.1: destroy() 1: salir() UI Generica Androide 6.2.18.3 CASO DE USO: REGISTRAR USUARIO 99 sd Registrar Usuario 1.1: registrar() EntrarAplicativoMovil RegistrarUsuario 1.2: mostrar registro() 1: solicita registrarse() 2.1: create() 2: guardar() UI Generica Androide Usuario 6.3 ANÁLISIS DE CLASES Una vez que se han Identificado las responsabilidades de cada clase en los diagramas de colaboración anteriores, ahora se identifican los atributos, asociaciones, agregaciones dando como resultado el siguiente listado de clases. Agencia Bodega BodegaDetalle FacturaDetalle Producto Categoria Descuento DescuentoProducto Marca Rol EmpleadoAgencia Empresa Factura MedioDePago Usuario 6.3.1 ATRIBUTOS DE LA CLASE AGENCIA Nombre id nombre direccion telefono eliminado empresa bodega empleadoAgencia factura Tipo de Dato int String String String boolean Empresa Set<Bodega> Set<EmpleadoAgencia> Set<Factura> Comentario Identificador de la Agencia Nombre de la Agencia Dirección física de la Agencia Número de Teléfono de Contacto Estado de la Agencia (True = Activo, False = Inactivo) Empresa a la que pertenece la agencia Conjunto de bodegas que tiene la Agencia Empleados de la Agencia Facturas que pertenecen a la agencia 6.3.2 ATRIBUTOS DE LA CLASE BODEGA Nombre id Tipo de Dato int Comentario Identificador de la Bodega 100 nombre direccion telefono eliminado agencia bodegaDetalle String String String boolean Agencia Set<BodegaDetalle> Nombre de la Bodega Dirección física de la Bodega Número de teléfono de la Bodega Estado de la Bodega (True=Activa, False=Inactiva) Agencia a la que pertenece la Bodega Conjunto de Productos de la Bodega 6.3.3 ATRIBUTOS DE LA CLASE BODEGADETALLE Nombre id cantidad precio eliminado bodega producto facturaDetalle Tipo de Dato int int double boolean Bodega Producto Set<FacturaDetalle> Comentario Identificador del Producto (Producto en una Bodega) Cantidad en Stock Precio de una unidad del producto Estado del producto en la Bodega Bodega a la que pertenece el producto Producto del catálogo al que se hace referencia Detalle de factura en el cual se ha registrado el producto de la bodega. 6.3.4 ATRIBUTOS DE LA CLASE CATEGORIA Nombre id nombre eliminado producto Tipo de Dato int String boolean Set<Producto> Comentario Identificador de la Categoría Nombre de la Categoría Estado de la Categoría (True = Activo, False =Inactivo) Conjunto de productos que pertenecen a la categoría 6.3.5 ATRIBUTOS DE LA CLASES DESCUENTO Nombre id nombre valor fechaInicio fechaFin eliminado descuentoProducto Tipo de Dato int String double Date Date boolean Set<DescuentoProducto> Comentario Identificador de Descuento Nombre del Descuento Valor del descuento Fecha inicial de aplicación Fecha final de aplicación Estado del Descuento (True = Activo, False= Inactivo) Conjunto de Producto al cual es asignado el descuento 6.3.6 ATRIBUTOS DE LA CLASE DESCUENTOPRODUCTO Nombre id eliminado producto descuento Tipo de Dato int boolean Producto Descuento Comentario Identificador de DescuentoProducto Estado del Descuento Producto Producto al cual es aplicado un descuento Descuento que es aplicado a un producto 6.3.7 ATRIBUTOS DE LA CLASE EMPLEADOAGENCIA Nombre id eliminado Tipo de Dato int boolean Comentario Identificador del empleado en una agencia Estado del Empleado en la agencia (True = Activo, False = Inactivo) 101 empleado agencia factura Usuario Agencia Set<Factura> Empleado del catálogo de empleados que pertenece a una agencia Agencia del Catálogo de agencias al que pertenece el empleado Conjunto de facturas que han sido realizadas por el empleado en la Agencia 6.3.8 ATRIBUTOS DE LA CLASE EMPRESA Nombre id razonSocial ruc direccion telefono iva eliminado agencia Tipo de Dato int String String String String double boolean Set<Agencia> Comentario Identificador de la Empresa Nombre de la Empresa Numero de RUC Dirección del establecimiento Número de Teléfono Tasa de IVA para facturación Estado de la Empresa (True = Activo, False = Inactiva) Agencias que pertenecen a la Empresa 6.3.9 ATRIBUTOS DE LA CLASE FACTURA Nombre id fecha eliminado subtotal iva descuento total pagado pendiente cliente empleadoAgencia medioDePago agencia facturaDetalle Tipo de Dato int Date boolean double double double double boolean boolean Usuario EmpleadoAgencia MedioDePago Agencia Set<FacturaDetalle> Comentario Identificador de la Factura Fecha de generación de la factura Estado de la Factura (True = Activa, False = Inactiva) Subtotal Total de IVA cobrado Valor Total de Descuento Valor Total considerado (IVA y Descuentos) True si la factura está en estado PAGADO True si la factura está en estado PENDIENTE Cliente al cual se le otorga la factura Empleado que atiende la factura Forma de Pago Agencia a la que pertenece la factura Conjunto de detalles de la factura 6.3.10 ATRIBUTOS DE LA CLASE FACTURADETALLE Nombre id cantidad precio subtotal iva descuento total eliminado factura bodegaDetalle Tipo de Dato int int double double double double double boolean Factura BodegaDetalle Comentario Identificador del detalle de factura Cantidad de producto Precio del producto Subtotal IVA cobrado descuento realizado al producto Total Estado del detalle (True= Activo, False = Inactivo) Factura a la que pertenece el detalle Determina el producto (Producto en una Bodega) 6.3.11 ATRIBUTOS DE LA CLASE MARCA Nombre Tipo de Dato Comentario 102 id nombre eliminado producto int String boolean Set<Producto> Identificador de Marca Nombre de la Marca de Producto Estado de la Marca (True=Activo, False = Inactivo) Conjunto de Producto que pertenecen a la Marca) 6.3.12 ATRIBUTOS DE LA CLASE MEDIODEPAGO Nombre id nombre eliminado factura Tipo de Dato int String boolean Factura Comentario Identificador del Medio de Pago Nombre del Medio de Pago Estado del Medio de Pago (True = Activo, False = Inactivo) Factura donde ha sido asignado el medio de pago 6.3.13 ATRIBUTOS DE LA CLASE PRODUCTO Nombre id nombre eliminado marca categoria bodegaDetalle descuentoProducto Tipo de Dato int String boolean Marca Categoria Set<BodegaDetalle> Set<DescuentoProducto> Comentario Identificador del Producto Nombre del Producto Estado del Producto (True= Activo, False = Inactivo) Marca del Producto Categoría a la que pertenece el producto Bodega en la que se encuentra el producto Conjunto de Descuento a los que está sujeto el producto 6.3.14 ATRIBUTOS DE LA CLASE ROL Nombre id nombre eliminado usuario Tipo de Dato int String boolean Set<Usuario> Comentario Identificador del Rol Nombre del Rol Estado del Rol (True= Activo, False= Inactivo) Conjunto de Usuarios a los que se ha asignado el Rol 6.3.15 ATRIBUTOS DE LA CLASE USUARIO Nombre id nombres apellidos fechaNacimiento direccion telefono email username password eliminado rol facturaCliente empleadoAgencia Tipo de Dato int String String Date String String String String String boolean Rol Set<Factura> Set<EmpleadoAgencia> Comentario Identificador de Usuario Nombres Apellidos Fecha de Nacimiento Dirección física Número de Teléfono Correo electrónico Nombre de Usuario de acceso al sistema Clave de Acceso al sistema Estado del Usuario (True = Activo, False = Inactivo) Rol asignado al Usuario Conjunto de Facturas que han sido facturas al cliente Conjunto de Agencias a la que pertenece en caso de que el usuario sea un Empleado 103 Con lo cual se ha obtenido el siguiente diagrama de clases y sus relaciones: class Diagrama de Clases Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} i d: i nt razonSocial : Stri ng ruc: String direccion: String tel efono: String i va: double eli minado: boolean agencia: Set<Agenci a> -empresa Seriali zable Seri ali zable entidades::Rol entidades::Agencia - Serializable entidades::Marca Seriali zable entidades::Categoria - id: int nombre: Stri ng eliminado: boolean producto: Set<Producto> serialVersionUID: l ong = 1L {readOnly} - id: i nt nombre: String el iminado: boolean producto: Set<Producto> seri alVersionUID: long = 1L {readOnl y} serialVersionUID: long = 1L {readOnly} i d: i nt nombre: String direccion: String tel efono: String eli minado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgenci a: Set<Empl eadoAgencia> factura: Set<Factura> - id: int nombre: Stri ng eliminado: boolean usuario: Set<Usuario> serialVersionUID: l ong = 1L {readOnly} -rol Serializable entidades::Usuario -agencia Seriali zable -marca entidades::EmpleadoAgencia -agenci a - -agencia -categoria Seri al izabl e id: int eliminado: boolean empleado: Usuario agencia: Agenci a factura: Set<Factura> serialVersionUID: l ong = 1L {readOnly} entidades::Bodega Serializable entidades::Producto - id: int nombre: Stri ng elimi nado: boolean marca: Marca categori a: Categoria bodegaDetal le: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> -producto serialVersionUID: l ong = 1L {readOnly} - serialVersionUID: l ong = 1L {readOnly} id: int nombre: Stri ng direcci on: Stri ng telefono: String elimi nado: boolean agencia: Agencia bodegaDetal le: Set<BodegaDetalle> -bodega -producto Serial izabl e entidades::BodegaDetalle Serializable entidades::DescuentoProducto - id: int eliminado: bool ean producto: Producto descuento: Descuento serial Versi onUID: l ong = 1L {readOnly} - id: int cantidad: int precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetal le: Set<FacturaDetalle> serialVersionUID: l ong = 1L {readOnly} -empleadoAgencia -empleado -cli ente - id: i nt nombres: String apel lidos: String fechaNacimiento: Date di reccion: String telefono: String email: String username: String password: Stri ng el iminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgenci a: Set<Empl eadoAgencia> seri alVersionUID: long = 1L {readOnl y} Serializable entidades::Factura -factura - id: int fecha: Date eliminado: boolean subtotal: doubl e iva: doubl e descuento: doubl e total: doubl e -factura pagado: bool ean pendi ente: boolean cl iente: Usuario empleadoAgencia: Empl eadoAgencia medioDePago: MedioDePago agencia: Agenci a facturaDetal le: Set<FacturaDetall e> serialVersionUID: l ong = 1L {readOnly} -medi oDePago Serializable entidades::MedioDePago - id: int nombre: String el iminado: bool ean factura: Factura seri al Versi onUID: long = 1L {readOnl y} -descuento -bodegaDetal le Serializable entidades::Descuento - i d: i nt nombre: String valor: double fechaInicio: Date fechaFi n: Date eli minado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} Seri al izabl e entidades::FacturaDetalle - id: int canti dad: i nt preci o: double subtotal : double iva: double descuento: double total: double el iminado: bool ean factura: Factura bodegaDetall e: BodegaDetalle seri al Versi onUID: long = 1L {readOnl y} 104 7 FLUJO DE TRABAJO: DISEÑO 7.1 DISEÑO DE LA ARQUITECTURA class Diseño de la Arquitectura dm Controlador usuario rol producto marca empleadoAgencia + AltaUsuario + AltaRol + AltaProducto + AltaMarca + AltaEmpleadoAgencia + BajaUsuario + BajaRol + BajaProducto + BajaMarca + BajaEmpleadoAgencia + CrearUsuario + CrearRol + CrearProducto + CrearMarca + CrearEmpleadoAgencia + ListarUsuario + ListarRol + ListarProducto + ListarMarca + ListarEmpleadoAgencia + ModificarUsuario + ModificarRol + ModificarProducto + ModificarMarca + ModificarEmpleadoAgencia (from beans) (from beans) (from beans) (from beans) (from beans) reportes descuentoProducto descuento bodegaDetalle bodega + rptStockProductos.jasper + AltaDescuentoProducto + AltaDescuento + AltaBodegaDetalle + BajaDescuentoProducto + BajaDescuento + BajaBodegaDetalle + CrearDescuentoProducto + CrearDescuento + CrearBodegaDetalle + ListarDescuentoProducto + ListarDescuento + ListarBodegaDetalle + ModificarDescuentoProducto + ModificarDescuento + ModificarBodegaDetalle (from beans) (from beans) (from beans) + AltaBodega + rptStockProductos.jrxml + BajaBodega + rptVentaCaja.jasper + CrearBodega + rptVentaCaja.jrxml + ListarBodega + rptVentas.jasper + ModificarBodega + rptVentas.jrxml + CierreDeCaja (from beans) + ConsolidadoVentas login compras rest + StockProductos + AdaptadorListaCarros + LoginActivity + AgenciaResource + AdaptadorListaProductos + LogoutActivity + AutenticacionResource + AddProductoActivity + NuevoUsuarioActivity + BodegaDetalleResource + CarrosComprasActivity (from android) + ComprasActivity + ConfirmarComprasActivity - ConfirmarT ask + EditProductoActivity - ListaMedioDePagosTask (from android) empresa + LoginUsuario (from beans) + CompraResource + AltaEmpresa + BajaEmpresa + MedioDePagoResource + CaptureActivity + AltaFactura + ModificarCategoria + BajaFactura (from beans) + GenerarFactura + ImprimirFactura agencia + JasperReports + ListarFacturaPagada + AltaAgencia + ListarFacturaPendiente + BajaAgencia (from beans) menu + rptFactura.jxrml + ListarCategoria zxing (from beans) + rptFactura.jasper + CrearCategoria (from beans) JasperReports factura + BajaCategoria + ListarEmpresa + ModificarEmpresa (from beans) + AltaCategoria + DescuentoResource + FacturaResource + LogoutUsuario categoria + FacturaDetalleResource + CrearEmpresa login (from android) + CrearAgencia (from beans) + ListarAgencia + Menu filters + ModificarAgencia + ForzarLoginFilter (from beans) (from beans) (from beans) dm Vista Vistas Aplicacion Web Vistas Aplicacion Android + administracion + AddProductoActivity + login + CaptureActivity + CarrosComprasActivity + ComprasActivity + ConfirmarComprasActivity + EditProductoActivity + login + NuevoUsuarioActivity dm Modelo entidades j pa + Agencia + Bodega + BodegaDetalle + Categoria + Descuento + DescuentoProducto + EmpleadoAgencia + Empresa + Factura + FacturaDetalle + Marca + MedioDePago + Producto + Rol + Usuario rest + AgenciaREST + BodegaDetalleREST + DescuentoREST + FacturaDetalleREST + FacturaREST + GenericREST + MedioPagoREST + RESTFactory + UsuarioREST (from android) dao + JPAAgenciaDAO + JPAAgenciaDAO ++JPABodegaDAO JPABodegaDAO + DAOFactory ++JPABodegaDetalleDAO JPABodegaDetalleDAO ++JPACategoriaDAO JPACategoriaDAO + BodegaDAO + JPADAOFactory + JPADAOFactory + JPADescuentoDAO + JPADescuentoDAO ++JPADescuentoProductoDAO JPADescuentoProductoDAO + CategoriaDAO ++JPAEmpleadoAgenciaDAO JPAEmpleadoAgenciaDAO ++JPAEmpresaDAO JPAEmpresaDAO + EmpleadoAgenciaDAO + JPAFacturaDAO + JPAFacturaDAO + JPAFacturaDetalleDAO + JPAFacturaDetalleDAO ++JPAGenericDAO JPAGenericDAO + FacturaDAO ++JPAMarcaDAO JPAMarcaDAO + JPAMedioPagoDAO + JPAMedioPagoDAO + JPAProductoDAO + JPAProductoDAO ++JPARolDAO JPARolDAO + MarcaDAO ++JPAUsuarioDAO JPAUsuarioDAO + UsuarioDAO + AgenciaDAO + BodegaDetalleDAO + DescuentoDAO + DescuentoProductoDAO + EmpresaDAO + FacturaDetalleDAO + GenericDAO + MedioPagoDAO + ProductoDAO + RolDAO 105 Basados en el esbozo de la arquitectura realizada en la fase de Análisis (capítulo 6.1), en la fase de Diseño se ha procedido a incorporar patrones de diseño que serán útiles principalmente en la capa de Modelo. Los cambios e incorporaciones se las detalla por cada sección: 7.1.1 SECCIÓN CONTROLADOR En el controlador se encuentran los paquetes distribuidos por cada paquete identificado en el Diagrama General de Casos de Uso y su respectiva modificación en el Análisis. Teniendo los siguientes: Nota: En el Diagrama de la arquitectura (Flujo de Diseño) se puede visualizar la diferencia entre los paquetes de controladores que son dominio de la aplicación web (denotados por "from beans" de acuerdo a la distribución realizada en el análisis) y los que son de dominio de la aplicación móvil (denotados por "from android" y que están en color verde obscuro) Paquete agencia bodega bodegaDetalle WEB X X X categoria descuento descuentoProducto X X X empleadoAgencia X empresa factura X X filters X login marca medioPago menú X X X X producto reportes X X rest X rol usuario compras X X login ANDROID X X Descripción Operaciones de Alta, Baja, Listar, Modificar y crear Agencias Operaciones de Alta, Baja, Listar, Modificar y crear Bodegas Operaciones de Alta, Baja, Listar, Modificar y crear los productos de una determinada bodega. Operaciones de Alta, Baja, Listar, Modificar y crear Categorías Operaciones de Alta, Baja, Listar, Modificar y crear Descuentos Operaciones de Alta, Baja, Listar, Modificar y crear Descuentos a Productos Operaciones de Alta, Baja, Listar, Modificar y crear Empleados en Agencias Operaciones de Alta, Baja, Listar, Modificar y crear Empresas Operaciones de la facturación como facturar, listar facturas pendientes, generadas. , adicionalmente se encuentran el archivo compilado (con extensión *.jasper) y el fuente en xml (extensión *.jrxml) del reporte realizado en JasperReports que es procesado por el controlador ImprimirFactura.java para generar la factura en PDF. Filtro utilizado para controlar las peticiones de los usuarios y restringir el acceso si no está logeado el usuario. Este controlador está configurado en el archivo web.xml de la aplicación a fin de que sea el primero en ser llamado ante cualquier petición de página del sistema. Operaciones referentes al acceso de los usuarios al sistema. Operaciones de Alta, Baja, Listar, Modificar y crear Marcas Operaciones de Alta, Baja, Listar, Modificar y crear Medios de Pago Operaciones para gestionar las acciones del menú de opciones de la aplicación. Operaciones de Alta, Baja, Listar, Modificar y crear un Producto Operaciones para generar reportes en formato PDF, adicionalmente se encuentran los archivos compilados (con extensión *.jasper) y los fuentes en xml (extensión *.jrxml) de los reportes realizados en JasperReports que son procesados por los controladores respectivos para su presentación. Operaciones referentes al a los servicios REST expuestos para ser consumidos por el dispositivo móvil(reemplazo del paquete Gestión Compras del Análisis) Operaciones de Alta, Baja, Listar, Modificar y crear un Rol Operaciones de Alta, Baja, Listar, Modificar y crear un Usuario Operaciones relativas a la compra de productos realizada mediante el aplicativo móvil. Incluye la personalización sobre la librería ZXING utilizada para capturar el Código QR del producto. Operaciones con relación al acceso del cliente a la aplicación móvil. 106 7.1.2 SECCIÓN VISTAS De las interfaces de usuario genéricas que estaban presentes en la fase de Análisis, en la fase de Diseño se ha realizado una distribución de las interfaces tanto para la aplicación móvil como para la Web de la siguiente manera: Vistas Aplicación Android. - Contiene las vistas para la aplicación Móvil. Vista AddProductoActivity CarrosComprasActivity ComprasActivity ConfirmarComprasActivity EditProductoActivity LoginActivity LogOutActivity NuevoUsuarioActivity Comentario Agrega un producto Lista todos los carros de compras del cliente Lista el Carro de Compras Activo. Confirmar el carro de compras activo. Editar un producto del carro de compras activo. Login de cliente. Salir de la Aplicación Móvil Registro del cliente. Vistas Aplicación Web.- Este paquete contendrá las vistas para la aplicación web de administración y facturación. Está conformado por dos sub paquetes, el primero "administración" que contendrá las vistas de administración y facturación, el segundo "login" contiene la vista para el acceso al sistema (a pesar de que contiene una sola vista, es necesario hacer esta división ya que el filtro que pondremos para asegurar el acceso a las páginas del sistema cumplirá con esta configuración de directorios descrita). Distribución de Vistas en el paquete “login”: Se tendrá una sola vista loginUsuario.xhtml que presentará el formulario de para el acceso al sistema tanto para el Administrador como para el Empleado. Distribución de vistas en el paquete “administración”: Subdirectorio Agencia Bodega bodegaDetalle Categoría Descuento descuentoProducto empleadoAgencia Empresa Vistas crearAgencia.xhtml listarAgencia.xhtml crearBodega.xhtml listarBodega.xhtml crearBodegaDetalle.xhtml listarBodegaDetalle.xhtml crearCategoria.xhtml listarCategoria.xhtml crearDescuento.xhtml listarDescuent.xhtml crearDescuentoProducto.xhtml listarDescuentoProducto.xhtml crearEmpleadoAgencia.xhtml listarEmpleadoAgencia.xhtml crearEmpresa.xhtml listarEmpresa.xhtml Subdirectorio medioPago Factura Marca Menú Producto Reportes Rol Usuario Vistas crearMedioPago.xhtml listarMedioPago.xhtml listarFactuarsPendientes.xhtml listarFacturasPagadas.xhtml crearMarca.xhtml listarMarca.xhtml menuAdmin.xhtml menuEmpleado.xhtml crearProducto.xhtml listarProducto.xhtml reporteMenu.xhtml crearRol.xhtml listarRol.xhtml crearUsuario.xhtml listarUsuario.xhtml 7.1.3 SECCIÓN MODELO Como consecuencia de la aplicación del Patrón DAO y una Fachada, se han incluido dos paquetes adicionales ("jpa" y "dao") en el Flujo de Diseño. Adicionalmente tenemos el paquete "rest" que será el modelo a ser utilizado en la aplicación móvil y que consumirá en sí los servicios RESTFul expuestos por el paquete del controlador "rest". 107 • • • • entidades.-Clases persistentes relacionadas que representan los datos, que son la lógica de negocio real u Objetos de Valor. Aplicado a la Aplicación Web y Móvil. dao.- Interfaces comunes entre la aplicación y la Base de Datos, dispuestas según el patrón de diseño DAO (Data Access Object), que junto con el paquete JPA nos aportan la ventaja de que cualquier objeto de negocio no requiera conocimiento del motor de base de datos que manipula los datos. Aplicado a la Aplicación Web. jpa.- API de persistencia de Java que basado en el paquete DAO, implementa las operaciones persistentes CRUD (creación, lectura, actualización y eliminación). Para la consecución de este proyecto hemos escogido la implementación de EclipseLink. Aplicado a la Aplicación Web. rest.- Factoría deGestores a ser utilizados en la Aplicación Móvil que básicamente realizan la comunicación con los servicios RESTFul expuestos por la aplicación Web. Aplicado a la Aplicación Móvil. Para ejemplificar la implementación del patrón DAO en la aplicación Web, se muestra a continuación las relaciones entre clases para las operaciones de la entidad “Empresa”. Nota: Obsérvese que las dos interfaces ubicadas en la parte superior pertenecen al paquete “dao” y las dos clases en la parte inferior pertenecen al paquete “jpa”. 7.2 DISEÑO DE CASOS DE USO 7.2.1 PAQUETE AGENCIA 7.2.1.1 CASO DE USO: ALTA AGENCIA 108 sd Alta Agencia agencia::ListarAgencia agencia::ListarAgencia agencia::AltaAgencia jpa::JPAAgenciaDAO entidades::Agencia Administrador onAlta() :String alta() :String update(T) guardar() render() (from Vista de Casos de Uso) 7.2.1.2 CASO DE USO: BAJA AGENCIA sd Baj a Agencia agencia::ListarAgencia agencia::ListarAgencia agencia::BajaAgencia jpa::JPAAgenciaDAO entidades::Agencia Administrador onBaja() :String baja() :String update(T) actualiza() render() (from Vista de Casos de Uso) 7.2.1.3 CASO DE USO: CREAR AGENCIA 109 sd Crear Agencia agenci a::ListarAgencia agencia::CrearAgencia agenci a::Li starAgencia agencia::CrearAgenci a jpa::JPAAgenci aDAO jpa::JPAEmpresaDAO entidades::Empresa entidades::Agencia Administrador onCrear() :Stri ng CrearAgencia() find(Stri ng[], String[], String, int, int) :List<T> leer() render() alt acciones guardar() :String create(T ) [guardar] crear() render() cancel ar() [cancelar] Li starAgencia() render() (from Vi sta de Casos de Uso) 7.2.1.4 CASO DE USO: LISTAR AGENCIA sd Listar Agencia agencia::ListarAgencia agencia::ListarAgencia jpa::JPAAgenciaDAO entidades::Agencia Administrador getLista() : List<Agencia> find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.1.5 CASO DE USO: MODIFICAR AGENCIA 110 sd Modificar Agencia agencia::ListarAgencia agencia::ListarAgencia agencia::ModificarAgencia jpa::JPAEmpresaDAO jpa::JPAAgenciaDAO entidades::Agencia entidades::Empresa Administrador onModificar(RowEditEvent) find(String[], String[], String, int, int) :List<T> lista() render() guardar() alt accion modificar() :String [guardar] update(T) actualiza() render() [cancelar] cancelar() deshabilita edicion() (from Vista de Casos de Uso) 7.2.2 PAQUETE: BODEGA 7.2.2.1 CASO DE USO: ALTA BODEGA sd Alta Bodega bodega::ListarBodega bodega::ListarBodega bodega::AltaBodega jpa::JPABodegaDAO entidades::Bode... Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.2.2 CASO DE USO: BAJA BODEGA 111 sd Baj a Bodega bodega::ListarBodega bodega::ListarBodega bodega::BajaBodega jpa::JPABodegaDAO entidades::Bode... Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.2.3 CASO DE USO: CREAR BODEGA sd Crear Bodega bodega::ListarBodega bodega::ListarBodega bodega::CrearBodega bodega::CrearBodega jpa::JPAAgenciaDAO jpa::JPABodegaDAO entidades::Bode... Administrador onCrear() :String CrearBodega() find(String[], String[], String, int, int) :List<T> leer() render() alt accion crear() :String create(T) [guardar] crear() render() [cancelar] cancelar() ListarBodega() render() (from Vista de Casos de Uso) 7.2.2.4 CASO DE USO: LISTAR BODEGA 112 entidades::Agencia sd Listar Bodega bodega::ListarBodega bodega::ListarBodega jpa::JPABodegaDAO entidades::Bode... Administrador getLista() : List<Bodega> find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.2.5 CASO DE USO: MODIFICAR BODEGA sd Modificar Bodega bodega::ListarBodega bodega::ListarBodega bodega::ModificarBodega jpa::JPABodegaDAO jpa::JPAAgenciaDAO entidades::Bode... entidades::Agencia Administrador onModificar(RowEditEvent) find(String[], String[], String, int, int) :List<T> leer() habilitar edicion() alt accion [guardar] onModificar(RowEditEvent) modificar() :String update(T) actualizar() render() [cancelar] cancelar() deshabilitar edicion() (from Vista de Casos de Uso) 7.2.3 PAQUETE: BODEGA DETALLE 7.2.3.1 CASO DE USO: ALTA BODEGA DETALLE 113 sd Alta Bodega Detalle bodegaDetalle::listarBodegaDetalle bodegaDetalle::ListarBodegaDetalle bodegaDetalle::AltaBodegaDetalle jpa::JPABodegaDetalleDAO entidades::BodegaDetalle Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.3.2 CASO DE USO: BAJA BODEGA DETALLE sd Baj a Bodega Detalle bodegaDetalle::listarBodegaDetalle bodegaDetalle::ListarBodegaDetalle bodegaDetalle::BajaBodegaDetalle jpa::JPABodegaDetalleDAO entidades::BodegaDetalle Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.3.3 CASO DE USO: CREAR BODEGA DETALLE sd Crear Bodega Detalle bodegaDetalle::crearBodegaDetalle bodegaDetalle::listarBodegaDetalle bodegaDetalle::ListarBodegaDetalle bodegaDetalle::CrearBodegaDetalle jpa::JPABodegaDetalleDAO jpa::JPAProductoDAO jpa::JPABodegaDAO entidades::Bode... entidades::Producto entidades::BodegaDetalle Administrador onCrear() :String getBodegas() : SelectItem find(String[], String[], String, int, int) :List<T> leer() getProductos() :SelectItem find(String[], String[], String, int, int) :List<T> leer() render() alt accion crear() :String create(T) [guardar] crear() render() [cancelar] cancelar() ListarBodegaDetalle() render() (from Vista de Casos de Uso) 7.2.3.4 CASO DE USO: LISTAR BODEGA DETALLE 114 sd Listar Bodega Detalle bodegaDetalle::listarBodegaDetalle bodegaDetalle::ListarBodegaDetalle jpa::JPABodegaDetalleDAO entidades::BodegaDetalle Administrador listarBodegaDetalle() find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.3.5 CASO DE USO: MODIFICAR BODEGA DETALLE sd Modificar Bodega Detalle bodegaDetal le::listarBodegaDetal le bodegaDetal le::ListarBodegaDeta... bodegaDetall e::Modifi carBodegaDetall e jpa::JPABodegaDAO j pa::JPABodegaDetal leDAO j pa::JPAProductoDAO entidades::BodegaDetal le enti dades::Producto enti dades::Bodega Admini strador onModificar(RowEdi tEvent) find(String[], String[], String, int, int) :List<T> leer() find(String[], String[], String, int, i nt) :List<T > l eer() habili tar edici on() alt acciones guardar() [guardar] modi ficar() :Stri ng update(T ) render() cancel ar() [cancelar] cancel ar() deshabili ta edicion() (from Vi sta de Casos de Uso) 7.2.4 PAQUETE: CATEGORIA 7.2.4.1 CASO DE USO: ALTA CATEGORIA 115 sd Alta Categoria categoria::listarCategoria categoria::ListarCategoria categoria::AltaCategoria jpa::JPACategoriaDAO entidades::Catego... Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.4.2 CASO DE USO: BAJA CATEGORIA sd Baj a Categoria categoria::listarCategoria categoria::ListarCategoria categoria::BajaCategoria jpa::JPACategoriaDAO entidades::Categoria Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.4.3 CASO DE USO: CREAR CATEGORIA 116 sd Crear Categoria categoria::listarCategoria categoria::ListarCategoria categoria::crearCategoria categoria::CrearCategoria jpa::JPACategoriaDAO entidades::Categoria Administrador onCrear() :String CrearCategoria() render() crear() :String alt acciones create(T) crear() [guardar] render() cancelar() [cancelar] ListarCategoria() render() (from Vista de Casos de Uso) 7.2.4.4 CASO DE USO: LISTAR CATEGORIA sd Listar Categoria categoria::listarCategoria categoria::ListarCategoria jpa::JPACategoriaDAO entidades::Categoria Administrador ListarCategoria() find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.4.5 CASO DE USO: MODIFICAR CATEGORIA 117 sd Modificar Categoria categoria::listarCategoria categoria::ListarCategoria categoria::ModificarCategoria jpa::JPACategoriaDAO entidades::Categoria Administrador onModificar(RowEditEvent) habilita edicion() alt accion guardar(event) [guardar] modificar() :String update(T) actualizar() habilita edicion() cancelar() [cancelar] deshabilita edicion() (from Vista de Casos de Uso) 7.2.5 PAQUETE: DESCUENTO 7.2.5.1 CASO DE USO: ALTA DESCUENTO sd Alta Descuento descuento::listarDescuento descuento::ListarDescuento descuento::AltaDescuento jpa::JPADescuentoDAO entidades::Descuento Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.5.2 CASO DE USO: BAJA DESCUENTO 118 sd Baj a Descuento descuento::listarDescuento descuento::ListarDescuento descuento::BajaDescuento jpa::JPADescuentoDAO entidades::Descuento Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.5.3 CASO DE USO: CREAR DESCUENTO sd Crear Descuento descuento::listarDescuento descuento::ListarDescuento descuento::crearDescuento descuento::CrearDescuento jpa::JPADescuentoDAO entidades::Descuento Administrador onCrear() :String CrearDescuento() render() crear() :String alt accion create(T) [guardar] crear() render() cancelar() [cancelar] ListarDescuento() render() (from Vista de Casos de Uso) 7.2.5.4 CASO DE USO: LISTAR DESCUENTO 119 sd Listar Descuento descuento::listarDescuento descuento::ListarDescuento jpa::JPADescuentoDAO entidades::Descuento Administrador ListarDescuento() find(String[], String[], String, int, int) :List<T> listar() render() (from Vista de Casos de Uso) 7.2.5.5 CASO DE USO: MODIFICAR DESCUENTO sd Modificar Descuento descuento::listarDescuento descuento::ListarDescuento descuento::ModificarDescuento jpa::JPADescuentoDAO entidades::Descuento Administrador onModificar(RowEditEvent) habilitar edicion() alt accion guardar(event) [guardar] modificar() :String update(T) actualizar() render() [cancelar] cancelar() deshabilitar edicion() (from Vista de Casos de Uso) 7.2.6 PAQUETE: DESCUENTO PRODUCTO 7.2.6.1 CASO DE USO: ALTA DESCUENTO PRODUCTO sd Alta Descuento Producto descuentoProducto::listarDescuentoProducto descuentoProducto::ListarDescuentoProducto descuentoProducto::AltaDescuentoProducto jpa::JPADescuentoProductoDAO entidades::DescuentoProducto Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 120 7.2.6.2 CASO DE USO: BAJA DESCUENTO PRODUCTO sd Baj a Descuento Producto descuentoProducto::listarDescuentoProducto descuentoProducto::ListarDescuentoProducto descuentoProducto::BajaDescuentoProducto jpa::JPADescuentoProductoDAO entidades::DescuentoProducto Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.6.3 CASO DE USO: CREAR DESCUENTO PRODUCTO sd Crear Descuento Producto descuentoProducto::crearDescuentoProducto descuentoProducto::listarDescuentoProducto descuentoProducto::ListarDescuentoProducto descuentoProducto::CrearDescuentoProducto jpa::JPADescuentoDAO entidades::Producto jpa::JPAProductoDAO entidades::Descuento jpa::JPADescuentoProductoDAO entidades::DescuentoProducto Administrador onCrear() :String CrearDescuentoProducto() find(String[], String[], String, int, int) :List<T> listar() find(String[], String[], String, int, int) :List<T> listar() render() alt accion [guardar] crear() :String create(T) crear() render() [cancelar] cancelar() ListarDescuentoProducto() render() (from Vista de Casos de Uso) 7.2.6.4 CASO DE USO: LISTAR DESCUENTO PRODUCTO sd Listar Descuento Producto descuentoProducto::listarDescuentoProducto descuentoProducto::ListarDescuentoProducto jpa::JPADescuentoProductoDAO entidades::DescuentoProducto Administrador ListarDescuentoProducto() find(String[], String[], String, int, int) :List<T> listar() render() (from Vista de Casos de Uso) 7.2.6.5 CASO DE USO: MODIFICAR DESCUENTO PRODUCTO 121 sd Modificar Descuento Producto descuentoProducto::listarDescuentoProducto descuentoProducto::ListarDescuentoProducto descuentoProducto::ModificarDescuentoProducto jpa::JPADescuentoProductoDAO entidades::DescuentoProducto jpa::JPADescuentoDAO entidades::Producto jpa::JPAProductoDAO entidades::Descuento Administrador onModificar(RowEditEvent) find(String[], String[], String, int, int) :List<T> listar() find(String[], String[], String, int, int) :List<T> listar() habilita edicion() alt acciones guardar() modificar() :String [guardar] update(T) actualizar() render() [cancelar] cancelar() deshabilita edicion() (from Vista de Casos de Uso) 7.2.7 PAQUETE: EMPLEADO AGENCIA 7.2.7.1 CASO DE USO: ALTA EMPLEADO AGENCIA sd Alta Empleado Agencia empleadoAgencia::listarEmpleadoAgencia empleadoAgencia::ListarEmpleadoAgencia empleadoAgencia::AltaEmpleadoAgencia jpa::JPAEmpleadoAgenciaDAO entidades::EmpleadoAgencia Administrador onAlta() :String alta() :String update(T ) actualizar() render() (from Vista de Casos de Uso) 7.2.7.2 CASO DE USO: BAJA EMPLEADO AGENCIA sd Baj a Empleado Agencia empleadoAgencia::listarEmpleadoAgencia empleadoAgencia::ListarEmpleadoAgencia empleadoAgencia::BajaEmpleadoAgencia jpa::JPAEmpleadoAgenciaDAO entidades::EmpleadoAgencia Administrador onBaja() :String baja() :String update(T) update() render() (from Vista de Casos de Uso) 7.2.7.3 CASO DE USO: CREAR EMPLEADO AGENCIA 122 sd Crear Empleado Agencia empleadoAgencia::listarEmpleadoAgencia empleadoAgencia::crearEmpleadoAgencia empleadoAgencia::CrearEmpleadoAgencia empleadoAgencia::ListarEmpleadoAgencia jpa::JPAEmpleadoAgenciaDAO jpa::JPAUsuarioDAO jpa::JPAAgenciaD... entidades::Agencia entidades::Usuario entidades::EmpleadoAgencia Administrador onCrear() :String CrearEmpleadoAgencia() Listar solo rol = Empleado find(String[], String[], String, int, int) :List<T> listar() find(String[], String[], String, int, int) :List<T> listar() render() alt accion crear() :String create(T) [guardar] crear() render() cancelar() [cancelar] ListarEmpleadoAgencia() render() (from Vista de Casos de Uso) 7.2.7.4 CASO DE USO: LISTAR EMPLEADO AGENCIA sd Listar Empleado Agencia empleadoAgencia::listarEmpleadoAgencia empleadoAgencia::ListarEmpleadoAgencia jpa::JPAEmpleadoAgenciaDAO entidades::EmpleadoAgencia Administrador ListarEmpleadoAgencia() find(String[], String[], String, int, int) :List<T> listar() render() (from Vista de Casos de Uso) 7.2.7.5 CASO DE USO: MODIFICAR EMPLEADO AGENCIA sd Modificar Empleado Agencia empleadoAgencia::listarEmpleadoAgencia empleadoAgencia::ListarEmpleadoAgencia empleadoAgencia::ModificarEmpleadoAgencia jpa::JPAEmpleadoAgenciaDAO jpa::JPAUsuarioDAO jpa::JPAAgenciaD... entidades::EmpleadoAgencia entidades::Usuario Administrador onModificar(RowEditEvent) find(String[], String[], String, int, int) :List<T> listar() find(String[], String[], String, int, int) :List<T> listar() habilita edicion() alt acciones guardar() [guardar] modificar() :String update(T) actualizar() render() [cancelar] cancelar() deshabilita edicion() (from Vista de Casos de Uso) 7.2.8 PAQUETE: EMPRESA 7.2.8.1 CASO DE USO: ALTA EMPRESA 123 entidades::Agencia sd Alta Empresa empresa::listarEmpresa empresa::ListarEmpresa empresa::AltaEmpresa jpa::JPAEmpresaDAO entidades::Empresa Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.8.2 CASO DE USO: BAJA EMPRESA sd Baj a Empresa empresa::listarEmpresa empresa::ListarEmpresa empresa::BajaEmpresa jpa::JPAEmpresaDAO entidades::Empresa Administrador onBaja() :String baja() :String update(T ) actualizar() render() (from Vista de Casos de Uso) 7.2.8.3 CASO DE USO: CREAR EMPRESA 124 sd Crear Empresa empresa::listarEmpresa empresa::ListarEmpresa empresa::crearEmpresa empresa::CrearEmpresa jpa::JPAEmpresaDAO entidades::Empresa Administrador onCrear() :String CrearEmpresa() render() alt accion crear() :String [guardar] create(T) crear() render() cancelar() [cancelar] ListarEmpresa() render() (from Vista de Casos de Uso) 7.2.8.4 CASO DE USO: LISTAR EMPRESA sd Listar Empresa empresa::listarEmpresa empresa::ListarEmpresa jpa::JPAEmpresaDAO entidades::Empresa Administrador ListarEmpresa() find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.8.5 CASO DE USO: MODIFICAR EMPRESA 125 sd Modificar Empresa empresa::listarEmpresa empresa::ListarEmpresa empresa::ModificarEmpresa jpa::JPAEmpresaDAO entidades::Empresa Administrador onModificar(RowEditEvent) habilitar edicion() alt acciones guardar(event) modificar() :String [guardar] update(T) actualizar() render() cancelar() [cancelar] deshabilitar edicion() (from Vista de Casos de Uso) 7.2.9 PAQUETE: FACTURA 7.2.9.1 CASO DE USO: ALTA FACTURA sd Alta Factura factura::ListarFacturasPendientes factura::ListarFacturaPendiente factura::AltaFactura jpa::JPAFacturaDAO entidades::Fact... Persona onAlta() :String alta() :String update(T) actualizar() render() Representa al Administrador o al Empleado (from Vista de Casos de Uso) 7.2.9.2 CASO DE USO: BAJA FACTURA 126 sd Baj a Factura factura::ListarFacturasPendientes factura::ListarFacturaPendie... factura::BajaFactura jpa::JPAFacturaDAO entidades::Fact... Persona onBaja() :String baja() :String update(T) actualizar() render() Representa al Administrador o al Empleado (from Vista de Casos de Uso) 7.2.9.3 CASO DE USO: GENERAR FACTURA sd Generar Factura factura::ListarFacturasPendientes factura::ListarFacturaPendie... factura::GenerarFactura jpa::JPAFacturaDAO entidades::Fact... Persona onGenerar() :String generar() :String update(T) actualizar() render() Administrador o Empleado (from Vista de Casos de Uso) 7.2.9.4 CASO DE USO: IMPRIMIR FACTURA 127 sd Imprimir Factura factura::ListarFacturasPagadas factura::ListarFacturaPagada JasperReports::JasperReports Persona onImprimir() :String exportReportToPdfStream() render (factura PDF) (from Vista de Casos de Uso) 7.2.9.5 CASO DE USO: LISTAR FACTURAS GENERADAS sd Listar Facturas Generadas factura::ListarFacturasPagadas factura::ListarFacturaPagada jpa::JPAFacturaDAO entidades::Fact... Persona getListaFacturasPagadas() :List<Factura> alt es Empleado [Rol = Empleado] getFacturasPagadasByEmpleado(Usuario) :List<Factura> leer() alt es Administrador [Rol = Administrador] getFacturasGeneradas() :List<Factura> leer() render() (from Vista de Casos de Uso) 7.2.9.6 CASO DE USO: LISTAR FACTURAS PENDIENTES 128 sd Listar Facturas Pendientes factura::ListarFacturasPendientes factura::ListarFacturaPendiente jpa::JPAFacturaDAO entidades::Fact... Persona getListaFacturas() :List<Factura> alt es Empleado [Rol = Empleado] listaFacturas= getFacturasPendientesByAgencia(Agencia, boolean) :List<Factura> Administrador o Empleado leer() alt es Administrador [Rol = Administrador] listaFacturas= getFacturasPendientes(true) :List<Factura> leer() render() (from Vista de Casos de Uso) 7.2.10 PAQUETE: LOGIN (FROM BEANS) 7.2.10.1 CASO DE USO: LOGINUSUARIO sd loginUsuario login::loginUsua... menu::menuAdmin menu::menuEmpleado login::LoginUsuario jpa::JPAUsuarioDAO entidades::Usua... Persona procesar() :String find(String[], String[], String, int, int) :List<T> leer() getRol() :Rol alt Rol render() [Rol = empleado] [Rol = administrador] render() (from Vista de Casos de Uso) 7.2.10.2 CASO DE USO: LOGOUT 129 sd logOut login::loginUsua... menu::menuEmpleado menu::menuAdmin login::LogoutUsuario Persona alt salir logout() :String [administrador] salir() [empleado] salir() salir() (from Vista de Casos de Uso) 7.2.11 PAQUETE: MARCA 7.2.11.1 CASO DE USO: ALTA MARCA sd Alta Marca marca::listarMarca marca::ListarMa... marca::AltaMarca jpa::JPAMarcaDAO entidades::Marca Administrador onAlta() alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.11.2 CASO DE USO: BAJA MARCA 130 sd Baj a Marca marca::listarMarca marca::ListarMa... marca::BajaMarca jpa::JPAMarcaDAO entidades::Marca Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.11.3 CASO DE USO: CREAR MARCA sd Crear Marca marca::listarMarca marca::ListarMa... marca::crearMar... marca::CrearMa... jpa::JPAMarcaDAO entidades::Marca Administrador onCrear() :String crear() :String render() alt accion crear() :String [guardar] create(T) crear() render() [cancelar] cancelar() ListarMarca() render() (from Vista de Casos de Uso) 7.2.11.4 CASO DE USO: LISTAR MARCA 131 sd Listar Marca marca::listarMarca marca::ListarMarca jpa::JPAMarcaDAO entidades::Marca Administrador getLista() :List<Marca> find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.11.5 CASO DE USO: MODIFICAR MARCA sd Modificar Marca marca::listarMarca marca::ListarMa... marca::ModificarMarca jpa::JPAMarcaDAO entidades::Marca Administrador onModificar(RowEditEvent) habilitar edicion() alt acciones guardar(event) modificar() :String [guardar] update(T ) actualizar() render() [cancelar] cancelar() deshabilitar edicion() (from Vista de Casos de Uso) 7.2.12 PAQUETE: MEDIO PAGO 7.2.12.1 CASO DE USO: ALTA MEDIO PAGO 132 sd Alta Medio Pago medioPago::listarMedioPago medioDePago::ListarMedioPago medioDePago::AltaMedioPago jpa::JPAMedioPagoDAO entidades::MedioDePago Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.12.2 CASO DE USO: BAJA MEDIO PAGO sd Baj a Medio Pago medioPago::listarMedioPago medioDePago::ListarMedioPago medioDePago::BajaMedioPago jpa::JPAMedioPagoDAO entidades::MedioDePago Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.12.3 CASO DE USO: CREAR MEDIO PAGO sd Crear Medio Pago medioPago::listarMedioPago medioDePago::ListarMedioPagomedioPago::crearMedioPago medioDePago::CrearMedioPago jpa::JPAMedioPagoDAO entidades::MedioDePago Administrador onCrear() :String CrearMedioPago() render() alt accion crear() :String [guardar] create(T) crear() render() [cancelar] cancelar() ListarMedioPago() render() (from Vista de Casos de Uso) 133 7.2.12.4 CASO DE USO: LISTAR MEDIO PAGO sd Listar Medio Pago medioPago::listarMedioPago medioDePago::ListarMedioPago jpa::JPAMedioPagoDAO entidades::MedioDePago Administrador getLista() :List<MedioDePago> lista= find(String[], String[], String, int, int) : List<T> leer() render() (from Vista de Casos de Uso) 7.2.12.5 CASO DE USO: MODIFICAR MEDIO PAGO sd Modificar Medio Pago medioPago::listarMedioPago medioDePago::ListarMedioPago medioDePago::ModificarMedioPago jpa::JPAMedioPagoDAO entidades::MedioDePago Administrador onModificar(RowEditEvent) habilitar edicion() alt acciones guardar(event) modificar() :String [guardar] update(T) actualizar() render() [cancelar] cancelar() deshabilitar edicion() (from Vista de Casos de Uso) 7.2.13 PAQUETE: PRODUCTO 7.2.13.1 CASO DE USO: ALTA PRODUCTO 134 sd Alta Producto producto::listarProducto producto::ListarProducto producto::AltaProducto jpa::JPAProductoDAO entidades::Producto Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.13.2 CASO DE USO: BAJA PRODUCTO sd Baj a Producto producto::listarProducto producto::ListarProducto producto::BajaProducto jpa::JPAProductoDAO entidades::Producto Administrador onBaja() :String baja() update(T ) actualizar() render() (from Vista de Casos de Uso) 7.2.13.3 CASO DE USO: CREAR PRODUCTO sd Crear Producto producto::listarProducto producto::crearProducto producto::ListarProducto producto::CrearProducto jpa::JPAProductoDAO jpa::JPACategoriaDAO jpa::JPAMarcaDAO entidades::Producto entidades::Marca Administrador onCrear() :String CrearProducto() find(String[], String[], String, int, int) :List<T> listar() find(String[], String[], String, int, int) :List<T> listar() render() crear() :String alt acciones create(T) [guardar] crear() render() cancelar() render() [cancelar] (from Vista de Casos de Uso) 135 entidades::Categoria 7.2.13.4 CASO DE USO: LISTAR PRODUCTO sd Listar Producto producto::listarProducto producto::ListarProducto jpa::JPAProductoDAO entidades::Producto Administrador ListarProducto() find(String[], String[], String, int, int) :List<T> listar() render() (from Vista de Casos de Uso) 7.2.13.5 CASO DE USO: MODIFICAR PRODUCTO sd Modificar Producto producto::listarProducto producto::ListarProducto producto::ModificarProducto jpa::JPAProductoDAO jpa::JPACategoriaDAO jpa::JPAMarcaDAO entidades::Producto entidades::Marca Administrador onModificar(RowEditEvent) find(String[], String[], String, int, int) :List<T > listar() find(String[], String[], String, int, int) :List<T> listar() habilitarEdicion() alt acciones [guardar] guardar() modificar() :String update(T) render() [cancelar] update() cancelar() deshabilitaEdicion() (from Vista de Casos de Uso) 7.2.14 PAQUETE: ROL 7.2.14.1 CASO DE USO: ALTA ROL 136 entidades::Categoria sd Alta Rol rol::listarRol rol::ListarRol rol::AltaRol jpa::JPARolDAO entidades::Rol Administrador onAlta() :String alta() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.14.2 CASO DE USO: BAJA ROL sd Baj a Rol rol::listarRol rol::ListarRol rol::BajaRol jpa::JPARolDAO entidades::Rol Administrador onBaja() :String baja() :String update(T ) actualizar() render() (from Vista de Casos de Uso) 7.2.14.3 CASO DE USO: CREAR ROL 137 sd Crear Rol rol::listarRol rol::ListarRol rol::crearRol rol::CrearRol jpa::JPARolDAO entidades::Rol Administrador onCrear() :String CrearRol() render() alt accion [guardar] crear() :String create(T) crear() render() [cancelar] cancelar() cancelar() render() (from Vista de Casos de Uso) 7.2.14.4 CASO DE USO: LISTAR ROL sd Listar Rol rol::listarRol rol::ListarRol jpa::JPARolDAO entidades::Rol Administrador getLista() :List<Rol> find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.14.5 CASO DE USO: MODIFICAR ROL 138 sd Modificar Rol rol::listarRol rol::ListarRol rol::ModificarRol jpa::JPARolDAO entidades::Rol Administrador onModificar(RowEditEvent) habilitar edicion() alt acciones [guardar] guardar(event) modificar() :String update(T) actualizar() render() [cancelar] cancelar() deshabilitar edicion() (from Vista de Casos de Uso) 7.2.15 PAQUETE: USUARIO 7.2.15.1 CASO DE USO: ALTA USUARIO sd Alta Usuario usuario::listaUsuario usuario::ListarUsu... usuario::AltaUsuario jpa::JPAUsuarioDAO entidades::Usuario Administrador onAlta() :String alta() :String update(T ) actualizar() render() (from Vista de Casos de Uso) 7.2.15.2 CASO DE USO: BAJA USUARIO 139 sd Baj a Usuario usuario::listaUsuario usuario::ListarUsu... usuario::BajaUsua... jpa::JPAUsuarioDAO entidades::Usuario Administrador onBaja() :String baja() :String update(T) actualizar() render() (from Vista de Casos de Uso) 7.2.15.3 CASO DE USO: CREAR USUARIO sd Crear Usuario usuario::listaUsuario usuario::crearUsua... usuario::ListarUsuario usuario::CrearUsu... jpa::JPARolDAO jpa::JPAUsuarioDAO entidades::Usuario Administrador onCrear() :String CrearUsuario() roles= find(String[], String[], String, int, int) :Li st<T> leer() render() alt acciones crear() :String create(T) [guardar] crear() render() [cancelar] cancelar() ListarUsuario() render() (from Vi sta de Casos de Uso) 7.2.15.4 CASO DE USO: LISTAR USUARIO 140 enti dades::Rol sd Listar Usuario usuario::listaUsuario usuario::ListarUsu... jpa::JPAUsuarioDAO entidades::Usuario Administrador getLista() :List<Usuario> lista= find(String[], String[], String, int, int) :List<T> leer() render() (from Vista de Casos de Uso) 7.2.15.5 CASO DE USO: MODIFICAR USUARIO sd Modificar Usuario usuario::listaUsuario usuario::ListarUsu... usuario::ModificarUsuario jpa::JPARolDAO jpa::JPAUsuarioDAO entidades::Rol entidades::Usuario Administrador onModificar(RowEditEvent) roles= find(String[], String[], String, int, int) : List<T> leer() habilita edicion() alt accion guardadr() modificar() :String [guardar] update(T) actualizar() render() [cancelar] cancelar() deshabilita edicion() (from Vista de Casos de Uso) 7.2.16 PAQUETE: REPORTES 7.2.16.1 CASO DE USO: REPORTE CIERRE CAJA 141 sd Reporte Cierre Caj a reportes::cierreDeCaja reportes::CierreDeCaja JasperReports::JasperReports jpa::JPAEmpleadoAgenciaDAO entidades::EmpleadoAgencia Administrador generarPDF(ActionEvent) read(ID) :T leer() exportReportToPdfStream() render() (from Vista de Casos de Uso) 7.2.16.2 CASO DE USO: REPORTE CONSOLIDADO VENTAS sd Reporte Consolidado Ventas reportes::consolidadoVentas reportes::ConsolidadoVentas JasperReports::JasperReports jpa::JPAEmpresaDAO entidades::Empresa Administrador solicita reporte() find(String[], String[], String, int, int) :List<T> leer() exportReportToPdfStream() render() (from Vista de Casos de Uso) 7.2.16.3 CASO DE USO: REPORTE STOCK PRODUCTOS sd Reporte Stock Productos reportes::stockProductos reportes::StockProductos JasperReports::JasperReports jpa::JPAAgenciaDAO jpa::JPAEmpresaDAO entidades::Agencia entidades::Empresa jpa::JPACategoriaDAO entidades::Categoria Administrador solicitar reporte() find(String[], String[], String, int, int) :List<T> leer() find(String[], String[], String, int, int) :List<T> leer() find(String[], String[], String, int, int) :List<T> leer() generar() exportReportToPdfStream() render() (from Vista de Casos de Uso) 142 7.2.17 PAQUETE: COMPRAS 7.2.17.1 CASO DE USO: AGREGAR PRODUCTO sd Agregar Producto Vistas Aplicacion compras::ComprasActivity Vistas Aplicacion Vistas Aplicacion compras::AddProductoActi vity rest::BodegaDetalleREST rest::FacturaDetalleREST rest::DescuentoREST zxing::CaptureActivity rest::BodegaDetalleResource rest::DescuentoResource rest::FacturaDetalleResource jpa::JPABodegaDetall eDAO entidades::BodegaDetall e jpa::JPAProductoDAO entidades::Producto jpa::JPADescuentoProductoDAO jpa::JPADescuentoDAO Android::ComprasActi vity Android::AddProductoActivity Android::CaptureActivity Cliente agregarProducto() btnAddProducto_onClick() abri rCapturadorQR() mostrar() capturaCodigo() decodificar QR y transformar a numero() onCreate(Bundle) getBodegaDetalleById(int) :BodegaDetall e getBodegaDetall eById(int) :Response read(ID) :T leer() getDescuentoByProducto(int) :Descuento getDescuentoByProducto(i nt) :Response read(ID) :T leer() getDescuentoId(Producto, boolean) :int getValorDescuentoByFecha(int, boolean) :Descuento getDescuentoByProducto(int) :Descuento setTotales(BodegaDetalle, Descuento, int) :FacturaDetalle mostrarProducto() modifica cantidad solicitada() calcularTotales() setTotales(BodegaDetalle, Descuento, int) :FacturaDetalle anadirProducto() existeProductoByFacturaDetalle(int, int) :boolean alt no existe producto en factura detalle anadirProducto(int, int, int, int, int, int) :i nt [canti dad < stock] aniadirProducto(int, int, int, int, int, int) :Response [canti dad > stock] cancelar() alt existe producto (duplicado) [existe producto] cancelar() (from Vista de Casos de Uso) 7.2.17.2 CASO DE USO: CONFIRMAR CARRO COMPRAS 143 sd Confirmar Carro Compras Vistas Aplicacion Android::ConfirmarComprasActivity compras::ConfirmarComprasActivity rest::FacturaREST rest::MedioPagoREST rest::FacturaResource rest::MedioDePagoResource Cliente confirmar() onCreate(Bundle) listMedioPago() :Map<Integer, String> listAgencias() :Response selecciona medio de pago() confirmar() confirmar() ConfirmaCompra(int, int) :int ConfirmarTotal(int, double) :Response alt totales cambiados [totalFacturaActual == totalFactura] ConfirmaCompra(int, int) :int ConfirmarCompra(int, int) :Response notifica exito() [totalFacturaActual != totalFactura] notifica valores cambiados() (from Vista de Casos de Uso) 7.2.17.3 CASO DE USO: EDITAR PRODUCTO sd Editar Producto Vistas Aplicacion Android::ComprasActivity Vistas Aplicacion Android::EditProductoActivity compras::ComprasActivity compras::EditProductoActivity rest::FacturaDetalleREST rest::BodegaDetalleREST rest::DescuentoREST rest::FacturaDetalleResource rest::BodegaDetalleResource rest::DescuentoResource Cliente selecciona producto() onItemClickListener() mostrar() onCreate(Bundle) getFacturaDetalleById(int) :FacturaDetalle getFacturaDetalleById(int) :Response getBodegaDetalleById(int) :BodegaDetal le getBodegaDetalleById(int) :Response getDescuentoByProducto(int) :Descuento getDescuentoByProducto(int) :Response alt accion guardar() actualizar() [guardar] actualizarProducto(i nt, int, int) :int actualizarProducto(int, int, int) :Response [el iminar] eliminar() eliminar() eliminarProducto(int) :int eliminarPoducto(int) :Response (from Vi sta de Casos de Uso) 7.2.17.4 CASO DE USO: LISTAR CARROS COMPRAS 144 sd Listar Carros Compras Vistas Aplicacion Android::CarrosComprasActivity compras::CarrosComprasActivity compras::AdaptadorListaCarros rest::FacturaREST rest::FacturaResource Cliente listarCarros() btnCarros_onClick() getCarrosCompra(int, int) :List<Factura> getCarrosCompra(int, int) :List<Factura> getView(int, View, ViewGroup) :View presenta carros compras() (from Vista de Casos de Uso) 7.2.17.5 CASO DE USO: LISTAR PRODUCTO CARRO COMPRA sd Listar Producto Carro Compra Vistas Aplicacion Android::ComprasActivity compras::ComprasActivity compras::AdaptadorListaProductos rest::FacturaDetalleREST rest::FacturaDetalleResource Cliente listar() onCreate(Bundle) getCarroActual(int) :List<FacturaDetalle> getCarroCompraActual(int) :List<FacturaDetalle> getView(int, View, ViewGroup) :View mostrar productos() (from Vista de Casos de Uso) 7.2.18 PAQUETE: LOGIN (FROM ANDROID) 7.2.18.1 CASO DE USO: ENTRAR APLICACION MOVIL 145 sd Entrar Aplicacion Mov il Vistas Aplicacion Android::login login::LoginActivity rest::AgenciaRE... rest::UsuarioREST rest::AgenciaResource rest::AutenticacionResource Cliente abrir aplicacion() onCreate(Bundle) listAgencias() :Map<Integer, String> listAgencias() :Response ingresar() login() login(String, String) :int loginXML(String, String) :Response alt autenticacion [usuario correcto] ingresa con exito() [usuario incorrecto] error en ingreso() (from Vista de Casos de Uso) 7.2.18.2 CASO DE USO: REGISTRO USUARIO sd Registro Usuario Vistas Apl icacion Android::login Vi stas Aplicaci on Android::NuevoUsuarioActivity l ogin::LoginActivity logi n::NuevoUsuarioActivity rest::UsuarioREST rest::AutenticacionResource Cliente nuevoUsuari o() nuevoUsuario() onCreate(Bundle) mostrar() guardar() nuevoUsuario() create(String[], String[]) :boolean createUsuarioXML(Usuario) :Response (from Vista de Casos de Uso) 7.2.18.3 CASO DE USO: SALIR APLICATIVO MOVIL 146 sd Salir Aplicativ o Mov il Vistas Aplicacion Android::login login::LogoutActivity Cliente aceptar() mostrar() (from Vista de Casos de Uso) 7.3 DISEÑO DE CLASES A continuación se presentan los diagramas Parciales de Clases para cada Caso de Uso: 7.3.1 CASO DE USO: ALTA FACTURA 147 class Alta Factura Serializable Serializable factura::ListarFacturaPendiente - altaFacturaBEAN: AltaFactura selectedFactura: Factura + + ListarFacturaPendiente() onAlta() : String factura::AltaFactura -altaFacturaBEAN factura::ListarFacturasPendientes + + + + facturaDAO: FacturaDAO factura: Factura + + AltaFactura() alta() : String JPAGenericDAO j pa::JPAFacturaDAO listarFacturasPendientes() : void bajaFactura() : void altaFactura() : void generarFactura() : void Serializable entidades::Factura - - id: int fecha: Date eliminado: boolean subtotal: double iva: double descuento: double total: double pagado: boolean pendiente: boolean cliente: Usuario empleadoAgencia: EmpleadoAgencia medioDePago: MedioDePago agencia: Agencia facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} + JPAFacturaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 148 7.3.2 CASO DE USO: BAJA FACTURA class Baj a Factura Serializable Serializable factura::Baj aFactura factura::ListarFacturaPendiente - bajaFacturaBEAN: BajaFactura selectedFacturas: Factura ([]) + + ListarFacturaPendiente() onBaja() : String + + factura::ListarFacturasPendientes + + + + listarFacturasPendientes() : void bajaFactura() : void altaFactura() : void generarFactura() : void Serializable entidades::Factura - -bajaFacturaBEAN - id: int fecha: Date eliminado: boolean subtotal: double iva: double descuento: double total: double pagado: boolean pendiente: boolean cliente: Usuario empleadoAgencia: EmpleadoAgencia medioDePago: MedioDePago agencia: Agencia facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} facturaDAO: FacturaDAO factura: Factura BajaFactura() baja() : String JPAGenericDAO j pa::JPAFacturaDAO + JPAFacturaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection 149 7.3.3 CASO DE USO: GENERAR FACTURA class Generar Factura Serializable Serializable factura::GenerarFactura factura::ListarFacturaPendiente - empleadoDAO: UsuarioDAO empleadoAgenciaDAO: EmpleadoAgenciaDAO generarFacturaBEAN: GenerarFactura empleado: Usuario selectedFacturas: Factura ([]) + + ListarFacturaPendiente() onGenerar() : String -generarFacturaBEAN - facturaDAO: FacturaDAO factura: Factura empleadoAgencia: EmpleadoAgencia + + GenerarFactura() generar() : String JPAGenericDAO j pa::JPAFacturaDAO factura::ListarFacturasPendientes + + + + + listarFacturasPendientes() : void bajaFactura() : void altaFactura() : void generarFactura() : void JPAFacturaDAO() JPAGenericDAO j pa::JPAEmpleadoAgenciaDAO JPAGenericDAO + + JPAEmpleadoAgenciaDAO() getAgenciaByEmpleado(Usuario) : EmpleadoAgencia j pa::JPAUsuarioDAO + + JPAUsuarioDAO() getEmpleado(Rol, boolean) : List<Usuario> Serializable Serializable entidades::EmpleadoAgencia - Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} +empleado -cliente id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} -empleadoAgencia entidades::Factura - id: int fecha: Date eliminado: boolean subtotal: double iva: double descuento: double total: double pagado: boolean pendiente: boolean cliente: Usuario empleadoAgencia: EmpleadoAgencia medioDePago: MedioDePago agencia: Agencia facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} 150 7.3.4 CASO DE USO: IMPRIMIR FACTURA class Imprimir Factura factura::ListarFacturaPagada - reporteMenuBEAN: ReporteMenu selectedFactura: Factura + + ListarFacturaPagada() onImprimir() : String factura:: ImprimirFactura JasperReports::JasperReports + exportReportToPdfStream() : void factura::ListarFacturasPagadas + + ListarFacturasPagadas() : void imprimirFactura() : void 151 7.3.5 CASO DE USO: LISTAR FACTURAS GENERADAS class Listar Facturas Generadas Serializable entidades::Agencia Serializable factura::ListarFacturaPendiente - facturaDAO: FacturaDAO empleadoDAO: UsuarioDAO empleadoAgenciaDAO: EmpleadoAgenciaDAO empleado: Usuario listaFacturas: List<Factura> listaFacturaDetalle: List<FacturaDetalle> + + ListarFacturaPendiente() getListaFacturas() : List<Factura> sesion - serialVersionUID: long = 1... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> JPAGenericDAO j pa::JPAFacturaDAO factura::ListarFacturasPendientes + + + + + + listarFacturasPendientes() : void bajaFactura() : void altaFactura() : void generarFactura() : void JPAGenericDAO JPAGenericDAO j pa::JPAEmpleadoAgenciaDAO j pa::JPAUsuarioDAO + + JPAUsuarioDAO() getEmpleado(Rol, boolean) : List<Usuario> JPAFacturaDAO() getFacturasPendientesByAgencia(Agencia, boolean) : List<Factura> + + JPAEmpleadoAgenciaDAO() getAgenciaByEmpleado(Usuario) : EmpleadoAgencia Serializable entidades::Factura Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} - id: int - eliminado: boolean - empleado: Usuario - agencia: Agencia - factura: Set<Factura> - serialVersionUID: long = 1L {readOnly} +empleado -empleadoAgencia -cliente Serializable entidades::EmpleadoAgencia id: int fecha: Date eliminado: boolean subtotal: double iva: double descuento: double total: double pagado: boolean pendiente: boolean cliente: Usuario empleadoAgencia: EmpleadoAgencia medioDePago: MedioDePago agencia: Agencia facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} 152 7.3.6 CASO DE USO: LISTAR FACTURAS PAGADAS class Listar Facturas Pagadas factura::ListarFacturaPagada - listaFacturasPagadas: List<Factura> listaFacturaDetalle: List<FacturaDetalle> facturaDAO: FacturaDAO facturaDetalleDAO: FacturaDetalleDAO + + ListarFacturaPagada() getListaFacturasPagadas() : List<Factura> JPAGenericDAO j pa::JPAFacturaDAO + + + factura::ListarFacturasPagadas + + JPAFacturaDAO() getFacturasGeneradasByEmpleado(Usuario) : List<Factura> getFacturasGeneradas() : List<Factura> ListarFacturasPagadas() : void imprimirFactura() : void JPAGenericDAO j pa::JPAFacturaDetalleDAO + + JPAFacturaDetalleDAO() getFacturaDetalleByFactura(Factura, boolean) : List<FacturaDetalle> Serializable entidades::Factura Serializable entidades::FacturaDetalle - id: int cantidad: int precio: double subtotal: double iva: double descuento: double total: double eliminado: boolean factura: Factura bodegaDetalle: BodegaDetalle serialVersionUID: long = 1L {readOnly} -factura - id: int fecha: Date eliminado: boolean subtotal: double iva: double descuento: double total: double pagado: boolean pendiente: boolean cliente: Usuario empleadoAgencia: EmpleadoAgencia medioDePago: MedioDePago agencia: Agencia facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} 153 7.3.7 CASO DE USO: ALTA AGENCIA class Alta Agencia Serializable Serializable agencia::ListarAgencia agencia::AltaAgencia - altaAgenciaBEAN: AltaAgencia selectedAgencias: Agencia ([]) - agenciaDAO: AgenciaDAO agencia: Agencia + + ListarAgencia() onAlta() : String + + AltaAgencia() alta() : String JPAGenericDAO + agencia::ListarAgencia j pa::JPAAgenciaDAO altaAgencia() : void + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Agencia - serialVersionUID: long = 1... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> 154 7.3.8 CASO DE USO: BAJA AGENCIA class Baj a Agencia Serializable Serializable agencia::ListarAgencia agencia::Baj aAgencia - bajaAgenciaBEAN: BajaAgencia selectedAgencias: Agencia ([]) - agenciaDAO: AgenciaDAO agencia: Agencia + + ListarAgencia() onBaja() : String + + BajaAgencia() baja() : String JPAGenericDAO j pa::JPAAgenciaDAO agencia::ListarAgencia + bajaAgencia() : void Serializable entidades::Agencia - + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection serialVersionUID: long = 1L... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> 155 7.3.9 CASO DE USO: CREAR AGENCIA class Crear Agencia Serializable agencia::CrearAgencia agencia::CrearAgencia + crearAgencia() : void - agenciaDAO: AgenciaDAO empresaDAO: EmpresaDAO agencia: Agencia = new Agencia() empresas: SelectItem ([]) empresa: String serialVersionUID: long = 1L {readOnly} + + CrearAgencia() crear() : String JPAGenericDAO JPAGenericDAO j pa::JPAEmpresaDAO j pa::JPAAgenciaDAO + getIvaByEmpresa(int, boolean) : double ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable Serializable entidades::Agencia entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> -empresa - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<EmpleadoAgencia> factura: Set<Factura> 156 7.3.10 CASO DE USO: LISTAR AGENCIA class Listar Agencia Serializable JPAGenericDAO agencia::ListarAgencia - lista: List<Agencia> empresas: SelectItem ([]) selectedAgencias: Agencia ([]) + + + ListarAgencia() getLista() : List<Agencia> getEmpresas() : SelectItem[] j pa::JPAAgenciaDAO + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection agencia::ListarAgencia + Serializable listarAgencia() : void entidades::Agencia - serialVersionUID: long = 1L {... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<Em... factura: Set<Factura> 157 7.3.11 CASO DE USO: MODIFICAR AGENCIA class Modificar Agencia Serializable Serializable agencia::ModificarAgencia agencia::ListarAgencia agencia::ListarAgencia + modificarAgencia() : void - modificarAgenciaBEAN: ModificarAgencia empresas: SelectItem ([]) empresa: String - serialVersionUID: long = 1L {readOnly} agenciaDAO: AgenciaDAO agencia: Agencia + + ListarAgencia() onModificar(RowEditEvent) : void + + ModificarAgencia() modificar() : String JPAGenericDAO JPAGenericDAO j pa::JPAAgenciaDAO j pa::JPAEmpresaDAO + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T ) : void + delete(T ) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection + getIvaByEmpresa(int, boolean) : double ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T ) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> entidades::Agencia -empresa - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<EmpleadoAgencia> factura: Set<Factura> 158 7.3.12 CASO DE USO: ALTA BODEGA class Alta Bodega Serializable Serializable bodega::ListarBodega - altaBodegaBEAN: AltaBodega selectedBodegas: Bodega ([]) + + + ListarBodega() getLista() : List<Bodega> onAlta() : String bodega::AltaBodega -altaBodegaBEAN + + bodegaDAO: BodegaDAO bodega: Bodega AltaBodega() alta() : String JPAGenericDAO j pa::JPABodegaDAO bodega::ListarBodega + altaBodega() : void Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 159 7.3.13 CASO DE USO: BAJA BODEGA class Baj a Bodega Serializable Serializable bodega::ListarBodega bodega::Baj aBodega - serialVersionUID: long = 1L {readOnly} bajaBodegaBEAN: BajaBodega selectedBodegas: Bodega ([]) + + ListarBodega() onBaja() : String -bajaBodegaBEAN + + bodegaDAO: BodegaDAO bodega: Bodega BajaBodega() baja() : String JPAGenericDAO j pa::JPABodegaDAO bodega::ListarBodega + bajaBodega() : void Serializable entidades::Bodega - + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> 160 7.3.14 CASO DE USO: CREAR BODEGA class Crear Bodega Serializable bodega::CrearBodega - bodegaDAO: BodegaDAO agenciaDAO: AgenciaDAO bodega: Bodega = new Bodega() agencias: SelectItem ([]) agencia: String + + CrearBodega() crear() : String bodega::CrearBodega + crearBodega() : void JPAGenericDAO JPAGenericDAO j pa::JPABodegaDAO j pa::JPAAgenciaDAO + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> entidades::Agencia -agencia - serialVersionUID: long = 1... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> 161 7.3.15 CASO DE USO: LISTAR BODEGA class Listar Bodega Serializable bodega::ListarBodega - bodegaDAO: BodegaDAO lista: List<Bodega> + + ListarBodega() getLista() : List<Bodega> JPAGenericDAO j pa::JPABodegaDAO + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection bodega::ListarBodega + listarBodega() : void Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> 162 7.3.16 CASO DE USO: MODIFICAR BODEGA class Modificar Bodega Serializable Serializable bodega::ListarBodega - agenciaDAO: AgenciaDAO modificarBodegaBEAN: ModificarBodega agencias: SelectItem ([]) agencia: String selectedBodegas: Bodega ([]) + + ListarBodega() onModificar(RowEditEvent) : void bodega::ModificarBodega - serialVersionUID: long = 1L {readOnly} bodegaDAO: BodegaDAO bodega: Bodega + modificar() : String JPAGenericDAO bodega::ListarBodega + j pa::JPABodegaDAO modificarBodega() : void + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection JPAGenericDAO j pa::JPAAgenciaDAO + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Agencia - serialVersionUID: long = 1... -agencia id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> 163 7.3.17 CASO DE USO: ALTA BODEGA DETALLE class Alta Bodega Detalle Serializable Serializable bodegaDetalle::AltaBodegaDetalle bodegaDetalle::ListarBodegaDetalle - altaBodegaDetalleBEAN: AltaBodegaDetalle + + ListarBodegaDetalle() onAlta() : String -altaBodegaDetalleBEAN - bodegaDetalleDAO: BodegaDetalleDAO bodegaDetalle: BodegaDetalle + + AltaBodegaDetalle() alta() : String JPAGenericDAO j pa::JPABodegaDetalleDAO bodegaDetalle:: listarBodegaDetalle + altaBodegaDetalle() : void Serializable entidades::BodegaDetalle - ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection id: int cantidad: int precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} 164 7.3.18 CASO DE USO: BAJA BODEGA DETALLE class Baj a Bodega Detalle Serializable Serializable bodegaDetalle::Baj aBodegaDetalle bodegaDetalle::ListarBodegaDetalle - bajaBodegaDetalleBEAN: BajaBodegaDetalle selectedBodegaDetalle: BodegaDetalle ([]) + + ListarBodegaDetalle() onBaja() : String -bajaBodegaDetalleBEAN - bodegaDetalleDAO: BodegaDetalleDAO bodegaDetalle: BodegaDetalle + + BajaBodegaDetalle() baja() : String JPAGenericDAO bodegaDetalle::listarBodegaDetalle j pa::JPABodegaDetalleDAO + bajaBodegaDetalle() : void Serializable entidades::BodegaDetalle - id: int cantidad: int precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 165 7.3.19 CASO DE USO: CREAR BODEGA DETALLE class Crear Bodega Detalle Serializable bodegaDetalle::CrearBodegaDetalle bodegaDetalle:: crearBodegaDetalle + - bodegaDetalleDAO: BodegaDetalleDAO bodegaDAO: BodegaDAO productoDAO: ProductoDAO bodegaDetalle: BodegaDetalle = new BodegaDetalle() bodegas: SelectItem ([]) productos: SelectItem ([]) + + CrearBodegaDetalle() crear() : String crearBodegaDetalle() : void JPAGenericDAO JPAGenericDAO JPAGenericDAO j pa::JPABodegaDAO j pa::JPABodegaDetalleDAO j pa::JPAProductoDAO + JPABodegaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String -bodega direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> - Serializable Serializable entidades::BodegaDetalle id: int cantidad: int +producto precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} entidades::Producto - id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 166 7.3.20 CASO DE USO: LISTAR BODEGA DETALLE class Listar Bodega Detalle Serializable bodegaDetalle::ListarBodegaDetalle - bodegaDetalleDAO: BodegaDetalleDAO lista: List<BodegaDetalle> + + ListarBodegaDetalle() getLista() : List<BodegaDetalle> JPAGenericDAO j pa::JPABodegaDetalleDAO bodegaDetalle::listarBodegaDetalle + listarBodegaDetalle() : void Serializable entidades::BodegaDetalle - + JPABodegaDetalleDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection id: int cantidad: int precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} 167 7.3.21 CASO DE USO: MODIFICAR BODEGA DETALLE class Modificar Bodega Detalle Serializable bodegaDetalle::ListarBodegaDetalle Serializable -modificarBodegaDetalleBEAN - modificarBodegaDetalleBEAN: ModificarBodegaDetalle selectedBodegaDetalle: BodegaDetalle ([]) + + ListarBodegaDetalle() onModificar(RowEditEvent) : void bodegaDetalle::ModificarBodegaDetalle - bodegaDetalleDAO: BodegaDetalleDAO bodegaDetalle: BodegaDetalle + + ModificarBodegaDetalle() modificar() : String bodegaDetalle::listarBodegaDetalle + modificarBodegaDetalle() : void JPAGenericDAO + JPABodegaDAO() Serializable entidades::Bodega - serialVersionUID: long = 1L {readOnly} id: int nombre: String -bodega direccion: String telefono: String eliminado: boolean agencia: Agencia bodegaDetalle: Set<BodegaDetalle> - JPAGenericDAO JPAGenericDAO j pa::JPABodegaDAO j pa::JPABodegaDetalleDAO + JPABodegaDetalleDAO() j pa::JPAProductoDAO + JPAProductoDAO() Serializable Serializable entidades::BodegaDetalle id: int cantidad: int +producto precio: double eliminado: boolean bodega: Bodega producto: Producto facturaDetalle: Set<FacturaDetalle> serialVersionUID: long = 1L {readOnly} entidades::Producto - id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 168 7.3.22 CASO DE USO: ALTA CATEGORIA class Alta Categoria Serializable Serializable categoria::ListarCategoria - altaCategoriaBEAN: AltaCategoria selectedCategorias: Categoria ([]) + + ListarCategoria() onAlta() : String categoria::AltaCategoria -altaCategoriaBEAN + + categoriaDAO: CategoriaDAO categoria: Categoria AltaCategoria() alta() : String JPAGenericDAO j pa::JPACategoriaDAO categoria::listarCategoria + altaCategoria() : void Serializable entidades::Categoria - + JPACategoriaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 169 7.3.23 CASO DE USO: BAJA CATEGORIA class Baj a Categoria Serializable Serializable categoria::ListarCategoria - bajaCategoriaBEAN: BajaCategoria selectedCategorias: Categoria ([]) + + ListarCategoria() onBaja() : String categoria::Baj aCategoria -bajaCategoriaBEAN + + categoriaDAO: CategoriaDAO categoria: Categoria BajaCategoria() baja() : String JPAGenericDAO categoria::listarCategoria + bajaCategoria() : void Serializable entidades::Categoria - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} j pa::JPACategoriaDAO + JPACategoriaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 170 7.3.24 CASO DE USO: CREAR CATEGORIA class Crear Categoria Serializable categoria::CrearCategoria - categoriaDAO: CategoriaDAO categoria: Categoria = new Categoria() + + CrearCategoria() crear() : String JPAGenericDAO j pa::JPACategoriaDAO categoria::crearCategoria + + JPACategoriaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection crearCategoria() : void Serializable entidades::Categoria - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 171 7.3.25 CASO DE USO: LISTAR CATEGORIA class Listar Categoria Serializable categoria::ListarCategoria - categoriaDAO: CategoriaDAO lista: List<Categoria> + + ListarCategoria() getLista() : List<Categoria> categoria::listarCategoria + listarCategoria() : void JPAGenericDAO j pa::JPACategoriaDAO + JPACategoriaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Categoria - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 172 7.3.26 CASO DE USO: MODIFICAR CATEGORIA class Modificar Categoria Serializable Serializable categoria::ModificarCategoria categoria::ListarCategoria - modificarCategoriaBEAN: ModificarCategoria selectedCategorias: Categoria ([]) + + ListarCategoria() onModificar(RowEditEvent) : void categoria::listarCategoria + + + categoriaDAO: CategoriaDAO categoria: Categoria ModificarCategoria() modificar() : String JPAGenericDAO modificarCategoria() : void Serializable entidades::Categoria - -modificarCategoriaBEAN - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} j pa::JPACategoriaDAO + JPACategoriaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 173 7.3.27 CASO DE USO: ALTA DESCUENTO class Alta Descuento Serializable Serializable descuento::ListarDescuento descuento::AltaDescuento - altaDescuentoBEAN: AltaDescuento selectedDescuentos: Descuento ([]) + + ListarDescuento() onAlta() : String -altaDescuentoBEAN - descuentoDAO: DescuentoDAO descuento: Descuento + + AltaDescuento() alta() : String JPAGenericDAO j pa::JPADescuentoDAO descuento::listarDescuento + listarDescuento() : void Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} + JPADescuentoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 174 7.3.28 CASO DE USO: BAJA DESCUENTO class Baj a Descuento Serializable Serializable descuento::ListarDescuento - bajaDescuentoBEAN: BajaDescuento selectedDescuentos: Descuento ([]) + + ListarDescuento() onBaja() : String descuento::Baj aDescuento -bajaDescuentoBEAN - descuentoDAO: DescuentoDAO descuento: Descuento + + BajaDescuento() baja() : String descuento::listarDescuento + bajaDescuento() : void JPAGenericDAO j pa::JPADescuentoDAO Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} + JPADescuentoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 175 7.3.29 CASO DE USO: CREAR DESCUENTO class Crear Descuento Serializable descuento::CrearDescuento - descuentoDAO: DescuentoDAO descuento: Descuento = new Descuento() + + CrearDescuento() crear() : String JPAGenericDAO j pa::JPADescuentoDAO descuento::crearDescuento + crearDescuento() : void + getValorDescuentoByFecha(int, boolean) : Descuento ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 176 7.3.30 CASO DE USO: LISTAR DESCUENTO class Listar Descuento Serializable descuento::ListarDescuento - descuentoDAO: DescuentoDAO lista: List<Descuento> + + ListarDescuento() getLista() : List<Descuento> JPAGenericDAO j pa::JPADescuentoDAO + JPADescuentoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection descuento::listarDescuento + listarDescuento() : void Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 177 7.3.31 CASO DE USO: MODIFICAR DESCUENTO class Modificar Descuento Serializable Serializable descuento::ListarDescuento descuento::ModificarDescuento - modificarDescuentoBEAN: ModificarDescuento selectedDescuentos: Descuento ([]) + + ListarDescuento() onModificar(RowEditEvent) : void -modificarDescuentoBEAN - descuentoDAO: DescuentoDAO descuento: Descuento + + ModificarDescuento() modificar() : String JPAGenericDAO j pa::JPADescuentoDAO descuento::listarDescuento + modificarDescuento() : void Serializable entidades::Descuento - + JPADescuentoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 178 7.3.32 CASO DE USO: ALTA DESCUENTO PRODUCTO class Alta Descuento Producto Serializable descuentoProducto::ListarDescuentoProducto - altaDescuentoProductoBEAN: AltaDescuentoProducto selectedDescuentoProducto: DescuentoProducto ([]) + + ListarDescuentoProducto() onAlta() : String -altaDescuentoProductoBEAN Serializable descuentoProducto::AltaDescuentoProducto descuentoProducto:: listarDescuentoProducto + altaDescuentoProducto() : void - descuentoProductoDAO: DescuentoProductoDAO descuentoProducto: DescuentoProducto + + AltaDescuentoProducto() alta() : String JPAGenericDAO Serializable j pa::JPADescuentoProductoDAO entidades::DescuentoProducto - id: int eliminado: boolean producto: Producto descuento: Descuento serialVersionUID: long = 1L {readOnly} + getDescuentoId(Producto, boolean) : int ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 179 7.3.33 CASO DE USO: BAJA DESCUENTO PRODUCTO class Baj a Descuento Producto Serializable descuentoProducto::ListarDescuentoProducto - bajaDescuentoProductoBEAN: BajaDescuentoProducto selectedDescuentoProducto: DescuentoProducto ([]) + + ListarDescuentoProducto() onBaja() : String -bajaDescuentoProductoBEAN Serializable descuentoProducto::Baj aDescuentoProducto descuentoProducto:: listarDescuentoProducto + bajaDescuentoProducto() : void - descuentoProductoDAO: DescuentoProductoDAO descuentoProducto: DescuentoProducto + + BajaDescuentoProducto() baja() : String JPAGenericDAO Serializable entidades::DescuentoProducto - id: int eliminado: boolean producto: Producto descuento: Descuento serialVersionUID: long = 1L {readOnly} j pa::JPADescuentoProductoDAO + JPADescuentoProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 180 7.3.34 CASO DE USO: CREAR DESCUENTO PRODUCTO class Crear Descuento Producto Serializable descuentoProducto::CrearDescuentoProducto - descuentoProductoDAO: DescuentoProductoDAO descuentoDAO: DescuentoDAO productoDAO: ProductoDAO descuentos: SelectItem ([]) productos: SelectItem ([]) + + CrearDescuentoProducto() crear() : String JPAGenericDAO j pa::JPAProductoDAO descuentoProducto:: crearDescuentoProducto + crearDescuentoProducto() : void JPAGenericDAO JPAGenericDAO j pa::JPADescuentoDAO + JPADescuentoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T ) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection j pa::JPADescuentoProductoDAO + getDescuentoId(Producto, boolean) : int ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T ) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T ) : void + read(ID) : T + update(T) : void + delete(T ) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection entidades::DescuentoProducto -descuento - id: int eliminado: boolean producto: Producto descuento: Descuento serialVersionUID: long = 1L {readOnly} 181 7.3.35 CASO DE USO: LISTAR DESCUENTO PRODUCTO class Listar Descuento Producto Serializable JPAGenericDAO descuentoProducto::ListarDescuentoProducto - descuentoProductoDAO: DescuentoProductoDAO lista: List<DescuentoProducto> + + ListarDescuentoProducto() getLista() : List<DescuentoProducto> descuentoProducto:: listarDescuentoProducto + j pa::JPADescuentoProductoDAO + JPADescuentoProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection listarDescuentoProducto() : void Serializable entidades::DescuentoProducto - id: int eliminado: boolean producto: Producto descuento: Descuento serialVersionUID: long = 1L {readOnly} 182 7.3.36 CASO DE USO: MODIFICAR DESCUENTO PRODUCTO class Modificar Descuento Producto Serializable descuentoProducto::ListarDescuentoProducto - modificarDescuentoProductoBEAN: ModificarDescuentoProducto descuentoDAO: DescuentoDAO productoDAO: ProductoDAO selectedDescuentoProducto: DescuentoProducto ([]) -modificarDescuentoProductoBEAN descuentos: SelectItem ([]) productos: SelectItem ([]) + + ListarDescuentoProducto() onModificar(RowEditEvent) : void Serializable descuentoProducto::ModificarDescuentoProducto - descuentoProductoDAO: DescuentoProductoDAO descuentoProducto: DescuentoProducto + + ModificarDescuentoProducto() modificar() : String descuentoProducto:: listarDescuentoProducto + modificarDescuentoProducto() : void JPAGenericDAO j pa::JPADescuentoProductoDAO JPAGenericDAO j pa::JPADescuentoDAO JPAGenericDAO + getValorDescuentoByFecha(int, boolean) : Descuento ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection j pa::JPAProductoDAO + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection + getDescuentoId(Producto, boolean) : int ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Producto Serializable entidades::Descuento - id: int nombre: String valor: double fechaInicio: Date fechaFin: Date eliminado: boolean descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} - id: int nombre: String eliminado: boolean +producto marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} - Serializable entidades::DescuentoProducto id: int eliminado: boolean producto: Producto descuento: Descuento serialVersionUID: long = 1L {readOnly} -descuento 183 7.3.37 CASO DE USO: ALTA EMPLEADO AGENCIA class Alta Empleado Agencia Serializable empleadoAgencia::ListarEmpleadoAgencia - altaEmpleadoAgenciaBEAN: AltaEmpleadoAgencia selectedEmpleadoAgencia: EmpleadoAgencia ([]) + + ListarEmpleadoAgencia() onAlta() : String -altaEmpleadoAgenciaBEAN Serializable empleadoAgencia::AltaEmpleadoAgencia empleadoAgencia:: listarEmpleadoAgencia + - empleadoAgenciaDAO: EmpleadoAgenciaDAO empleadoAgencia: EmpleadoAgencia + + AltaEmpleadoAgencia() alta() : String altaEmpleadoAgencia() : void JPAGenericDAO Serializable j pa::JPAEmpleadoAgenciaDAO entidades::EmpleadoAgencia - id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} + JPAEmpleadoAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 184 7.3.38 CASO DE USO: BAJA EMPLEADO AGENCIA class Baj a Empleado Agencia Serializable empleadoAgencia::ListarEmpleadoAgencia - altaEmpleadoAgenciaBEAN: AltaEmpleadoAgencia selectedEmpleadoAgencia: EmpleadoAgencia ([]) + + ListarEmpleadoAgencia() onBaja() : String -bajaEmpleadoAgenciaBEAN Serializable empleadoAgencia::Baj aEmpleadoAgencia empleadoAgencia:: listarEmpleadoAgencia + - empleadoAgenciaDAO: EmpleadoAgenciaDAO empleadoAgencia: EmpleadoAgencia + + BajaEmpleadoAgencia() baja() : String bajaEmpleadoAgencia() : void JPAGenericDAO j pa::JPAEmpleadoAgenciaDAO Serializable entidades::EmpleadoAgencia - id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} + JPAEmpleadoAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 185 7.3.39 CASO DE USO: LISTAR EMPLEADO AGENCIA class Listar Empleado Agencia Serializable empleadoAgencia::ListarEmpleadoAgencia - empleadoAgenciaDAO: EmpleadoAgenciaDAO lista: List<EmpleadoAgencia> + + ListarEmpleadoAgencia() getLista() : List<EmpleadoAgencia> JPAGenericDAO j pa::JPAEmpleadoAgenciaDAO empleadoAgencia:: listarEmpleadoAgencia + listarEmpleadoAgencia() : void + JPAEmpleadoAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T ) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::EmpleadoAgencia - id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} 186 7.3.40 CASO DE USO: MODIFICAREMPLEADOAGENCIA class ModificarEmpleadoAgencia Serializable Serializable empleadoAgencia::ListarEmpleadoAgencia - empleadoAgenciaDAO: EmpleadoAgenciaDAO modificarEmpleadoAgenciaBEAN: ModificarEmpleadoAgencia agenciaDAO: AgenciaDAO empleadoDAO: UsuarioDAO agencias: SelectItem ([]) empleados: SelectItem ([]) selectedEmpleadoAgencia: EmpleadoAgencia ([]) + + ListarEmpleadoAgencia() onModificar(RowEditEvent) : void empleadoAgencia:: listarEmpleadoAgencia empleadoAgencia::ModificarEmpleadoAgencia -modificarEmpleadoAgenciaBEAN JPAGenericDAO j pa::JPAUsuarioDAO + modificarEmpleadoAgencia() : void + JPAUsuarioDAO() - empleadoAgenciaDAO: EmpleadoAgenciaDAO empleadoAgencia: EmpleadoAgencia + + ModificarEmpleadoAgencia() modificar() : String JPAGenericDAO JPAGenericDAO j pa::JPAAgenciaDAO j pa::JPAEmpleadoAgenciaDAO + + JPAAgenciaDAO() JPAEmpleadoAgenciaDAO() Serializable Serializable entidades::Agencia entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} - serialVersionUID: long = 1... id: int nombre: String direccion: String telefono: String -agencia eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> Serializable entidades::EmpleadoAgencia - id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} +empleado 187 7.3.41 CASO DE USO: ALTA EMPRESA class Alta Empresa Serializable Serializable empresa::ListarEmpresa empresa::AltaEmpresa - altaEmpresaBEAN: AltaEmpresa selectedEmpresas: Empresa ([]) -altaEmpresaBEAN + + ListarEmpresa() getAltaEmpresaBEAN() : AltaEmpresa - empresaDAO: EmpresaDAO empresa: Empresa + + AltaEmpresa() alta() : String JPAGenericDAO j pa::JPAEmpresaDAO empresa::listarEmpresa + listarEmpresa() : void {query} Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> + JPAEmpresaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 188 7.3.42 CASO DE USO: BAJA EMPRESA class Baj a Empresa Serializable Serializable empresa::ListarEmpresa - bajaEmpresaBEAN: BajaEmpresa selectedEmpresas: Empresa ([]) + + ListarEmpresa() onBaja() : String empresa::Baj aEmpresa -bajaEmpresaBEAN empresa::listarEmpresa + empresaDAO: EmpresaDAO empresa: Empresa + + BajaEmpresa() baja() : String JPAGenericDAO j pa::JPAEmpresaDAO bajaEmpresa() : void Serializable entidades::Empresa - - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> + JPAEmpresaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 189 7.3.43 CASO DE USO: CREAR EMPRESA class Crear Empresa Serializable JPAGenericDAO empresa::CrearEmpresa - empresaDAO: EmpresaDAO empresa: Empresa = new Empresa() + + CrearEmpresa() crear() : String j pa::JPAEmpresaDAO + JPAEmpresaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Empresa empresa::crearEmpresa + crearEmpresa() : void - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> 190 7.3.44 CASO DE USO: LISTAR EMPRESA class Listar Empresa Serializable JPAGenericDAO empresa::ListarEmpresa - empresaDAO: EmpresaDAO lista: List<Empresa> + + ListarEmpresa() getLista() : List<Empresa> j pa::JPAEmpresaDAO + JPAEmpresaDAO() + getIvaByEmpresa(int, boolean) : double ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection empresa::listarEmpresa + listarEmpresa() : void {query} Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> 191 7.3.45 CASO DE USO: MODIFICAR EMPRESA class Modificar Empresa Serializable Serializable empresa::ListarEmpresa - modificarEmpresaBEAN: ModificarEmpresa selectedEmpresas: Empresa ([]) + + ListarEmpresa() onModificar(RowEditEvent) : void empresa::ModificarEmpresa -modificarEmpresaBEAN - empresaDAO: EmpresaDAO empresa: Empresa + + ModificarEmpresa() modificar() : String empresa::listarEmpresa + modificarEmpresa() : void Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> JPAGenericDAO j pa::JPAEmpresaDAO + JPAEmpresaDAO() + getIvaByEmpresa(int, boolean) : double ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection 192 7.3.46 CASO DE USO: LOGINUSUARIO class loginUsuario JPAGenericDAO j pa::JPAUsuarioDAO Serializable + JPAUsuarioDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection login::LoginUsuario - usuarioDAO: UsuarioDAO usuario: Usuario = new Usuario() isLogeado: boolean = false + procesar() : String Serializable login::loginUsuario + procesar() : void entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} 193 7.3.47 CASO DE USO: LOGOUT class logOut Serializable login::LogoutUsuario - serialVersionUID: long = 1L {readOnly} + + LogoutUsuario() logout() : String login::loginUsuario + procesar() : void menu::menuAdmin menu::menuEmpleado 194 7.3.48 CASO DE USO: ALTA MARCA class Alta Marca Serializable Serializable marca::ListarMarca - altaMarcaBEAN: AltaMarca selectedMarcas: Marca ([]) + + ListarMarca() onAlta() : String marca::AltaMarca -altaMarcaBEAN - marcaDAO: MarcaDAO marca: Marca + + AltaMarca() alta() : String JPAGenericDAO marca::listarMarca j pa::JPAMarcaDAO + + + + listarMarca() : void altaMarca() : void bajaMarca() : void actualizarMarca() : void + JPAMarcaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Marca - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 195 7.3.49 CASO DE USO: BAJA MARCA class Baj a Marca Serializable Serializable marca::Baj aMarca marca::ListarMarca - bajaMarcaBEAN: BajaMarca selectedMarcas: Marca ([]) + + ListarMarca() onBaja() : String -bajaMarcaBEAN + + marcaDAO: MarcaDAO marca: Marca BajaMarca() baja() : String JPAGenericDAO j pa::JPAMarcaDAO marca::listarMarca + + + + listarMarca() : void altaMarca() : void bajaMarca() : void actualizarMarca() : void + JPAMarcaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Marca - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 196 7.3.50 CASO DE USO: CREAR MARCA class Crear Marca Serializable marca::CrearMarca + + marcaDAO: MarcaDAO marca: Marca = new Marca() CrearMarca() crear() : String JPAGenericDAO j pa::JPAMarcaDAO + JPAMarcaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection marca::crearMarca + crearMarca() : void Serializable entidades::Marca - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 197 7.3.51 CASO DE USO: LISTAR MARCA class Listar Marca Serializable marca::ListarMarca - JPAGenericDAO marcaDAO: MarcaDAO j pa::JPAMarcaDAO + + ListarMarca() getLista() : List<Marca> + JPAMarcaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection marca::listarMarca + listarMarca() : void Serializable entidades::Marca - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 198 7.3.52 CASO DE USO: MODIFICAR MARCA class Modificar Marca Serializable Serializable marca::ModificarMarca marca::ListarMarca -modificarMarcaBEAN - modificarMarcaBEAN: ModificarMarca selectedMarcas: Marca ([]) - marcaDAO: MarcaDAO marca: Marca + + ListarMarca() onModificar(RowEditEvent) : void + + ModificarMarca() modificar() : String JPAGenericDAO j pa::JPAMarcaDAO marca::listarMarca + + + + listarMarca() : void altaMarca() : void bajaMarca() : void actualizarMarca() : void + JPAMarcaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Marca - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 199 7.3.53 CASO DE USO: ALTA PRODUCTO class Alta Producto Serializable Serializable producto::AltaProducto producto::ListarProducto - altaProductoBEAN: AltaProducto selectedProductos: Producto ([]) + + ListarProducto() onAlta() : String -altaProductoBEAN + + productoDAO: ProductoDAO producto: Producto AltaProducto() alta() : String JPAGenericDAO producto::listarProducto j pa::JPAProductoDAO + altaProducto() : void Serializable entidades::Producto - id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 200 7.3.54 CASO DE USO: BAJA PRODUCTO class Baj a Producto Serializable Serializable producto::Baj aProducto producto::ListarProducto - bajaProductoBEAN: BajaProducto selectedProductos: Producto ([]) + + ListarProducto() onBaja() : String -bajaProductoBEAN + + productoDAO: ProductoDAO producto: Producto BajaProducto() baja() : String JPAGenericDAO j pa::JPAProductoDAO producto::listarProducto + bajaProducto() : void Serializable + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection entidades::Producto - id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 201 7.3.55 CASO DE USO: CREAR PRODUCTO class Crear Producto Serializable producto::CrearProducto producto::crearProducto + crearProducto() : void - productoDAO: ProductoDAO marcaDAO: MarcaDAO categoriaDAO: CategoriaDAO producto: Producto = new Producto() categorias: SelectItem ([]) marcas: SelectItem ([]) + + CrearProducto() crear() : String JPAGenericDAO j pa::JPACategoriaDAO + JPACategoriaDAO() JPAGenericDAO JPAGenericDAO j pa::JPAProductoDAO j pa::JPAMarcaDAO + + JPAProductoDAO() Serializable Serializable entidades::Categoria - id: int -categoria nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} - JPAMarcaDAO() entidades::Producto id: int -marca nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} Serializable entidades::Marca id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} 202 7.3.56 CASO DE USO: LISTAR PRODUCTO class Listar Producto Serializable producto::ListarProducto - productoDAO: ProductoDAO lista: List<Producto> + + ListarProducto() getLista() : List<Producto> JPAGenericDAO j pa::JPAProductoDAO + JPAProductoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection producto::listarProducto + listarProducto() : void Serializable entidades::Producto - id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 203 7.3.57 CASO DE USO: MODIFICAR PRODUCTO class Modificar Producto Serializable producto::ListarProducto - productoDAO: ProductoDAO marcaDAO: MarcaDAO categoriaDAO: CategoriaDAO modificarProductoBEAN: ModificarProducto marcas: SelectItem ([]) categorias: SelectItem ([]) selectedProductos: Producto ([]) + + ListarProducto() onModificar(RowEditEvent) : void Serializable producto::ModificarProducto -modificarProductoBEAN - productoDAO: ProductoDAO producto: Producto + + ModificarProducto() modificar() : String producto::listarProducto + JPAGenericDAO modificarProducto() : void j pa::JPACategoriaDAO + JPAGenericDAO JPACategoriaDAO() j pa::JPAMarcaDAO + JPAGenericDAO j pa::JPAProductoDAO + JPAProductoDAO() JPAMarcaDAO() Serializable entidades::Categoria Serializable entidades::Marca - id: int nombre: String eliminado: boolean -marca producto: Set<Producto> serialVersionUID: long = 1L {readOnly} - id: int nombre: String -categoria eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} - Serializable entidades::Producto id: int nombre: String eliminado: boolean marca: Marca categoria: Categoria bodegaDetalle: Set<BodegaDetalle> descuentoProducto: Set<DescuentoProducto> serialVersionUID: long = 1L {readOnly} 204 7.3.58 CASO DE USO: ALTA ROL class Alta Rol Serializable Serializable rol::AltaRol rol::ListarRol - altaRolBEAN: AltaRol selectedRoles: Rol ([]) + + ListarRol() onAlta() : String -altaRolBEAN + + rolDAO: RolDAO rol: Rol AltaRol() alta() : String JPAGenericDAO j pa::JPARolDAO rol::listarRol + altaRol() : void Serializable entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 205 7.3.59 CASO DE USO: BAJA ROL class Baj a Rol Serializable Serializable rol::Baj aRol rol::ListarRol - bajaRolBEAN: BajaRol selectedRoles: Rol ([]) + + ListarRol() onBaja() : String -bajaRolBEAN + + rolDAO: RolDAO rol: Rol BajaRol() baja() : String JPAGenericDAO rol::listarRol + bajaRol() : void j pa::JPARolDAO + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} 206 7.3.60 CASO DE USO: CREAR ROL class Crear Rol JPAGenericDAO Serializable j pa::JPARolDAO rol::CrearRol - rolDAO: RolDAO rol: Rol = new Rol() + + CrearRol() crear() : String + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable rol::crearRol + crearRol() : void entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} 207 7.3.61 CASO DE USO: LISTAR ROL class Listar Rol Serializable JPAGenericDAO rol::ListarRol j pa::JPARolDAO - rolDAO: RolDAO lista: List<Rol> + + ListarRol() getLista() : List<Rol> + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection rol::listarRol + listarRol() : void Serializable entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} 208 7.3.62 CASO DE USO: MODIFICAR ROL class Modificar Rol Serializable Serializable rol::ListarRol - modificarRolBEAN: ModificarRol selectedRoles: Rol ([]) + + ListarRol() onModificar(RowEditEvent) : void rol::ModificarRol -modificarRolBEAN - rolDAO: RolDAO rol: Rol + + ModificarRol() modificar() : String JPAGenericDAO j pa::JPARolDAO rol::listarRol + modificarRol() : void + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} 209 7.3.63 CASO DE USO: ALTA USUARIO class Alta Usuario Serializable Serializable usuario::ListarUsuario - altaUsuarioBEAN: AltaUsuario selectedUsuarios: Usuario ([]) + + ListarUsuario() onAlta() : String usuario::AltaUsuario -altaUsuarioBEAN + + usuarioDAO: UsuarioDAO usuario: Usuario AltaUsuario() alta() : String JPAGenericDAO usuario::listaUsuario j pa::JPAUsuarioDAO + altaUsuario() : void Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} + JPAUsuarioDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection 210 7.3.64 CASO DE USO: BAJA USUARIO class Baj a Usuario Serializable Serializable usuario::ListarUsuario - bajaUsuarioBEAN: BajaUsuario selectedUsuarios: Usuario ([]) + + ListarUsuario() onBaja() : String usuario::Baj aUsuario -bajaUsuarioBEAN - usuarioDAO: UsuarioDAO usuario: Usuario + + BajaUsuario() baja() : String JPAGenericDAO j pa::JPAUsuarioDAO + + JPAUsuarioDAO() getEmpleado(Rol, boolean) : List<Usuario> usuario::listaUsuario + bajaUsuario() : void Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} 211 7.3.65 CASO DE USO: CREAR USUARIO class Crear Usuario Serializable usuario::CrearUsuario + + usuarioDAO: UsuarioDAO rolDAO: RolDAO roles: SelectItem ([]) JPAGenericDAO j pa::JPAUsuarioDAO CrearUsuario() crear() : String JPAGenericDAO j pa::JPARolDAO usuario::crearUsuario + + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection crearUsuario() : void Serializable entidades::Rol - id: int nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} -rol + getEmpleado(Rol, boolean) : List<Usuario> ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T ) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} 212 7.3.66 CASO DE USO: LISTA USUARIO class Lista Usuario Serializable usuario::ListarUsuario + + JPAGenericDAO j pa::JPAUsuarioDAO usuarioDAO: UsuarioDAO lista: List<Usuario> + JPAUsuarioDAO() + getEmpleado(Rol, boolean) : List<Usuario> ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection ListarUsuario() getLista() : List<Usuario> usuario::listaUsuario + listaUsuario() : void Serializable entidades::Usuario - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} 213 7.3.67 CASO DE USO: MODIFICAR USUARIO class Modificar Usuario Serializable Serializable usuario::ListarUsuario usuario::ModificarUsuario - modificarUsuarioBEAN: ModificarUsuario roles: SelectItem ([]) selectedUsuarios: Usuario ([]) + + ListarUsuario() onModificar(RowEditEvent) : void -modificarUsuarioBEAN - usuarioDAO: UsuarioDAO usuario: Usuario + + ModificarUsuario() modificar() : String JPAGenericDAO j pa::JPAUsuarioDAO JPAGenericDAO j pa::JPARolDAO usuario::listaUsuario + + JPARolDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection modificarUsuario() : void + JPAUsuarioDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::Usuario Serializable entidades::Rol - id: int -rol nombre: String eliminado: boolean usuario: Set<Usuario> serialVersionUID: long = 1L {readOnly} - id: int nombres: String apellidos: String fechaNacimiento: Date direccion: String telefono: String email: String username: String password: String eliminado: boolean rol: Rol facturaCliente: Set<Factura> empleadoAgencia: Set<EmpleadoAgencia> serialVersionUID: long = 1L {readOnly} 214 7.3.68 CASO DE USO: ALTA MEDIO PAGO class Alta Medio Pago Serializable Serializable medioDePago::ListarMedioPago - altaMedioPagoBEAN: AltaMedioPago selectedMedioPagos: MedioDePago ([]) + + ListarMedioPago() onAlta() : String medioDePago::AltaMedioPago -altaMedioPagoBEAN - medioPagoDAO: MedioPagoDAO medioPago: MedioDePago + + AltaMedioPago() alta() : String JPAGenericDAO j pa::JPAMedioPagoDAO medioPago:: listarMedioPago + altaMedioPago() : void + JPAMedioPagoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection Serializable entidades::MedioDePago - id: int nombre: String eliminado: boolean factura: Factura serialVersionUID: long = 1L {readOnly} 215 7.3.69 CASO DE USO: BAJA MEDIO PAGO class Baj a Medio Pago Serializable Serializable medioDePago::Baj aMedioPago medioDePago::ListarMedioPago - bajaMedioPagoBEAN: BajaMedioPago selectedMedioPagos: MedioDePago ([]) + + ListarMedioPago() onBaja() : String -bajaMedioPagoBEAN + + medioPago:: listarMedioPago + BajaMedioPago() baja() : String JPAGenericDAO j pa::JPAMedioPagoDAO bajaMedioPago() : void Serializable entidades::MedioDePago - medioPagoDAO: MedioPagoDAO medioPago: MedioDePago + JPAMedioPagoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection id: int nombre: String eliminado: boolean factura: Factura serialVersionUID: long = 1L {readOnly} 216 7.3.70 CASO DE USO: CREAR MEDIO PAGO class Crear Medio Pago JPAGenericDAO Serializable j pa::JPAMedioPagoDAO medioDePago::CrearMedioPago - medioPagoDAO: MedioPagoDAO medioPago: MedioDePago = new MedioDePago() + + CrearMedioPago() crear() : String medioPago::crearMedioPago + + JPAMedioPagoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection crearMedioPago() : void Serializable entidades::MedioDePago - id: int nombre: String eliminado: boolean factura: Factura serialVersionUID: long = 1L {readOnly} 217 7.3.71 CASO DE USO: LISTAR MEDIO PAGO class Listar Medio Pago JPAGenericDAO Serializable j pa::JPAMedioPagoDAO medioDePago::ListarMedioPago - medioPagoDAO: MedioPagoDAO lista: List<MedioDePago> + + ListarMedioPago() getLista() : List<MedioDePago> + JPAMedioPagoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection medioPago::listarMedioPago + listarMedioPago() : void Serializable entidades::MedioDePago - id: int nombre: String eliminado: boolean factura: Factura serialVersionUID: long = 1L {readOnly} 218 7.3.72 CASO DE USO: MODIFICAR MEDIO PAGO class Modificar Medio Pago Serializable Serializable medioDePago::ListarMedioPago - modificarMedioPagoBEAN: ModificarMedioPago selectedMedioPagos: MedioDePago ([]) + + ListarMedioPago() onModificar(RowEditEvent) : void medioDePago::ModificarMedioPago -modificarMedioPagoBEAN + + medioPagoDAO: MedioPagoDAO medioPago: MedioDePago ModificarMedioPago() modificar() : String medioPago::listarMedioPago + modificarMedioPago() : void JPAGenericDAO j pa::JPAMedioPagoDAO Serializable entidades::MedioDePago - id: int nombre: String eliminado: boolean factura: Factura serialVersionUID: long = 1L {readOnly} + JPAMedioPagoDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T >) + create(T ) : void + read(ID) : T + update(T ) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection 219 7.3.73 CASO DE USO: ENTRAR APLICATIVO MOVIL class Entrar Aplicativ o Mov il Activity login::LoginActiv ity Vistas Aplicacion Android::login - username: EditText password: EditText agencia: Spinner mapaAgencias: Map<Integer, String> = new HashMap<Int... listaAgencias: List<String> = new ArrayList<S... REQUEST_ACTIVIT Y: int = 1 {readOnly} + + + + + onCreate(Bundle) : void login() : void nuevoUsuario() : void onActivityResult(int, int, Intent) : void onBackPressed() : void GenericREST rest::AgenciaREST GenericREST rest::UsuarioREST + + + UsuarioREST () login(String, String) : int create(String[], String[]) : boolean + + + AgenciaREST() getJSONParserAgencia(JSONObject) : Agencia listAgencias() : Map<Integer, String> RESTFull RESTFull rest::AgenciaResource rest::AutenticacionResource + + createUsuarioXML(Usuario) : Response loginXML(String, String) : Response + listAgencias() : Response 220 7.3.74 CASO DE USO: REGISTRO USUARIO class Registro Usuario Activity login::Nuev oUsuarioActiv ity - nombres: EditText apellidos: EditText direccion: EditText telefono: EditText fechaNacimiento: EditText email: EditText username: EditText password: EditText fc2: String = null # + + + onCreate(Bundle) : void nuevoUsuario() : void cancelar() : void onBackPressed() : void GenericREST rest::UsuarioREST + + + Vistas Aplicacion Android:: Nuev oUsuarioActiv ity UsuarioREST() login(String, String) : int create(String[], String[]) : boolean RESTFull rest::AutenticacionResource + + createUsuarioXML(Usuario) : Response loginXML(String, String) : Response 221 7.3.75 CASO DE USO: SALIR APLICATIVO MOVIL class Salir Aplicativ o Mov il Activity login::LogoutActiv ity Vistas Aplicacion Android::login - idAgencia: int idCliente: int idFactura: int nombreAgencia: String # + + + onCreate(Bundle) : void aceptar() : void cancelar() : void onBackPressed() : void 222 7.3.76 CASO DE USO: AGREGAR PRODUCTO class Agregar Producto Activity compras::AddProductoActiv ity - nombre: EditText precio: EditText subtotal: EditText descuento: EditText iva: EditT ext total: EditText cantidad: NumberPicker idBodegaDetalle: int idAgencia: int nombreAgencia: String idFactura: int idCliente: int bodegaDetalle: BodegaDetalle = new BodegaDetalle() des: Descuento = new Descuento() facturaDetalle: FacturaDetalle = new FacturaDetalle() # + + + + onCreate(Bundle) : void calcularTotales() : void anadirProducto() : void cancelar() : void onBackPressed() : void GenericREST rest::FacturaDetalleREST + + + + + + + + + FacturaDetalleREST() getJSONParserFacturaDetalle(JSONObject) : FacturaDetalle getFacturaDetalleById(int) : FacturaDetalle setTotales(BodegaDetalle, Descuento, int) : FacturaDetalle anadirProducto(int, int, int, int, int, int) : int actualizarProducto(int, int, int) : int eliminarProducto(int) : int existeProductoByFacturaDetalle(int, int) : boolean getCarroActual(int) : List<FacturaDetalle> GenericREST GenericREST rest::DescuentoREST + + + DescuentoREST() getJSONParserDescuento(JSONObject) : Descuento getDescuentoByProducto(int) : Descuento rest::BodegaDetalleREST RESTFull + + + REST Full BodegaDetalleREST() getJSONParserBodegaDetalle(JSONObject) : BodegaDetalle getBodegaDetalleById(int) : BodegaDetalle RESTFull rest::FacturaDetalleResource rest::DescuentoResource + getDescuentoByProducto(int) : Response rest::BodegaDetalleResource + getBodegaDetalleById(int) : Response + + + + + + getCarroCompraActual(int) : List<FacturaDetalle> getFacturaDetalleById(int) : Response existeProductoByFacturaDetalle(int, int) : Response aniadirProducto(int, int, int, int, int, int) : Response actualizarProducto(int, int, int) : Response eliminarPoducto(int) : Response 223 7.3.77 CASO DE USO: CONFIRMAR CARRO COMPRAS class Confirmar Carro Compras Activity compras::ConfirmarComprasActiv ity - idAgencia: int nombreAgencia: String idFactura: int idCliente: int totalFactura: double totalFacturaActual: double total: EditText medioPago: Spinner mapaMedioPago: Map<Integer, String> = new HashMap<Int... listaMedioPagp: List<String> = new ArrayList<S... # + + + onCreate(Bundle) : void confirmar() : void cancelar() : void onBackPressed() : void GenericREST GenericREST rest::MedioPagoREST rest::FacturaREST + + + + + + FacturaREST() getJSONParserFactura(JSONObject) : Factura getCarrosCompra(int, int) : List<Factura> EliminarFactura(int) : int ConfirmaTotal(int, double) : double ConfirmaCompra(int, int) : int RESTFull + + MedioPagoREST() listMedioPago() : Map<Integer, String> RESTFull rest::MedioDePagoResource + listAgencias() : Response rest::FacturaResource + + + + + getCarrosCompra(int, int) : List<Factura> EliminarFactura(int) : Response read(ID) : T ConfirmarTotal(int, double) : Response ConfirmarCompra(int, int) : Response 224 7.3.78 CASO DE USO: EDITAR PRODUCTO class Editar Producto Activity compras::EditProductoActiv ity GenericREST - nombre: EditText precio: EditText subtotal: EditText descuento: EditText iva: EditText total: EditText cantidad: NumberPicker idFacturaDetalle: int idAgencia: int nombreAgencia: String idFactura: int idCliente: int facturaDetalle: FacturaDetalle = new FacturaDetalle() bodegaDetalle: BodegaDetalle = new BodegaDetalle() des: Descuento = new Descuento() # + + + + + onCreate(Bundle) : void calcularTotales() : void actualizar() : void eliminar() : void cancelar() : void onBackPressed() : void rest::BodegaDetalleREST + + + BodegaDetalleREST() getJSONParserBodegaDetalle(JSONObject) : BodegaDetalle getBodegaDetalleById(int) : BodegaDetalle Vistas Aplicacion Android:: EditProductoActiv ity RESTFull rest::BodegaDetalleResource + getBodegaDetalleById(int) : Response GenericREST rest::FacturaREST + + + + + + GenericREST rest::DescuentoREST + + + DescuentoREST() getJSONParserDescuento(JSONObject) : Descuento getDescuentoByProducto(int) : Descuento FacturaREST() getJSONParserFactura(JSONObject) : Factura getCarrosCompra(int, int) : List<Factura> EliminarFactura(int) : int ConfirmaTotal(int, double) : double ConfirmaCompra(int, int) : int RESTFull RESTFull rest::FacturaDetalleResource rest::DescuentoResource + getDescuentoByProducto(int) : Response + + + + + + getCarroCompraActual(int) : List<FacturaDetalle> getFacturaDetalleById(int) : Response existeProductoByFacturaDetalle(int, int) : Response aniadirProducto(int, int, int, int, int, int) : Response actualizarProducto(int, int, int) : Response eliminarPoducto(int) : Response 225 7.3.79 CASO DE USO: LISTAR CARRO COMPRAS class Listar Carro Compras ListActivity compras::CarrosComprasActiv ity - listaCarros: List<Factura> = null btnCarro: Button btnCarros: Button lblTitulo: TextView lblAgencia: TextView idAgencia: int idCliente: int idFactura: int nombreAgencia: String + + + + + onCreate(Bundle) : void btnCarro_onClick() : void btnCarros_onClick() : void cancelar() : void onBackPressed() : void BaseAdapter compras::AdaptadorListaCarros - actividad: Activity {readOnly} listaCarros: List<Factura> {readOnly} + + + + + AdaptadorListaCarros(Activity, List<Factura>) getCount() : int getItem(int) : Object getItemId(int) : long getView(int, View, ViewGroup) : View GenericREST rest::FacturaREST + + + + + + Vistas Aplicacion Android:: CarrosComprasActiv ity FacturaREST() getJSONParserFactura(JSONObject) : Factura getCarrosCompra(int, int) : List<Factura> EliminarFactura(int) : int ConfirmaTotal(int, double) : double ConfirmaCompra(int, int) : int RESTFull rest::FacturaResource + + + + + getCarrosCompra(int, int) : List<Factura> EliminarFactura(int) : Response read(ID) : T ConfirmarTotal(int, double) : Response ConfirmarCompra(int, int) : Response 226 7.3.80 CASO DE USO: LISTAR PRODUCTO CARRO COMPRA class Listar Producto Carro Compra ListActivity compras::ComprasActiv ity Vistas Aplicacion Android:: ComprasActiv ity - listaProductos: List<FacturaDetalle> = null btnConfirmar: Button btnAgregarProducto: Button btnCarro: Button btnCarros: Button btnEliminar: Button lblTotal: TextView lblAgencia: TextView idAgencia: int idCliente: int idFactura: int totalFactura: double nombreAgencia: String = "FALTA" + + + + + + + + + onCreate(Bundle) : void btnConfirmar_onClick() : void btnAddProducto_onClick() : void btnCarro_onClick() : void btnCarros_onClick() : void btnEliminar_onClick() : void onBackPressed() : void onCreateOptionsMenu(Menu) : boolean onMenuItemSelected(int, MenuItem) : boolean BaseAdapter compras::AdaptadorListaProductos RESTFull rest::FacturaDetalleResource + + + + + + - actividad: Activity {readOnly} listaProductos: List<FacturaDetalle> {readOnly} + + + + + AdaptadorListaProductos(Activity, List<FacturaDetalle>) getCount() : int getItem(int) : Object getItemId(int) : long getView(int, View, ViewGroup) : View GenericREST rest::FacturaDetalleREST + + + + + + + + + FacturaDetalleREST() getJSONParserFacturaDetalle(JSONObject) : FacturaDetalle getFacturaDetalleById(int) : FacturaDetalle setTotales(BodegaDetalle, Descuento, int) : FacturaDetalle anadirProducto(int, int, int, int, int, int) : int actualizarProducto(int, int, int) : int eliminarProducto(int) : int existeProductoByFacturaDetalle(int, int) : boolean getCarroActual(int) : List<FacturaDetalle> getCarroCompraActual(int) : List<FacturaDetalle> getFacturaDetalleById(int) : Response existeProductoByFacturaDetalle(int, int) : Response aniadirProducto(int, int, int, int, int, int) : Response actualizarProducto(int, int, int) : Response eliminarPoducto(int) : Response 227 7.3.81 CASO DE USO: REPORTE CIERRE CAJA class Reporte Cierre Caj a Serializable reportes::CierreDeCaj a - empleadoAgenciaDAO: EmpleadoAgenciaDAO jasperPrint: JasperPrint + + CierreDeCaja() generarPDF(ActionEvent) : void JasperReports::JasperReports + exportReportToPdfStream() : void JPAGenericDAO j pa::JPAEmpleadoAgenciaDAO reportes:: cierreDeCaj a Serializable + JPAEmpleadoAgenciaDAO() + getAgenciaByEmpleado(Usuario) : EmpleadoAgencia ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection entidades::EmpleadoAgencia - id: int eliminado: boolean empleado: Usuario agencia: Agencia factura: Set<Factura> serialVersionUID: long = 1L {readOnly} 228 7.3.82 CASO DE USO: REPORTE CONSOLIDADO VENTAS class Reporte Consolidado Ventas Serializable reportes::ConsolidadoVentas - empresaDAO: EmpresaDAO jasperPrint: JasperPrint + + ConsolidadoVentas() generarPDF(ActionEvent) : void JasperReports::JasperReports + exportReportT oPdfStream() : void JPAGenericDAO j pa::JPAEmpresaDAO reportes:: consolidadoVentas Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> + JPAEmpresaDAO() + getIvaByEmpresa(int, boolean) : double ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T ) : void + delete(T ) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T > + getConexion() : Connection 229 7.3.83 CASO DE USO: REPORTE STOCK PRODUCTOS class Reporte Stock Productos reportes::StockProductos - empresaDAO: EmpresaDAO agenciaDAO: AgenciaDAO categoriaDAO: CategoriaDAO jasperPrint: JasperPrint + + StockProductos() generarPDF(ActionEvent) : void JasperReports::JasperReports + exportReportToPdfStream() : void reportes:: stockProductos JPAGenericDAO j pa::JPACategoriaDAO JPAGenericDAO + JPACategoriaDAO() j pa::JPAAgenciaDAO JPAGenericDAO + JPAAgenciaDAO() ::JPAGenericDAO + JPAGenericDAO(Class<T>) + create(T) : void + read(ID) : T + update(T) : void + delete(T) : void + deleteByID(ID) : void + find(String[], String[], String, int, int) : List<T> + getConexion() : Connection j pa::JPAEmpresaDAO + + JPAEmpresaDAO() getIvaByEmpresa(int, boolean) : double Serializable entidades::Categoria - id: int nombre: String eliminado: boolean producto: Set<Producto> serialVersionUID: long = 1L {readOnly} Serializable Serializable entidades::Empresa - serialVersionUID: long = 1L {readOnly} id: int razonSocial: String ruc: String direccion: String telefono: String iva: double eliminado: boolean agencia: Set<Agencia> entidades::Agencia -empresa - serialVersionUID: long = 1... id: int nombre: String direccion: String telefono: String eliminado: boolean empresa: Empresa bodega: Set<Bodega> empleadoAgencia: Set<E... factura: Set<Factura> 7.4 DIAGRAMADE DESPLIEGUE El modelo de despliegue nos permite modelar el hardware utilizado en las implementaciones de sistemas y las relaciones entre sus componentes. En el gráfico siguiente se muestra la relación entre los diferentes nodos necesarios para el funcionamiento de la solución acompañado de su respectivo detalle de características mínimas para el buen funcionamiento. 230 deployment Diagrama de Despliegue Serv idor Web «device» Dispositiv o Mobil REST Serv idor BDD JPA A A HT TP Cliente Web A 7.4.1 CLIENTE WEB Componente Procesador Disco Duro Pantalla NIC Mínimo Core 2 Dúo 1,8 Ghz o superior 250 Gb. Pantalla plana de 19 pulgadas. Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo. Memoria Ancho de banda Latencia de red Navegador S.O Computadora General Impresora 2 GB de RAM 50 kbps Inferior a 150 ms Mozilla Firefox 20.0 Windows XP, 7, Vista, Linux. Plug and Play ( para Windows XP,Vista,Mac) Impresora Láser compatible con el Sistema operativo instalado. Formato A4 (210 mm x 297 mm). Lengua PostScript. Capacidad de 12 a 16 ppm. Resolución de 600 dpi. Recomendado Core 2 Dúo 1,8 Ghz o superior 250 Gb. Pantalla plana de 19 pulgadas. Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo. 4 GB de RAM o más 50 kbps o más Inferior a 150 ms Mozilla Firefox 20.0 Windows XP, 7, Vista, Linux. Plug and Play ( para Windows XP,Vista,Mac) Impresora Láser compatible con el Sistema operativo instalado. Formato A4 (210 mm x 297 mm). Lengua PostScript. Capacidad de 12 a 16 ppm. Resolución de 600 dpi. 7.4.2 SERVIDOR BDD Componente Procesador Memoria Pantalla NIC Mínimo Core 2 Duo 1,8 Ghz o superior 2 GB de RAM Pantalla plana de 19 pulgadas. Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo. Ancho de banda 50 kbps Recomendado Core 2 Duo 1,8 Ghz o superior 4 GB de RAM o más Pantalla plana de 19 pulgadas. Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo. 50 kbps o más 231 Latencia de red S.O Motor de BDD Inferior a 150 ms Linux. MySQL 5.5.25 Inferior a 150 ms Linux. MySQL 5.5.25 7.4.3 SERVIDOR WEB Componente Procesador Memoria Ancho de banda NIC Mínimo Core 2 Duo 1,8 Ghz o superior 2 GB de RAM 50 kbps Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo Latencia de red S.O Apache TOMCAT Inferior a 150 ms Linux. Versión 7.0.35 Recomendado Core 2 Duo 1,8 Ghz o superior 4 GB de RAM o más 50 kbps o más Tarjeta de red soportada por la red instalada 100 Mb/s para un rendimiento óptimo Inferior a 150 ms Linux. Versión 7.0.35 7.4.4 DISPOSITIVO MOBIL Componente Red Sistema Operativo Velocidad de CPU Memoria de Usuario Resolución de Cámara Mínimo Recomendado GSM 850 / 900 / 1800 / 1900 - HSDPA 900 / 2100 / 1700 GSM 850 / 900 / 1800 / 1900 - HSDPA 900 / 2100 / 1700 Andorid 4.1.2 Jelly Bean 1.4 Ghz 512 MB RAM Andorid 4.1.2 Jelly Bean 1.4 Ghz 512 MB 5 MP (Trasera) 8 MP (Trasera) Separando los paquetes en cada Nodo del despliegue, el diseño de la solución es el siguiente: 232 7.5 DISEÑO DE DATOS El modelo de datos (Modelo Entidad Relación) mostrado a continuación es el modelo generado por EclipseLink automáticamente desde las entidades generadas en el punto 6.1.3 dm Modelo de Datos empresa categoria marca «column» *PK ID: INT EGER * ELIMINADO: T INYINT = 0 * NOMBRE: VARCHAR(255) descuento_producto «column» *PK ID: INT EGER * ELIMINADO: TINYINT = 0 * NOMBRE: VARCHAR(255) rol «column» *PK ID: INT EGER DIRECCION: VARCHAR(255) * ELIMINADO: T INYINT = 0 * IVA: DOUBLE * RAZON_SOCIAL: VARCHAR(255) * RUC: VARCHAR(255) T ELEFONO: VARCHAR(255) «column» *PK ID: INT EGER * ELIMINADO: T INYINT = 0 *FK DESCUENT O_ID: INT EGER *FK PRODUCT O_ID: INT EGER «column» *PK ID: INT EGER * ELIMINADO: T INYINT = 0 * NOMBRE: VARCHAR(255) 1 1 (ROL_ID = ID) (EMPRESA_ID = ID) 0..* 1 1 usuario 0..* 0..* 0..* «column» *PK ID: INT EGER * APELLIDOS: VARCHAR(255) DIRECCION: VARCHAR(255) * ELIMINADO: T INYINT = 0 * EMAIL: VARCHAR(255) FECHA_NACIMIENTO: DAT E * NOMBRES: VARCHAR(255) * PASSWORD: VARCHAR(255) T ELEFONO: VARCHAR(255) * USERNAME: VARCHAR(255) *FK ROL_ID: INT EGER agencia «column» *PK ID: INT EGER DIRECCION: VARCHAR(255) * ELIMINADO: T INYINT = 0 * NOMBRE: VARCHAR(255) T ELEFONO: VARCHAR(255) *FK EMPRESA_ID: INTEGER (MARCA_ID = ID) (CATEGORIA_ID = ID) (PRODUCTO_ID = ID) 0..* 0..* 1 (DESCUENT O_ID = ID) 1 producto descuento «column» *PK ID: INT EGER * ELIMINADO: T INYINT = 0 * NOMBRE: VARCHAR(255) *FK CAT EGORIA_ID: INTEGER *FK MARCA_ID: INT EGER 1 «column» *PK ID: INTEGER * ELIMINADO: TINYINT = 0 * FECHA_FIN: DATE * FECHA_INICIO: DAT E * NOMBRE: VARCHAR(255) * VALOR: DOUBLE 1 1 1 1 (AGENCIA_ID = ID) (AGENCIA_ID = ID) (EMPLEADO_ID = ID) (AGENCIA_ID = ID) 1 0..* 0..* 0..* empleado_agencia bodega (PRODUCT O_ID = ID) «column» *PK ID: INTEGER * ELIMINADO: T INYINT = 0 *FK AGENCIA_ID: INTEGER *FK EMPLEADO_ID: INT EGER «column» *PK ID: INTEGER DIRECCION: VARCHAR(255) * ELIMINADO: T INYINT = 0 * NOMBRE: VARCHAR(255) TELEFONO: VARCHAR(255) 1 *FK AGENCIA_ID: INTEGER (CLIENT E_ID = ID) 1 0..* (BODEGA_ID = ID) bodega_detalle «column» *PK ID: INT EGER * CANT IDAD: INT EGER * ELIMINADO: TINYINT = 0 * PRECIO: DOUBLE *FK BODEGA_ID: INT EGER *FK PRODUCTO_ID: INTEGER (EMPLEADOAGENCIA_ID = ID) 0..* 0..* 0..* factura factura_detalle 1 (BODEGADET ALLE_ID = ID) «column» *PK ID: INTEGER * CANTIDAD: INTEGER * DESCUENT O: DOUBLE 0..* * ELIMINADO: T INYINT = 0 * IVA: DOUBLE * PRECIO: DOUBLE * SUBTOT AL: DOUBLE * TOTAL: DOUBLE *FK BODEGADET ALLE_ID: INT EGER *FK FACT URA_ID: INTEGER (FACT URA_ID = ID) 0..* «column» *PK ID: INT EGER * DESCUENT O: DOUBLE * ELIMINADO: T INYINT = 0 * FECHA: DAT E * IVA: DOUBLE * PAGADO: T INYINT = 0 1 * PENDIENT E: T INYINT = 0 * SUBTOTAL: DOUBLE * TOTAL: DOUBLE *FK AGENCIA_ID: INT EGER *FK CLIENT E_ID: INTEGER FK EMPLEADOAGENCIA_ID: INT EGER FK MEDIODEPAGO_ID: INT EGER 0..* medio_pago (MEDIODEPAGO_ID = ID) 0..* «column» *PK ID: INT EGER ELIMINADO: T INYINT = 0 1 * * NOMBRE: VARCHAR(255) 233 8 CONCLUSIONES • En cuanto al uso de PrimeFaces, como marco de trabajo para el desarrollo del front end, es una buena opción para simplificar e incrementar el rendimiento en el desarrollo. En cuanto al soporte brindado se puede decir que es una librería en crecimiento, respaldada con una comunidad muy activa que continuamente está aportando para implementar mejoras y corregir errores, esto ha aportado rapidez en el desarrollo del proyecto. • La metodología de desarrollo, guiada por casos de uso, nos ha permitido tener una mayor organización, gestión y control en cada flujo de trabajo lo que ha contribuido a la realización efectiva de pruebas puntuales del sistema. Las incidencias encontradas en las pruebas han sido localizadas y resultas rápidamente debido a la trazabilidad que nos aporta la metodología. • La implementación de servicios RESTFul nos ha permitido establecer una comunicación entre el dispositivo móvil y la aplicación web de una manera simple, ligera y eficiente , mediante el uso del formato JSON que es el que hemos utilizado para el envío de mensajes. Es necesario anotar que otra alternativa es el uso de SOAP, sin embargo este protocolo envía mensajes únicamente en formato XML lo que genera mayor procesamiento y por ende el rendimiento es inferior al de RESTFul. • La implantación del sistema en una tienda de compra de productos , automatiza el proceso de compra dotándolo de agilidad y eficiencia. El no tener que hacer uso de un carro de compras físico, incrementa la satisfacción del cliente en el proceso de compra. Del mismo modo, el cambio de paradigma propuesto, promueve a la tienda la oportunidad de incrementar las ventas ya que al no contar con estanterías físicas sino únicamente con paneles de productos expuestos, se tendrá la oportunidad de ofertar más productos. La disminución en tiempo tanto para cliente, en la espera en filas, y para el empleado, en la verificación de productos en caja, aporta una significante optimización en el proceso. 9 BIBLIOGRAFÍA • Design Patterns, Elements of Reusable Object-Oriented Software, Erich Gamma, Richard Helm, Ralp Johnson, John Vlissides • El Proceso Unificado de Desarrollo de Software, I. Jacobson, G. Booch, J. Rumbaugh, PEARSON EDUCACION, S. A., Madrid, 2000. ISBN 13: 978-84-7829-036-9 • Android 4, Desarrollo de Aplicaciones. Wei-Meng Lee. Ediciones ANAYA MULTIMEDIA • RESTFul Web Services, Leonard Richardson & Sam Ruby. O’REILLY 2007 • Pro JSF and AJAX Building Rich Internet Components. Jonas Jacobi and John R. Fallows. Apress 2006 234 10 APENDICE: CODIGO FUENTE APLICACIÓN WEB 10.1 BEANS (CONTROLADORES) 10.1.1 AGENCIA 10.1.1.1 ALTAAGENCIA.JAVA packagepfm.beans.agencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.AgenciaDAO; importpfm.entidades.Agencia; @ManagedBean(name="altaAgencia") @RequestScoped publicclassAltaAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; privateAgenciaagencia; publicAltaAgencia(){ } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } publicStringalta(){ try{ agencia.setEliminado(false); getAgenciaDAO().update(agencia); FacesMessagemsg=newFacesMessage("Agencia dada de alta", String.valueOf(agencia.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", 235 "Agencia no dada de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarAgencia"; } } 10.1.1.2 BAJAAGENCIA.JAVA packagepfm.beans.agencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.AgenciaDAO; importpfm.entidades.Agencia; @ManagedBean(name="bajaAgencia") @RequestScoped publicclassBajaAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; privateAgenciaagencia; publicBajaAgencia(){ } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } publicStringbaja(){ try{ agencia.setEliminado(true); getAgenciaDAO().update(agencia); FacesMessagemsg=newFacesMessage("Agencia dada de baja", String.valueOf(agencia.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); 236 }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Agencia no dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarAgencia"; } } 10.1.1.3 CREARAGENCIA.JAVA packagepfm.beans.agencia; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.AgenciaDAO; importpfm.dao.EmpresaDAO; importpfm.entidades.Agencia; importpfm.entidades.Empresa; @ManagedBean(name="crearAgencia") publicclassCrearAgenciaimplementsSerializable{ @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateAgenciaagencia=newAgencia(); privateSelectItem[]empresas; privateStringempresa; privatestaticfinallongserialVersionUID=1L; publicCrearAgencia(){ } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } 237 publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } publicSelectItem[]getEmpresas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Empresa>listaEmpresas=newArrayList<Empresa>(); listaEmpresas=empresaDAO.find(attributes,values,order,index,size); this.empresas=newSelectItem[listaEmpresas.size()]; for(Empresae:listaEmpresas){ this.empresas[i]=newSelectItem(e.getId(),e.getRazonSocial()); i++; } returnempresas; } publicvoidsetEmpresas(SelectItem[]empresas){ this.empresas=empresas; } publicStringgetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Stringempresa){ this.empresa=empresa; } publicStringcrear(){ try{ agencia.setEmpresa(empresaDAO.read(Integer.parseInt(getEmpresa()))); agenciaDAO.create(agencia); FacesMessagemsg=newFacesMessage("Agencia creada"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Agencia no creada"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarAgencia"; } } 10.1.1.4 LISTARAGENCIA.JAVA packagepfm.beans.agencia; importjava.io.Serializable; importjava.util.ArrayList; 238 importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; importpfm.dao.AgenciaDAO; importpfm.dao.EmpresaDAO; importpfm.entidades.Agencia; importpfm.entidades.Empresa; @ManagedBean(name="listarAgencia") @RequestScoped publicclassListarAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; @ManagedProperty(value="#{modificarAgencia}") privateModificarAgenciamodificarAgenciaBEAN; @ManagedProperty(value="#{altaAgencia}") privateAltaAgenciaaltaAgenciaBEAN; @ManagedProperty(value="#{bajaAgencia}") privateBajaAgenciabajaAgenciaBEAN; privateList<Agencia>lista; privateList<Agencia>filtered; privateSelectItem[]empresas; privateStringempresa; privateAgencia[]selectedAgencias; publicListarAgencia(){ } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicModificarAgenciagetModificarAgenciaBEAN(){ returnmodificarAgenciaBEAN; } publicvoidsetModificarAgenciaBEAN(ModificarAgenciamodificarAgenciaBEAN){ this.modificarAgenciaBEAN=modificarAgenciaBEAN; } publicAltaAgenciagetAltaAgenciaBEAN(){ returnaltaAgenciaBEAN; } 239 publicvoidsetAltaAgenciaBEAN(AltaAgenciaaltaAgenciaBEAN){ this.altaAgenciaBEAN=altaAgenciaBEAN; } publicBajaAgenciagetBajaAgenciaBEAN(){ returnbajaAgenciaBEAN; } publicvoidsetBajaAgenciaBEAN(BajaAgenciabajaAgenciaBEAN){ this.bajaAgenciaBEAN=bajaAgenciaBEAN; } publicList<Agencia>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(agenciaDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Agencia>lista){ this.lista=lista; } publicList<Agencia>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Agencia>filtered){ this.filtered=filtered; } publicSelectItem[]getEmpresas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Empresa>listaEmpresas=newArrayList<Empresa>(); listaEmpresas=empresaDAO.find(attributes,values,order,index,size); this.empresas=newSelectItem[listaEmpresas.size()]; for(Empresae:listaEmpresas){ this.empresas[i]=newSelectItem(e.getId(),e.getRazonSocial()); i++; } returnempresas; } publicvoidsetEmpresas(SelectItem[]empresas){ this.empresas=empresas; } publicStringgetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Stringempresa){ this.empresa=empresa; } publicAgencia[]getSelectedAgencias(){ returnselectedAgencias; } 240 publicvoidsetSelectedAgencias(Agencia[]selectedAgencias){ this.selectedAgencias=selectedAgencias; } publicStringonCrear(){ return"crearAgencia"; } publicvoidonModificar(RowEditEventevent){ Agenciaagencia=newAgencia(); agencia=(Agencia)event.getObject(); agencia.setEmpresa(empresaDAO.read(Integer.parseInt(getEmpresa()))); modificarAgenciaBEAN.setAgencia(agencia); modificarAgenciaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Agencia cancelada", String.valueOf(((Agencia)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedAgencias.length>0){ for(Agenciaa:selectedAgencias){ bajaAgenciaBEAN.setAgencia(a); bajaAgenciaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas agencias"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpresa"; } publicStringonAlta(){ if(selectedAgencias.length>0){ for(Agenciaa:selectedAgencias){ altaAgenciaBEAN.setAgencia(a); altaAgenciaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas agencias"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpresa"; } } 10.1.1.5 MODIFICARAGENCIA.JAVA packagepfm.beans.agencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; 241 importpfm.dao.AgenciaDAO; importpfm.entidades.Agencia; @ManagedBean(name="modificarAgencia") @RequestScoped publicclassModificarAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; privateAgenciaagencia; publicModificarAgencia(){ } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } publicStringmodificar(){ try{ getAgenciaDAO().update(agencia); FacesMessagemsg=newFacesMessage("Agencia actualizada", String.valueOf(agencia.getId())); FacesContext.getCurrentInstance().addMessage(null, msg); } catch (Exception e) { FacesMessage msg = new FacesMessage("Error", "Agencia no actualizada"); FacesContext.getCurrentInstance().addMessage(null, msg); FacesContext.getCurrentInstance().validationFailed(); } return "listarAgencia"; } } 10.1.2 BODEGADETALLE 10.1.2.1 MODIFICARBODEGADETALLE.JAVA packagepfm.beans.bodegaDetalle; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDetalleDAO; importpfm.entidades.BodegaDetalle; @ManagedBean(name="modificarBodegaDetalle") 242 @RequestScoped publicclassModificarBodegaDetalleimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDetalleDAO}") privateBodegaDetalleDAObodegaDetalleDAO; privateBodegaDetallebodegaDetalle; publicModificarBodegaDetalle(){ } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicBodegaDetallegetBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(BodegaDetallebodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } publicStringmodificar(){ try{ getBodegaDetalleDAO().update(bodegaDetalle); FacesMessagemsg=newFacesMessage( "Producto por Bodega actualizado", String.valueOf(bodegaDetalle.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto por Bodega no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodegaDetalle"; } } 10.1.2.2 ALTABODEGADETALLE.JAVA packagepfm.beans.bodegaDetalle; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDetalleDAO; importpfm.entidades.BodegaDetalle; 243 @ManagedBean(name="altaBodegaDetalle") @RequestScoped publicclassAltaBodegaDetalleimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDetalleDAO}") privateBodegaDetalleDAObodegaDetalleDAO; privateBodegaDetallebodegaDetalle; publicAltaBodegaDetalle(){ } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicBodegaDetallegetBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(BodegaDetallebodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } publicStringalta(){ try{ bodegaDetalle.setEliminado(false); getBodegaDetalleDAO().update(bodegaDetalle); FacesMessagemsg=newFacesMessage( "Producto por Bodega dado de alta", String.valueOf(bodegaDetalle.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto por Bodega no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodegaDetalle"; } } 10.1.2.3 BAJABODEGADETALLE.JAVA packagepfm.beans.bodegaDetalle; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDetalleDAO; importpfm.entidades.BodegaDetalle; @ManagedBean(name="bajaBodegaDetalle") @RequestScoped publicclassBajaBodegaDetalleimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDetalleDAO}") 244 privateBodegaDetalleDAObodegaDetalleDAO; privateBodegaDetallebodegaDetalle; publicBajaBodegaDetalle(){ } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicBodegaDetallegetBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(BodegaDetallebodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } publicStringbaja(){ try{ bodegaDetalle.setEliminado(true); getBodegaDetalleDAO().update(bodegaDetalle); FacesMessagemsg=newFacesMessage( "Producto por Bodega dado de baja", String.valueOf(bodegaDetalle.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto por Bodega no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodegaDetalle"; } } 10.1.2.4 CREARBODEGADETALLE.JAVA packagepfm.beans.bodegaDetalle; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.BodegaDAO; importpfm.dao.BodegaDetalleDAO; importpfm.dao.ProductoDAO; importpfm.entidades.Bodega; importpfm.entidades.BodegaDetalle; importpfm.entidades.Producto; @ManagedBean(name="crearBodegaDetalle") publicclassCrearBodegaDetalleimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDetalleDAO}") privateBodegaDetalleDAObodegaDetalleDAO; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; 245 @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateBodegaDetallebodegaDetalle=newBodegaDetalle(); privateSelectItem[]bodegas; privateSelectItem[]productos; privateStringbodega; privateStringproducto; publicCrearBodegaDetalle(){ } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicBodegaDetallegetBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(BodegaDetallebodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } publicSelectItem[]getBodegas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Bodega>listaBodegas=newArrayList<Bodega>(); listaBodegas=bodegaDAO.find(attributes,values,order,index,size); this.bodegas=newSelectItem[listaBodegas.size()]; for(Bodegab:listaBodegas){ this.bodegas[i]=newSelectItem(b.getId(),b.getNombre()); i++; } returnbodegas; } publicvoidsetBodegas(SelectItem[]bodegas){ this.bodegas=bodegas; } publicSelectItem[]getProductos(){ String[]attributes={"eliminado"}; String[]values={"0"}; 246 Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Producto>listaProductos=newArrayList<Producto>(); listaProductos=productoDAO.find(attributes,values,order,index, size); this.productos=newSelectItem[listaProductos.size()]; for(Productop:listaProductos){ this.productos[i]=newSelectItem(p.getId(),p.getNombre()); i++; } returnproductos; } publicvoidsetProductos(SelectItem[]productos){ this.productos=productos; } publicStringgetBodega(){ returnbodega; } publicvoidsetBodega(Stringbodega){ this.bodega=bodega; } publicStringgetProducto(){ return producto; } publicvoidsetProducto(Stringproducto){ this.producto=producto; } publicStringcrear(){ try{ bodegaDetalle.setBodega(bodegaDAO.read(Integer .parseInt(getBodega()))); bodegaDetalle.setProducto(productoDAO.read(Integer .parseInt(getProducto()))); bodegaDetalleDAO.create(bodegaDetalle); FacesMessagemsg=newFacesMessage("Producto por Bodega FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ creado"); FacesMessagemsg=newFacesMessage("Error", "Producto por Bodega no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarBodegaDetalle"; } } 10.1.2.5 LISTARBODEGADETALLE.JAVA packagepfm.beans.bodegaDetalle; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; 247 importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.BodegaDetalleDAO; importpfm.entidades.BodegaDetalle; @ManagedBean(name="listarBodegaDetalle") @RequestScoped publicclassListarBodegaDetalleimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDetalleDAO}") privateBodegaDetalleDAObodegaDetalleDAO; @ManagedProperty(value="#{modificarBodegaDetalle}") privateModificarBodegaDetallemodificarBodegaDetalleBEAN; @ManagedProperty(value="#{bajaBodegaDetalle}") privateBajaBodegaDetallebajaBodegaDetalleBEAN; @ManagedProperty(value="#{altaBodegaDetalle}") privateAltaBodegaDetallealtaBodegaDetalleBEAN; privateList<BodegaDetalle>lista; privateList<BodegaDetalle>filtered; privateBodegaDetalle[]selectedBodegaDetalle; publicListarBodegaDetalle(){ } publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnbodegaDetalleDAO; } publicvoidsetBodegaDetalleDAO(BodegaDetalleDAObodegaDetalleDAO){ this.bodegaDetalleDAO=bodegaDetalleDAO; } publicModificarBodegaDetallegetModificarBodegaDetalleBEAN(){ returnmodificarBodegaDetalleBEAN; } publicvoidsetModificarBodegaDetalleBEAN( ModificarBodegaDetallemodificarBodegaDetalleBEAN){ this.modificarBodegaDetalleBEAN=modificarBodegaDetalleBEAN; } publicBajaBodegaDetallegetBajaBodegaDetalleBEAN(){ returnbajaBodegaDetalleBEAN; } publicvoidsetBajaBodegaDetalleBEAN(BajaBodegaDetallebajaBodegaDetalleBEAN){ this.bajaBodegaDetalleBEAN=bajaBodegaDetalleBEAN; } publicAltaBodegaDetallegetAltaBodegaDetalleBEAN(){ returnaltaBodegaDetalleBEAN; } publicvoidsetAltaBodegaDetalleBEAN(AltaBodegaDetallealtaBodegaDetalleBEAN){ this.altaBodegaDetalleBEAN=altaBodegaDetalleBEAN; } publicList<BodegaDetalle>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; 248 setLista(bodegaDetalleDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<BodegaDetalle>lista){ this.lista=lista; } publicList<BodegaDetalle>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<BodegaDetalle>filtered){ this.filtered=filtered; } publicBodegaDetalle[]getSelectedBodegaDetalle(){ returnselectedBodegaDetalle; } publicvoidsetSelectedBodegaDetalle(BodegaDetalle[]selectedBodegaDetalle){ this.selectedBodegaDetalle=selectedBodegaDetalle; } publicStringonCrear(){ return"crearBodegaDetalle"; } publicvoidonModificar(RowEditEventevent){ modificarBodegaDetalleBEAN.setBodegaDetalle((BodegaDetalle)event .getObject()); modificarBodegaDetalleBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Bodega cancelada", String.valueOf(((BodegaDetalle)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedBodegaDetalle.length>0){ for(BodegaDetalleb:selectedBodegaDetalle){ bajaBodegaDetalleBEAN.setBodegaDetalle(b); bajaBodegaDetalleBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas productos por bodega"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarBodegaDetalle"; } publicStringonAlta(){ if(selectedBodegaDetalle.length>0){ for(BodegaDetalleb:selectedBodegaDetalle){ altaBodegaDetalleBEAN.setBodegaDetalle(b); altaBodegaDetalleBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas productos por bodega"); FacesContext.getCurrentInstance().addMessage(null,msg); 249 } return"listarBodegaDetalle"; } } 10.1.3 BODEGA 10.1.3.1 LISTARBODEGA.JAVA packagepfm.beans.bodega; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; importpfm.dao.AgenciaDAO; importpfm.dao.BodegaDAO; importpfm.entidades.Agencia; importpfm.entidades.Bodega; @ManagedBean(name="listarBodega") @RequestScoped publicclassListarBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{modificarBodega}") privateModificarBodegamodificarBodegaBEAN; @ManagedProperty(value="#{altaBodega}") privateAltaBodegaaltaBodegaBEAN; @ManagedProperty(value="#{bajaBodega}") privateBajaBodegabajaBodegaBEAN; privateList<Bodega>lista; privateList<Bodega>filtered; privateSelectItem[]agencias; privateStringagencia; privateBodega[]selectedBodegas; publicListarBodega(){ } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } 250 publicModificarBodegagetModificarBodegaBEAN(){ returnmodificarBodegaBEAN; } publicvoidsetModificarBodegaBEAN(ModificarBodegamodificarBodegaBEAN){ this.modificarBodegaBEAN=modificarBodegaBEAN; } publicAltaBodegagetAltaBodegaBEAN(){ returnaltaBodegaBEAN; } publicvoidsetAltaBodegaBEAN(AltaBodegaaltaBodegaBEAN){ this.altaBodegaBEAN=altaBodegaBEAN; } publicBajaBodegagetBajaBodegaBEAN(){ returnbajaBodegaBEAN; } publicvoidsetBajaBodegaBEAN(BajaBodegabajaBodegaBEAN){ this.bajaBodegaBEAN=bajaBodegaBEAN; } publicList<Bodega>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(bodegaDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Bodega>lista){ this.lista=lista; } publicList<Bodega>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Bodega>filtered){ this.filtered=filtered; } publicSelectItem[]getAgencias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Agencia>listaAgencias=newArrayList<Agencia>(); listaAgencias=agenciaDAO.find(attributes,values,order,index,size); this.agencias=newSelectItem[listaAgencias.size()]; for(Agenciaa:listaAgencias){ this.agencias[i]=newSelectItem(a.getId(),a.getNombre()); i++; } return agencias; } publicvoidsetAgencias(SelectItem[]agencias){ this.agencias=agencias; } 251 publicStringgetAgencia(){ returnagencia; } publicvoidsetAgencia(Stringagencia){ this.agencia=agencia; } publicBodega[]getSelectedBodegas(){ returnselectedBodegas; } publicvoidsetSelectedBodegas(Bodega[]selectedBodegas){ this.selectedBodegas=selectedBodegas; } publicStringonCrear(){ return"crearBodega"; } publicvoidonModificar(RowEditEventevent){ Bodegabodega=newBodega(); bodega=(Bodega)event.getObject(); bodega.setAgencia(agenciaDAO.read(Integer.parseInt(getAgencia()))); modificarBodegaBEAN.setBodega(bodega); modificarBodegaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Bodega cancelada", String.valueOf(((Bodega)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedBodegas.length>0){ for(Bodegab:selectedBodegas){ bajaBodegaBEAN.setBodega(b); bajaBodegaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas bodegas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarBodega"; } publicStringonAlta(){ if(selectedBodegas.length>0){ for(Bodegab:selectedBodegas){ altaBodegaBEAN.setBodega(b); altaBodegaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas bodegas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarBodega"; } } 252 10.1.3.2 CREARBODEGA.JAVA packagepfm.beans.bodega; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.AgenciaDAO; importpfm.dao.BodegaDAO; importpfm.entidades.Agencia; importpfm.entidades.Bodega; @ManagedBean(name="crearBodega") publicclassCrearBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; privateBodegabodega=newBodega(); privateSelectItem[]agencias; privateStringagencia; publicCrearBodega(){ } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicBodegagetBodega(){ returnbodega; } publicvoidsetBodega(Bodegabodega){ this.bodega=bodega; } publicSelectItem[]getAgencias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Agencia>listaAgencias=newArrayList<Agencia>(); listaAgencias=agenciaDAO.find(attributes,values,order,index,size); 253 this.agencias=newSelectItem[listaAgencias.size()]; for(Agenciaa:listaAgencias){ this.agencias[i]=newSelectItem(a.getId(),a.getNombre()); i++; } returnagencias; } publicvoidsetAgencias(SelectItem[]agencias){ this.agencias=agencias; } publicStringgetAgencia(){ returnagencia; } publicvoidsetAgencia(Stringagencia){ this.agencia=agencia; } publicStringcrear(){ try{ bodega.setAgencia(agenciaDAO.read(Integer.parseInt(getAgencia()))); bodegaDAO.create(bodega); FacesMessagemsg=newFacesMessage("Bodega creada"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Bodega no creada"); FacesContext.getCurrentInstance().addMessage(null, msg); } return "listarBodega"; } } 10.1.3.3 BAJABODEGA.JAVA packagepfm.beans.bodega; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDAO; importpfm.entidades.Bodega; @ManagedBean(name="bajaBodega") @RequestScoped publicclassBajaBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; privateBodegabodega; publicBajaBodega(){ } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } 254 publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicBodegagetBodega(){ returnbodega; } publicvoidsetBodega(Bodegabodega){ this.bodega=bodega; } publicStringbaja(){ try{ bodega.setEliminado(true); getBodegaDAO().update(bodega); FacesMessagemsg=newFacesMessage("Bodega dada de baja", String.valueOf(bodega.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Bodega no dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodega"; } } 10.1.3.4 ALTABODEGA.JAVA packagepfm.beans.bodega; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDAO; importpfm.entidades.Bodega; @ManagedBean(name="altaBodega") @RequestScoped publicclassAltaBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; privateBodegabodega; publicAltaBodega(){ } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicBodegagetBodega(){ returnbodega; } 255 publicvoidsetBodega(Bodegabodega){ this.bodega=bodega; } publicStringalta(){ try{ bodega.setEliminado(false); getBodegaDAO().update(bodega); FacesMessagemsg=newFacesMessage("Bodega dada de alta", String.valueOf(bodega.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Bodega no dada de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodega"; } } 10.1.3.5 MODIFICARBODEGA.JAVA packagepfm.beans.bodega; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.BodegaDAO; importpfm.entidades.Bodega; @ManagedBean(name="modificarBodega") @RequestScoped publicclassModificarBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.bodegaDAO}") privateBodegaDAObodegaDAO; privateBodegabodega; publicModificarBodega(){ } publicBodegaDAOgetBodegaDAO(){ returnbodegaDAO; } publicvoidsetBodegaDAO(BodegaDAObodegaDAO){ this.bodegaDAO=bodegaDAO; } publicBodegagetBodega(){ returnbodega; } publicvoidsetBodega(Bodegabodega){ this.bodega=bodega; } publicStringmodificar(){ try{ getBodegaDAO().update(bodega); FacesMessagemsg=newFacesMessage("Bodega String.valueOf(bodega.getId())); actualizada", 256 FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Bodega no actualizada"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarBodega"; } } 10.1.4 CATEGORIA 10.1.4.1 LISTARCATEGORIA.JAVA packagepfm.beans.categoria; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; @ManagedBean(name="listarCategoria") @RequestScoped publicclassListarCategoriaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; @ManagedProperty(value="#{modificarCategoria}") privateModificarCategoriamodificarCategoriaBEAN; @ManagedProperty(value="#{bajaCategoria}") privateBajaCategoriabajaCategoriaBEAN; @ManagedProperty(value="#{altaCategoria}") privateAltaCategoriaaltaCategoriaBEAN; privateList<Categoria>lista; privateList<Categoria>filtered; privateCategoria[]selectedCategorias; publicListarCategoria(){ } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicModificarCategoriagetModificarCategoriaBEAN(){ returnmodificarCategoriaBEAN; } publicvoidsetModificarCategoriaBEAN(ModificarCategoriamodificarCategoriaBEAN){ this.modificarCategoriaBEAN=modificarCategoriaBEAN; } 257 publicBajaCategoriagetBajaCategoriaBEAN(){ returnbajaCategoriaBEAN; } publicvoidsetBajaCategoriaBEAN(BajaCategoriabajaCategoriaBEAN){ this.bajaCategoriaBEAN=bajaCategoriaBEAN; } publicAltaCategoriagetAltaCategoriaBEAN(){ returnaltaCategoriaBEAN; } publicvoidsetAltaCategoriaBEAN(AltaCategoriaaltaCategoriaBEAN){ this.altaCategoriaBEAN=altaCategoriaBEAN; } publicList<Categoria>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(categoriaDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Categoria>lista){ this.lista=lista; } publicList<Categoria>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Categoria>filtered){ this.filtered=filtered; } publicCategoria[]getSelectedCategorias(){ returnselectedCategorias; } publicvoidsetSelectedCategorias(Categoria[]selectedCategorias){ this.selectedCategorias=selectedCategorias; } publicStringonCrear(){ return"crearCategoria"; } publicvoidonModificar(RowEditEventevent){ modificarCategoriaBEAN.setCategoria((Categoria)event.getObject()); modificarCategoriaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Categoria cancelada", String.valueOf(((Categoria)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedCategorias.length>0){ for(Categoriae:selectedCategorias){ bajaCategoriaBEAN.setCategoria(e); 258 bajaCategoriaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas categorias"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarCategoria"; } publicStringonAlta(){ if(selectedCategorias.length>0){ for(Categoriae:selectedCategorias){ altaCategoriaBEAN.setCategoria(e); altaCategoriaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas categorias"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarCategoria"; } } 10.1.4.2 CREARCATEGORIA.JAVA packagepfm.beans.categoria; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; @ManagedBean(name="crearCategoria") publicclassCrearCategoriaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateCategoriacategoria=newCategoria(); publicCrearCategoria(){ } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicCategoriagetCategoria(){ returncategoria; } publicvoidsetCategoria(Categoriacategoria){ this.categoria=categoria; } publicStringcrear(){ 259 try{ categoriaDAO.create(categoria); FacesMessagemsg=newFacesMessage("Categoria creada"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Categoria no FacesContext.getCurrentInstance().addMessage(null,msg); } creada"); return"listarCategoria"; } } 10.1.4.3 BAJACATEGORIA.JAVA packagepfm.beans.categoria; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; @ManagedBean(name="bajaCategoria") @RequestScoped publicclassBajaCategoriaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateCategoriacategoria; publicBajaCategoria(){ } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicCategoriagetCategoria(){ returncategoria; } publicvoidsetCategoria(Categoriacategoria){ this.categoria=categoria; } publicStringbaja(){ try{ categoria.setEliminado(true); getCategoriaDAO().update(categoria); FacesMessagemsg=newFacesMessage("Categoria baja",String.valueOf(categoria.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Categoria no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); dada de dada de baja"); 260 } return"listarCategoria"; } } 10.1.4.4 ALTACATEGORIA.JAVA packagepfm.beans.categoria; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; @ManagedBean(name="altaCategoria") @RequestScoped publicclassAltaCategoriaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateCategoriacategoria; publicAltaCategoria(){ } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicCategoriagetCategoria(){ returncategoria; } publicvoidsetCategoria(Categoriacategoria){ this.categoria=categoria; } publicStringalta(){ try{ categoria.setEliminado(false); getCategoriaDAO().update(categoria); FacesMessagemsg=newFacesMessage("Categoria alta",String.valueOf(categoria.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Categoria no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarCategoria"; } } dada de dada de alta"); 10.1.4.5 MODIFICARCATEGORIA.JAVA packagepfm.beans.categoria; importjava.io.Serializable; 261 importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; @ManagedBean(name="modificarCategoria") @RequestScoped publicclassModificarCategoriaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateCategoriacategoria; publicModificarCategoria(){ } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicCategoriagetCategoria(){ returncategoria; } publicvoidsetCategoria(Categoriacategoria){ this.categoria=categoria; } publicStringmodificar(){ try{ getCategoriaDAO().update(categoria); FacesMessagemsg=newFacesMessage("Categoria actualizada",String.valueOf(categoria.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Categoria no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarCategoria"; } } actualizada"); 10.1.5 DESCUENTO 10.1.5.1 LISTARDESCUENTO.JAVA packagepfm.beans.descuento; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; 262 importorg.primefaces.event.RowEditEvent; importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; @ManagedBean(name="listarDescuento") @RequestScoped publicclassListarDescuentoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; @ManagedProperty(value="#{modificarDescuento}") privateModificarDescuentomodificarDescuentoBEAN; @ManagedProperty(value="#{bajaDescuento}") privateBajaDescuentobajaDescuentoBEAN; @ManagedProperty(value="#{altaDescuento}") privateAltaDescuentoaltaDescuentoBEAN; privateList<Descuento>lista; privateList<Descuento>filtered; privateDescuento[]selectedDescuentos; publicListarDescuento(){ } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicModificarDescuentogetModificarDescuentoBEAN(){ returnmodificarDescuentoBEAN; } publicvoidsetModificarDescuentoBEAN( ModificarDescuentomodificarDescuentoBEAN){ this.modificarDescuentoBEAN=modificarDescuentoBEAN; } publicBajaDescuentogetBajaDescuentoBEAN(){ returnbajaDescuentoBEAN; } publicvoidsetBajaDescuentoBEAN(BajaDescuentobajaDescuentoBEAN){ this.bajaDescuentoBEAN=bajaDescuentoBEAN; } publicAltaDescuentogetAltaDescuentoBEAN(){ returnaltaDescuentoBEAN; } publicvoidsetAltaDescuentoBEAN(AltaDescuentoaltaDescuentoBEAN){ this.altaDescuentoBEAN=altaDescuentoBEAN; } publicList<Descuento>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(descuentoDAO.find(attributes,values,order,index,size)); returnlista; } 263 publicvoidsetLista(List<Descuento>lista){ this.lista=lista; } publicList<Descuento>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Descuento>filtered){ this.filtered=filtered; } publicDescuento[]getSelectedDescuentos(){ returnselectedDescuentos; } publicvoidsetSelectedDescuentos(Descuento[]selectedDescuentos){ this.selectedDescuentos=selectedDescuentos; } publicStringonCrear(){ return"crearDescuento"; } publicvoidonModificar(RowEditEventevent){ modificarDescuentoBEAN.setDescuento((Descuento)event.getObject()); modificarDescuentoBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Descuento cancelada", String.valueOf(((Descuento)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedDescuentos.length>0){ for(Descuentod:selectedDescuentos){ bajaDescuentoBEAN.setDescuento(d); bajaDescuentoBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas descuentos"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuento"; } publicStringonAlta(){ if(selectedDescuentos.length>0){ for(Descuentod:selectedDescuentos){ altaDescuentoBEAN.setDescuento(d); altaDescuentoBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas descuentos"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuento"; } } 264 10.1.5.2 CREARDESCUENTO.JAVA packagepfm.beans.descuento; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; @ManagedBean(name="crearDescuento") publicclassCrearDescuentoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; privateDescuentodescuento=newDescuento(); publicCrearDescuento(){ } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicDescuentogetDescuento(){ returndescuento; } publicvoidsetDescuento(Descuentodescuento){ this.descuento=descuento; } publicStringcrear(){ if(descuento.getFechaInicio().before(descuento.getFechaFin()) ||descuento.getFechaInicio().equals(descuento.getFechaFin())){ try{ descuentoDAO.create(descuento); FacesMessagemsg=newFacesMessage("Descuento creado"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuento"; }else{ FacesMessagemsg=newFacesMessage("Error", "La fecha de inicio debe ser menor a la de fin"); FacesContext.getCurrentInstance().addMessage(null,msg); return"crearDesccuento"; } } } 265 10.1.5.3 BAJADESCUENTO.JAVA packagepfm.beans.descuento; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; @ManagedBean(name="bajaDescuento") @RequestScoped publicclassBajaDescuentoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; privateDescuentodescuento; publicBajaDescuento(){ } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicDescuentogetDescuento(){ returndescuento; } publicvoidsetDescuento(Descuentodescuento){ this.descuento=descuento; } publicStringbaja(){ try{ descuento.setEliminado(true); getDescuentoDAO().update(descuento); FacesMessagemsg=newFacesMessage("Descuento dado de String.valueOf(descuento.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuento"; } baja", } 10.1.5.4 ALTADESCUENTO.JAVA packagepfm.beans.descuento; importjava.io.Serializable; 266 importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; @ManagedBean(name="altaDescuento") @RequestScoped publicclassAltaDescuentoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; privateDescuentodescuento; publicAltaDescuento(){ } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicDescuentogetDescuento(){ returndescuento; } publicvoidsetDescuento(Descuentodescuento){ this.descuento=descuento; } publicStringalta(){ try{ descuento.setEliminado(false); getDescuentoDAO().update(descuento); FacesMessagemsg=newFacesMessage("Descuento dado de String.valueOf(descuento.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuento"; } } alta", 10.1.5.5 MODIFICARDESCUENTO.JAVA packagepfm.beans.descuento; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; 267 importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; @ManagedBean(name="modificarDescuento") @RequestScoped publicclassModificarDescuentoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; privateDescuentodescuento; publicModificarDescuento(){ } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicDescuentogetDescuento(){ returndescuento; } publicvoidsetDescuento(Descuentodescuento){ this.descuento=descuento; } publicStringmodificar(){ try{ getDescuentoDAO().update(descuento); FacesMessagemsg=newFacesMessage("Descuento actualizado", String.valueOf(descuento.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuento"; } } 10.1.6 DESCUENTOPRODUCTO 10.1.6.1 LISTARDESCUENTOPRODUCTO.JAVA packagepfm.beans.descuentoProducto; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; 268 importpfm.dao.DescuentoDAO; importpfm.dao.DescuentoProductoDAO; importpfm.dao.ProductoDAO; importpfm.entidades.Descuento; importpfm.entidades.DescuentoProducto; importpfm.entidades.Producto; @ManagedBean(name="listarDescuentoProducto") @RequestScoped publicclassListarDescuentoProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoProductoDAO}") privateDescuentoProductoDAOdescuentoProductoDAO; @ManagedProperty(value="#{modificarDescuentoProducto}") privateModificarDescuentoProductomodificarDescuentoProductoBEAN; @ManagedProperty(value="#{bajaDescuentoProducto}") privateBajaDescuentoProductobajaDescuentoProductoBEAN; @ManagedProperty(value="#{altaDescuentoProducto}") privateAltaDescuentoProductoaltaDescuentoProductoBEAN; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateList<DescuentoProducto>lista; privateList<DescuentoProducto>filtered; privateDescuentoProducto[]selectedDescuentoProducto; privateSelectItem[]descuentos; privateSelectItem[]productos; privateStringdescuento; privateStringproducto; publicListarDescuentoProducto(){ } publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returndescuentoProductoDAO; } publicvoidsetDescuentoProductoDAO( DescuentoProductoDAOdescuentoProductoDAO){ this.descuentoProductoDAO=descuentoProductoDAO; } publicModificarDescuentoProductogetModificarDescuentoProductoBEAN(){ returnmodificarDescuentoProductoBEAN; } publicvoidsetModificarDescuentoProductoBEAN( ModificarDescuentoProductomodificarDescuentoProductoBEAN){ this.modificarDescuentoProductoBEAN=modificarDescuentoProductoBEAN; } publicBajaDescuentoProductogetBajaDescuentoProductoBEAN(){ returnbajaDescuentoProductoBEAN; } publicvoidsetBajaDescuentoProductoBEAN( BajaDescuentoProductobajaDescuentoProductoBEAN){ this.bajaDescuentoProductoBEAN=bajaDescuentoProductoBEAN; } publicAltaDescuentoProductogetAltaDescuentoProductoBEAN(){ returnaltaDescuentoProductoBEAN; } publicvoidsetAltaDescuentoProductoBEAN( AltaDescuentoProductoaltaDescuentoProductoBEAN){ 269 this.altaDescuentoProductoBEAN=altaDescuentoProductoBEAN; } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicList<DescuentoProducto>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(descuentoProductoDAO.find(attributes,values,order,index, size)); returnlista; } publicvoidsetLista(List<DescuentoProducto>lista){ this.lista=lista; } publicList<DescuentoProducto>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<DescuentoProducto>filtered){ this.filtered=filtered; } publicDescuentoProducto[]getSelectedDescuentoProducto(){ returnselectedDescuentoProducto; } publicvoidsetSelectedDescuentoProducto( DescuentoProducto[]selectedDescuentoProducto){ this.selectedDescuentoProducto=selectedDescuentoProducto; } publicSelectItem[]getDescuentos(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Descuento>listaDescuentos=newArrayList<Descuento>(); listaDescuentos=descuentoDAO.find(attributes,values,order,index, size); this.descuentos=newSelectItem[listaDescuentos.size()]; for(Descuentod:listaDescuentos){ this.descuentos[i]=newSelectItem(d.getId(),d.getNombre()); i++; } returndescuentos; 270 } publicvoidsetDescuentos(SelectItem[]descuentos){ this.descuentos=descuentos; } publicSelectItem[]getProductos(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Producto>listaProductos=newArrayList<Producto>(); listaProductos=productoDAO.find(attributes,values,order,index, size); this.productos=newSelectItem[listaProductos.size()]; for(Productop:listaProductos){ this.productos[i]=newSelectItem(p.getId(),p.getNombre()); i++; } returnproductos; } publicvoidsetProductos(SelectItem[]productos){ this.productos=productos; } publicStringgetDescuento(){ returndescuento; } publicvoidsetDescuento(Stringdescuento){ this.descuento=descuento; } publicStringgetProducto(){ returnproducto; } publicvoidsetProducto(Stringproducto){ this.producto=producto; } publicStringonCrear(){ return"crearDescuentoProducto"; } publicvoidonModificar(RowEditEventevent){ DescuentoProductod=newDescuentoProducto(); d=(DescuentoProducto)event.getObject(); d.setDescuento(descuentoDAO.read(Integer.parseInt(getDescuento()))); d.setProducto(productoDAO.read(Integer.parseInt(getProducto()))); modificarDescuentoProductoBEAN.setDescuentoProducto(d); modificarDescuentoProductoBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Descuento por Producto cancelada", String.valueOf(((DescuentoProducto)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ 271 if(selectedDescuentoProducto.length>0){ for(DescuentoProductod:selectedDescuentoProducto){ bajaDescuentoProductoBEAN.setDescuentoProducto(d); bajaDescuentoProductoBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas descuentos por producto"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuentoProducto"; } publicStringonAlta(){ if(selectedDescuentoProducto.length>0){ for(DescuentoProductod:selectedDescuentoProducto){ altaDescuentoProductoBEAN.setDescuentoProducto(d); altaDescuentoProductoBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas descuentos por producto"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuentoProducto"; } } 10.1.6.2 CREARDESCUENTOPRODUCTO.JAVA packagepfm.beans.descuentoProducto; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.DescuentoDAO; importpfm.dao.DescuentoProductoDAO; importpfm.dao.ProductoDAO; importpfm.entidades.Descuento; importpfm.entidades.DescuentoProducto; importpfm.entidades.Producto; @ManagedBean(name="crearDescuentoProducto") publicclassCrearDescuentoProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoProductoDAO}") privateDescuentoProductoDAOdescuentoProductoDAO; @ManagedProperty(value="#{DAOFactory.descuentoDAO}") privateDescuentoDAOdescuentoDAO; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateDescuentoProductodescuentoProducto=newDescuentoProducto(); privateSelectItem[]descuentos; privateSelectItem[]productos; privateStringdescuento; privateStringproducto; publicCrearDescuentoProducto(){ } 272 publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returndescuentoProductoDAO; } publicvoidsetDescuentoProductoDAO( DescuentoProductoDAOdescuentoProductoDAO){ this.descuentoProductoDAO=descuentoProductoDAO; } publicDescuentoDAOgetDescuentoDAO(){ returndescuentoDAO; } publicvoidsetDescuentoDAO(DescuentoDAOdescuentoDAO){ this.descuentoDAO=descuentoDAO; } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicDescuentoProductogetDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(DescuentoProductodescuentoProducto){ this.descuentoProducto=descuentoProducto; } publicSelectItem[]getDescuentos(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Descuento>listaDescuentos=newArrayList<Descuento>(); listaDescuentos=descuentoDAO.find(attributes,values,order,index, size); this.descuentos=newSelectItem[listaDescuentos.size()]; for(Descuentod:listaDescuentos){ this.descuentos[i]=newSelectItem(d.getId(),d.getNombre()); i++; } returndescuentos; } publicvoidsetDescuentos(SelectItem[]descuentos){ this.descuentos=descuentos; } publicSelectItem[]getProductos(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Producto>listaProductos=newArrayList<Producto>(); 273 listaProductos=productoDAO.find(attributes,values,order,index, size); this.productos=newSelectItem[listaProductos.size()]; for(Productop:listaProductos){ this.productos[i]=newSelectItem(p.getId(),p.getNombre()); i++; } returnproductos; } publicvoidsetProductos(SelectItem[]productos){ this.productos=productos; } publicStringgetDescuento(){ returndescuento; } publicvoidsetDescuento(Stringdescuento){ this.descuento=descuento; } publicStringgetProducto(){ returnproducto; } publicvoidsetProducto(Stringproducto){ this.producto=producto; } publicStringcrear(){ try{ descuentoProducto.setDescuento(descuentoDAO.read(Integer .parseInt(getDescuento()))); descuentoProducto.setProducto(productoDAO.read(Integer .parseInt(getProducto()))); descuentoProductoDAO.create(descuentoProducto); FacesMessagemsg=newFacesMessage("Descuento por Producto FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ creado"); FacesMessagemsg=newFacesMessage("Error", "Descuento por Producto no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarDescuentoProducto"; } } 10.1.6.3 BAJADESCUENTOPRODUCTO.JAVA packagepfm.beans.descuentoProducto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoProductoDAO; importpfm.entidades.DescuentoProducto; @ManagedBean(name="bajaDescuentoProducto") @RequestScoped publicclassBajaDescuentoProductoimplementsSerializable{ 274 privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoProductoDAO}") privateDescuentoProductoDAOdescuentoProductoDAO; privateDescuentoProductodescuentoProducto; publicBajaDescuentoProducto(){ } publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returndescuentoProductoDAO; } publicvoidsetDescuentoProductoDAO( DescuentoProductoDAOdescuentoProductoDAO){ this.descuentoProductoDAO=descuentoProductoDAO; } publicDescuentoProductogetDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(DescuentoProductodescuentoProducto){ this.descuentoProducto=descuentoProducto; } publicStringbaja(){ try{ descuentoProducto.setEliminado(true); getDescuentoProductoDAO().update(descuentoProducto); FacesMessagemsg=newFacesMessage( "Descuento por Producto dado de baja", String.valueOf(descuentoProducto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento por Producto no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuentoProducto"; } } 10.1.6.4 ALTADESCUENTOPRODUCTO.JAVA packagepfm.beans.descuentoProducto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoProductoDAO; importpfm.entidades.DescuentoProducto; @ManagedBean(name="altaDescuentoProducto") @RequestScoped publicclassAltaDescuentoProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoProductoDAO}") privateDescuentoProductoDAOdescuentoProductoDAO; privateDescuentoProductodescuentoProducto; 275 publicAltaDescuentoProducto(){ } publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returndescuentoProductoDAO; } publicvoidsetDescuentoProductoDAO( DescuentoProductoDAOdescuentoProductoDAO){ this.descuentoProductoDAO=descuentoProductoDAO; } publicDescuentoProductogetDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(DescuentoProductodescuentoProducto){ this.descuentoProducto=descuentoProducto; } publicStringalta(){ try{ descuentoProducto.setEliminado(false); getDescuentoProductoDAO().update(descuentoProducto); FacesMessagemsg=newFacesMessage( "Descuento por Producto dado de alta", String.valueOf(descuentoProducto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento por Producto no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuentoProducto"; } } 10.1.6.5 MODIFICARDESCUENTOPRODUCTO.JAVA packagepfm.beans.descuentoProducto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.DescuentoProductoDAO; importpfm.entidades.DescuentoProducto; @ManagedBean(name="modificarDescuentoProducto") @RequestScoped publicclassModificarDescuentoProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.descuentoProductoDAO}") privateDescuentoProductoDAOdescuentoProductoDAO; privateDescuentoProductodescuentoProducto; publicModificarDescuentoProducto(){ } 276 publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returndescuentoProductoDAO; } publicvoidsetDescuentoProductoDAO( DescuentoProductoDAOdescuentoProductoDAO){ this.descuentoProductoDAO=descuentoProductoDAO; } publicDescuentoProductogetDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(DescuentoProductodescuentoProducto){ this.descuentoProducto=descuentoProducto; } publicStringmodificar(){ try{ getDescuentoProductoDAO().update(descuentoProducto); FacesMessagemsg=newFacesMessage( "Descuento por Producto actualizado", String.valueOf(descuentoProducto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Descuento por Producto no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarDescuentoProducto"; } } 10.1.7 EMPLEADOAGENCIA 10.1.7.1 LISTAREMPLEADOAGENCIA.JAVA packagepfm.beans.empleadoAgencia; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; importpfm.dao.AgenciaDAO; importpfm.dao.EmpleadoAgenciaDAO; importpfm.dao.RolDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.Agencia; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Rol; importpfm.entidades.Usuario; @ManagedBean(name="listarEmpleadoAgencia") @RequestScoped publicclassListarEmpleadoAgenciaimplementsSerializable{ 277 privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; @ManagedProperty(value="#{modificarEmpleadoAgencia}") privateModificarEmpleadoAgenciamodificarEmpleadoAgenciaBEAN; @ManagedProperty(value="#{altaEmpleadoAgencia}") privateAltaEmpleadoAgenciaaltaEmpleadoAgenciaBEAN; @ManagedProperty(value="#{bajaEmpleadoAgencia}") privateBajaEmpleadoAgenciabajaEmpleadoAgenciaBEAN; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOempleadoDAO; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateList<EmpleadoAgencia>lista; privateList<EmpleadoAgencia>filtered; privateSelectItem[]agencias; privateSelectItem[]empleados; privateStringagencia; privateStringempleado; privateEmpleadoAgencia[]selectedEmpleadoAgencia; publicListarEmpleadoAgencia(){ } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicModificarEmpleadoAgenciagetModificarEmpleadoAgenciaBEAN(){ returnmodificarEmpleadoAgenciaBEAN; } publicvoidsetModificarEmpleadoAgenciaBEAN( ModificarEmpleadoAgenciamodificarEmpleadoAgenciaBEAN){ this.modificarEmpleadoAgenciaBEAN=modificarEmpleadoAgenciaBEAN; } publicAltaEmpleadoAgenciagetAltaEmpleadoAgenciaBEAN(){ returnaltaEmpleadoAgenciaBEAN; } publicvoidsetAltaEmpleadoAgenciaBEAN( AltaEmpleadoAgenciaaltaEmpleadoAgenciaBEAN){ this.altaEmpleadoAgenciaBEAN=altaEmpleadoAgenciaBEAN; } publicBajaEmpleadoAgenciagetBajaEmpleadoAgenciaBEAN(){ returnbajaEmpleadoAgenciaBEAN; } publicvoidsetBajaEmpleadoAgenciaBEAN( BajaEmpleadoAgenciabajaEmpleadoAgenciaBEAN){ this.bajaEmpleadoAgenciaBEAN=bajaEmpleadoAgenciaBEAN; } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } 278 publicUsuarioDAOgetEmpleadoDAO(){ returnempleadoDAO; } publicvoidsetEmpleadoDAO(UsuarioDAOempleadoDAO){ this.empleadoDAO=empleadoDAO; } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicList<EmpleadoAgencia>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(empleadoAgenciaDAO .find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<EmpleadoAgencia>lista){ this.lista=lista; } publicList<EmpleadoAgencia>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<EmpleadoAgencia>filtered){ this.filtered=filtered; } publicSelectItem[]getAgencias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Agencia>listaAgencias=newArrayList<Agencia>(); listaAgencias=agenciaDAO.find(attributes,values,order,index,size); this.agencias=newSelectItem[listaAgencias.size()]; for(Agenciaa:listaAgencias){ this.agencias[i]=newSelectItem(a.getId(),a.getNombre()); i++; } returnagencias; } publicvoidsetAgencias(SelectItem[]agencias){ this.agencias=agencias; } publicSelectItem[]getEmpleados(){ inti=0; Rolrol=newRol(); rol=rolDAO.read(1);// el rol 1 debe ser de empleado List<Usuario>listaEmpleados=newArrayList<Usuario>(); 279 listaEmpleados=empleadoDAO.getEmpleado(rol,false); this.empleados=newSelectItem[listaEmpleados.size()]; for(Usuarioe:listaEmpleados){ this.empleados[i]=newSelectItem(e.getId(),e.toString()); i++; } returnempleados; } publicvoidsetEmpleados(SelectItem[]empleados){ this.empleados=empleados; } publicStringgetAgencia(){ returnagencia; } publicvoidsetAgencia(Stringagencia){ this.agencia=agencia; } publicStringgetEmpleado(){ returnempleado; } publicvoidsetEmpleado(Stringempleado){ this.empleado=empleado; } publicEmpleadoAgencia[]getSelectedEmpleadoAgencia(){ returnselectedEmpleadoAgencia; } publicvoidsetSelectedEmpleadoAgencia( EmpleadoAgencia[]selectedEmpleadoAgencia){ this.selectedEmpleadoAgencia=selectedEmpleadoAgencia; } publicStringonCrear(){ return"crearEmpleadoAgencia"; } publicvoidonModificar(RowEditEventevent){ EmpleadoAgenciae=newEmpleadoAgencia(); e=(EmpleadoAgencia)event.getObject(); e.setAgencia(agenciaDAO.read(Integer.parseInt(getAgencia()))); e.setEmpleado(empleadoDAO.read(Integer.parseInt(getEmpleado()))); modificarEmpleadoAgenciaBEAN.setEmpleadoAgencia(e); modificarEmpleadoAgenciaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Empleado por agencia cancelado", String.valueOf(((EmpleadoAgencia)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedEmpleadoAgencia.length>0){ for(EmpleadoAgenciae:selectedEmpleadoAgencia){ bajaEmpleadoAgenciaBEAN.setEmpleadoAgencia(e); bajaEmpleadoAgenciaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas empleados por agencia"); FacesContext.getCurrentInstance().addMessage(null,msg); 280 } return"listarEmpleadoAgencia"; } publicStringonAlta(){ if(selectedEmpleadoAgencia.length>0){ for(EmpleadoAgenciae:selectedEmpleadoAgencia){ altaEmpleadoAgenciaBEAN.setEmpleadoAgencia(e); altaEmpleadoAgenciaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas empleados por agencia"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpleadoAgencia"; } } 10.1.7.2 CREAREMPLEADOAGENCIA.JAVA packagepfm.beans.empleadoAgencia; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.AgenciaDAO; importpfm.dao.EmpleadoAgenciaDAO; importpfm.dao.RolDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.Agencia; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Rol; importpfm.entidades.Usuario; @ManagedBean(name="crearEmpleadoAgencia") publicclassCrearEmpleadoAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOempleadoDAO; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateEmpleadoAgenciaempleadoAgencia=newEmpleadoAgencia(); privateSelectItem[]agencias; privateSelectItem[]empleados; privateStringagencia; privateStringempleado; publicCrearEmpleadoAgencia(){ } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } 281 publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicUsuarioDAOgetEmpleadoDAO(){ returnempleadoDAO; } publicvoidsetEmpleadoDAO(UsuarioDAOempleadoDAO){ this.empleadoDAO=empleadoDAO; } publicstaticlonggetSerialversionuid(){ returnserialVersionUID; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicSelectItem[]getAgencias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Agencia>listaAgencias=newArrayList<Agencia>(); listaAgencias=agenciaDAO.find(attributes,values,order,index,size); this.agencias=newSelectItem[listaAgencias.size()]; for(Agenciaa:listaAgencias){ this.agencias[i]=newSelectItem(a.getId(),a.getNombre()); i++; } returnagencias; } publicvoidsetAgencias(SelectItem[]agencias){ this.agencias=agencias; } publicSelectItem[]getEmpleados(){ inti=0; Rolrol=newRol(); rol=rolDAO.read(1);//el rol 1 debe ser de empleado List<Usuario>listaEmpleados=newArrayList<Usuario>(); listaEmpleados=empleadoDAO.getEmpleado(rol,false); this.empleados=newSelectItem[listaEmpleados.size()]; for(Usuarioe:listaEmpleados){ this.empleados[i]=newSelectItem(e.getId(),e.toString()); i++; } 282 returnempleados; } publicvoidsetEmpleados(SelectItem[]empleados){ this.empleados=empleados; } publicStringgetAgencia(){ returnagencia; } publicvoidsetAgencia(Stringagencia){ this.agencia=agencia; } publicStringgetEmpleado(){ returnempleado; } publicvoidsetEmpleado(Stringempleado){ this.empleado=empleado; } publicStringcrear(){ try{ empleadoAgencia.setAgencia(agenciaDAO.read(Integer .parseInt(getAgencia()))); empleadoAgencia.setEmpleado(empleadoDAO.read(Integer .parseInt(getEmpleado()))); empleadoAgenciaDAO.create(empleadoAgencia); FacesMessagemsg=newFacesMessage("Empleado por agencia FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empleado por agencia no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpleadoAgencia"; } creado"); } 10.1.7.3 BAJAEMPLEADOAGENCIA.JAVA packagepfm.beans.empleadoAgencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpleadoAgenciaDAO; importpfm.entidades.EmpleadoAgencia; @ManagedBean(name="bajaEmpleadoAgencia") @RequestScoped publicclassBajaEmpleadoAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; privateEmpleadoAgenciaempleadoAgencia; publicBajaEmpleadoAgencia(){ } 283 publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicStringbaja(){ try{ empleadoAgencia.setEliminado(true); getEmpleadoAgenciaDAO().update(empleadoAgencia); FacesMessagemsg=newFacesMessage( "Empleado por agencia dado de baja", String.valueOf(empleadoAgencia.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empleado por agencia no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarEmpleadoAgencia"; } } 10.1.7.4 ALTAEMPLEADOAGENCIA.JAVA packagepfm.beans.empleadoAgencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpleadoAgenciaDAO; importpfm.entidades.EmpleadoAgencia; @ManagedBean(name="altaEmpleadoAgencia") @RequestScoped publicclassAltaEmpleadoAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; privateEmpleadoAgenciaempleadoAgencia; publicAltaEmpleadoAgencia(){ } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } 284 publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicStringalta(){ try{ empleadoAgencia.setEliminado(false); getEmpleadoAgenciaDAO().update(empleadoAgencia); FacesMessagemsg=newFacesMessage( "Empleado por agencia dado de alta", String.valueOf(empleadoAgencia.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empleado por agencia no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarEmpleadoAgencia"; } } 10.1.7.5 MODIFICAREMPLEADOAGENCIA.JAVA packagepfm.beans.empleadoAgencia; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpleadoAgenciaDAO; importpfm.entidades.EmpleadoAgencia; @ManagedBean(name="modificarEmpleadoAgencia") @RequestScoped publicclassModificarEmpleadoAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; privateEmpleadoAgenciaempleadoAgencia; publicModificarEmpleadoAgencia(){ } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; 285 } publicStringmodificar(){ try{ getEmpleadoAgenciaDAO().update(empleadoAgencia); FacesMessagemsg=newFacesMessage( "Empleado por agencia actualizado", String.valueOf(empleadoAgencia.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empleado por agencia no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarEmpleadoAgencia"; } } 10.1.8 EMPRESA 10.1.8.1 LISTAREMPRESA.JAVA packagepfm.beans.empresa; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; @ManagedBean(name="listarEmpresa") @RequestScoped publicclassListarEmpresaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; @ManagedProperty(value="#{modificarEmpresa}") privateModificarEmpresamodificarEmpresaBEAN; @ManagedProperty(value="#{bajaEmpresa}") privateBajaEmpresabajaEmpresaBEAN; @ManagedProperty(value="#{altaEmpresa}") privateAltaEmpresaaltaEmpresaBEAN; privateList<Empresa>lista; privateList<Empresa>filtered; privateEmpresa[]selectedEmpresas; publicListarEmpresa(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } 286 publicModificarEmpresagetModificarEmpresaBEAN(){ returnmodificarEmpresaBEAN; } publicvoidsetModificarEmpresaBEAN(ModificarEmpresamodificarEmpresaBEAN){ this.modificarEmpresaBEAN=modificarEmpresaBEAN; } publicBajaEmpresagetBajaEmpresaBEAN(){ returnbajaEmpresaBEAN; } publicvoidsetBajaEmpresaBEAN(BajaEmpresabajaEmpresaBEAN){ this.bajaEmpresaBEAN=bajaEmpresaBEAN; } publicAltaEmpresagetAltaEmpresaBEAN(){ returnaltaEmpresaBEAN; } publicvoidsetAltaEmpresaBEAN(AltaEmpresaaltaEmpresaBEAN){ this.altaEmpresaBEAN=altaEmpresaBEAN; } publicList<Empresa>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(empresaDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Empresa>lista){ this.lista=lista; } publicList<Empresa>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Empresa>filtered){ this.filtered=filtered; } publicEmpresa[]getSelectedEmpresas(){ returnselectedEmpresas; } publicvoidsetSelectedEmpresas(Empresa[]selectedEmpresas){ this.selectedEmpresas=selectedEmpresas; } publicStringonCrear(){ return"crearEmpresa"; } publicvoidonModificar(RowEditEventevent){ modificarEmpresaBEAN.setEmpresa((Empresa)event.getObject()); modificarEmpresaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Empresa cancelada", String.valueOf(((Empresa)event.getObject()).getId())); 287 FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedEmpresas.length>0){ for(Empresae:selectedEmpresas){ bajaEmpresaBEAN.setEmpresa(e); bajaEmpresaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas empresas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpresa"; } publicStringonAlta(){ if(selectedEmpresas.length>0){ for(Empresae:selectedEmpresas){ altaEmpresaBEAN.setEmpresa(e); altaEmpresaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas empresas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarEmpresa"; } } 10.1.8.2 CREAREMPRESA.JAVA packagepfm.beans.empresa; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; @ManagedBean(name="crearEmpresa") publicclassCrearEmpresaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateEmpresaempresa=newEmpresa(); publicCrearEmpresa(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicEmpresagetEmpresa(){ 288 returnempresa; } publicvoidsetEmpresa(Empresaempresa){ this.empresa=empresa; } publicStringcrear(){ try{ empresaDAO.create(empresa); FacesMessagemsg=newFacesMessage("Empresa creada"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Empresa no FacesContext.getCurrentInstance().addMessage(null,msg); } creada"); return"listarEmpresa"; } } 10.1.8.3 BAJAEMPRESA.JAVA packagepfm.beans.empresa; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; @ManagedBean(name="bajaEmpresa") @RequestScoped publicclassBajaEmpresaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateEmpresaempresa; publicBajaEmpresa(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicEmpresagetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Empresaempresa){ this.empresa=empresa; } publicStringbaja(){ try{ empresa.setEliminado(true); getEmpresaDAO().update(empresa); 289 FacesMessagemsg=newFacesMessage("Empresa dada de baja", String.valueOf(empresa.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empresa no dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarEmpresa"; } } 10.1.8.4 ALTAEMPRESA.JAVA packagepfm.beans.empresa; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; @ManagedBean(name="altaEmpresa") @RequestScoped publicclassAltaEmpresaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateEmpresaempresa; publicAltaEmpresa(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicEmpresagetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Empresaempresa){ this.empresa=empresa; } publicStringalta(){ try{ empresa.setEliminado(false); getEmpresaDAO().update(empresa); FacesMessagemsg=newFacesMessage("Empresa dada de alta", String.valueOf(empresa.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empresa no dada de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } 290 return"listarEmpresa"; } } 10.1.8.5 MODIFICAREMPRESA.JAVA packagepfm.beans.empresa; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; @ManagedBean(name="modificarEmpresa") @RequestScoped publicclassModificarEmpresaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateEmpresaempresa; publicModificarEmpresa(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicEmpresagetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Empresaempresa){ this.empresa=empresa; } publicStringmodificar(){ try{ getEmpresaDAO().update(empresa); FacesMessagemsg=newFacesMessage("Empresa actualizada", String.valueOf(empresa.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Empresa no actualizada"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarEmpresa"; } } 10.1.9 FACTURA 10.1.9.1 LISTARFACTURAGENERADA.JAVA packagepfm.beans.factura; 291 importjava.io.Serializable; importjava.util.List; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.FacturaDAO; importpfm.dao.FacturaDetalleDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.entidades.Usuario; @ManagedBean(name="listarFacturaGenerada") @RequestScoped publicclassListarFacturaGeneradaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; privateList<Factura>listaFacturas; privateList<FacturaDetalle>listaFacturaDetalle; privateUsuarioempleado; privateEmpleadoAgenciaempleadoAgencia; privateList<Factura>filteredFacturas; @ManagedProperty(value="#{DAOFactory.facturaDAO}") privateFacturaDAOfacturaDAO; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOempleadoDAO; @ManagedProperty(value="#{DAOFactory.facturaDetalleDAO}") privateFacturaDetalleDAOfacturaDetalleDAO; @ManagedProperty(value="#{imprimirFactura}") privateImprimirFacturaimprimirFacturaBEAN; privateFacturaselectedFactura; publicListarFacturaGenerada(){ this.empleado=(Usuario)FacesContext.getCurrentInstance() .getExternalContext().getSessionMap().get("UsuarioBean"); } publicList<FacturaDetalle>getListaFacturaDetalle(){ try{ setListaFacturaDetalle(facturaDetalleDAO .getFacturaDetalleByFactura(getSelectedFactura(),false)); }catch(Exceptione){ System.out.println("ERROR <<ListarFacturaPagada>>: } returnlistaFacturaDetalle; } getLista()"+e); publicvoidsetListaFacturaDetalle(List<FacturaDetalle>listaFacturaDetalle){ this.listaFacturaDetalle=listaFacturaDetalle; } publicUsuariogetEmpleado(){ returnempleado; } publicvoidsetEmpleado(Usuarioempleado){ this.empleado=empleado; } publicFacturaDAOgetFacturaDAO(){ returnfacturaDAO; } publicvoidsetFacturaDAO(FacturaDAOfacturaDAO){ this.facturaDAO=facturaDAO; 292 } publicUsuarioDAOgetEmpleadoDAO(){ returnempleadoDAO; } publicvoidsetEmpleadoDAO(UsuarioDAOempleadoDAO){ this.empleadoDAO=empleadoDAO; } publicFacturaDetalleDAOgetFacturaDetalleDAO(){ returnfacturaDetalleDAO; } publicvoidsetFacturaDetalleDAO(FacturaDetalleDAOfacturaDetalleDAO){ this.facturaDetalleDAO=facturaDetalleDAO; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicList<Factura>getListaFacturas(){ try{ if(getEmpleado().getRol().getId()==1){ setListaFacturas(facturaDAO.getFacturasGeneradasByEmpleado(this .getEmpleado())); }elseif(getEmpleado().getRol().getId()==3){ setListaFacturas(facturaDAO.getFacturasGeneradas()); } }catch(Exceptione){ System.out .println("ERROR <<ListarFacturaPagadas>>: +e); } returnthis.listaFacturas; } getListaFacturas()" publicvoidsetListaFacturas(List<Factura>listaFacturas){ this.listaFacturas=listaFacturas; } publicList<Factura>getFilteredFacturas(){ returnfilteredFacturas; } publicvoidsetFilteredFacturas(List<Factura>filteredFacturas){ this.filteredFacturas=filteredFacturas; } publicImprimirFacturagetImprimirFacturaBEAN(){ returnimprimirFacturaBEAN; } publicvoidsetImprimirFacturaBEAN(ImprimirFacturaimprimirFacturaBEAN){ this.imprimirFacturaBEAN=imprimirFacturaBEAN; } publicFacturagetSelectedFactura(){ returnselectedFactura; } publicvoidsetSelectedFactura(FacturaselectedFactura){ this.selectedFactura=selectedFactura; 293 } publicStringonImprimir(){ imprimirFacturaBEAN.imprimirFactura(getSelectedFactura()); returnnull; } } 10.1.9.2 IMPRIMIRFACTURA.JAVA packagepfm.beans.factura; importjava.io.IOException; importjava.io.InputStream; importjava.io.OutputStream; importjava.io.Serializable; importjava.sql.Connection; importjava.util.HashMap; importjava.util.Map; importjavax.faces.bean.ManagedBean; importjavax.faces.context.FacesContext; importjavax.servlet.http.HttpServletResponse; importnet.sf.jasperreports.engine.JRException; importnet.sf.jasperreports.engine.JasperCompileManager; importnet.sf.jasperreports.engine.JasperExportManager; importnet.sf.jasperreports.engine.JasperFillManager; importnet.sf.jasperreports.engine.JasperPrint; importnet.sf.jasperreports.engine.JasperReport; importnet.sf.jasperreports.engine.design.JasperDesign; importnet.sf.jasperreports.engine.xml.JRXmlLoader; importpfm.entidades.Factura; importpfm.jpa.JPADAOFactory; @ManagedBean(name="imprimirFactura") publicclassImprimirFacturaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; privateStringpathReportes="rptFactura.jrxml"; publicImprimirFactura(){ } @SuppressWarnings({"rawtypes","unchecked"}) publicvoidimprimirFactura(Facturaf){ Mapparameters=newHashMap(); parameters.put("parIdFactura",f.getId()); parameters.put("nombreEmpresa",f.getAgencia().getEmpresa() .getRazonSocial()); parameters.put("direccionEmpresa",f.getAgencia().getEmpresa() .getDireccion()); parameters.put("telefonoEmpresa",f.getAgencia().getEmpresa() .getTelefono()); parameters.put("rucEmpresa",f.getAgencia().getEmpresa().getRuc()); JasperPrintprint=null; HttpServletResponseresponse=null; OutputStreamout=null; FacesContextcontext=null; try{ context=FacesContext.getCurrentInstance(); response=(HttpServletResponse)context.getExternalContext() 294 .getResponse(); out=response.getOutputStream(); InputStreamis=this.getClass().getResourceAsStream(pathReportes); JasperDesignmasterDesign=JRXmlLoader.load(is); JasperReportmasterReport=JasperCompileManager .compileReport(masterDesign); Connectionconnection=JPADAOFactory.getFactory().getAgenciaDAO() .getConexion(); print=JasperFillManager.fillReport(masterReport,parameters, connection); byte[]bytes=JasperExportManager.exportReportToPdf(print); response.setHeader("Content-disposition","attachment; +"Factura"+"PDF"); response.setHeader("Cache-Control","max-age=30"); response.setHeader("Pragma","No-cache"); response.setDateHeader("Expires",0); response.setContentType("application/pdf"); response.setContentLength(bytes.length); out.write(bytes); out.flush(); out.close(); context.responseComplete(); }catch(JRExceptione){ response.setContentType("text/plain"); }catch(IOExceptionio){ System.out.println("ERROR IO: "+io.getMessage()); }finally{ filename=" // conn.close(); } } } 10.1.9.3 RPTFACTURA.JXRML <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="rptStockProductos" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="64c83927-e902-486d-af738458994f3fa4"> <property name="ireport.zoom" value="1.5"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <style name="CajaDetalle" mode="Opaque" fill="Solid" isBold="false"> <pen lineColor="#666666"/> <paragraph rightIndent="5"/> </style> <parameter name="parIdFactura" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="nombreEmpresa" class="java.lang.String"/> <parameter name="direccionEmpresa" class="java.lang.String"/> <parameter name="telefonoEmpresa" class="java.lang.String"/> <parameter name="rucEmpresa" class="java.lang.String"/> <queryString> <![CDATA[SELECT FACTURA.ID, FACTURA.DESCUENTO, 295 FACTURA.ELIMINADO, FACTURA.FECHA, FACTURA.IVA, FACTURA.PAGADO, FACTURA.PENDIENTE, FACTURA.SUBTOTAL, FACTURA.TOTAL, FACTURA.AGENCIA_ID, FACTURA.CLIENTE_ID, FACTURA.EMPLEADOAGENCIA_ID, FACTURA.MEDIODEPAGO_ID, MEDIO_PAGO.NOMBRE AS MEDIOPAGO, USUARIO.USERNAME AS EMPLEADO, AGENCIA.NOMBRE AS AGENCIA, USUARIO_1.USERNAME as CLI_USERNAME, USUARIO_1.NOMBRES as CLI_NOMBRE, USUARIO_1.APELLIDOS as CLI_APELLIDO, FACTURA_DETALLE.CANTIDAD, FACTURA_DETALLE.DESCUENTO, FACTURA_DETALLE.IVA, FACTURA_DETALLE.PRECIO, FACTURA_DETALLE.SUBTOTAL as SUBTOTAL_DETALLE, FACTURA_DETALLE.TOTAL as TOTAL_DETALLE, FACTURA_DETALLE.BODEGADETALLE_ID, PRODUCTO.NOMBRE AS PRODUCTO_NOMBRE FROM ( ( ( ( ( ( ( FACTURA_DETALLE FACTURA_DETALLE INNER JOIN FACTURA FACTURA ON (FACTURA_DETALLE.FACTURA_ID = FACTURA.ID)) INNER JOIN BODEGA_DETALLE BODEGA_DETALLE ON (FACTURA_DETALLE.BODEGADETALLE_ID = BODEGA_DETALLE.ID)) INNER JOIN PRODUCTO PRODUCTO ON (BODEGA_DETALLE.PRODUCTO_ID = PRODUCTO.ID)) INNER JOIN MEDIO_PAGO MEDIO_PAGO ON (FACTURA.MEDIODEPAGO_ID = MEDIO_PAGO.ID)) INNER JOIN EMPLEADO_AGENCIA EMPLEADO_AGENCIA ON (FACTURA.EMPLEADOAGENCIA_ID = EMPLEADO_AGENCIA.ID)) INNER JOIN USUARIO USUARIO ON (EMPLEADO_AGENCIA.EMPLEADO_ID = USUARIO.ID)) INNER JOIN AGENCIA AGENCIA ON (FACTURA.AGENCIA_ID = AGENCIA.ID)) INNER JOIN USUARIO USUARIO_1 ON (USUARIO_1.ID = FACTURA.CLIENTE_ID) WHERE (FACTURA.ID = $P{parIdFactura})]]> </queryString> <field name="ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="DESCUENTO" class="java.lang.Double"> 296 <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="ELIMINADO" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="FECHA" class="java.sql.Date"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="IVA" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PAGADO" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PENDIENTE" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="SUBTOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="TOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="AGENCIA_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="CLIENTE_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="EMPLEADOAGENCIA_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="MEDIODEPAGO_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="MEDIOPAGO" class="java.lang.String"/> <field name="EMPLEADO" class="java.lang.String"/> <field name="AGENCIA" class="java.lang.String"/> <field name="CLI_USERNAME" class="java.lang.String"/> <field name="CLI_NOMBRE" class="java.lang.String"/> <field name="CLI_APELLIDO" class="java.lang.String"/> <field name="CANTIDAD" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PRECIO" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="SUBTOTAL_DETALLE" class="java.lang.Double"/> <field name="TOTAL_DETALLE" class="java.lang.Double"/> <field name="BODEGADETALLE_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PRODUCTO_NOMBRE" class="java.lang.String"/> <variable name="totalCantidad" class="java.lang.Integer" calculation="Sum"> <variableExpression><![CDATA[]]></variableExpression> </variable> <background> <band splitType="Stretch"/> 297 </background> <title> <band height="70" splitType="Stretch"> <rectangle> <reportElement uuid="9779b109-85e0-45fe-b27f-09d1c4672974" width="572" height="48" backcolor="#8DB4DF"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> <rectangle> <reportElement uuid="d1480583-947b-49e5-b66b-ea0504bd8bf8" y="48" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <staticText> <reportElement uuid="bc2f5a4b-06f9-48b0-8dd4-b19f0938e9af" y="8" width="324" height="35" forecolor="#FFFFFF"/> <textElement> <font size="24" isBold="true"/> </textElement> <text><![CDATA[Factura]]></text> </staticText> <textField pattern="dd/MM/yyyy"> <reportElement uuid="a330ab73-7b5d-4689-9fdf-8e2dda8b5e31" y="51" width="67" height="17" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <staticText> <reportElement uuid="68ab8d91-a751-4f81-8e9d-31b43bbcb4f0" y="51" width="100" height="17" forecolor="#FFFF33"/> <textElement/> <text><![CDATA[Fecha de Impresión:]]></text> </staticText> </band> </title> <pageHeader> <band height="11" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="125" splitType="Stretch"> <rectangle radius="10"> <reportElement uuid="4965f762-b744-4285-9cc5-7998bf716cd3" mode="Transparent" x="292" y="0" width="280" height="92"/> </rectangle> <rectangle radius="10"> <reportElement uuid="ff267c72-9035-446b-8a68-ed7f28ceef78" mode="Transparent" x="0" y="0" width="280" height="92"/> </rectangle> <staticText> <reportElement uuid="8faaca66-4eff-4265-a5b1-cdd6c05de9a8" mode="Opaque" x="40" y="105" width="299" height="20" backcolor="#CCCCCC"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> x="0" y="0" x="0" x="12" x="505" x="403" 298 <paragraph leftIndent="4"/> </textElement> <text><![CDATA[Producto]]></text> </staticText> <staticText> <reportElement uuid="2ce6bece-7aa3-4913-aed3-912296bfc8d3" mode="Opaque" x="0" y="105" width="40" height="20" backcolor="#CCCCCC"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Codigo]]></text> </staticText> <staticText> <reportElement uuid="1bdfb292-a66f-4a5a-ac28-19b3fe7bc878" mode="Opaque" x="339" y="105" width="71" height="20" backcolor="#CCCCCC"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Cantidad]]></text> </staticText> <staticText> <reportElement uuid="2a6a10d9-fded-4a53-9ed2-cf6229639d0c" mode="Opaque" x="409" y="105" width="56" height="20" backcolor="#CCCCCC"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Precio]]></text> </staticText> <textField> <reportElement uuid="7be6903b-6fe6-4e2a-ba1f-be01070fe4b9" x="292" y="8" width="280" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{nombreEmpresa}]]></textFieldExpressio n> </textField> <textField> <reportElement uuid="064c6bbd-6a4c-42a4-a092-a5f83c44be63" x="292" y="27" width="280" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{direccionEmpresa}]]></textFieldExpres sion> </textField> <textField> <reportElement uuid="447ea8e7-bd16-47e3-9b14-624d0307ec84" x="292" y="46" width="280" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{telefonoEmpresa}]]></textFieldExpress ion> </textField> <textField> <reportElement uuid="03198d05-fcac-4f2d-aaa9-f4ba3828db40" x="292" y="65" width="280" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$P{rucEmpresa}]]></textFieldExpression> </textField> <textField> 299 <reportElement uuid="dd513c4f-b4ee-43a8-97ac-33ab404d3704" x="91" y="47" width="176" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{EMPLEADO}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="58c09f32-efac-4ab7-b831-3e56cb6aaa8c" x="12" y="66" width="80" height="20"/> <textElement/> <text><![CDATA[Beneficiario :]]></text> </staticText> <staticText> <reportElement uuid="ebfee819-24fa-4995-a5db-b1b6e5bee9a0" x="12" y="47" width="80" height="20"/> <textElement/> <text><![CDATA[Atendido por:]]></text> </staticText> <textField> <reportElement uuid="1679944f-e786-4105-9983-497980628567" x="92" y="28" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{FECHA}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="a0af7cf0-b923-426b-ab1f-ad0efbcae60a" x="12" y="28" width="80" height="20"/> <textElement/> <text><![CDATA[Fecha:]]></text> </staticText> <staticText> <reportElement uuid="4a49d5bd-e7bc-47ea-83de-2e55cde3b32d" x="12" y="9" width="80" height="20"/> <textElement/> <text><![CDATA[Factura Nº:]]></text> </staticText> <textField> <reportElement uuid="f70e4644-fa53-49c0-b178-b04e4746641f" x="92" y="9" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression> </textField> <textField> <reportElement uuid="007fdc00-b68c-436a-bd46-9ae9191fa043" x="92" y="66" width="176" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{CLI_APELLIDO}.concat( " " ).concat($F{CLI_NOMBRE})]]></textFieldExpression> </textField> <staticText> <reportElement uuid="095c5bcc-4b04-4516-9511-2ee471fe5877" mode="Opaque" x="465" y="105" width="67" height="20" backcolor="#CCCCCC"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> <paragraph rightIndent="3"/> </textElement> <text><![CDATA[Subtotal]]></text> </staticText> </band> 300 </columnHeader> <detail> <band height="20" splitType="Stretch"> <textField> <reportElement uuid="012a4167-15d1-4492-b725-55c5a4fc65eb" x="40" y="0" width="299" height="20"/> <textElement> <paragraph leftIndent="4"/> </textElement> <textFieldExpression><![CDATA[$F{PRODUCTO_NOMBRE}]]></textFieldExpress ion> </textField> <textField> <reportElement uuid="a54d2f2e-a156-481c-9f36-bbe5bc824e93" x="0" y="0" width="40" height="20"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{BODEGADETALLE_ID}]]></textFieldExpres sion> </textField> <textField> <reportElement uuid="5e3fc067-9792-4a4f-b210-624064d6086c" x="339" y="0" width="71" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{CANTIDAD}]]></textFieldExpression> </textField> <textField> <reportElement uuid="d080c207-89ec-4bf1-beef-370d73518e68" x="410" y="0" width="55" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{PRECIO}]]></textFieldExpression> </textField> <textField> <reportElement uuid="e685c4cf-a580-4372-bea7-706db9051c64" x="465" y="0" width="67" height="20"/> <textElement textAlignment="Right"> <paragraph rightIndent="3"/> </textElement> <textFieldExpression><![CDATA[$F{SUBTOTAL_DETALLE}]]></textFieldExpres sion> </textField> </band> </detail> <columnFooter> <band height="92" splitType="Stretch"> <rectangle radius="10"> <reportElement uuid="fd392c7d-98b4-4ae4-bfc8-95ecb1016095" mode="Transparent" x="1" y="10" width="280" height="62"/> </rectangle> <textField> <reportElement uuid="1d642d11-22f4-4cac-acbd-0a203e006aa4" x="432" y="72" width="100" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> <paragraph rightIndent="3"/> </textElement> <textFieldExpression><![CDATA[$F{TOTAL}]]></textFieldExpression> </textField> <textField> 301 <reportElement uuid="7254e2b9-36ad-4b75-ba52-7c8d75e19e3f" x="432" y="52" width="100" height="20"/> <textElement textAlignment="Right"> <paragraph rightIndent="3"/> </textElement> <textFieldExpression><![CDATA[$F{IVA}]]></textFieldExpression> </textField> <textField> <reportElement uuid="72dc2181-e5d5-4eb1-9d87-78cd213e3ccc" x="432" y="32" width="100" height="20"/> <textElement textAlignment="Right"> <paragraph rightIndent="3"/> </textElement> <textFieldExpression><![CDATA[$F{DESCUENTO}]]></textFieldExpression> </textField> <textField> <reportElement uuid="44f05b90-2256-49a1-9b4c-a0eb2b7331a9" x="74" y="32" width="194" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{MEDIOPAGO}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="0c6f871e-b568-4d38-8ad1-e5c4f760575d" x="332" y="32" width="100" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[Descuento :]]></text> </staticText> <staticText> <reportElement uuid="f91724f3-4c39-4798-98b2-d5a9c003e681" x="332" y="72" width="100" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[TOTAL :]]></text> </staticText> <staticText> <reportElement uuid="4e18234a-3f8f-4f2b-bb20-8af563299b71" x="332" y="52" width="100" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[IVA :]]></text> </staticText> <line> <reportElement uuid="d89abf61-8b15-478f-b2c9-ea4d5991911b" x="0" y="6" width="532" height="1"/> </line> <staticText> <reportElement uuid="c27b0f49-6df8-4481-bba1-17f272dc0b83" x="9" y="13" width="100" height="20"/> <textElement/> <text><![CDATA[Medio de Pago:]]></text> </staticText> <staticText> <reportElement uuid="0c8f0ac5-5035-4b79-a2f6-373fc0bc1630" x="332" y="13" width="100" height="20"/> <textElement textAlignment="Right"> 302 <font isBold="true"/> </textElement> <text><![CDATA[Subtotal :]]></text> </staticText> <textField> <reportElement uuid="45caab61-2355-43af-8178-8a945b59436f" x="432" y="13" width="100" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{SUBTOTAL}]]></textFieldExpression> </textField> </band> </columnFooter> <pageFooter> <band height="26" splitType="Stretch"> <rectangle> <reportElement uuid="44d83d1f-8489-4942-8a19-33d62582834d" x="0" y="6" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <textField> <reportElement uuid="6a8d8d10-bcc1-4035-bfa9-edc59020b409" x="232" y="8" width="80" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement uuid="5b05ba5f-6bac-4f44-8bcc-c0ae825f44c1" x="316" y="8" width="40" height="15" forecolor="#FFFFFF"/> <textElement/> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="35" splitType="Stretch"/> </summary> </jasperReport> 10.1.9.4 GENERARFACTURA.JAVA packagepfm.beans.factura; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.FacturaDAO; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Factura; @ManagedBean(name="generarFactura") @RequestScoped publicclassGenerarFacturaimplementsSerializable{ 303 privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.facturaDAO}") privateFacturaDAOfacturaDAO; privateFacturafactura; privateEmpleadoAgenciaempleadoAgencia; publicGenerarFactura(){ } publicFacturaDAOgetFacturaDAO(){ returnfacturaDAO; } publicvoidsetFacturaDAO(FacturaDAOfacturaDAO){ this.facturaDAO=facturaDAO; } publicFacturagetFactura(){ returnfactura; } publicvoidsetFactura(Facturafactura){ this.factura=factura; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicStringgenerar(){ try{ if(factura.getEliminado()==false){ if(factura.isPagado()){ factura.setEmpleadoAgencia(empleadoAgencia); getFacturaDAO().update(factura); FacesMessagemsg=newFacesMessage("Factura generada", String.valueOf(factura.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }else{ FacesMessagemsg=newFacesMessage("Error", "La factura no ha sido pagada"); FacesContext.getCurrentInstance().addMessage(null,msg); } }else{ FacesMessagemsg=newFacesMessage("Error", "La factura se encuentra dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); } }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Factura no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } generada"); return"listarFacturaPendiente"; } } 10.1.9.5 BAJAFACTURA.JAVA packagepfm.beans.factura; 304 importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.FacturaDAO; importpfm.entidades.Factura; @ManagedBean(name="bajaFactura") @RequestScoped publicclassBajaFacturaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.facturaDAO}") privateFacturaDAOfacturaDAO; privateFacturafactura; publicBajaFactura(){ } publicFacturaDAOgetFacturaDAO(){ returnfacturaDAO; } publicvoidsetFacturaDAO(FacturaDAOfacturaDAO){ this.facturaDAO=facturaDAO; } publicFacturagetFactura(){ returnfactura; } publicvoidsetFactura(Facturafactura){ this.factura=factura; } publicStringbaja(){ try{ factura.setEliminado(true); getFacturaDAO().update(factura); FacesMessagemsg=newFacesMessage("Factura dada de baja", String.valueOf(factura.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Factura no dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarFacturaPendiente"; } } 10.1.9.6 ALTAFACTURA.JAVA packagepfm.beans.factura; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; 305 importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.FacturaDAO; importpfm.entidades.Factura; @ManagedBean(name="altaFactura") @RequestScoped publicclassAltaFacturaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.facturaDAO}") privateFacturaDAOfacturaDAO; privateFacturafactura; publicAltaFactura(){ } publicFacturaDAOgetFacturaDAO(){ returnfacturaDAO; } publicvoidsetFacturaDAO(FacturaDAOfacturaDAO){ this.facturaDAO=facturaDAO; } publicFacturagetFactura(){ returnfactura; } publicvoidsetFactura(Facturafactura){ this.factura=factura; } publicStringalta(){ try{ factura.setEliminado(false); getFacturaDAO().update(factura); FacesMessagemsg=newFacesMessage("Factura dada de alta", String.valueOf(factura.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Factura no dada de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarFacturaPendiente"; } } 10.1.9.7 LISTARFACTURASPENDIENTES.JAVA packagepfm.beans.factura; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.EmpleadoAgenciaDAO; importpfm.dao.FacturaDAO; importpfm.dao.FacturaDetalleDAO; importpfm.dao.UsuarioDAO; 306 importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.entidades.Usuario; @ManagedBean(name="listarFacturaPendiente") @RequestScoped publicclassListarFacturaPendienteimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.facturaDAO}") privateFacturaDAOfacturaDAO; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOempleadoDAO; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; @ManagedProperty(value="#{DAOFactory.facturaDetalleDAO}") privateFacturaDetalleDAOfacturaDetalleDAO; @ManagedProperty(value="#{generarFactura}") privateGenerarFacturagenerarFacturaBEAN; @ManagedProperty(value="#{bajaFactura}") privateBajaFacturabajaFacturaBEAN; @ManagedProperty(value="#{altaFactura}") privateAltaFacturaaltaFacturaBEAN; privateEmpleadoAgenciaempleadoAgencia; privateUsuarioempleado; privateList<Factura>listaFacturas; privateList<Factura>filteredFacturas; privateFactura[]selectedFacturas; privateFacturaselectedFactura; privateList<FacturaDetalle>listaFacturaDetalle; publicListarFacturaPendiente(){ } publicFacturaDAOgetFacturaDAO(){ returnfacturaDAO; } publicvoidsetFacturaDAO(FacturaDAOfacturaDAO){ this.facturaDAO=facturaDAO; } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicUsuarioDAOgetEmpleadoDAO(){ returnempleadoDAO; } publicvoidsetEmpleadoDAO(UsuarioDAOempleadoDAO){ this.empleadoDAO=empleadoDAO; } publicFacturaDetalleDAOgetFacturaDetalleDAO(){ returnfacturaDetalleDAO; } publicvoidsetFacturaDetalleDAO(FacturaDetalleDAOfacturaDetalleDAO){ this.facturaDetalleDAO=facturaDetalleDAO; } 307 publicGenerarFacturagetGenerarFacturaBEAN(){ returngenerarFacturaBEAN; } publicvoidsetGenerarFacturaBEAN(GenerarFacturagenerarFacturaBEAN){ this.generarFacturaBEAN=generarFacturaBEAN; } publicBajaFacturagetBajaFacturaBEAN(){ returnbajaFacturaBEAN; } publicvoidsetBajaFacturaBEAN(BajaFacturabajaFacturaBEAN){ this.bajaFacturaBEAN=bajaFacturaBEAN; } publicAltaFacturagetAltaFacturaBEAN(){ returnaltaFacturaBEAN; } publicvoidsetAltaFacturaBEAN(AltaFacturaaltaFacturaBEAN){ this.altaFacturaBEAN=altaFacturaBEAN; } publicEmpleadoAgenciagetEmpleadoAgencia(){ setEmpleadoAgencia(empleadoAgenciaDAO.getAgenciaByEmpleado(empleadoDAO .read(getEmpleado().getId()))); returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicUsuariogetEmpleado(){ setEmpleado((Usuario)FacesContext.getCurrentInstance() .getExternalContext().getSessionMap().get("UsuarioBean")); returnempleado; } publicvoidsetEmpleado(Usuarioempleado){ this.empleado=empleado; } publicList<Factura>getListaFacturas(){ try{ if(getEmpleado().getRol().getId()==1){ setListaFacturas(facturaDAO.getFacturasPendientesByAgencia( getEmpleadoAgencia().getAgencia(),false)); }elseif(getEmpleado().getRol().getId()==3){ setListaFacturas(facturaDAO.getFacturasPendientes(false)); } }catch(Exceptione){ System.out .println("ERROR <<ListarFacturaPendiente>>: +e); } returnlistaFacturas; } getListaFacturas()" publicvoidsetListaFacturas(List<Factura>listaFacturas){ this.listaFacturas=listaFacturas; } publicList<Factura>getFilteredFacturas(){ returnfilteredFacturas; 308 } publicvoidsetFilteredFacturas(List<Factura>filteredFacturas){ this.filteredFacturas=filteredFacturas; } publicFactura[]getSelectedFacturas(){ returnselectedFacturas; } publicvoidsetSelectedFacturas(Factura[]selectedFacturas){ this.selectedFacturas=selectedFacturas; } publicFacturagetSelectedFactura(){ returnselectedFactura; } publicvoidsetSelectedFactura(FacturaselectedFactura){ this.selectedFactura=selectedFactura; } publicList<FacturaDetalle>getListaFacturaDetalle(){ try{ setListaFacturaDetalle(facturaDetalleDAO .getFacturaDetalleByFactura(getSelectedFactura(),false)); }catch(Exceptione){ System.out.println("ERROR <<ListarFacturaPendiente>>: +e); } returnlistaFacturaDetalle; } getLista()" publicvoidsetListaFacturaDetalle(List<FacturaDetalle>listaFacturaDetalle){ this.listaFacturaDetalle=listaFacturaDetalle; } publicStringonGenerar(){ if(selectedFacturas.length>0){ for(Facturaf:selectedFacturas){ if(getEmpleado().getRol().getId()==1){ generarFacturaBEAN.setEmpleadoAgencia(getEmpleadoAgencia()); generarFacturaBEAN.setFactura(f); generarFacturaBEAN.generar(); }elseif(getEmpleado().getRol().getId()==3){ FacesMessagemsg=newFacesMessage("Error", "No puede generar la factura, no tiene el rol de empleado"); FacesContext.getCurrentInstance().addMessage(null,msg); } } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas facturas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarFacturaPendiente"; } publicStringonBaja(){ if(selectedFacturas.length>0){ for(Facturaf:selectedFacturas){ bajaFacturaBEAN.setFactura(f); bajaFacturaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas facturas"); 309 FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarFacturaPendiente"; } publicStringonAlta(){ if(selectedFacturas.length>0){ for(Facturaf:selectedFacturas){ altaFacturaBEAN.setFactura(f); altaFacturaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas facturas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarFacturaPendiente"; } } 10.1.10 FILTER 10.1.10.1 FORZARLOGINFILTER.JAVA packagepfm.beans.filters; importjava.io.IOException; importjavax.servlet.Filter; importjavax.servlet.FilterChain; importjavax.servlet.FilterConfig; importjavax.servlet.RequestDispatcher; importjavax.servlet.ServletException; importjavax.servlet.ServletRequest; importjavax.servlet.ServletResponse; importjavax.servlet.http.HttpSession; importjavax.servlet.http.HttpServletRequest; importpfm.beans.login.LoginUsuario; importpfm.entidades.Usuario; publicclassForzarLoginFilterimplementsFilter{ privatestaticfinalStringLOGIN_JSP="/login/loginUsuario.jsf"; publicForzarLoginFilter(){ } @Override publicvoiddestroy(){ // TODO Auto-generated method stub } privatestaticbooleancheckLoginState(ServletRequestrequest,ServletResponseresponse)throws IOException,ServletException{ booleanesLogeado=false; HttpSessionsession=((HttpServletRequest)request).getSession(false); if(null!=session&&(null!=((Usuario)session.getAttribute("UsuarioBean")))){ HttpServletRequestreq=(HttpServletRequest)request; LoginUsuariologinBean=(LoginUsuario)req.getSession().getAttribute("loginUsuario"); if(loginBean.isLogeado()){ 310 esLogeado=true; } } returnesLogeado; } @Override publicvoiddoFilter(ServletRequestrequest,ServletResponseresponse,FilterChainchain)throws IOException,ServletException{ booleanisLoggedIn=checkLoginState(request,response); if(isRedirect((HttpServletRequest)request)&&!isLoggedIn){ StringloginURI=LOGIN_JSP; RequestDispatcherrequestDispatcher=request.getRequestDispatcher(loginURI); // Force the login requestDispatcher.forward(request,response); return; }else{ try{ chain.doFilter(request,response); }catch(Throwablet){ } } } privatebooleanisRedirect(HttpServletRequestrequest){ StringrequestURI=request.getRequestURI(); return(!requestURI.contains(LOGIN_JSP)); } @Override publicvoidinit(FilterConfigarg0)throwsServletException{ } } 10.1.11 LOGIN 10.1.11.1 LOGINUSUARIO.JAVA packagepfm.beans.login; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.SessionScoped; importjavax.faces.context.FacesContext; importpfm.dao.UsuarioDAO; importpfm.entidades.Usuario; importpfm.jpa.JPADAOFactory; @ManagedBean(name="loginUsuario") @SessionScoped publicclassLoginUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; privateUsuariousuario=newUsuario(); privatebooleanisLogeado=false; 311 //GETTERS AND SETTERS publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } //OPERACIONES publicStringprocesar(){ Stringnavegacion=null; List<Usuario>usuarios=JPADAOFactory.getFactory().getUsuarioDAO() .find(newString[]{"username","password"},newString[]{this.getUsuario().getUsername( ),this.getUsuario().getPassword()},null,0,0); if(usuarios.size()==1){ this.setUsuario(usuarios.get(0)); //Solo puede darse que ingrese un Administrador o un empleado, pero nunca un cliente. //TODO: Poner el codigo de Cliente en Enumeracion. switch(this.getUsuario().getRol().getId()){ case3: FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("UsuarioBe an",this.getUsuario()); this.setLogeado(true); navegacion="admin"; break; case1: FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("UsuarioBe an",this.getUsuario()); this.setLogeado(true); navegacion="empleado"; break; default: FacesMessagemsg=newFacesMessage(FacesMessage.SEVERITY_INFO,"Usuario o clave incorrecta!!",""); FacesContext.getCurrentInstance().addMessage(null,msg); break; } }else{ FacesMessagemsg=newFacesMessage(FacesMessage.SEVERITY_INFO,"Usuario o clave incorrecta!!",""); FacesContext.getCurrentInstance().addMessage(null,msg); } returnnavegacion; } publicUsuariogetUsuario(){ returnusuario; } publicvoidsetUsuario(Usuariousuario){ this.usuario=usuario; } publicbooleanisLogeado(){ returnisLogeado; } 312 publicvoidsetLogeado(booleanisLogeado){ this.isLogeado=isLogeado; } } 10.1.11.2 LOGOUTUSUARIO.JAVA packagepfm.beans.login; importjava.io.Serializable; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.SessionScoped; importjavax.faces.context.FacesContext; importjavax.servlet.http.HttpSession; @ManagedBean(name="logoutUsuario") @SessionScoped publicclassLogoutUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; publicLogoutUsuario(){ } publicStringlogout(){ ((HttpSession)FacesContext.getCurrentInstance().getExternalContext() .getSession(false)).invalidate(); return"logout"; } } 10.1.12 MARCA 10.1.12.1 LISTARMARCA.JAVA packagepfm.beans.marca; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; @ManagedBean(name="listarMarca") @RequestScoped publicclassListarMarcaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; @ManagedProperty(value="#{modificarMarca}") privateModificarMarcamodificarMarcaBEAN; @ManagedProperty(value="#{bajaMarca}") privateBajaMarcabajaMarcaBEAN; @ManagedProperty(value="#{altaMarca}") privateAltaMarcaaltaMarcaBEAN; 313 privateList<Marca>lista; privateList<Marca>filtered; privateMarca[]selectedMarcas; publicListarMarca(){ } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicModificarMarcagetModificarMarcaBEAN(){ returnmodificarMarcaBEAN; } publicvoidsetModificarMarcaBEAN(ModificarMarcamodificarMarcaBEAN){ this.modificarMarcaBEAN=modificarMarcaBEAN; } publicBajaMarcagetBajaMarcaBEAN(){ returnbajaMarcaBEAN; } publicvoidsetBajaMarcaBEAN(BajaMarcabajaMarcaBEAN){ this.bajaMarcaBEAN=bajaMarcaBEAN; } publicAltaMarcagetAltaMarcaBEAN(){ returnaltaMarcaBEAN; } publicvoidsetAltaMarcaBEAN(AltaMarcaaltaMarcaBEAN){ this.altaMarcaBEAN=altaMarcaBEAN; } publicList<Marca>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(marcaDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Marca>lista){ this.lista=lista; } publicList<Marca>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Marca>filtered){ this.filtered=filtered; } publicMarca[]getSelectedMarcas(){ returnselectedMarcas; } publicvoidsetSelectedMarcas(Marca[]selectedMarcas){ this.selectedMarcas=selectedMarcas; } 314 publicStringonCrear(){ return"crearMarca"; } publicvoidonModificar(RowEditEventevent){ modificarMarcaBEAN.setMarca((Marca)event.getObject()); modificarMarcaBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Marca cancelada", String.valueOf(((Marca)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedMarcas.length>0){ for(Marcae:selectedMarcas){ bajaMarcaBEAN.setMarca(e); bajaMarcaBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas marcas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMarca"; } publicStringonAlta(){ if(selectedMarcas.length>0){ for(Marcae:selectedMarcas){ altaMarcaBEAN.setMarca(e); altaMarcaBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas marcas"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMarca"; } } 10.1.12.2 CREARMARCA.JAVA packagepfm.beans.marca; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; @ManagedBean(name="crearMarca") publicclassCrearMarcaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; privateMarcamarca=newMarca(); 315 publicCrearMarca(){ } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicMarcagetMarca(){ returnmarca; } publicvoidsetMarca(Marcamarca){ this.marca=marca; } publicStringcrear(){ try{ marcaDAO.create(marca); FacesMessagemsg=newFacesMessage("Marca creada"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Marca no creada"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMarca"; } } 10.1.12.3 BAJAMARCA.JAVA packagepfm.beans.marca; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; @ManagedBean(name="bajaMarca") @RequestScoped publicclassBajaMarcaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; privateMarcamarca; publicBajaMarca(){ } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ 316 this.marcaDAO=marcaDAO; } publicMarcagetMarca(){ returnmarca; } publicvoidsetMarca(Marcamarca){ this.marca=marca; } publicStringbaja(){ try{ marca.setEliminado(true); getMarcaDAO().update(marca); FacesMessagemsg=newFacesMessage("Marca dada de baja", String.valueOf(marca.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Marca no dada de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMarca"; } } 10.1.12.4 ALTAMARCA.JAVA packagepfm.beans.marca; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; @ManagedBean(name="altaMarca") @RequestScoped publicclassAltaMarcaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; privateMarcamarca; publicAltaMarca(){ } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicMarcagetMarca(){ returnmarca; } publicvoidsetMarca(Marcamarca){ this.marca=marca; 317 } publicStringalta(){ try{ marca.setEliminado(false); getMarcaDAO().update(marca); FacesMessagemsg=newFacesMessage("Marca dada de alta", String.valueOf(marca.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Marca no dada de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMarca"; } } 10.1.12.5 MODIFICARMARCA.JAVA packagepfm.beans.marca; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; @ManagedBean(name="modificarMarca") @RequestScoped publicclassModificarMarcaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; privateMarcamarca; publicModificarMarca(){ } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicMarcagetMarca(){ returnmarca; } publicvoidsetMarca(Marcamarca){ this.marca=marca; } publicStringmodificar(){ try{ getMarcaDAO().update(marca); FacesMessagemsg=newFacesMessage("Marca actualizada", String.valueOf(marca.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ 318 FacesMessagemsg=newFacesMessage("Error", "Marca no actualizada"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMarca"; } } 10.1.13 MEDIOPAGO 10.1.13.1 LISTARMEDIOPAGO.JAVA packagepfm.beans.medioDePago; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; @ManagedBean(name="listarMedioPago") @RequestScoped publicclassListarMedioPagoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.medioPagoDAO}") privateMedioPagoDAOmedioPagoDAO; @ManagedProperty(value="#{modificarMedioPago}") privateModificarMedioPagomodificarMedioPagoBEAN; @ManagedProperty(value="#{bajaMedioPago}") privateBajaMedioPagobajaMedioPagoBEAN; @ManagedProperty(value="#{altaMedioPago}") privateAltaMedioPagoaltaMedioPagoBEAN; privateList<MedioDePago>lista; privateList<MedioDePago>filtered; privateMedioDePago[]selectedMedioPagos; publicListarMedioPago(){ } publicMedioPagoDAOgetMedioPagoDAO(){ returnmedioPagoDAO; } publicvoidsetMedioPagoDAO(MedioPagoDAOmedioPagoDAO){ this.medioPagoDAO=medioPagoDAO; } publicModificarMedioPagogetModificarMedioPagoBEAN(){ returnmodificarMedioPagoBEAN; } publicvoidsetModificarMedioPagoBEAN( ModificarMedioPagomodificarMedioPagoBEAN){ this.modificarMedioPagoBEAN=modificarMedioPagoBEAN; } 319 publicBajaMedioPagogetBajaMedioPagoBEAN(){ returnbajaMedioPagoBEAN; } publicvoidsetBajaMedioPagoBEAN(BajaMedioPagobajaMedioPagoBEAN){ this.bajaMedioPagoBEAN=bajaMedioPagoBEAN; } publicAltaMedioPagogetAltaMedioPagoBEAN(){ returnaltaMedioPagoBEAN; } publicvoidsetAltaMedioPagoBEAN(AltaMedioPagoaltaMedioPagoBEAN){ this.altaMedioPagoBEAN=altaMedioPagoBEAN; } publicList<MedioDePago>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(medioPagoDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<MedioDePago>lista){ this.lista=lista; } publicList<MedioDePago>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<MedioDePago>filtered){ this.filtered=filtered; } publicMedioDePago[]getSelectedMedioPagos(){ returnselectedMedioPagos; } publicvoidsetSelectedMedioPagos(MedioDePago[]selectedMedioPagos){ this.selectedMedioPagos=selectedMedioPagos; } publicStringonCrear(){ return"crearMedioPago"; } publicvoidonModificar(RowEditEventevent){ modificarMedioPagoBEAN.setMedioPago((MedioDePago)event.getObject()); modificarMedioPagoBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Medio de Pago cancelado", String.valueOf(((MedioDePago)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedMedioPagos.length>0){ for(MedioDePagom:selectedMedioPagos){ bajaMedioPagoBEAN.setMedioPago(m); bajaMedioPagoBEAN.baja(); } }else{ 320 FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas medios de pago"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMedioPago"; } publicStringonAlta(){ if(selectedMedioPagos.length>0){ for(MedioDePagom:selectedMedioPagos){ altaMedioPagoBEAN.setMedioPago(m); altaMedioPagoBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas medio de pago"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMedioPago"; } } 10.1.13.2 CREARMEDIOPAGO.JAVA packagepfm.beans.medioDePago; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; @ManagedBean(name="crearMedioPago") publicclassCrearMedioPagoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.medioPagoDAO}") privateMedioPagoDAOmedioPagoDAO; privateMedioDePagomedioPago=newMedioDePago(); publicCrearMedioPago(){ } publicMedioPagoDAOgetMedioPagoDAO(){ returnmedioPagoDAO; } publicvoidsetMedioPagoDAO(MedioPagoDAOmedioPagoDAO){ this.medioPagoDAO=medioPagoDAO; } publicMedioDePagogetMedioPago(){ returnmedioPago; } publicvoidsetMedioPago(MedioDePagomedioPago){ this.medioPago=medioPago; } publicStringcrear(){ try{ medioPagoDAO.create(medioPago); FacesMessagemsg=newFacesMessage("Medio de Pago creado"); 321 FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Medio de Pago no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarMedioPago"; } } 10.1.13.3 BAJAMEDIOPAGO.JAVA packagepfm.beans.medioDePago; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; @ManagedBean(name="bajaMedioPago") @RequestScoped publicclassBajaMedioPagoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.medioPagoDAO}") privateMedioPagoDAOmedioPagoDAO; privateMedioDePagomedioPago; publicBajaMedioPago(){ } publicMedioPagoDAOgetMedioPagoDAO(){ returnmedioPagoDAO; } publicvoidsetMedioPagoDAO(MedioPagoDAOmedioPagoDAO){ this.medioPagoDAO=medioPagoDAO; } publicMedioDePagogetMedioPago(){ returnmedioPago; } publicvoidsetMedioPago(MedioDePagomedioPago){ this.medioPago=medioPago; } publicStringbaja(){ try{ medioPago.setEliminado(true); getMedioPagoDAO().update(medioPago); FacesMessagemsg=newFacesMessage("Medio de Pago dado String.valueOf(medioPago.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Medio de pago no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMedioPago"; de baja", 322 } } 10.1.13.4 ALTAMEDIOPAGO packagepfm.beans.medioDePago; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; @ManagedBean(name="altaMedioPago") @RequestScoped publicclassAltaMedioPagoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.medioPagoDAO}") privateMedioPagoDAOmedioPagoDAO; privateMedioDePagomedioPago; publicAltaMedioPago(){ } publicMedioPagoDAOgetMedioPagoDAO(){ returnmedioPagoDAO; } publicvoidsetMedioPagoDAO(MedioPagoDAOmedioPagoDAO){ this.medioPagoDAO=medioPagoDAO; } publicMedioDePagogetMedioPago(){ returnmedioPago; } publicvoidsetMedioPago(MedioDePagomedioPago){ this.medioPago=medioPago; } publicStringalta(){ try{ medioPago.setEliminado(false); getMedioPagoDAO().update(medioPago); FacesMessagemsg=newFacesMessage("Medio de Pago dado String.valueOf(medioPago.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Medio de pago no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMedioPago"; } } 10.1.13.5 de alta", MODIFICARMEDIOPAGO.JAVA packagepfm.beans.medioDePago; 323 importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; @ManagedBean(name="modificarMedioPago") @RequestScoped publicclassModificarMedioPagoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.medioPagoDAO}") privateMedioPagoDAOmedioPagoDAO; privateMedioDePagomedioPago; publicModificarMedioPago(){ } publicMedioPagoDAOgetMedioPagoDAO(){ returnmedioPagoDAO; } publicvoidsetMedioPagoDAO(MedioPagoDAOmedioPagoDAO){ this.medioPagoDAO=medioPagoDAO; } publicMedioDePagogetMedioPago(){ returnmedioPago; } publicvoidsetMedioPago(MedioDePagomedioPago){ this.medioPago=medioPago; } publicStringmodificar(){ try{ getMedioPagoDAO().update(medioPago); FacesMessagemsg=newFacesMessage("Medio de Pago actualizado", String.valueOf(medioPago.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Medio de Pago no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarMedioPago"; } } 10.1.14 MENU 10.1.14.1 MENU.JAVA packagepfm.beans.menu; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.entidades.Usuario; 324 @ManagedBean(name="menu") @RequestScoped publicclassMenu{ publicbooleangetIsAdmin(){ UsuariousuarioSesion=(Usuario)FacesContext.getCurrentInstance() .getExternalContext().getSessionMap().get("UsuarioBean"); if(usuarioSesion.getRol().getId()==3) returntrue; else returnfalse; } } 10.1.15 PRODUCTO 10.1.15.1 LISTARPRODUCTO.JAVA packagepfm.beans.producto; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; importpfm.dao.CategoriaDAO; importpfm.dao.MarcaDAO; importpfm.dao.ProductoDAO; importpfm.entidades.Categoria; importpfm.entidades.Marca; importpfm.entidades.Producto; @ManagedBean(name="listarProducto") @RequestScoped publicclassListarProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; @ManagedProperty(value="#{modificarProducto}") privateModificarProductomodificarProductoBEAN; @ManagedProperty(value="#{bajaProducto}") privateBajaProductobajaProductoBEAN; @ManagedProperty(value="#{altaProducto}") privateAltaProductoaltaProductoBEAN; privateList<Producto>lista; privateList<Producto>filtered; privateSelectItem[]marcas; privateStringmarca; privateSelectItem[]categorias; privateStringcategoria; privateProducto[]selectedProductos; publicListarProducto(){ 325 } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicModificarProductogetModificarProductoBEAN(){ returnmodificarProductoBEAN; } publicvoidsetModificarProductoBEAN(ModificarProductomodificarProductoBEAN){ this.modificarProductoBEAN=modificarProductoBEAN; } publicBajaProductogetBajaProductoBEAN(){ returnbajaProductoBEAN; } publicvoidsetBajaProductoBEAN(BajaProductobajaProductoBEAN){ this.bajaProductoBEAN=bajaProductoBEAN; } publicAltaProductogetAltaProductoBEAN(){ returnaltaProductoBEAN; } publicvoidsetAltaProductoBEAN(AltaProductoaltaProductoBEAN){ this.altaProductoBEAN=altaProductoBEAN; } publicList<Producto>getLista(){ try{ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(productoDAO.find(attributes,values,order,index,size)); returnlista; }catch(Exceptionex){ System.out.println(ex.getMessage()); returnlista; } } publicvoidsetLista(List<Producto>lista){ this.lista=lista; } 326 publicList<Producto>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Producto>filtered){ this.filtered=filtered; } publicSelectItem[]getMarcas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Marca>listaMarcas=newArrayList<Marca>(); listaMarcas=marcaDAO.find(attributes,values,order,index,size); this.marcas=newSelectItem[listaMarcas.size()]; for(Marcae:listaMarcas){ this.marcas[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returnmarcas; } publicvoidsetMarcas(SelectItem[]marcas){ this.marcas=marcas; } publicSelectItem[]getCategorias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Categoria>listaCategorias=newArrayList<Categoria>(); listaCategorias=categoriaDAO.find(attributes,values,order,index, size); this.categorias=newSelectItem[listaCategorias.size()]; for(Categoriae:listaCategorias){ this.categorias[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returncategorias; } publicvoidsetCategorias(SelectItem[]categorias){ this.categorias=categorias; } publicStringgetMarca(){ returnmarca; } publicvoidsetMarca(Stringmarca){ this.marca=marca; } publicStringgetCategoria(){ returncategoria; } publicvoidsetCategoria(Stringcategoria){ this.categoria=categoria; 327 } publicProducto[]getSelectedProductos(){ returnselectedProductos; } publicvoidsetSelectedProductos(Producto[]selectedProductos){ this.selectedProductos=selectedProductos; } publicStringonCrear(){ return"crearProducto"; } publicvoidonModificar(RowEditEventevent){ Productoproducto=newProducto(); producto=(Producto)event.getObject(); producto.setCategoria(categoriaDAO.read(Integer .parseInt(getCategoria()))); producto.setMarca(marcaDAO.read(Integer.parseInt(getMarca()))); modificarProductoBEAN.setProducto(producto); modificarProductoBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Producto cancelado", String.valueOf(((Producto)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedProductos.length>0){ for(Productop:selectedProductos){ bajaProductoBEAN.setProducto(p); bajaProductoBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas productos"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarProducto"; } publicStringonAlta(){ if(selectedProductos.length>0){ for(Productop:selectedProductos){ altaProductoBEAN.setProducto(p); altaProductoBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas productos"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarProducto"; } } 10.1.15.2 CREARPRODUCTO.JAVA packagepfm.beans.producto; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; 328 importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.CategoriaDAO; importpfm.dao.MarcaDAO; importpfm.dao.ProductoDAO; importpfm.entidades.Categoria; importpfm.entidades.Marca; importpfm.entidades.Producto; @ManagedBean(name="crearProducto") publicclassCrearProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; @ManagedProperty(value="#{DAOFactory.marcaDAO}") privateMarcaDAOmarcaDAO; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateProductoproducto=newProducto(); privateSelectItem[]categorias; privateSelectItem[]marcas; privateStringcategoria; privateStringmarca; publicCrearProducto(){ } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicMarcaDAOgetMarcaDAO(){ returnmarcaDAO; } publicvoidsetMarcaDAO(MarcaDAOmarcaDAO){ this.marcaDAO=marcaDAO; } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } publicSelectItem[]getCategorias(){ String[]attributes={"eliminado"}; 329 String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Categoria>listaCategorias=newArrayList<Categoria>(); listaCategorias=categoriaDAO.find(attributes,values,order,index, size); this.categorias=newSelectItem[listaCategorias.size()]; for(Categoriae:listaCategorias){ this.categorias[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returncategorias; } publicvoidsetCategorias(SelectItem[]categorias){ this.categorias=categorias; } publicSelectItem[]getMarcas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Marca>listaMarcas=newArrayList<Marca>(); listaMarcas=marcaDAO.find(attributes,values,order,index,size); this.marcas=newSelectItem[listaMarcas.size()]; for(Marcae:listaMarcas){ this.marcas[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returnmarcas; } publicvoidsetMarcas(SelectItem[]marcas){ this.marcas=marcas; } publicStringgetCategoria(){ returncategoria; } publicvoidsetCategoria(Stringcategoria){ this.categoria=categoria; } publicStringgetMarca(){ returnmarca; } publicvoidsetMarca(Stringmarca){ this.marca=marca; } publicStringcrear(){ try{ producto.setCategoria(categoriaDAO.read(Integer .parseInt(getCategoria()))); producto.setMarca(marcaDAO.read(Integer.parseInt(getMarca()))); productoDAO.create(producto); FacesMessagemsg=newFacesMessage("Producto creado"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ 330 FacesMessagemsg=newFacesMessage("Error","Producto no FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarProducto"; } } 10.1.15.3 creado"); BAJAPRODUCTO.JAVA packagepfm.beans.producto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.ProductoDAO; importpfm.entidades.Producto; @ManagedBean(name="bajaProducto") @RequestScoped publicclassBajaProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateProductoproducto; publicBajaProducto(){ } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } publicStringbaja(){ try{ producto.setEliminado(true); getProductoDAO().update(producto); FacesMessagemsg=newFacesMessage("Producto dado de baja", String.valueOf(producto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto no dado de baja"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarProducto"; } } 331 10.1.15.4 ALTAPRODUCTO.JAVA packagepfm.beans.producto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.ProductoDAO; importpfm.entidades.Producto; @ManagedBean(name="altaProducto") @RequestScoped publicclassAltaProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateProductoproducto; publicAltaProducto(){ } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } publicStringalta(){ try{ producto.setEliminado(false); getProductoDAO().update(producto); FacesMessagemsg=newFacesMessage("Producto dado de alta", String.valueOf(producto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto no dado de alta"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarProducto"; } } 10.1.15.5 MODIFICARPRODUCTO.JAVA packagepfm.beans.producto; importjava.io.Serializable; importjavax.faces.application.FacesMessage; 332 importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.ProductoDAO; importpfm.entidades.Producto; @ManagedBean(name="modificarProducto") @RequestScoped publicclassModificarProductoimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.productoDAO}") privateProductoDAOproductoDAO; privateProductoproducto; publicModificarProducto(){ } publicProductoDAOgetProductoDAO(){ returnproductoDAO; } publicvoidsetProductoDAO(ProductoDAOproductoDAO){ this.productoDAO=productoDAO; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } publicStringmodificar(){ try{ getProductoDAO().update(producto); FacesMessagemsg=newFacesMessage("Producto actualizado", String.valueOf(producto.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error", "Producto no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarProducto"; } } 10.1.16 REPORTES 10.1.16.1 CONSOLIDADOVENTAS.JAVA packagepfm.beans.reportes; importjava.io.IOException; importjava.io.InputStream; importjava.io.OutputStream; importjava.io.Serializable; importjava.sql.Connection; importjava.util.ArrayList; importjava.util.Date; importjava.util.HashMap; 333 importjava.util.List; importjava.util.Map; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.event.ActionEvent; importjavax.faces.model.SelectItem; importjavax.servlet.http.HttpServletResponse; importnet.sf.jasperreports.engine.JRException; importnet.sf.jasperreports.engine.JasperCompileManager; importnet.sf.jasperreports.engine.JasperExportManager; importnet.sf.jasperreports.engine.JasperFillManager; importnet.sf.jasperreports.engine.JasperPrint; importnet.sf.jasperreports.engine.JasperReport; importnet.sf.jasperreports.engine.design.JasperDesign; importnet.sf.jasperreports.engine.xml.JRXmlLoader; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; importpfm.jpa.JPADAOFactory; @ManagedBean(name="consolidadoVentas") publicclassConsolidadoVentasimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; privateStringempresa; privateSelectItem[]empresas; privateDatefechaInicio; privateDatefechaFin; privateStringpathReportes="rptVentas.jrxml"; publicConsolidadoVentas(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicStringgetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Stringempresa){ this.empresa=empresa; } publicSelectItem[]getEmpresas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Empresa>listaEmpresas=newArrayList<Empresa>(); listaEmpresas=empresaDAO.find(attributes,values,order,index,size); this.empresas=newSelectItem[listaEmpresas.size()]; for(Empresae:listaEmpresas){ this.empresas[i]=newSelectItem(e.getId(),e.getRazonSocial()); 334 i++; } returnempresas; } publicvoidsetEmpresas(SelectItem[]empresas){ this.empresas=empresas; } publicDategetFechaInicio(){ returnfechaInicio; } publicvoidsetFechaInicio(DatefechaInicio){ this.fechaInicio=fechaInicio; } publicDategetFechaFin(){ returnfechaFin; } publicvoidsetFechaFin(DatefechaFin){ this.fechaFin=fechaFin; } publicStringgetPathReportes(){ returnpathReportes; } publicvoidsetPathReportes(StringpathReportes){ this.pathReportes=pathReportes; } @SuppressWarnings({"rawtypes","unchecked"}) publicvoidgenerarPDF(ActionEventevent){ Mapparameters=newHashMap(); parameters.put("parIdEmpresa",Integer.parseInt(empresa)); parameters.put("parFechaInicio",fechaInicio); parameters.put("parFechaFin",fechaFin); JasperPrintprint=null; HttpServletResponseresponse=null; OutputStreamout=null; FacesContextcontext=null; try{ context=FacesContext.getCurrentInstance(); response=(HttpServletResponse)context.getExternalContext() .getResponse(); out=response.getOutputStream(); InputStreamis=this.getClass().getResourceAsStream(pathReportes); JasperDesignmasterDesign=JRXmlLoader.load(is); JasperReportmasterReport=JasperCompileManager .compileReport(masterDesign); Connectionconnection=JPADAOFactory.getFactory().getAgenciaDAO() .getConexion(); print=JasperFillManager.fillReport(masterReport,parameters, connection); byte[]bytes=JasperExportManager.exportReportToPdf(print); response.setHeader("Content-disposition","attachment; +"Consolidado de ventas"+"PDF"); response.setHeader("Cache-Control","max-age=30"); response.setHeader("Pragma","No-cache"); response.setDateHeader("Expires",0); filename=" 335 response.setContentType("application/pdf"); response.setContentLength(bytes.length); out.write(bytes); out.flush(); out.close(); context.responseComplete(); }catch(JRExceptione){ response.setContentType("text/plain"); }catch(IOExceptionio){ System.out.println("ERROR IO: "+io.getMessage()); }finally{ // conn.close(); } } } 10.1.16.2 RPTVENTAS.JRXML <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="rptVentas" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="64c83927-e902-486d-af73-8458994f3fa4"> <property name="ireport.zoom" value="2.0"/> <property name="ireport.x" value="98"/> <property name="ireport.y" value="17"/> <parameter name="parIdEmpresa" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="parFechaInicio" class="java.util.Date"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="parFechaFin" class="java.util.Date"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <queryString> <![CDATA[SELECT EMPRESA.ID AS idempresa, AGENCIA.ID AS idagencia, FACTURA.ID AS idfactura, FACTURA.FECHA AS fecha, USUARIO.USERNAME AS empleado, EMPRESA.RAZON_SOCIAL AS razonsocial, EMPRESA.IVA AS iva, AGENCIA.NOMBRE AS nombreagencia, FACTURA.DESCUENTO, FACTURA.IVA, FACTURA.SUBTOTAL, FACTURA.TOTAL, FACTURA.CLIENTE_ID, USUARIO_1.USERNAME AS cliente, MEDIO_PAGO.ID, MEDIO_PAGO.NOMBRE, FACTURA.PAGADO, FACTURA.PENDIENTE, EMPLEADO_AGENCIA.ID AS idempleadoagencia FROM ( ( ( ( ( AGENCIA AGENCIA INNER JOIN EMPRESA EMPRESA 336 ON (AGENCIA.EMPRESA_ID = EMPRESA.ID)) INNER JOIN FACTURA FACTURA ON (FACTURA.AGENCIA_ID = AGENCIA.ID)) INNER JOIN EMPLEADO_AGENCIA EMPLEADO_AGENCIA ON (FACTURA.EMPLEADOAGENCIA_ID = EMPLEADO_AGENCIA.ID)) INNER JOIN USUARIO USUARIO ON (EMPLEADO_AGENCIA.EMPLEADO_ID = USUARIO.ID)) INNER JOIN USUARIO USUARIO_1 ON (FACTURA.CLIENTE_ID = USUARIO_1.ID)) INNER JOIN MEDIO_PAGO MEDIO_PAGO ON (FACTURA.MEDIODEPAGO_ID = MEDIO_PAGO.ID) WHERE (FACTURA.PAGADO = 1) AND(FACTURA.PENDIENTE = 0) AND(EMPRESA.ID = $P{parIdEmpresa}) AND((DATE(FACTURA.FECHA) BETWEEN $P{parFechaInicio} AND $P{parFechaFin})) AND(FACTURA.ELIMINADO = 0)]]> </queryString> <field name="idempresa" class="java.lang.Integer"/> <field name="idagencia" class="java.lang.Integer"/> <field name="idfactura" class="java.lang.Integer"/> <field name="fecha" class="java.sql.Date"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="empleado" class="java.lang.String"/> <field name="razonsocial" class="java.lang.String"/> <field name="iva" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="nombreagencia" class="java.lang.String"/> <field name="DESCUENTO" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="SUBTOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="TOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="CLIENTE_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="cliente" class="java.lang.String"/> <field name="ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="NOMBRE" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PAGADO" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="PENDIENTE" class="java.lang.Boolean"> <fieldDescription><![CDATA[]]></fieldDescription> 337 </field> <field name="idempleadoagencia" class="java.lang.Integer"/> <variable name="SumTOTAL" class="java.lang.Double" calculation="Sum"> <variableExpression><![CDATA[$F{TOTAL}]]></variableExpression> </variable> <group name="Empresa"> <groupExpression><![CDATA[$F{idempresa}]]></groupExpression> <groupHeader> <band height="15"> <textField> <reportElement uuid="5601b8e9-8e42-446a-a078-f22511c21e87" x="55" y="0" width="179" height="15" forecolor="#0033CC"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{razonsocial}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="ad884240-4e05-4423-aa68-60263d346a36" x="2" y="0" width="52" height="15"/> <textElement/> <text><![CDATA[Empresa :]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="50"> <textField> <reportElement uuid="e39e0536-5201-49bc-9230-5d7e9042ac59" x="322" y="19" width="50" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$V{SumTOTAL}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="694c6670-2ad3-4827-baee-0954c19ad7ad" x="214" y="20" width="102" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[TOTAL EMPRESA :]]></text> </staticText> <line> <reportElement uuid="b0e390a4-4128-4d0d-9918-d1313daa9e44" x="12" y="19" width="570" height="1"/> </line> </band> </groupFooter> </group> <group name="Agencia"> <groupExpression><![CDATA[$F{idagencia}]]></groupExpression> <groupHeader> <band height="46"> <line> <reportElement uuid="cb46866e-2e83-494c-a194-f088961c229d" x="0" y="43" width="570" height="1"/> </line> <staticText> 338 <reportElement uuid="de617934-e29e-445f-884d-44332f09dc4f" y="25" width="81" height="20"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[Fecha]]></text> </staticText> <staticText> <reportElement uuid="d21a5a2d-af17-46f4-86f9-17938364db6b" y="24" width="74" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[COD. CLIENTE]]></text> </staticText> <staticText> <reportElement uuid="0d99a3bf-a37b-4604-9f23-841f9c241c22" y="25" width="32" height="19"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[Cod.]]></text> </staticText> <staticText> <reportElement uuid="5dc734ee-aaf0-491f-a277-32d645be2526" y="25" width="68" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[SUBTOTAL]]></text> </staticText> <staticText> <reportElement uuid="921db3ca-7078-46d0-8350-22e0cf45b558" y="25" width="68" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[DESCUENTO]]></text> </staticText> <staticText> <reportElement uuid="15553360-8e00-459c-a33d-a58c9d9bec1a" y="25" width="60" height="20"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[TOTAL]]></text> </staticText> <staticText> <reportElement uuid="82af6e42-3ae3-4a80-af9f-5b7393f82bde" y="25" width="88" height="20"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[COD. EMPLEADO]]></text> </staticText> <staticText> <reportElement uuid="3ed93256-6c8d-4ed4-8e37-421c0e09ae4b" y="25" width="32" height="20"/> <textElement> x="32" x="396" x="0" x="115" x="196" x="312" x="482" x="280" 339 <font isBold="true"/> </textElement> <text><![CDATA[IVA]]></text> </staticText> <rectangle> <reportElement uuid="f04341d9-6d5f-4058-916a-ff38bfa3af86" x="2" y="1" width="570" height="15" backcolor="#D8E3F9"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> <staticText> <reportElement uuid="b12f2804-8b69-4e75-865e-fdecf5782c7f" x="12" y="1" width="52" height="15"/> <textElement/> <text><![CDATA[Agencia :]]></text> </staticText> <textField> <reportElement uuid="dba16d2a-1c22-4e2d-bc4f-fc418dab2373" x="64" y="0" width="100" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{nombreagencia}]]></textFieldExpressio n> </textField> </band> </groupHeader> <groupFooter> <band height="31"> <textField isBlankWhenNull="true"> <reportElement uuid="21b1f438-55d3-45d6-a99c-9bbd293bbb23" x="319" y="11" width="53" height="15" forecolor="#0033CC"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$V{SumTOTAL}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="c7fe2371-7d82-4511-9257-711942380eac" x="210" y="11" width="102" height="20"/> <textElement textAlignment="Right"> <font isBold="true" isItalic="false"/> </textElement> <text><![CDATA[TOTAL AGENCIA :]]></text> </staticText> </band> </groupFooter> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="70" splitType="Stretch"> <rectangle> <reportElement uuid="9779b109-85e0-45fe-b27f-09d1c4672974" x="0" y="0" width="572" height="48" backcolor="#8DB4DF"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> 340 <rectangle> <reportElement uuid="d1480583-947b-49e5-b66b-ea0504bd8bf8" x="0" y="48" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <staticText> <reportElement uuid="bc2f5a4b-06f9-48b0-8dd4-b19f0938e9af" x="12" y="8" width="241" height="35" forecolor="#FFFFFF"/> <textElement> <font size="24" isBold="true"/> </textElement> <text><![CDATA[VENTAS TOTALES]]></text> </staticText> <textField pattern="dd/MM/yyyy"> <reportElement uuid="a330ab73-7b5d-4689-9fdf-8e2dda8b5e31" x="505" y="51" width="67" height="17" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <staticText> <reportElement uuid="abe481e3-77c5-4bf1-9f95-82da795fc29b" x="453" y="51" width="52" height="15" forecolor="#FFFF00"/> <textElement textAlignment="Right"/> <text><![CDATA[Fecha:]]></text> </staticText> </band> </title> <pageHeader> <band height="11" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="22" splitType="Stretch"> <textField pattern="dd/MM/yyyy"> <reportElement uuid="ea2e0d3d-ecf3-4312-a6ca-b6fe6d438f75" x="180" y="2" width="100" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{parFechaInicio}]]></textFieldExpressi on> </textField> <textField pattern="dd/MM/yyyy"> <reportElement uuid="faa5f94b-a4e7-487c-a4ab-daf58d2ce644" x="296" y="2" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$P{parFechaFin}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="b435cd26-bd2e-4781-9776-8c7d2d382075" x="280" y="2" width="12" height="20"/> <textElement textAlignment="Center"/> <text><![CDATA[-]]></text> </staticText> </band> </columnHeader> <detail> <band height="18" splitType="Stretch"> <line> 341 <reportElement uuid="82245828-55aa-4099-80e2-3412283b2422" x="2" y="16" width="570" height="1"/> </line> <textField pattern="dd/MM/yyyy"> <reportElement uuid="12b14102-fc8a-4de0-a509-7cebdecf0741" x="34" y="0" width="81" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{fecha}]]></textFieldExpression> </textField> <textField> <reportElement uuid="678c0aab-3396-4e3c-bf68-69c4b31fa1b6" x="2" y="0" width="32" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{idfactura}]]></textFieldExpression> </textField> <textField> <reportElement uuid="f64fe653-b4b7-4927-b1e4-4966222e76a3" x="115" y="0" width="68" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{SUBTOTAL}]]></textFieldExpression> </textField> <textField> <reportElement uuid="76318fcb-9ba3-4d22-b748-566edd925654" x="196" y="0" width="68" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{DESCUENTO}]]></textFieldExpression> </textField> <textField> <reportElement uuid="a2e4f568-1695-4335-914f-fbb8b2347ed9" x="312" y="1" width="60" height="15"/> <textElement textAlignment="Right"> <font isBold="false"/> </textElement> <textFieldExpression><![CDATA[$F{TOTAL}]]></textFieldExpression> </textField> <textField> <reportElement uuid="308f11c0-a276-4d31-a3ed-9206f6d6a668" x="527" y="1" width="22" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{idempleadoagencia}]]></textFieldExpre ssion> </textField> <textField> <reportElement uuid="851a6b23-df23-401a-8048-439844dc39c9" x="280" y="0" width="32" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{iva}]]></textFieldExpression> </textField> <textField> <reportElement uuid="89802f17-3a7e-4748-ad19-1db8f4922363" x="418" y="0" width="52" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{CLIENTE_ID}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> 342 <pageFooter> <band height="26" splitType="Stretch"> <rectangle> <reportElement uuid="44d83d1f-8489-4942-8a19-33d62582834d" x="0" y="6" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <textField> <reportElement uuid="6a8d8d10-bcc1-4035-bfa9-edc59020b409" x="232" y="8" width="80" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement uuid="5b05ba5f-6bac-4f44-8bcc-c0ae825f44c1" x="316" y="8" width="40" height="15" forecolor="#FFFFFF"/> <textElement/> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="35" splitType="Stretch"/> </summary> </jasperReport> 10.1.16.3 CIERREDECAJA.JAVA packagepfm.beans.reportes; importjava.io.IOException; importjava.io.InputStream; importjava.io.OutputStream; importjava.io.Serializable; importjava.sql.Connection; importjava.util.ArrayList; importjava.util.Date; importjava.util.HashMap; importjava.util.List; importjava.util.Map; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.event.ActionEvent; importjavax.faces.model.SelectItem; importjavax.servlet.http.HttpServletResponse; importnet.sf.jasperreports.engine.JRException; importnet.sf.jasperreports.engine.JasperCompileManager; importnet.sf.jasperreports.engine.JasperExportManager; importnet.sf.jasperreports.engine.JasperFillManager; importnet.sf.jasperreports.engine.JasperPrint; importnet.sf.jasperreports.engine.JasperReport; importnet.sf.jasperreports.engine.design.JasperDesign; importnet.sf.jasperreports.engine.xml.JRXmlLoader; importpfm.dao.EmpleadoAgenciaDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.EmpleadoAgencia; 343 importpfm.entidades.Usuario; importpfm.jpa.JPADAOFactory; @ManagedBean(name="cierreDeCaja") publicclassCierreDeCajaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOempleadoDAO; @ManagedProperty(value="#{DAOFactory.empleadoAgenciaDAO}") privateEmpleadoAgenciaDAOempleadoAgenciaDAO; privateUsuarioempleado; privateStringempleadoAgencia; privateSelectItem[]empleadosAgencia; privateDatefecha; privateStringpathReportes="rptVentaCaja.jrxml"; publicCierreDeCaja(){ } publicUsuarioDAOgetEmpleadoDAO(){ returnempleadoDAO; } publicvoidsetEmpleadoDAO(UsuarioDAOempleadoDAO){ this.empleadoDAO=empleadoDAO; } publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnempleadoAgenciaDAO; } publicvoidsetEmpleadoAgenciaDAO(EmpleadoAgenciaDAOempleadoAgenciaDAO){ this.empleadoAgenciaDAO=empleadoAgenciaDAO; } publicStringgetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(StringempleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } publicSelectItem[]getEmpleadosAgencia(){ if(getEmpleado().getRol().getId()==1){ EmpleadoAgenciae=empleadoAgenciaDAO .getAgenciaByEmpleado(empleadoDAO.read(getEmpleado() .getId())); empleadosAgencia=newSelectItem[1]; empleadosAgencia[0]=newSelectItem(e.getId(),e.getEmpleado() .toString()); }else{ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<EmpleadoAgencia>listaEmpleadosAgencia=newArrayList<EmpleadoAgencia>(); listaEmpleadosAgencia=empleadoAgenciaDAO.find(attributes,values, order,index,size); empleadosAgencia=newSelectItem[listaEmpleadosAgencia.size()]; for(EmpleadoAgenciae:listaEmpleadosAgencia){ empleadosAgencia[i]=newSelectItem(e.getId(),e.getEmpleado() 344 .toString()); i++; } } returnempleadosAgencia; } publicvoidsetEmpleadosAgencia(SelectItem[]empleadosAgencia){ this.empleadosAgencia=empleadosAgencia; } publicUsuariogetEmpleado(){ setEmpleado((Usuario)FacesContext.getCurrentInstance() .getExternalContext().getSessionMap().get("UsuarioBean")); returnempleado; } publicvoidsetEmpleado(Usuarioempleado){ this.empleado=empleado; } publicDategetFecha(){ returnfecha; } publicvoidsetFecha(Datefecha){ this.fecha=fecha; } publicStringgetPathReportes(){ returnpathReportes; } publicvoidsetPathReportes(StringpathReportes){ this.pathReportes=pathReportes; } @SuppressWarnings({"rawtypes","unchecked"}) publicvoidgenerarPDF(ActionEventevent){ Mapparameters=newHashMap(); parameters.put("parIdEmpleadoAgencia", Integer.parseInt(empleadoAgencia)); parameters.put("parFechaActual",fecha); JasperPrintprint=null; HttpServletResponseresponse=null; OutputStreamout=null; FacesContextcontext=null; try{ context=FacesContext.getCurrentInstance(); response=(HttpServletResponse)context.getExternalContext() .getResponse(); out=response.getOutputStream(); InputStreamis=this.getClass().getResourceAsStream(pathReportes); JasperDesignmasterDesign=JRXmlLoader.load(is); JasperReportmasterReport=JasperCompileManager .compileReport(masterDesign); Connectionconnection=JPADAOFactory.getFactory().getAgenciaDAO() .getConexion(); print=JasperFillManager.fillReport(masterReport,parameters, connection); byte[]bytes=JasperExportManager.exportReportToPdf(print); response.setHeader("Content-disposition","attachment; +"Cierre de Caja"+"PDF"); response.setHeader("Cache-Control","max-age=30"); filename=" 345 response.setHeader("Pragma","No-cache"); response.setDateHeader("Expires",0); response.setContentType("application/pdf"); response.setContentLength(bytes.length); out.write(bytes); out.flush(); out.close(); context.responseComplete(); }catch(JRExceptione){ response.setContentType("text/plain"); }catch(IOExceptionio){ System.out.println("ERROR IO: "+io.getMessage()); }finally{ // conn.close(); } } } 10.1.16.4 RPTVENTACAJA.JRXML <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="rptVentaCaja" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="64c83927-e902-486d-af73-8458994f3fa4"> <property name="ireport.zoom" value="2.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="99"/> <parameter name="parIdEmpleadoAgencia" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="parFechaActual" class="java.util.Date"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <queryString> <![CDATA[SELECT EMPRESA.ID AS idempresa, AGENCIA.ID AS idagencia, FACTURA.ID AS idfactura, FACTURA.FECHA AS fecha, EMPRESA.RAZON_SOCIAL AS razonsocial, EMPRESA.IVA AS iva, AGENCIA.NOMBRE AS nombreagencia, FACTURA.DESCUENTO, FACTURA.IVA, FACTURA.SUBTOTAL, FACTURA.TOTAL, FACTURA.CLIENTE_ID, cliente.USERNAME AS cliente, USUARIO.APELLIDOS, USUARIO.NOMBRES FROM ( ( ( ( FACTURA FACTURA INNER JOIN USUARIO cliente ON (FACTURA.CLIENTE_ID = cliente.ID)) INNER JOIN AGENCIA AGENCIA 346 ON (FACTURA.AGENCIA_ID = AGENCIA.ID)) INNER JOIN EMPRESA EMPRESA ON (AGENCIA.EMPRESA_ID = EMPRESA.ID)) INNER JOIN EMPLEADO_AGENCIA EMPLEADO_AGENCIA ON (FACTURA.EMPLEADOAGENCIA_ID = EMPLEADO_AGENCIA.ID)) INNER JOIN USUARIO USUARIO ON (EMPLEADO_AGENCIA.EMPLEADO_ID = USUARIO.ID) WHERE (FACTURA.ELIMINADO = 0) AND(EMPLEADO_AGENCIA.ID = $P{parIdEmpleadoAgencia}) AND(FACTURA.FECHA = $P{parFechaActual})]]> </queryString> <field name="idempresa" class="java.lang.Integer"/> <field name="idagencia" class="java.lang.Integer"/> <field name="idfactura" class="java.lang.Integer"/> <field name="fecha" class="java.sql.Date"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="razonsocial" class="java.lang.String"/> <field name="iva" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="nombreagencia" class="java.lang.String"/> <field name="DESCUENTO" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="SUBTOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="TOTAL" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="CLIENTE_ID" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="cliente" class="java.lang.String"/> <field name="APELLIDOS" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="NOMBRES" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <variable name="totalVentas" class="java.lang.Double" calculation="Sum"> <variableExpression><![CDATA[$F{TOTAL}]]></variableExpression> </variable> <group name="Empresa"> <groupExpression><![CDATA[$F{idempresa}]]></groupExpression> <groupHeader> <band height="15"> <textField> <reportElement uuid="5601b8e9-8e42-446a-a078-f22511c21e87" x="55" y="0" width="179" height="15" forecolor="#0033CC"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{razonsocial}]]></textFieldExpression> 347 </textField> <staticText> <reportElement uuid="ad884240-4e05-4423-aa68-60263d346a36" x="2" y="0" width="52" height="15"/> <textElement/> <text><![CDATA[Empresa :]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="50"/> </groupFooter> </group> <group name="Agencia"> <groupExpression><![CDATA[$F{idagencia}]]></groupExpression> <groupHeader> <band height="45"> <staticText> <reportElement uuid="173e59bb-d5f1-44cf-bb82-7e09dd727288" x="95" y="25" width="79" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[SUBTOTAL]]></text> </staticText> <staticText> <reportElement uuid="b29227d3-2828-4b42-a19f-05bdccfd3c9d" x="174" y="25" width="100" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[DESCUENTO]]></text> </staticText> <staticText> <reportElement uuid="90d8ea91-ee27-4760-bf37-d04c97e2953b" x="275" y="25" width="61" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[IVA]]></text> </staticText> <staticText> <reportElement uuid="61bc0a29-972b-407f-9067-d4f7c345520c" x="5" y="25" width="80" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[COD. FACTURA]]></text> </staticText> <staticText> <reportElement uuid="b12f2804-8b69-4e75-865e-fdecf5782c7f" x="5" y="1" width="52" height="15"/> <textElement/> <text><![CDATA[Agencia :]]></text> </staticText> <textField> <reportElement uuid="5e5511c4-1fed-4914-932b-ed5e5c699912" x="55" y="0" width="159" height="15" forecolor="#006666"/> <textElement> 348 <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{nombreagencia}]]></textFieldExpressio n> </textField> <line> <reportElement uuid="cb46866e-2e83-494c-a194-f088961c229d" x="5" y="0" width="426" height="1"/> </line> <staticText> <reportElement uuid="545e4739-a946-4b65-9b66-dcdb01fc690a" x="336" y="25" width="61" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[TOTAL]]></text> </staticText> <staticText> <reportElement uuid="0e40b2e2-ded4-4997-979a-62d7e1cc18a6" x="426" y="25" width="79" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[COD. CLIENTE]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="50"> <textField> <reportElement uuid="ce8f5d48-01f7-4c02-971c-a97e42271cdb" x="331" y="0" width="66" height="20" forecolor="#0033FF"/> <textElement textAlignment="Right" verticalAlignment="Middle"/> <textFieldExpression><![CDATA[$V{totalVentas}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="9442d570-e9a7-410a-9aac-5ca09988c0cd" x="214" y="0" width="117" height="20"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[TOTAL VENTAS :]]></text> </staticText> </band> </groupFooter> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="70" splitType="Stretch"> <rectangle> <reportElement uuid="9779b109-85e0-45fe-b27f-09d1c4672974" x="0" y="0" width="572" height="48" backcolor="#8DB4DF"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> <rectangle> 349 <reportElement uuid="d1480583-947b-49e5-b66b-ea0504bd8bf8" y="48" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <staticText> <reportElement uuid="bc2f5a4b-06f9-48b0-8dd4-b19f0938e9af" y="8" width="324" height="35" forecolor="#FFFFFF"/> <textElement> <font size="24" isBold="true"/> </textElement> <text><![CDATA[Ventas en Caja]]></text> </staticText> <textField pattern="dd/MM/yyyy"> <reportElement uuid="a330ab73-7b5d-4689-9fdf-8e2dda8b5e31" y="51" width="67" height="17" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <staticText> <reportElement uuid="abe481e3-77c5-4bf1-9f95-82da795fc29b" y="51" width="52" height="15" forecolor="#FFFF00"/> <textElement textAlignment="Right"/> <text><![CDATA[Fecha:]]></text> </staticText> </band> </title> <pageHeader> <band height="11" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="29" splitType="Stretch"> <staticText> <reportElement uuid="8d87afa5-7931-4991-95bf-bb5f2b6fca23" width="54" height="15"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[Empleado :]]></text> </staticText> <textField> <reportElement uuid="105d9c81-5290-447f-80a8-b3cda7ff9366" y="2" width="175" height="15"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{APELLIDOS} + " " +$F{NOMBRES}]]></textFieldExpression> </textField> </band> </columnHeader> <detail> <band height="16" splitType="Stretch"> <textField> <reportElement uuid="a5fdcd64-f3d1-4a10-bee0-d7fd038b2906" y="0" width="79" height="15"/> <textElement textAlignment="Right"/> x="0" x="12" x="505" x="453" x="3" y="2" x="57" x="95" 350 <textFieldExpression><![CDATA[$F{SUBTOTAL}]]></textFieldExpression> </textField> <textField> <reportElement uuid="5ee044e6-98e6-421e-b859-520b1a1a7c2b" x="174" y="0" width="100" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{DESCUENTO}]]></textFieldExpression> </textField> <textField> <reportElement uuid="c2d16954-505e-4ae2-9713-83453029053f" x="275" y="0" width="61" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{iva}]]></textFieldExpression> </textField> <line> <reportElement uuid="82245828-55aa-4099-80e2-3412283b2422" x="5" y="15" width="426" height="1"/> </line> <textField> <reportElement uuid="ebefca42-5e01-4fa2-b715-c97f383985c7" x="29" y="1" width="25" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{idfactura}]]></textFieldExpression> </textField> <textField> <reportElement uuid="712de6de-a6c3-445d-ac26-6f29d262a4ce" x="336" y="1" width="61" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{TOTAL}]]></textFieldExpression> </textField> <textField> <reportElement uuid="20da8867-67e5-4cab-ae88-9d6ad05d7c3f" x="426" y="1" width="79" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{CLIENTE_ID}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="26" splitType="Stretch"> <rectangle> <reportElement uuid="44d83d1f-8489-4942-8a19-33d62582834d" x="0" y="6" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <textField> <reportElement uuid="6a8d8d10-bcc1-4035-bfa9-edc59020b409" x="232" y="8" width="80" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> </textField> <textField evaluationTime="Report"> 351 <reportElement uuid="5b05ba5f-6bac-4f44-8bcc-c0ae825f44c1" x="316" y="8" width="40" height="15" forecolor="#FFFFFF"/> <textElement/> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="35" splitType="Stretch"/> </summary> </jasperReport> 10.1.16.5 STOCKPRODUCTOS.JAVA packagepfm.beans.reportes; importjava.sql.Connection; importjava.util.ArrayList; importjava.util.HashMap; importjava.util.List; importjava.util.Map; importjava.io.IOException; importjava.io.InputStream; importjava.io.OutputStream; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.event.ActionEvent; importjavax.faces.model.SelectItem; importjavax.servlet.http.HttpServletResponse; importnet.sf.jasperreports.engine.JRException; importnet.sf.jasperreports.engine.JasperCompileManager; importnet.sf.jasperreports.engine.JasperExportManager; importnet.sf.jasperreports.engine.JasperFillManager; importnet.sf.jasperreports.engine.JasperPrint; importnet.sf.jasperreports.engine.JasperReport; importnet.sf.jasperreports.engine.design.JasperDesign; importnet.sf.jasperreports.engine.xml.JRXmlLoader; importpfm.dao.AgenciaDAO; importpfm.dao.CategoriaDAO; importpfm.dao.EmpresaDAO; importpfm.entidades.Agencia; importpfm.entidades.Categoria; importpfm.entidades.Empresa; importpfm.jpa.JPADAOFactory; @ManagedBean(name="stockProductos") publicclassStockProductos{ @ManagedProperty(value="#{DAOFactory.empresaDAO}") privateEmpresaDAOempresaDAO; @ManagedProperty(value="#{DAOFactory.agenciaDAO}") privateAgenciaDAOagenciaDAO; @ManagedProperty(value="#{DAOFactory.categoriaDAO}") privateCategoriaDAOcategoriaDAO; privateSelectItem[]empresas; privateSelectItem[]agencias; privateSelectItem[]categorias; privateintempresa; privateintagencia; privateintcategoria; privateStringpathReportes="rptStockProductos.jrxml"; 352 publicStockProductos(){ } publicEmpresaDAOgetEmpresaDAO(){ returnempresaDAO; } publicvoidsetEmpresaDAO(EmpresaDAOempresaDAO){ this.empresaDAO=empresaDAO; } publicSelectItem[]getEmpresas(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Empresa>listaEmpresas=newArrayList<Empresa>(); listaEmpresas=empresaDAO.find(attributes,values,order,index,size); this.empresas=newSelectItem[listaEmpresas.size()]; for(Empresae:listaEmpresas){ this.empresas[i]=newSelectItem(e.getId(),e.getRazonSocial()); i++; } returnempresas; } publicvoidsetEmpresas(SelectItem[]empresas){ this.empresas=empresas; } publicSelectItem[]getAgencias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Agencia>listaAgencias=newArrayList<Agencia>(); listaAgencias=agenciaDAO.find(attributes,values,order,index,size); this.agencias=newSelectItem[listaAgencias.size()]; for(Agenciae:listaAgencias){ this.agencias[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returnagencias; } publicvoidsetAgencias(SelectItem[]agencias){ this.agencias=agencias; } publicSelectItem[]getCategorias(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Categoria>listaCategorias=newArrayList<Categoria>(); listaCategorias=categoriaDAO.find(attributes,values,order,index, 353 size); this.categorias=newSelectItem[listaCategorias.size()]; for(Categoriae:listaCategorias){ this.categorias[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returncategorias; } publicvoidsetCategorias(SelectItem[]categorias){ this.categorias=categorias; } publicAgenciaDAOgetAgenciaDAO(){ returnagenciaDAO; } publicvoidsetAgenciaDAO(AgenciaDAOagenciaDAO){ this.agenciaDAO=agenciaDAO; } publicCategoriaDAOgetCategoriaDAO(){ returncategoriaDAO; } publicvoidsetCategoriaDAO(CategoriaDAOcategoriaDAO){ this.categoriaDAO=categoriaDAO; } publicintgetEmpresa(){ returnempresa; } publicvoidsetEmpresa(intempresa){ this.empresa=empresa; } publicintgetAgencia(){ returnagencia; } publicvoidsetAgencia(intagencia){ this.agencia=agencia; } publicintgetCategoria(){ returncategoria; } publicvoidsetCategoria(intcategoria){ this.categoria=categoria; } publicStringgetPathReportes(){ returnpathReportes; } publicvoidsetPathReportes(StringpathReportes){ this.pathReportes=pathReportes; } @SuppressWarnings({"rawtypes","unchecked"}) publicvoidgenerarPDF(ActionEventevent){ Mapparameters=newHashMap(); parameters.put("parIdEmpresa",getEmpresa()); parameters.put("parIdAgencia",getAgencia()); parameters.put("parIdCategoria",getCategoria()); JasperPrintprint=null; HttpServletResponseresponse=null; 354 OutputStreamout=null; FacesContextcontext=null; try{ context=FacesContext.getCurrentInstance(); response=(HttpServletResponse)context.getExternalContext() .getResponse(); out=response.getOutputStream(); InputStreamis=this.getClass().getResourceAsStream(pathReportes); JasperDesignmasterDesign=JRXmlLoader.load(is); JasperReportmasterReport=JasperCompileManager .compileReport(masterDesign); Connectionconnection=JPADAOFactory.getFactory().getAgenciaDAO() .getConexion(); print=JasperFillManager.fillReport(masterReport,parameters, connection); byte[]bytes=JasperExportManager.exportReportToPdf(print); response.setHeader("Content-disposition","attachment; +"Stock de Productos"+"PDF"); response.setHeader("Cache-Control","max-age=30"); response.setHeader("Pragma","No-cache"); response.setDateHeader("Expires",0); response.setContentType("application/pdf"); response.setContentLength(bytes.length); out.write(bytes); out.flush(); out.close(); FacesContext.getCurrentInstance().responseComplete(); }catch(JRExceptione){ System.out.println("ERROR JREXCEPTION: e.printStackTrace(); response.setContentType("text/plain"); }catch(IOExceptionio){ io.printStackTrace(); System.out.println("ERROR IOEXCEPTION: }finally{ filename=" "); "+io.getMessage()); // conn.close(); } } } 10.1.16.6 RPTSTOCKPRODUCTOS.JRXML <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="rptStockProductos" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="64c83927-e902-486d-af738458994f3fa4"> <property name="ireport.zoom" value="2.0"/> <property name="ireport.x" value="98"/> <property name="ireport.y" value="551"/> <parameter name="parIdEmpresa" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> 355 </parameter> <parameter name="parIdAgencia" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <parameter name="parIdCategoria" class="java.lang.Integer"> <defaultValueExpression><![CDATA[]]></defaultValueExpression> </parameter> <queryString> <![CDATA[SELECT EMPRESA.ID AS idempresa, AGENCIA.ID AS idagencia, BODEGA.ID AS idbodega, PRODUCTO.ID AS idproducto, CATEGORIA.ID AS idcategoria, MARCA.ID AS idmarca, BODEGA_DETALLE.ID AS idbodegadetalle, EMPRESA.RAZON_SOCIAL AS razonsocial, AGENCIA.NOMBRE AS nombreagencia, BODEGA.NOMBRE AS nombrebodega, CATEGORIA.NOMBRE AS nombrecategoria, PRODUCTO.NOMBRE AS nombreproducto, MARCA.NOMBRE AS nombremarca, BODEGA_DETALLE.CANTIDAD AS cantidad, BODEGA_DETALLE.PRECIO AS precio, PRODUCTO.ELIMINADO AS eliminadoproducto, CATEGORIA.ELIMINADO AS eliminadocategoria, MARCA.ELIMINADO AS eliminadomarca, BODEGA_DETALLE.ELIMINADO AS eliminadobodegadetalle, BODEGA.ELIMINADO AS eliminadobodega, AGENCIA.ELIMINADO AS eliminadoagencia, EMPRESA.ELIMINADO AS eliminadoempresa FROM ( ( ( ( ( BODEGA BODEGA INNER JOIN AGENCIA AGENCIA ON (BODEGA.AGENCIA_ID = AGENCIA.ID)) INNER JOIN BODEGA_DETALLE BODEGA_DETALLE ON (BODEGA_DETALLE.BODEGA_ID = BODEGA.ID)) INNER JOIN PRODUCTO PRODUCTO ON (BODEGA_DETALLE.PRODUCTO_ID = PRODUCTO.ID)) INNER JOIN CATEGORIA CATEGORIA ON (PRODUCTO.CATEGORIA_ID = CATEGORIA.ID)) INNER JOIN MARCA MARCA ON (PRODUCTO.MARCA_ID = MARCA.ID)) INNER JOIN EMPRESA EMPRESA ON (AGENCIA.EMPRESA_ID = EMPRESA.ID) WHERE (PRODUCTO.ELIMINADO = 0) AND(CATEGORIA.ELIMINADO = 0) AND(MARCA.ELIMINADO = 0) AND(BODEGA_DETALLE.ELIMINADO = 0) AND(BODEGA.ELIMINADO = 0) AND(AGENCIA.ELIMINADO = 0) AND(EMPRESA.ELIMINADO = 0) AND EMPRESA.ID= $P{parIdEmpresa} AND AGENCIA.ID =$P{parIdAgencia} AND CATEGORIA.ID =$P{parIdCategoria}]]> 356 </queryString> <field name="idempresa" class="java.lang.Integer"/> <field name="idagencia" class="java.lang.Integer"/> <field name="idbodega" class="java.lang.Integer"/> <field name="idproducto" class="java.lang.Integer"/> <field name="idcategoria" class="java.lang.Integer"/> <field name="idmarca" class="java.lang.Integer"/> <field name="idbodegadetalle" class="java.lang.Integer"/> <field name="razonsocial" class="java.lang.String"/> <field name="nombreagencia" class="java.lang.String"/> <field name="nombrebodega" class="java.lang.String"/> <field name="nombrecategoria" class="java.lang.String"/> <field name="nombreproducto" class="java.lang.String"/> <field name="nombremarca" class="java.lang.String"/> <field name="cantidad" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="precio" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="eliminadoproducto" class="java.lang.Boolean"/> <field name="eliminadocategoria" class="java.lang.Boolean"/> <field name="eliminadomarca" class="java.lang.Boolean"/> <field name="eliminadobodegadetalle" class="java.lang.Boolean"/> <field name="eliminadobodega" class="java.lang.Boolean"/> <field name="eliminadoagencia" class="java.lang.Boolean"/> <field name="eliminadoempresa" class="java.lang.Boolean"/> <variable name="totalCantidad" class="java.lang.Integer" calculation="Sum"> <variableExpression><![CDATA[$F{cantidad}]]></variableExpression> </variable> <group name="Empresa"> <groupExpression><![CDATA[$F{idempresa}]]></groupExpression> <groupHeader> <band height="15"> <textField> <reportElement uuid="5601b8e9-8e42-446a-a078-f22511c21e87" x="55" y="0" width="179" height="15" forecolor="#0033CC"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{razonsocial}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="ad884240-4e05-4423-aa68-60263d346a36" x="2" y="0" width="52" height="15"/> <textElement/> <text><![CDATA[Empresa :]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="50"/> </groupFooter> </group> <group name="Agencia"> <groupExpression><![CDATA[$F{idagencia}]]></groupExpression> <groupHeader> <band height="15"> 357 <textField> <reportElement uuid="5e5511c4-1fed-4914-932b-ed5e5c699912" x="63" y="0" width="159" height="15" forecolor="#006666"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{nombreagencia}]]></textFieldExpressio n> </textField> <staticText> <reportElement uuid="b12f2804-8b69-4e75-865e-fdecf5782c7f" x="12" y="0" width="52" height="15"/> <textElement/> <text><![CDATA[Agencia :]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="50"/> </groupFooter> </group> <group name="categoria"> <groupExpression><![CDATA[$F{idcategoria}]]></groupExpression> <groupHeader> <band height="41"> <rectangle> <reportElement uuid="f04341d9-6d5f-4058-916a-ff38bfa3af86" x="22" y="0" width="550" height="15" backcolor="#D8E3F9"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> <textField> <reportElement uuid="a4b802ba-3c5a-4652-9e60-0f0bb4edd131" x="75" y="0" width="131" height="15" forecolor="#000066"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{nombrecategoria}]]></textFieldExpress ion> </textField> <staticText> <reportElement uuid="173e59bb-d5f1-44cf-bb82-7e09dd727288" x="132" y="20" width="100" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Producto]]></text> </staticText> <staticText> <reportElement uuid="b29227d3-2828-4b42-a19f-05bdccfd3c9d" x="256" y="20" width="100" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Marca]]></text> </staticText> <staticText> 358 <reportElement uuid="90d8ea91-ee27-4760-bf37-d04c97e2953b" x="375" y="20" width="100" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Cantidad]]></text> </staticText> <line> <reportElement uuid="cb46866e-2e83-494c-a194-f088961c229d" x="49" y="40" width="426" height="1"/> </line> <staticText> <reportElement uuid="99473bc2-bfb8-4055-9ed1-c0b19329f9c4" x="92" y="20" width="38" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[Id Prod.]]></text> </staticText> <staticText> <reportElement uuid="61bc0a29-972b-407f-9067-d4f7c345520c" x="49" y="20" width="44" height="20"/> <textElement verticalAlignment="Middle"> <font isBold="true"/> </textElement> <text><![CDATA[QR]]></text> </staticText> <staticText> <reportElement uuid="dfee0ca9-4a2d-4895-a310-8fb467d1243f" x="22" y="0" width="52" height="15"/> <textElement/> <text><![CDATA[Categoría :]]></text> </staticText> </band> </groupHeader> <groupFooter> <band height="34"> <textField> <reportElement uuid="eeec0990-003a-4516-91bf-57e60abda24d" x="134" y="5" width="100" height="15"/> <textElement/> <textFieldExpression><![CDATA[$V{categoria_COUNT}]]></textFieldExpress ion> </textField> <textField isBlankWhenNull="false"> <reportElement uuid="572f42a3-6a51-4e47-85b8-f599c5f1c1d0" x="373" y="7" width="102" height="15"/> <textElement/> <textFieldExpression><![CDATA[$V{totalCantidad}]]></textFieldExpressio n> </textField> <staticText> <reportElement uuid="eb6c7bca-e339-4ad5-91a9-cfd54e46c676" x="49" y="5" width="83" height="15"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[núm. Productos:]]></text> </staticText> 359 <staticText> <reportElement uuid="dfa12522-4aa5-485b-ac50-b9831f155847" y="7" width="83" height="15"/> <textElement textAlignment="Right"> <font isBold="true"/> </textElement> <text><![CDATA[Cantidad Total:]]></text> </staticText> </band> </groupFooter> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="70" splitType="Stretch"> <rectangle> <reportElement uuid="9779b109-85e0-45fe-b27f-09d1c4672974" width="572" height="48" backcolor="#8DB4DF"/> <graphicElement> <pen lineWidth="0.0"/> </graphicElement> </rectangle> <rectangle> <reportElement uuid="d1480583-947b-49e5-b66b-ea0504bd8bf8" y="48" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <staticText> <reportElement uuid="bc2f5a4b-06f9-48b0-8dd4-b19f0938e9af" y="8" width="324" height="35" forecolor="#FFFFFF"/> <textElement> <font size="24" isBold="true"/> </textElement> <text><![CDATA[STOCK DE PRODUCTOS]]></text> </staticText> <textField pattern="dd/MM/yyyy"> <reportElement uuid="a330ab73-7b5d-4689-9fdf-8e2dda8b5e31" y="51" width="67" height="17" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <staticText> <reportElement uuid="abe481e3-77c5-4bf1-9f95-82da795fc29b" y="51" width="52" height="15" forecolor="#FFFF00"/> <textElement textAlignment="Right"/> <text><![CDATA[Fecha:]]></text> </staticText> </band> </title> <pageHeader> <band height="11" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="14" splitType="Stretch"/> </columnHeader> x="290" x="0" y="0" x="0" x="12" x="505" x="453" 360 <detail> <band height="16" splitType="Stretch"> <textField> <reportElement uuid="a5fdcd64-f3d1-4a10-bee0-d7fd038b2906" x="132" y="0" width="100" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{nombreproducto}]]></textFieldExpressi on> </textField> <textField> <reportElement uuid="5ee044e6-98e6-421e-b859-520b1a1a7c2b" x="256" y="0" width="100" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{nombremarca}]]></textFieldExpression> </textField> <textField> <reportElement uuid="c2d16954-505e-4ae2-9713-83453029053f" x="375" y="0" width="100" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{cantidad}]]></textFieldExpression> </textField> <line> <reportElement uuid="82245828-55aa-4099-80e2-3412283b2422" x="49" y="15" width="426" height="1"/> </line> <textField> <reportElement uuid="b01d5e0f-2aa6-49bf-ab7e-cb87cdc6274a" x="93" y="0" width="36" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{idproducto}]]></textFieldExpression> </textField> <textField> <reportElement uuid="ebefca42-5e01-4fa2-b715-c97f383985c7" x="49" y="0" width="25" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{idbodegadetalle}]]></textFieldExpress ion> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="26" splitType="Stretch"> <rectangle> <reportElement uuid="44d83d1f-8489-4942-8a19-33d62582834d" x="0" y="6" width="572" height="20" backcolor="#000000"/> <graphicElement> <pen lineWidth="0.0" lineStyle="Dotted"/> </graphicElement> </rectangle> <textField> <reportElement uuid="6a8d8d10-bcc1-4035-bfa9-edc59020b409" x="232" y="8" width="80" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression> </textField> 361 <textField evaluationTime="Report"> <reportElement uuid="5b05ba5f-6bac-4f44-8bcc-c0ae825f44c1" x="316" y="8" width="40" height="15" forecolor="#FFFFFF"/> <textElement/> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="35" splitType="Stretch"/> </summary> </jasperReport> 10.1.17 REST 10.1.17.1 FACTURARESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjava.util.ArrayList; importjava.util.List; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.PathParam; importjavax.ws.rs.Produces; importjavax.ws.rs.core.GenericEntity; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.Agencia; importpfm.entidades.BodegaDetalle; importpfm.entidades.Descuento; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.entidades.MedioDePago; importpfm.entidades.Usuario; importpfm.jpa.JPADAOFactory; @Path("/factura/") publicclassFacturaResource{ @GET @Path("/carrosCompra/{idUsuario}/{idAgencia}") @Produces(MediaType.APPLICATION_JSON) publicList<Factura>getCarrosCompra(@PathParam("idUsuario")intidUsuario, @PathParam("idAgencia")intidAgencia){ Usuariocliente=JPADAOFactory.getFactory().getUsuarioDAO() .read(idUsuario); Agenciaagencia=JPADAOFactory.getFactory().getAgenciaDAO() .read(idAgencia); returnJPADAOFactory.getFactory().getFacturaDAO() .getFacturasPendientesByClienteAndAgencia(cliente,agencia); } @GET @Path("/delete/{id}") 362 @Produces(MediaType.APPLICATION_JSON) publicResponseEliminarFactura(@PathParam("id")intid) throwsURISyntaxException{ Facturafactura=newFactura(); factura=JPADAOFactory.getFactory().getFacturaDAO().read(id); factura.setEliminado(true); factura.setPendiente(false); JPADAOFactory.getFactory().getFacturaDAO().update(factura); returnResponse.ok(factura).build(); } @GET @Path("/confirmaTotal/{id}/{totalFactura}") @Produces(MediaType.APPLICATION_JSON) publicResponseConfirmarTotal(@PathParam("id")intid, @PathParam("totalFactura")doubletotalFactura) throwsURISyntaxException{ doublevalorDescuento; doublevalorIva; // obtiene la factura por id Facturafactura=newFactura(); factura=JPADAOFactory.getFactory().getFacturaDAO().read(id); // obtiene el listado de facturaDetalle List<FacturaDetalle>facturasDetalle=newArrayList<FacturaDetalle>(); facturasDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); // recorre la factura detalle actualizando los totales for(FacturaDetallef:facturasDetalle){ // obtiene el descuento del producto Descuentodescuento=newDescuento(); intidDescuento=JPADAOFactory.getFactory() .getDescuentoProductoDAO() .getDescuentoId(f.getBodegaDetalle().getProducto(),false); if(idDescuento!=0){ descuento=JPADAOFactory.getFactory().getDescuentoDAO() .getValorDescuentoByFecha(idDescuento,false); if(descuento!=null){ valorDescuento=descuento.getValor(); }else{ valorDescuento=0; } }else{ valorDescuento=0; } // obtiene el iva de la empresa valorIva=JPADAOFactory .getFactory() .getEmpresaDAO() .getIvaByEmpresa( f.getBodegaDetalle().getBodega().getAgencia() .getEmpresa().getId(),false); // actualiza el precio f.setPrecio(JPADAOFactory .getFactory() .getBodegaDetalleDAO() .getPrecioByBodegaDetalle(f.getBodegaDetalle().getId(), false)); // setea los totales JPADAOFactory.getFactory().getFacturaDetalleDAO() .setTotalesFacturaDetalle(f,valorDescuento,valorIva); // actualiza el detalle JPADAOFactory.getFactory().getFacturaDetalleDAO().update(f); } // obtiene nuevamente el listado de facturaDetalle facturasDetalle=newArrayList<FacturaDetalle>(); facturasDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() 363 .getFacturaDetalleByFactura(factura,false); // sete el total de la factura JPADAOFactory.getFactory().getFacturaDAO() .setTotalesFactura(factura,facturasDetalle); // actualiza la factura JPADAOFactory.getFactory().getFacturaDAO().update(factura); returnResponse.ok(factura).build(); } @GET @Path("/confirmaCompra/{idFactura}/{idMedioDePago}") @Produces(MediaType.APPLICATION_JSON) publicResponseConfirmarCompra(@PathParam("idFactura")intidFactura, @PathParam("idMedioDePago")intidMedioDePago) throwsURISyntaxException{ Facturafactura=newFactura(); factura=JPADAOFactory.getFactory().getFacturaDAO().read(idFactura); MedioDePagomedioDePago=newMedioDePago(); medioDePago=JPADAOFactory.getFactory().getMedioPagoDAO() .read(idMedioDePago); // setea la factura en modo confirmar factura.setPagado(true); factura.setMedioDePago(medioDePago); factura.setPendiente(false); // revisa el stock disponible List<FacturaDetalle>listaFacturaDetalle=JPADAOFactory.getFactory() .getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); List<FacturaDetalle>listaFacturaDetalleErroneos=newArrayList<FacturaDetalle>(); BodegaDetallebodegaDetalle=newBodegaDetalle(); for(FacturaDetallef:listaFacturaDetalle){ bodegaDetalle=JPADAOFactory.getFactory().getBodegaDetalleDAO() .read(f.getBodegaDetalle().getId()); if(f.getCantidad()>bodegaDetalle.getCantidad()){ listaFacturaDetalleErroneos.add(f); } } if(listaFacturaDetalleErroneos.size()==0){ for(FacturaDetallef:listaFacturaDetalle){ // actualiza el stock bodegaDetalle=JPADAOFactory.getFactory() .getBodegaDetalleDAO() .read(f.getBodegaDetalle().getId()); bodegaDetalle.setCantidad(bodegaDetalle.getCantidad() -f.getCantidad()); JPADAOFactory.getFactory().getBodegaDetalleDAO() .update(bodegaDetalle); } // actualiza la factura JPADAOFactory.getFactory().getFacturaDAO().update(factura); returnResponse.ok(factura).build(); }else{ GenericEntity<List<FacturaDetalle>>entity=newGenericEntity<List<FacturaDetalle>>( listaFacturaDetalleErroneos){ }; returnResponse.ok(entity).build(); } } } 10.1.17.2 FACTURADETALLERESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; 364 importjava.util.ArrayList; importjava.util.Date; importjava.util.List; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.PathParam; importjavax.ws.rs.Produces; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.BodegaDetalle; importpfm.entidades.Descuento; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.jpa.JPADAOFactory; @Path("/facturaDetalle/") publicclassFacturaDetalleResource{ @GET @Path("/carroCompraActual/{idFactura}") @Produces(MediaType.APPLICATION_JSON) publicList<FacturaDetalle>getCarroCompraActual( @PathParam("idFactura")intidFactura){ Facturafactura=JPADAOFactory.getFactory().getFacturaDAO() .read(idFactura); List<FacturaDetalle>listaFacturaDetalle=newArrayList<FacturaDetalle>(); if(factura!=null){ listaFacturaDetalle=JPADAOFactory.getFactory() .getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); } returnlistaFacturaDetalle; } @GET @Path("/getFacturaDetalleById/{id}") @Produces(MediaType.APPLICATION_JSON) publicResponsegetFacturaDetalleById(@PathParam("id")intid) throwsURISyntaxException{ FacturaDetallefacturaDetalle=newFacturaDetalle(); facturaDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() .read(id); if(facturaDetalle!=null) returnResponse.ok(facturaDetalle).build(); else returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+id).build(); } @GET @Path("/existeProductoByFacturaDetalle/{idFactura}/{idBodegaDetalle}") @Produces(MediaType.APPLICATION_JSON) publicResponseexisteProductoByFacturaDetalle( @PathParam("idFactura")intidFactura, @PathParam("idBodegaDetalle")intidBodegaDetalle) throwsURISyntaxException{ Facturafactura=newFactura(); factura=JPADAOFactory.getFactory().getFacturaDAO().read(idFactura); BodegaDetallebodegaDetalle=newBodegaDetalle(); bodegaDetalle=JPADAOFactory.getFactory().getBodegaDetalleDAO() .read(idBodegaDetalle); FacturaDetallefacturaDetalle=newFacturaDetalle(); 365 facturaDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() .getFacturaDetalleByBodDetAndFac(factura,bodegaDetalle); if(facturaDetalle!=null) returnResponse.ok(facturaDetalle).build(); else returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+idFactura).build(); } @GET @Path("/create/{idFactura}/{idAgencia}/{idCliente}/{idBodegaDetalle}/{id Descuento}/{cantidad}") @Produces(MediaType.APPLICATION_JSON) publicResponseaniadirProducto(@PathParam("idFactura")intidFactura, @PathParam("idAgencia")intidAgencia, @PathParam("idCliente")intidCliente, @PathParam("idBodegaDetalle")intidBodegaDetalle, @PathParam("idDescuento")intidDescuento, @PathParam("cantidad")intcantidad)throwsURISyntaxException{ Facturafactura=newFactura(); // si el idFactura == 0 : crear una nueva if(idFactura==0){ factura.setAgencia(JPADAOFactory.getFactory().getAgenciaDAO() .read(idAgencia)); factura.setCliente(JPADAOFactory.getFactory().getUsuarioDAO() .read(idCliente)); factura.setEliminado(false); factura.setEmpleadoAgencia(null); factura.setFecha(newDate()); factura.setMedioDePago(null); factura.setPagado(false); factura.setPendiente(true); factura.setSubtotal(0); factura.setDescuento(0); factura.setIva(0); factura.setTotal(0); // crea la nuevaFactura JPADAOFactory.getFactory().getFacturaDAO().create(factura); }else{ factura=JPADAOFactory.getFactory().getFacturaDAO() .read(idFactura); } BodegaDetallebodegaDetalle=newBodegaDetalle(); bodegaDetalle=JPADAOFactory.getFactory().getBodegaDetalleDAO() .read(idBodegaDetalle); Descuentodescuento=newDescuento(); descuento=JPADAOFactory.getFactory().getDescuentoDAO() .getValorDescuentoByFecha(idDescuento,false); doublevalorDescuento=0.00; if(descuento!=null){ valorDescuento=descuento.getValor(); } doublevalorIva=JPADAOFactory .getFactory() .getEmpresaDAO() .getIvaByEmpresa( bodegaDetalle.getBodega().getAgencia().getEmpresa() .getId(),false); // genera facturaDetalle FacturaDetallefacturaDetalle=newFacturaDetalle(); facturaDetalle.setFactura(factura); facturaDetalle.setBodegaDetalle(bodegaDetalle); facturaDetalle.setCantidad(cantidad); facturaDetalle.setPrecio(bodegaDetalle.getPrecio()); 366 facturaDetalle.setSubtotal(0); facturaDetalle.setDescuento(0); facturaDetalle.setIva(0); facturaDetalle.setTotal(0); facturaDetalle.setEliminado(false); // setea los totales de la facturaDetalle JPADAOFactory .getFactory() .getFacturaDetalleDAO() .setTotalesFacturaDetalle(facturaDetalle,valorDescuento, valorIva); // crear facturaDetalle JPADAOFactory.getFactory().getFacturaDetalleDAO() .create(facturaDetalle); // obtiene el listado de facturaDetalle List<FacturaDetalle>listaFacturaDetalle=JPADAOFactory.getFactory() .getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); // setea los totales de la factura JPADAOFactory.getFactory().getFacturaDAO() .setTotalesFactura(factura,listaFacturaDetalle); // actualiza la factura JPADAOFactory.getFactory().getFacturaDAO().update(factura); if(factura!=null) returnResponse.ok(factura).build(); else returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+idFactura).build(); } @GET @Path("/update/{idFacturaDetalle}/{idDescuento}/{cantidad}") @Produces(MediaType.APPLICATION_JSON) publicResponseactualizarProducto( @PathParam("idFacturaDetalle")intidFacturaDetalle, @PathParam("idDescuento")intidDescuento, @PathParam("cantidad")intcantidad)throwsURISyntaxException{ FacturaDetallefacturaDetalle=newFacturaDetalle(); Facturafactura=newFactura(); facturaDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() .read(idFacturaDetalle); if(cantidad!=facturaDetalle.getCantidad()){ facturaDetalle.setCantidad(cantidad); facturaDetalle.setPrecio(facturaDetalle.getBodegaDetalle() .getPrecio()); Descuentodescuento=newDescuento(); descuento=JPADAOFactory.getFactory().getDescuentoDAO() .getValorDescuentoByFecha(idDescuento,false); doublevalorDescuento=0.00; if(descuento!=null){ valorDescuento=descuento.getValor(); } doublevalorIva=JPADAOFactory .getFactory() .getEmpresaDAO() .getIvaByEmpresa( facturaDetalle.getBodegaDetalle().getBodega() .getAgencia().getEmpresa().getId(),false); // setea los totales de la facturaDetalle JPADAOFactory .getFactory() .getFacturaDetalleDAO() .setTotalesFacturaDetalle(facturaDetalle,valorDescuento, 367 valorIva); // actualiza facturaDetalle JPADAOFactory.getFactory().getFacturaDetalleDAO() .update(facturaDetalle); // obtiene la factura factura=facturaDetalle.getFactura(); // obtiene el listado de facturaDetalle List<FacturaDetalle>listaFacturaDetalle=JPADAOFactory .getFactory().getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); // setea los totales de la factura JPADAOFactory.getFactory().getFacturaDAO() .setTotalesFactura(factura,listaFacturaDetalle); // actualiza la factura JPADAOFactory.getFactory().getFacturaDAO().update(factura); } returnResponse.ok(factura).build(); } @GET @Path("/delete/{idFacturaDetalle}") @Produces(MediaType.APPLICATION_JSON) publicResponseeliminarPoducto( @PathParam("idFacturaDetalle")intidFacturaDetalle) throwsURISyntaxException{ FacturaDetallefacturaDetalle=newFacturaDetalle(); Facturafactura=newFactura(); facturaDetalle=JPADAOFactory.getFactory().getFacturaDetalleDAO() .read(idFacturaDetalle); factura=facturaDetalle.getFactura(); // elimina facturaDetalle By id JPADAOFactory.getFactory().getFacturaDetalleDAO() .deleteByID(idFacturaDetalle); // obtiene el listado de facturaDetalle List<FacturaDetalle>listaFacturaDetalle=JPADAOFactory.getFactory() .getFacturaDetalleDAO() .getFacturaDetalleByFactura(factura,false); // setea los totales de la factura JPADAOFactory.getFactory().getFacturaDAO() .setTotalesFactura(factura,listaFacturaDetalle); // actualiza la factura JPADAOFactory.getFactory().getFacturaDAO().update(factura); returnResponse.ok(factura).build(); } } 10.1.17.3 DESCUENTORESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.PathParam; importjavax.ws.rs.Produces; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.Descuento; importpfm.entidades.Producto; importpfm.jpa.JPADAOFactory; 368 @Path("/descuento/") publicclassDescuentoResource{ @GET @Path("/getDescuentoByProducto/{idProducto}") @Produces(MediaType.APPLICATION_JSON) publicResponsegetDescuentoByProducto( @PathParam("idProducto")intidProducto)throwsURISyntaxException{ Productoproducto=newProducto(); producto=JPADAOFactory.getFactory().getProductoDAO().read(idProducto); intidDescuento=JPADAOFactory.getFactory().getDescuentoProductoDAO() .getDescuentoId(producto,false); Descuentodescuento=JPADAOFactory.getFactory().getDescuentoDAO() .getValorDescuentoByFecha(idDescuento,false); if(descuento!=null) returnResponse.ok(descuento).build(); else returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+idProducto).build(); } } 10.1.17.4 BODEGADETALLERESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.PathParam; importjavax.ws.rs.Produces; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.BodegaDetalle; importpfm.jpa.JPADAOFactory; @Path("/bodegaDetalle/") publicclassBodegaDetalleResource{ @GET @Path("/getBodegaDetalleById/{id}") @Produces(MediaType.APPLICATION_JSON) publicResponsegetBodegaDetalleById(@PathParam("id")intid) throwsURISyntaxException{ BodegaDetallebodegaDetalle=newBodegaDetalle(); bodegaDetalle=JPADAOFactory.getFactory().getBodegaDetalleDAO() .read(id); if(bodegaDetalle!=null) returnResponse.ok(bodegaDetalle).build(); else returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+id).build(); } } 10.1.17.5 AUTENTICACIONRESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjava.util.List; importjavax.ws.rs.Consumes; 369 importjavax.ws.rs.GET; importjavax.ws.rs.POST; importjavax.ws.rs.Path; importjavax.ws.rs.PathParam; importjavax.ws.rs.Produces; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.Usuario; importpfm.jpa.JPADAOFactory; @Path("/autenticacion/") publicclassAutenticacionResource{ @POST @Path("/create") @Consumes(MediaType.APPLICATION_JSON) publicResponsecreateUsuarioXML(Usuariouser)throwsURISyntaxException{ // rol 2 = cliente user.setRol(JPADAOFactory.getFactory().getRolDAO().read(2)); JPADAOFactory.getFactory().getUsuarioDAO().create(user); returnResponse.status(204).entity("1").build(); } @GET @Path("/login/{username}/{clave}") @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) publicResponseloginXML(@PathParam("username")Stringusername, @PathParam("clave")Stringclave)throwsURISyntaxException{ Usuariousuario=null; String[]attributes={"eliminado","username","password"}; String[]values={"0",username,clave}; Stringorder="id"; intindex=-1; intsize=-1; List<Usuario>usuarios=JPADAOFactory.getFactory().getUsuarioDAO() .find(attributes,values,order,index,size); if(usuarios.size()==1){ usuario=usuarios.get(0); if(usuario.getRol().getId()==2){ returnResponse.ok(usuario).build(); }else{ returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+username) .build(); } }else{ returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: "+username).build(); } } } 10.1.17.6 AGENCIARESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjava.util.List; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.Produces; 370 importjavax.ws.rs.core.GenericEntity; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.Agencia; importpfm.jpa.JPADAOFactory; @Path("/agencia/") publicclassAgenciaResource{ @GET @Path("/listAgencias") @Produces(MediaType.APPLICATION_JSON) publicResponselistAgencias()throwsURISyntaxException{ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; List<Agencia>agencias=JPADAOFactory.getFactory().getAgenciaDAO() .find(attributes,values,order,index,size); if(agencias!=null){ GenericEntity<List<Agencia>>entity=newGenericEntity<List<Agencia>>( agencias){ }; returnResponse.ok(entity).build(); }else{ returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: ").build(); } } } 10.1.17.7 MEDIODEPAGORESOURCE.JAVA packagepfm.beans.rest; importjava.net.URISyntaxException; importjava.util.List; importjavax.ws.rs.GET; importjavax.ws.rs.Path; importjavax.ws.rs.Produces; importjavax.ws.rs.core.GenericEntity; importjavax.ws.rs.core.MediaType; importjavax.ws.rs.core.Response; importpfm.entidades.MedioDePago; importpfm.jpa.JPADAOFactory; @Path("/medioDePago/") publicclassMedioDePagoResource{ @GET @Path("/listMedioPago") @Produces(MediaType.APPLICATION_JSON) publicResponselistAgencias()throwsURISyntaxException{ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; List<MedioDePago>medioDePagos=JPADAOFactory.getFactory() 371 .getMedioPagoDAO().find(attributes,values,order,index,size); if(medioDePagos!=null){ GenericEntity<List<MedioDePago>>entity=newGenericEntity<List<MedioDePago>>( medioDePagos){ }; returnResponse.ok(entity).build(); }else{ returnResponse.status(Response.Status.NOT_FOUND) .entity("Entity not found for UUID: ").build(); } } } 10.1.18 ROL 10.1.18.1 LISTARROL.JAVA packagepfm.beans.rol; importjava.io.Serializable; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importorg.primefaces.event.RowEditEvent; importpfm.dao.RolDAO; importpfm.entidades.Rol; @ManagedBean(name="listarRol") @RequestScoped publicclassListarRolimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; @ManagedProperty(value="#{modificarRol}") privateModificarRolmodificarRolBEAN; @ManagedProperty(value="#{bajaRol}") privateBajaRolbajaRolBEAN; @ManagedProperty(value="#{altaRol}") privateAltaRolaltaRolBEAN; privateList<Rol>lista; privateList<Rol>filtered; privateRol[]selectedRoles; publicListarRol(){ } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicModificarRolgetModificarRolBEAN(){ returnmodificarRolBEAN; } 372 publicvoidsetModificarRolBEAN(ModificarRolmodificarRolBEAN){ this.modificarRolBEAN=modificarRolBEAN; } publicBajaRolgetBajaRolBEAN(){ returnbajaRolBEAN; } publicvoidsetBajaRolBEAN(BajaRolbajaRolBEAN){ this.bajaRolBEAN=bajaRolBEAN; } publicAltaRolgetAltaRolBEAN(){ returnaltaRolBEAN; } publicvoidsetAltaRolBEAN(AltaRolaltaRolBEAN){ this.altaRolBEAN=altaRolBEAN; } publicList<Rol>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(rolDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Rol>lista){ this.lista=lista; } publicList<Rol>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Rol>filtered){ this.filtered=filtered; } publicRol[]getSelectedRoles(){ returnselectedRoles; } publicvoidsetSelectedRoles(Rol[]selectedRoles){ this.selectedRoles=selectedRoles; } publicStringonCrear(){ return"crearRol"; } publicvoidonModificar(RowEditEventevent){ modificarRolBEAN.setRol((Rol)event.getObject()); modificarRolBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Rol cancelada", String.valueOf(((Rol)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ 373 if(selectedRoles.length>0){ for(Rolr:selectedRoles){ bajaRolBEAN.setRol(r); bajaRolBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas roles"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarRol"; } publicStringonAlta(){ if(selectedRoles.length>0){ for(Rolr:selectedRoles){ altaRolBEAN.setRol(r); altaRolBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error", "Debe seleccionar uno o mas roles"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarRol"; } } 10.1.18.2 CREARROL.JAVA packagepfm.beans.rol; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importpfm.dao.RolDAO; importpfm.entidades.Rol; @ManagedBean(name="crearRol") publicclassCrearRolimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateRolrol=newRol(); publicCrearRol(){ } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicRolgetRol(){ returnrol; } publicvoidsetRol(Rolrol){ this.rol=rol; 374 } publicStringcrear(){ try{ rolDAO.create(rol); FacesMessagemsg=newFacesMessage("Rol creado"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Rol no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarRol"; } } 10.1.18.3 BAJAROL.JAVA packagepfm.beans.rol; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.RolDAO; importpfm.entidades.Rol; @ManagedBean(name="bajaRol") @RequestScoped publicclassBajaRolimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateRolrol; publicBajaRol(){ } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicRolgetRol(){ returnrol; } publicvoidsetRol(Rolrol){ this.rol=rol; } publicStringbaja(){ try{ rol.setEliminado(true); getRolDAO().update(rol); FacesMessagemsg=newFacesMessage("Rol dado de baja", String.valueOf(rol.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ 375 FacesMessagemsg=newFacesMessage("Error","Rol no dado FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } de baja"); return"listarRol"; } } 10.1.18.4 ALTAROL.JAVA packagepfm.beans.rol; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.RolDAO; importpfm.entidades.Rol; @ManagedBean(name="altaRol") @RequestScoped publicclassAltaRolimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateRolrol; publicAltaRol(){ } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicRolgetRol(){ returnrol; } publicvoidsetRol(Rolrol){ this.rol=rol; } publicStringalta(){ try{ rol.setEliminado(false); getRolDAO().update(rol); FacesMessagemsg=newFacesMessage("Rol dado de alta", String.valueOf(rol.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Rol no dado FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } de alta"); return"listarRol"; } } 376 10.1.18.5 MODIFICARROL.JAVA packagepfm.beans.rol; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.RolDAO; importpfm.entidades.Rol; @ManagedBean(name="modificarRol") @RequestScoped publicclassModificarRolimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateRolrol; publicModificarRol(){ } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } publicRolgetRol(){ returnrol; } publicvoidsetRol(Rolrol){ this.rol=rol; } publicStringmodificar(){ try{ getRolDAO().update(rol); FacesMessagemsg=newFacesMessage("Rol actualizado", String.valueOf(rol.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Rol no actualizado"); FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarRol"; } } 10.1.19 USUARIO 10.1.19.1 LISTARUSUARIO.JAVA packagepfm.beans.usuario; importjava.io.Serializable; importjava.util.ArrayList; 377 importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importorg.primefaces.event.RowEditEvent; importpfm.dao.RolDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.Rol; importpfm.entidades.Usuario; @ManagedBean(name="listarUsuario") @RequestScoped publicclassListarUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; @ManagedProperty(value="#{modificarUsuario}") privateModificarUsuariomodificarUsuarioBEAN; @ManagedProperty(value="#{bajaUsuario}") privateBajaUsuariobajaUsuarioBEAN; @ManagedProperty(value="#{altaUsuario}") privateAltaUsuarioaltaUsuarioBEAN; privateList<Usuario>lista; privateList<Usuario>filtered; privateSelectItem[]roles; privateStringrol; privateUsuario[]selectedUsuarios; publicListarUsuario(){ } publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } publicModificarUsuariogetModificarUsuarioBEAN(){ returnmodificarUsuarioBEAN; } publicvoidsetModificarUsuarioBEAN(ModificarUsuariomodificarUsuarioBEAN){ this.modificarUsuarioBEAN=modificarUsuarioBEAN; } publicBajaUsuariogetBajaUsuarioBEAN(){ returnbajaUsuarioBEAN; } publicvoidsetBajaUsuarioBEAN(BajaUsuariobajaUsuarioBEAN){ this.bajaUsuarioBEAN=bajaUsuarioBEAN; } publicAltaUsuariogetAltaUsuarioBEAN(){ returnaltaUsuarioBEAN; } 378 publicvoidsetAltaUsuarioBEAN(AltaUsuarioaltaUsuarioBEAN){ this.altaUsuarioBEAN=altaUsuarioBEAN; } publicList<Usuario>getLista(){ String[]attributes={}; String[]values={}; Stringorder="id"; intindex=-1; intsize=-1; setLista(usuarioDAO.find(attributes,values,order,index,size)); returnlista; } publicvoidsetLista(List<Usuario>lista){ this.lista=lista; } publicList<Usuario>getFiltered(){ returnfiltered; } publicvoidsetFiltered(List<Usuario>filtered){ this.filtered=filtered; } publicUsuario[]getSelectedUsuarios(){ returnselectedUsuarios; } publicvoidsetSelectedUsuarios(Usuario[]selectedUsuarios){ this.selectedUsuarios=selectedUsuarios; } publicStringonCrear(){ return"crearUsuario"; } publicvoidonModificar(RowEditEventevent){ modificarUsuarioBEAN.setUsuario((Usuario)event.getObject()); modificarUsuarioBEAN.modificar(); } publicvoidonCancel(RowEditEventevent){ FacesMessagemsg=newFacesMessage("Usuario cancelada",String.valueOf(((Usuario)event.getObject()).getId())); FacesContext.getCurrentInstance().addMessage(null,msg); } publicStringonBaja(){ if(selectedUsuarios.length>0){ for(Usuarioe:selectedUsuarios){ bajaUsuarioBEAN.setUsuario(e); bajaUsuarioBEAN.baja(); } }else{ FacesMessagemsg=newFacesMessage("Error","Debe seleccionar usuarios"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarUsuario"; } uno o mas publicStringonAlta(){ 379 if(selectedUsuarios.length>0){ for(Usuarioe:selectedUsuarios){ altaUsuarioBEAN.setUsuario(e); altaUsuarioBEAN.alta(); } }else{ FacesMessagemsg=newFacesMessage("Error","Debe seleccionar usuarios"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarUsuario"; } uno o mas publicSelectItem[]getRoles(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Rol>listaRoles=newArrayList<Rol>(); listaRoles=rolDAO.find(attributes,values,order,index,size); this.roles=newSelectItem[listaRoles.size()]; for(Role:listaRoles){ this.roles[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returnroles; } publicvoidsetRoles(SelectItem[]roles){ this.roles=roles; } publicStringgetRol(){ returnrol; } publicvoidsetRol(Stringrol){ this.rol=rol; } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } } 10.1.19.2 CREARUSUARIO.JAVA packagepfm.beans.usuario; importjava.io.Serializable; importjava.util.ArrayList; importjava.util.List; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.context.FacesContext; importjavax.faces.model.SelectItem; importpfm.dao.RolDAO; importpfm.dao.UsuarioDAO; importpfm.entidades.Rol; importpfm.entidades.Usuario; 380 @ManagedBean(name="crearUsuario") publicclassCrearUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; @ManagedProperty(value="#{DAOFactory.rolDAO}") privateRolDAOrolDAO; privateUsuariousuario=newUsuario(); privateSelectItem[]roles; privateStringrol; publicCrearUsuario(){ } publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } publicUsuariogetUsuario(){ returnusuario; } publicvoidsetUsuario(Usuariousuario){ this.usuario=usuario; } publicStringcrear(){ try{ usuario.setRol(rolDAO.read(Integer.parseInt(this.getRol()))); usuarioDAO.create(usuario); FacesMessagemsg=newFacesMessage("Usuario creado"); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Usuario no creado"); FacesContext.getCurrentInstance().addMessage(null,msg); } return"listarUsuario"; } publicSelectItem[]getRoles(){ String[]attributes={"eliminado"}; String[]values={"0"}; Stringorder="id"; intindex=-1; intsize=-1; inti=0; List<Rol>listaRoles=newArrayList<Rol>(); listaRoles=rolDAO.find(attributes,values,order,index,size); this.roles=newSelectItem[listaRoles.size()]; for(Role:listaRoles){ this.roles[i]=newSelectItem(e.getId(),e.getNombre()); i++; } returnroles; } publicvoidsetRoles(SelectItem[]roles){ this.roles=roles; 381 } publicStringgetRol(){ returnrol; } publicvoidsetRol(Stringrol){ this.rol=rol; } publicRolDAOgetRolDAO(){ returnrolDAO; } publicvoidsetRolDAO(RolDAOrolDAO){ this.rolDAO=rolDAO; } } 10.1.19.3 BAJAUSUARIO.JAVA packagepfm.beans.usuario; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.UsuarioDAO; importpfm.entidades.Usuario; @ManagedBean(name="bajaUsuario") @RequestScoped publicclassBajaUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; privateUsuariousuario; publicBajaUsuario(){ } publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } publicUsuariogetUsuario(){ returnusuario; } publicvoidsetUsuario(Usuariousuario){ this.usuario=usuario; } publicStringbaja(){ try{ usuario.setEliminado(true); getUsuarioDAO().update(usuario); 382 FacesMessagemsg=newFacesMessage("Usuario baja",String.valueOf(usuario.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Usuario no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarUsuario"; } } 10.1.19.4 dada de dada de baja"); ALTAUSUARIO.JAVA packagepfm.beans.usuario; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.UsuarioDAO; importpfm.entidades.Usuario; @ManagedBean(name="altaUsuario") @RequestScoped publicclassAltaUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; privateUsuariousuario; publicAltaUsuario(){ } publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } publicUsuariogetUsuario(){ returnusuario; } publicvoidsetUsuario(Usuariousuario){ this.usuario=usuario; } publicStringalta(){ try{ usuario.setEliminado(false); getUsuarioDAO().update(usuario); FacesMessagemsg=newFacesMessage("Usuario alta",String.valueOf(usuario.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Usuario no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarUsuario"; dada de dada de alta"); 383 } } 10.1.19.5 MODIFICARUSUARIO.JAVA packagepfm.beans.usuario; importjava.io.Serializable; importjavax.faces.application.FacesMessage; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.ManagedProperty; importjavax.faces.bean.RequestScoped; importjavax.faces.context.FacesContext; importpfm.dao.UsuarioDAO; importpfm.entidades.Usuario; @ManagedBean(name="modificarUsuario") @RequestScoped publicclassModificarUsuarioimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @ManagedProperty(value="#{DAOFactory.usuarioDAO}") privateUsuarioDAOusuarioDAO; privateUsuariousuario; publicModificarUsuario(){ } publicUsuarioDAOgetUsuarioDAO(){ returnusuarioDAO; } publicvoidsetUsuarioDAO(UsuarioDAOusuarioDAO){ this.usuarioDAO=usuarioDAO; } publicUsuariogetUsuario(){ returnusuario; } publicvoidsetUsuario(Usuariousuario){ this.usuario=usuario; } publicStringmodificar(){ try{ getUsuarioDAO().update(usuario); FacesMessagemsg=newFacesMessage("Usuario actualizada",String.valueOf(usuario.getId())); FacesContext.getCurrentInstance().addMessage(null,msg); }catch(Exceptione){ FacesMessagemsg=newFacesMessage("Error","Usuario no FacesContext.getCurrentInstance().addMessage(null,msg); FacesContext.getCurrentInstance().validationFailed(); } return"listarUsuario"; } } actualizada"); 10.2 DAO 10.2.1 USUARIODAO.JAVA packagepfm.dao; importjava.util.List; 384 importpfm.entidades.Rol; importpfm.entidades.Usuario; publicinterfaceUsuarioDAOextendsGenericDAO<Usuario,Integer>{ publicList<Usuario>getEmpleado(Rolrol,booleaneliminado); } 10.2.2 AGENCIADAO.JAVA packagepfm.dao; importpfm.entidades.Agencia; publicinterfaceAgenciaDAOextendsGenericDAO<Agencia,Integer>{ } 10.2.3 BODEGADAO.JAVA packagepfm.dao; importpfm.entidades.Bodega; publicinterfaceBodegaDAOextendsGenericDAO<Bodega,Integer>{ } 10.2.4 BODEGADETALLEDAO.JAVA packagepfm.dao; importjava.util.List; importpfm.entidades.Bodega; importpfm.entidades.BodegaDetalle; importpfm.entidades.Producto; publicinterfaceBodegaDetalleDAOextendsGenericDAO<BodegaDetalle,Integer>{ publicList<BodegaDetalle>getBodegaDetalleByBodegaAndProducto( Productoproducto,Bodegabodega); publicdoublegetPrecioByBodegaDetalle(intid,booleaneliminado); } 10.2.5 CATEGORIADAO.JAVA packagepfm.dao; importpfm.entidades.Categoria; publicinterfaceCategoriaDAOextendsGenericDAO<Categoria,Integer>{ } 10.2.6 DAOFACTORY.JAVA packagepfm.dao; importpfm.jpa.JPADAOFactory; publicabstractclassDAOFactory{ protectedstaticDAOFactoryfactory=newJPADAOFactory(); publicstaticDAOFactorygetFactory(){ returnfactory; } 385 publicabstractAgenciaDAOgetAgenciaDAO(); publicabstractBodegaDAOgetBodegaDAO(); publicabstractBodegaDetalleDAOgetBodegaDetalleDAO(); publicabstractCategoriaDAOgetCategoriaDAO(); publicabstractDescuentoDAOgetDescuentoDAO(); publicabstractDescuentoProductoDAOgetDescuentoProductoDAO(); publicabstractEmpresaDAOgetEmpresaDAO(); publicabstractFacturaDAOgetFacturaDAO(); publicabstractFacturaDetalleDAOgetFacturaDetalleDAO(); publicabstractMarcaDAOgetMarcaDAO(); publicabstractMedioPagoDAOgetMedioPagoDAO(); publicabstractProductoDAOgetProductoDAO(); publicabstractRolDAOgetRolDAO(); publicabstractUsuarioDAOgetUsuarioDAO(); publicabstractEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(); } 10.2.7 DESCUENTODAO.JAVA packagepfm.dao; importpfm.entidades.Descuento; publicinterfaceDescuentoDAOextendsGenericDAO<Descuento,Integer>{ publicDescuentogetValorDescuentoByFecha(intid,booleaneliminado); } 10.2.8 DESCUENTOPRODUCTODAO.JAVA packagepfm.dao; importpfm.entidades.DescuentoProducto; importpfm.entidades.Producto; publicinterfaceDescuentoProductoDAOextends GenericDAO<DescuentoProducto,Integer>{ publicintgetDescuentoId(Productoproducto,booleaneliminado); } 10.2.9 EMPLEADOAGENCIADAO.JAVA packagepfm.dao; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Usuario; publicinterfaceEmpleadoAgenciaDAOextends GenericDAO<EmpleadoAgencia,Integer>{ publicEmpleadoAgenciagetAgenciaByEmpleado(Usuarioempleado); 386 } 10.2.10 EMPRESADAO.JAVA packagepfm.dao; importpfm.entidades.Empresa; publicinterfaceEmpresaDAOextendsGenericDAO<Empresa,Integer>{ publicdoublegetIvaByEmpresa(intid,booleaneliminado); } 10.2.11 FACTURADAO.JAVA packagepfm.dao; importjava.util.List; importpfm.entidades.Agencia; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.entidades.Usuario; publicinterfaceFacturaDAOextendsGenericDAO<Factura,Integer>{ publicList<Factura>getFacturasPendientesByAgencia(Agenciaagencia, booleanpendiente); publicList<Factura>getFacturasPendientes(booleanpendiente); publicList<Factura>getFacturasPendientesByCliente(Usuariocliente); publicList<Factura>getFacturasPendientesByClienteAndAgencia( Usuariocliente,Agenciaagencia); publicvoidsetTotalesFactura(Facturafactura, List<FacturaDetalle>listaFacturaDetalle); publicList<Factura>getFacturasGeneradasByEmpleado(Usuarioempleado); publicList<Factura>getFacturasGeneradas(); } 10.2.12 FACTURADETALLEDAO.JAVA packagepfm.dao; importjava.util.List; importpfm.entidades.BodegaDetalle; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; publicinterfaceFacturaDetalleDAOextendsGenericDAO<FacturaDetalle,Integer>{ publicList<FacturaDetalle>getFacturaDetalleByFactura(Facturafactura, booleaneliminado); publicFacturaDetallegetFacturaDetalleByBodDetAndFac(Facturafactura, BodegaDetallebodegaDetalle); publicvoidsetPrecioByBodegaDetalle(FacturaDetallefacturaDetalle, doubleprecio); publicvoidsetTotalesFacturaDetalle(FacturaDetallefacturaDetalle, 387 doublevalorDescuento,doublevalorIva); } 10.2.13 GENERICDAO.JAVA packagepfm.dao; importjava.util.List; publicinterfaceGenericDAO<T,ID>{ publicvoidcreate(Tentity); publicTread(IDid); publicvoidupdate(Tentity); publicvoiddelete(Tentity); publicvoiddeleteByID(IDid); publicList<T>find(String[]attributes,String[]values,Stringorder, intindex,intsize); publicjava.sql.ConnectiongetConexion(); } 10.2.14 MARCADAO.JAVA packagepfm.dao; importpfm.entidades.Marca; publicinterfaceMarcaDAOextendsGenericDAO<Marca,Integer>{ } 10.2.15 MEDIOPAGODAO.JAVA packagepfm.dao; importpfm.entidades.MedioDePago; publicinterfaceMedioPagoDAOextendsGenericDAO<MedioDePago,Integer>{ } 10.2.16 PRODUCTODAO.JAVA packagepfm.dao; importpfm.entidades.Producto; publicinterfaceProductoDAOextendsGenericDAO<Producto,Integer>{ } 10.2.17 ROLDAO.JAVA packagepfm.dao; importpfm.entidades.Rol; publicinterfaceRolDAOextendsGenericDAO<Rol,Integer>{ } 388 10.3 ENTIDADES 10.3.1 USUARIO.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjava.util.Date; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @NamedQuery(name="getEmpleado",query="SELECT :rol AND u.eliminado = :eliminado") @Entity publicclassUsuarioimplementsSerializable{ u FROM Usuario u WHERE u.rol = @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(nullable=false) privateStringnombres; @Column(nullable=false) privateStringapellidos; @Temporal(TemporalType.DATE) @Column(name="FECHA_NACIMIENTO") privateDatefechaNacimiento; privateStringdireccion; privateStringtelefono; @Column(unique=true,nullable=false) privateStringemail; @Column(unique=true,nullable=false) privateStringusername; @Column(nullable=false) privateStringpassword; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateRolrol; @OneToMany(cascade=CascadeType.ALL,mappedBy="cliente") privateSet<Factura>facturaCliente; @OneToMany(cascade=CascadeType.ALL,mappedBy="empleado") privateSet<EmpleadoAgencia>empleadoAgencia; privatestaticfinallongserialVersionUID=1L; publicUsuario(){ } publicUsuario(intid,Stringnombres,Stringapellidos, DatefechaNacimiento,Stringdireccion,Stringtelefono, Stringemail,Stringusername,Stringpassword,booleaneliminado){ this.id=id; this.nombres=nombres; this.apellidos=apellidos; this.fechaNacimiento=fechaNacimiento; this.direccion=direccion; this.telefono=telefono; this.email=email; this.username=username; this.password=password; this.eliminado=eliminado; } 389 publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombres(){ returnthis.nombres; } publicvoidsetNombres(Stringnombres){ this.nombres=nombres; } publicStringgetApellidos(){ returnthis.apellidos; } publicvoidsetApellidos(Stringapellidos){ this.apellidos=apellidos; } publicDategetFechaNacimiento(){ returnthis.fechaNacimiento; } publicvoidsetFechaNacimiento(DatefechaNacimiento){ this.fechaNacimiento=fechaNacimiento; } publicStringgetDireccion(){ returnthis.direccion; } publicvoidsetDireccion(Stringdireccion){ this.direccion=direccion; } publicStringgetTelefono(){ returnthis.telefono; } publicvoidsetTelefono(Stringtelefono){ this.telefono=telefono; } publicStringgetEmail(){ returnemail; } publicvoidsetEmail(Stringemail){ this.email=email; } publicStringgetUsername(){ returnthis.username; } publicvoidsetUsername(Stringusername){ this.username=username; } publicStringgetPassword(){ returnthis.password; } publicvoidsetPassword(Stringpassword){ 390 this.password=password; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicRolgetRol(){ returnrol; } publicvoidsetRol(Rolrol){ this.rol=rol; } @XmlTransient publicSet<Factura>getFacturaCliente(){ returnfacturaCliente; } publicvoidsetFacturaCliente(Set<Factura>facturaCliente){ this.facturaCliente=facturaCliente; } @XmlTransient publicSet<EmpleadoAgencia>getEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(Set<EmpleadoAgencia>empleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } @Override publicStringtoString(){ returnnombres+" "+apellidos; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((apellidos==null)?0:apellidos.hashCode()); result=prime*result +((direccion==null)?0:direccion.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+((email==null)?0:email.hashCode()); result=prime*result +((fechaNacimiento==null)?0:fechaNacimiento.hashCode()); result=prime*result+id; result=prime*result+((nombres==null)?0:nombres.hashCode()); result=prime*result +((password==null)?0:password.hashCode()); result=prime*result+((rol==null)?0:rol.hashCode()); result=prime*result +((telefono==null)?0:telefono.hashCode()); result=prime*result +((username==null)?0:username.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ 391 if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Usuarioother=(Usuario)obj; if(apellidos==null){ if(other.apellidos!=null) returnfalse; }elseif(!apellidos.equals(other.apellidos)) returnfalse; if(direccion==null){ if(other.direccion!=null) returnfalse; }elseif(!direccion.equals(other.direccion)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(email==null){ if(other.email!=null) returnfalse; }elseif(!email.equals(other.email)) returnfalse; if(fechaNacimiento==null){ if(other.fechaNacimiento!=null) returnfalse; }elseif(!fechaNacimiento.equals(other.fechaNacimiento)) returnfalse; if(id!=other.id) returnfalse; if(nombres==null){ if(other.nombres!=null) returnfalse; }elseif(!nombres.equals(other.nombres)) returnfalse; if(password==null){ if(other.password!=null) returnfalse; }elseif(!password.equals(other.password)) returnfalse; if(rol==null){ if(other.rol!=null) returnfalse; }elseif(!rol.equals(other.rol)) returnfalse; if(telefono==null){ if(other.telefono!=null) returnfalse; }elseif(!telefono.equals(other.telefono)) returnfalse; if(username==null){ if(other.username!=null) returnfalse; }elseif(!username.equals(other.username)) returnfalse; returntrue; } } 10.3.2 AGENCIA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement 392 @Entity publicclassAgenciaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; privateStringdireccion; privateStringtelefono; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateEmpresaempresa; @OneToMany(cascade=CascadeType.ALL,mappedBy="agencia") privateSet<Bodega>bodega; @OneToMany(cascade=CascadeType.ALL,mappedBy="agencia") privateSet<EmpleadoAgencia>empleadoAgencia; @OneToMany(cascade=CascadeType.ALL,mappedBy="agencia") privateSet<Factura>factura; publicAgencia(){ } publicAgencia(intid,Stringnombre,Stringdireccion,Stringtelefono, booleaneliminado){ this.id=id; this.nombre=nombre; this.direccion=direccion; this.telefono=telefono; this.eliminado=eliminado; } publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnnombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicStringgetDireccion(){ returndireccion; } publicvoidsetDireccion(Stringdireccion){ this.direccion=direccion; } publicStringgetTelefono(){ returntelefono; } publicvoidsetTelefono(Stringtelefono){ this.telefono=telefono; } publicbooleanisEliminado(){ 393 returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicEmpresagetEmpresa(){ returnempresa; } publicvoidsetEmpresa(Empresaempresa){ this.empresa=empresa; } @XmlTransient publicSet<Bodega>getBodega(){ returnbodega; } publicvoidsetBodega(Set<Bodega>bodega){ this.bodega=bodega; } @XmlTransient publicSet<EmpleadoAgencia>getEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(Set<EmpleadoAgencia>empleadoAgencia){ this.empleadoAgencia=empleadoAgencia; } @XmlTransient publicSet<Factura>getFactura(){ returnfactura; } publicvoidsetFactura(Set<Factura>factura){ this.factura=factura; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((direccion==null)?0:direccion.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+((empresa==null)?0:empresa.hashCode()); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); result=prime*result +((telefono==null)?0:telefono.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) 394 returnfalse; Agenciaother=(Agencia)obj; if(direccion==null){ if(other.direccion!=null) returnfalse; }elseif(!direccion.equals(other.direccion)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(empresa==null){ if(other.empresa!=null) returnfalse; }elseif(!empresa.equals(other.empresa)) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; if(telefono==null){ if(other.telefono!=null) returnfalse; }elseif(!telefono.equals(other.telefono)) returnfalse; returntrue; } } 10.3.3 BODEGA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity publicclassBodegaimplementsSerializable{ privatestaticfinallongserialVersionUID=1L; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; privateStringdireccion; privateStringtelefono; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateAgenciaagencia; @OneToMany(cascade=CascadeType.ALL,mappedBy="bodega") privateSet<BodegaDetalle>bodegaDetalle; publicBodega(){ } publicBodega(intid,Stringnombre,Stringdireccion,Stringtelefono, booleaneliminado){ this.id=id; this.nombre=nombre; this.direccion=direccion; 395 this.telefono=telefono; this.eliminado=eliminado; } publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnnombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicStringgetDireccion(){ returndireccion; } publicvoidsetDireccion(Stringdireccion){ this.direccion=direccion; } publicStringgetTelefono(){ returntelefono; } publicvoidsetTelefono(Stringtelefono){ this.telefono=telefono; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } @XmlTransient publicSet<BodegaDetalle>getBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(Set<BodegaDetalle>bodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; 396 intresult=1; result=prime*result+((agencia==null)?0:agencia.hashCode()); result=prime*result +((direccion==null)?0:direccion.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); result=prime*result +((telefono==null)?0:telefono.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Bodegaother=(Bodega)obj; if(agencia==null){ if(other.agencia!=null) returnfalse; }elseif(!agencia.equals(other.agencia)) returnfalse; if(direccion==null){ if(other.direccion!=null) returnfalse; }elseif(!direccion.equals(other.direccion)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; if(telefono==null){ if(other.telefono!=null) returnfalse; }elseif(!telefono.equals(other.telefono)) returnfalse; returntrue; } } 10.3.4 BODEGADETALLE.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; importorg.eclipse.persistence.annotations.Index; importorg.eclipse.persistence.annotations.Indexes; @XmlRootElement @NamedQueries({ @NamedQuery(name="getBodegaDetalleByBodegaAndProducto",query="SELECT d FROM BodegaDetalle d WHERE d.producto = :producto AND d.bodega = :bodega"), @NamedQuery(name="getPrecioByBodegaDetalle",query="SELECT d FROM BodegaDetalle d WHERE d.id = :id AND d.eliminado= :eliminado")}) 397 @Entity @Table(name="BODEGA_DETALLE") @Indexes({ @Index(name="FK_BODEGA_DETALLE_PRODUCTO_ID",columnNames={"PRODUCTO_ID"}), @Index(name="FK_BODEGA_DETALLE_BODEGA_ID",columnNames={"BODEGA_ID"}), @Index(name="UK_BODEGA_DETALLE",columnNames={"BODEGA_ID", "PRODUCTO_ID"},unique=true)}) publicclassBodegaDetalleimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(nullable=false) privateintcantidad; @Column(nullable=false) privatedoubleprecio; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateBodegabodega; @ManyToOne @JoinColumn(nullable=false) privateProductoproducto; @OneToMany(cascade=CascadeType.ALL,mappedBy="bodegaDetalle") privateSet<FacturaDetalle>facturaDetalle; privatestaticfinallongserialVersionUID=1L; publicBodegaDetalle(){ } publicBodegaDetalle(intid,intcantidad,doubleprecio,booleaneliminado){ this.id=id; this.cantidad=cantidad; this.precio=precio; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicintgetCantidad(){ returnthis.cantidad; } publicvoidsetCantidad(intcantidad){ this.cantidad=cantidad; } publicdoublegetPrecio(){ returnthis.precio; } publicvoidsetPrecio(doubleprecio){ this.precio=precio; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ 398 this.eliminado=eliminado; } publicBodegagetBodega(){ returnbodega; } publicvoidsetBodega(Bodegabodega){ this.bodega=bodega; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } @XmlTransient publicSet<FacturaDetalle>getFacturaDetalle(){ returnfacturaDetalle; } publicvoidsetFacturaDetalle(Set<FacturaDetalle>facturaDetalle){ this.facturaDetalle=facturaDetalle; } @Override publicStringtoString(){ return"BodegaDetalle [id="+id+", cantidad="+cantidad +", precio="+precio+", eliminado="+eliminado +", bodega="+bodega+", producto="+producto+"]"; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+((bodega==null)?0:bodega.hashCode()); result=prime*result+cantidad; result=prime*result+(eliminado?1231:1237); result=prime*result+id; longtemp; temp=Double.doubleToLongBits(precio); result=prime*result+(int)(temp^(temp>>>32)); result=prime*result +((producto==null)?0:producto.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; BodegaDetalleother=(BodegaDetalle)obj; if(bodega==null){ if(other.bodega!=null) returnfalse; }elseif(!bodega.equals(other.bodega)) returnfalse; if(cantidad!=other.cantidad) returnfalse; if(eliminado!=other.eliminado) returnfalse; 399 if(id!=other.id) returnfalse; if(Double.doubleToLongBits(precio)!=Double .doubleToLongBits(other.precio)) returnfalse; if(producto==null){ if(other.producto!=null) returnfalse; }elseif(!producto.equals(other.producto)) returnfalse; returntrue; } } 10.3.5 CATEGORIA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity publicclassCategoriaimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatebooleaneliminado; @OneToMany(cascade=CascadeType.ALL,mappedBy="categoria") privateSet<Producto>producto; privatestaticfinallongserialVersionUID=1L; publicCategoria(){ } publicCategoria(intid,Stringnombre,booleaneliminado){ this.id=id; this.nombre=nombre; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnthis.nombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicbooleangetEliminado(){ returnthis.eliminado; 400 } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } @XmlTransient publicSet<Producto>getProducto(){ returnproducto; } publicvoidsetProducto(Set<Producto>producto){ this.producto=producto; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Categoriaother=(Categoria)obj; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; returntrue; } } 10.3.6 DESCUENTO.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjava.util.Date; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement 401 @NamedQuery(name="getValorDescuentoByFecha",query="SELECT d WHERE d.id = :id AND d.eliminado = BETWEEN d.fechaInicio AND d.fechaFin ") :eliminado d FROM Descuento AND :fechaActual @Entity publicclassDescuentoimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatedoublevalor; @Temporal(TemporalType.DATE) @Column(name="FECHA_INICIO",nullable=false) privateDatefechaInicio; @Temporal(TemporalType.DATE) @Column(name="FECHA_FIN",nullable=false) privateDatefechaFin; @Column(nullable=false) privatebooleaneliminado; @OneToMany(cascade=CascadeType.ALL,mappedBy="descuento") privateSet<DescuentoProducto>descuentoProducto; privatestaticfinallongserialVersionUID=1L; publicDescuento(){ } publicDescuento(intid,Stringnombre,doublevalor,DatefechaInicio, DatefechaFin,booleaneliminado){ this.id=id; this.nombre=nombre; this.valor=valor; this.fechaInicio=fechaInicio; this.fechaFin=fechaFin; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnthis.nombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicdoublegetValor(){ returnthis.valor; } publicvoidsetValor(doublevalor){ this.valor=valor; } publicDategetFechaInicio(){ returnfechaInicio; } publicvoidsetFechaInicio(DatefechaInicio){ this.fechaInicio=fechaInicio; 402 } publicDategetFechaFin(){ returnfechaFin; } publicvoidsetFechaFin(DatefechaFin){ this.fechaFin=fechaFin; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } @XmlTransient publicSet<DescuentoProducto>getDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(Set<DescuentoProducto>descuentoProducto){ this.descuentoProducto=descuentoProducto; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+(eliminado?1231:1237); result=prime*result +((fechaFin==null)?0:fechaFin.hashCode()); result=prime*result +((fechaInicio==null)?0:fechaInicio.hashCode()); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); longtemp; temp=Double.doubleToLongBits(valor); result=prime*result+(int)(temp^(temp>>>32)); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Descuentoother=(Descuento)obj; if(eliminado!=other.eliminado) returnfalse; if(fechaFin==null){ if(other.fechaFin!=null) returnfalse; }elseif(!fechaFin.equals(other.fechaFin)) returnfalse; if(fechaInicio==null){ if(other.fechaInicio!=null) returnfalse; }elseif(!fechaInicio.equals(other.fechaInicio)) returnfalse; 403 if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; if(Double.doubleToLongBits(valor)!=Double .doubleToLongBits(other.valor)) returnfalse; returntrue; } } 10.3.7 DESCUENTOPRODUCTO.JAVA packagepfm.entidades; importjava.io.Serializable; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importorg.eclipse.persistence.annotations.Index; importorg.eclipse.persistence.annotations.Indexes; @XmlRootElement @NamedQuery(name="getDescuentoId",query="SELECT d FROM DescuentoProducto d WHERE d.producto = :producto AND d.eliminado = :eliminado") @Entity @Table(name="DESCUENTO_PRODUCTO") @Indexes({ @Index(name="FK_DESCUENTO_PRODUCTO_PRODUCTO_ID",columnNames={"PRODUCTO_ID"}) , @Index(name="FK_DESCUENTO_PRODUCTO_DESCUENTO_ID",columnNames={"DESCUENTO_ID" }), @Index(name="UK_DESCUENTO_PRODUCTO",columnNames={"PRODUCTO_ID", "DESCUENTO_ID"},unique=true)}) publicclassDescuentoProductoimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateProductoproducto; @ManyToOne @JoinColumn(nullable=false) privateDescuentodescuento; privatestaticfinallongserialVersionUID=1L; publicDescuentoProducto(){ } publicDescuentoProducto(intid,booleaneliminado){ this.id=id; this.eliminado=eliminado; } publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } 404 publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicProductogetProducto(){ returnproducto; } publicvoidsetProducto(Productoproducto){ this.producto=producto; } publicDescuentogetDescuento(){ returndescuento; } publicvoidsetDescuento(Descuentodescuento){ this.descuento=descuento; } @Override publicStringtoString(){ return"DescuentoProducto [id="+id+", eliminado="+eliminado +", producto="+producto+", descuento="+descuento+"]"; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((descuento==null)?0:descuento.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result +((producto==null)?0:producto.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; DescuentoProductoother=(DescuentoProducto)obj; if(descuento==null){ if(other.descuento!=null) returnfalse; }elseif(!descuento.equals(other.descuento)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(producto==null){ if(other.producto!=null) returnfalse; }elseif(!producto.equals(other.producto)) returnfalse; returntrue; } } 405 10.3.8 EMPLEADOAGENCIA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; importorg.eclipse.persistence.annotations.Index; importorg.eclipse.persistence.annotations.Indexes; @XmlRootElement @NamedQuery(name="getAgenciaByEmpleado",query="SELECT a FROM EmpleadoAgencia a WHERE a.empleado = :empleado") @Entity @Table(name="EMPLEADO_AGENCIA") @Indexes({ @Index(name="FK_EMPLEADO_AGENCIA_AGENCIA_ID",columnNames={"AGENCIA_ID"}), @Index(name="FK_EMPLEADO_AGENCIA_EMPLEADO_ID",columnNames={"EMPLEADO_ID"}), @Index(name="UK_EMPLEADO_AGENCIA",columnNames={"AGENCIA_ID", "EMPLEADO_ID"},unique=true)}) publicclassEmpleadoAgenciaimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateUsuarioempleado; @ManyToOne @JoinColumn(nullable=false) privateAgenciaagencia; @OneToMany(cascade=CascadeType.ALL,mappedBy="empleadoAgencia") privateSet<Factura>factura; privatestaticfinallongserialVersionUID=1L; publicEmpleadoAgencia(){ super(); } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicUsuariogetEmpleado(){ returnempleado; } publicvoidsetEmpleado(Usuarioempleado){ this.empleado=empleado; 406 } publicAgenciagetAgencia(){ returnagencia; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } @XmlTransient publicSet<Factura>getFactura(){ returnfactura; } publicvoidsetFactura(Set<Factura>factura){ this.factura=factura; } @Override publicStringtoString(){ return"EmpleadoAgencia [id="+id+", eliminado="+eliminado +", empleado="+empleado+", agencia="+agencia+"]"; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+((agencia==null)?0:agencia.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result +((empleado==null)?0:empleado.hashCode()); result=prime*result+id; returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; EmpleadoAgenciaother=(EmpleadoAgencia)obj; if(agencia==null){ if(other.agencia!=null) returnfalse; }elseif(!agencia.equals(other.agencia)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(empleado==null){ if(other.empleado!=null) returnfalse; }elseif(!empleado.equals(other.empleado)) returnfalse; if(id!=other.id) returnfalse; returntrue; } } 10.3.9 EMPRESA.JAVA packagepfm.entidades; importjava.io.Serializable; 407 importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @NamedQuery(name="getIvaByEmpresa",query="SELECT e.id = :id AND e.eliminado = :eliminado") @Entity publicclassEmpresaimplementsSerializable{ e FROM Empresa e WHERE privatestaticfinallongserialVersionUID=1L; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(name="RAZON_SOCIAL",unique=true,nullable=false) privateStringrazonSocial; @Column(nullable=false) privateStringruc; privateStringdireccion; privateStringtelefono; @Column(nullable=false) privatedoubleiva; @Column(nullable=false) privatebooleaneliminado; @OneToMany(cascade=CascadeType.ALL,mappedBy="empresa") privateSet<Agencia>agencia; publicEmpresa(){ } publicEmpresa(intid,StringrazonSocial,Stringruc,Stringdireccion, Stringtelefono,doubleiva,booleaneliminado){ this.id=id; this.razonSocial=razonSocial; this.ruc=ruc; this.direccion=direccion; this.telefono=telefono; this.iva=iva; this.eliminado=eliminado; } publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetRazonSocial(){ returnrazonSocial; } publicvoidsetRazonSocial(StringrazonSocial){ this.razonSocial=razonSocial; } publicStringgetRuc(){ returnruc; } publicvoidsetRuc(Stringruc){ this.ruc=ruc; } 408 publicStringgetDireccion(){ returndireccion; } publicvoidsetDireccion(Stringdireccion){ this.direccion=direccion; } publicStringgetTelefono(){ returntelefono; } publicvoidsetTelefono(Stringtelefono){ this.telefono=telefono; } publicdoublegetIva(){ returniva; } publicvoidsetIva(doubleiva){ this.iva=iva; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } @XmlTransient publicSet<Agencia>getAgencia(){ returnagencia; } publicvoidsetAgencia(Set<Agencia>agencia){ this.agencia=agencia; } @Override publicStringtoString(){ returnrazonSocial; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((direccion==null)?0:direccion.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+id; longtemp; temp=Double.doubleToLongBits(iva); result=prime*result+(int)(temp^(temp>>>32)); result=prime*result +((razonSocial==null)?0:razonSocial.hashCode()); result=prime*result+((ruc==null)?0:ruc.hashCode()); result=prime*result +((telefono==null)?0:telefono.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; 409 if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Empresaother=(Empresa)obj; if(direccion==null){ if(other.direccion!=null) returnfalse; }elseif(!direccion.equals(other.direccion)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(Double.doubleToLongBits(iva)!=Double.doubleToLongBits(other.iva)) returnfalse; if(razonSocial==null){ if(other.razonSocial!=null) returnfalse; }elseif(!razonSocial.equals(other.razonSocial)) returnfalse; if(ruc==null){ if(other.ruc!=null) returnfalse; }elseif(!ruc.equals(other.ruc)) returnfalse; if(telefono==null){ if(other.telefono!=null) returnfalse; }elseif(!telefono.equals(other.telefono)) returnfalse; returntrue; } } 10.3.10 FACTURA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Date; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @NamedQueries({ @NamedQuery(name="getFacturasPendientesByAgencia",query="SELECT f FROM Factura f WHERE f.agencia = :agencia AND f.pendiente = :pendiente AND f.empleadoAgencia IS NULL"), @NamedQuery(name="getFacturasPendientes",query="SELECT f FROM Factura f WHERE f.pendiente = :pendiente AND f.empleadoAgencia IS NULL"), @NamedQuery(name="getFacturasPendientesByCliente",query="SELECT f FROM Factura f WHERE f.cliente = :cliente AND f.pagado = false AND f.pendiente = true"), @NamedQuery(name="getFacturasPendientesByClienteAndAgencia",query="SELECT f FROM Factura f WHERE f.agencia = :agencia AND f.cliente = :cliente AND f.pagado = false AND f.pendiente = true AND f.eliminado = false"), @NamedQuery(name="getFacturasGeneradasByEmpleado",query="SELECT f FROM Factura f JOIN f.empleadoAgencia e WHERE e.empleado =:empleado AND f.pagado = true"), @NamedQuery(name="getFacturasGeneradas",query="SELECT f FROM Factura f WHERE f.pagado = true")}) @Entity publicclassFacturaimplementsSerializable{ 410 @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Temporal(TemporalType.DATE) @Column(nullable=false) privateDatefecha; @Column(nullable=false) privatebooleaneliminado; @Column(nullable=false) privatedoublesubtotal; @Column(nullable=false) privatedoubleiva; @Column(nullable=false) privatedoubledescuento; @Column(nullable=false) privatedoubletotal; @Column(nullable=false) privatebooleanpagado; @Column(nullable=false) privatebooleanpendiente; @ManyToOne @JoinColumn(nullable=false) privateUsuariocliente; @ManyToOne @JoinColumn privateEmpleadoAgenciaempleadoAgencia; @OneToOne @JoinColumn(nullable=true) privateMedioDePagomedioDePago; @ManyToOne @JoinColumn(nullable=false) privateAgenciaagencia; @OneToMany(cascade=CascadeType.ALL,mappedBy="factura") privateSet<FacturaDetalle>facturaDetalle; privatestaticfinallongserialVersionUID=1L; publicFactura(){ } publicFactura(intid,Datefecha,booleaneliminado,doublesubtotal, doubleiva,doubledescuento,doubletotal,booleanpagado, booleanpendiente){ this.id=id; this.fecha=fecha; this.eliminado=eliminado; this.subtotal=subtotal; this.iva=iva; this.descuento=descuento; this.total=total; this.pagado=pagado; this.pendiente=pendiente; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicDategetFecha(){ returnthis.fecha; } publicvoidsetFecha(Datefecha){ this.fecha=fecha; } 411 publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicdoublegetSubtotal(){ returnthis.subtotal; } publicvoidsetSubtotal(doublesubtotal){ this.subtotal=subtotal; } publicdoublegetIva(){ returnthis.iva; } publicvoidsetIva(doubleiva){ this.iva=iva; } publicdoublegetDescuento(){ returndescuento; } publicvoidsetDescuento(doubledescuento){ this.descuento=descuento; } publicdoublegetTotal(){ returntotal; } publicvoidsetTotal(doubletotal){ this.total=total; } publicbooleanisPagado(){ returnpagado; } publicvoidsetPagado(booleanpagado){ this.pagado=pagado; } publicvoidsetPendiente(booleanpendiente){ this.pendiente=pendiente; } publicbooleanisPendiente(){ returnpendiente; } publicUsuariogetCliente(){ returncliente; } publicvoidsetCliente(Usuariocliente){ this.cliente=cliente; } publicEmpleadoAgenciagetEmpleadoAgencia(){ returnempleadoAgencia; } publicvoidsetEmpleadoAgencia(EmpleadoAgenciaempleadoAgencia){ 412 this.empleadoAgencia=empleadoAgencia; } @XmlTransient publicSet<FacturaDetalle>getFacturaDetalle(){ returnfacturaDetalle; } publicvoidsetFacturaDetalle(Set<FacturaDetalle>facturaDetalle){ this.facturaDetalle=facturaDetalle; } publicMedioDePagogetMedioDePago(){ returnmedioDePago; } publicvoidsetMedioDePago(MedioDePagomedioDePago){ this.medioDePago=medioDePago; } publicvoidsetAgencia(Agenciaagencia){ this.agencia=agencia; } publicAgenciagetAgencia(){ returnagencia; } @Override publicStringtoString(){ return"Factura [id="+id+", fecha="+fecha+", eliminado=" +eliminado+", subtotal="+subtotal+", iva="+iva +", descuento="+descuento+", total="+total+", pagado=" +pagado+", pendiente="+pendiente+", cliente="+cliente +", empleadoAgencia="+empleadoAgencia+", medioDePago=" +medioDePago+", agencia="+agencia+", facturaDetalle=" +facturaDetalle+"]"; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+((agencia==null)?0:agencia.hashCode()); result=prime*result+((cliente==null)?0:cliente.hashCode()); longtemp; temp=Double.doubleToLongBits(descuento); result=prime*result+(int)(temp^(temp>>>32)); result=prime*result+(eliminado?1231:1237); result=prime*result +((empleadoAgencia==null)?0:empleadoAgencia.hashCode()); result=prime*result+((fecha==null)?0:fecha.hashCode()); result=prime*result+id; temp=Double.doubleToLongBits(iva); result=prime*result+(int)(temp^(temp>>>32)); result=prime*result +((medioDePago==null)?0:medioDePago.hashCode()); result=prime*result+(pagado?1231:1237); result=prime*result+(pendiente?1231:1237); temp=Double.doubleToLongBits(subtotal); result=prime*result+(int)(temp^(temp>>>32)); temp=Double.doubleToLongBits(total); result=prime*result+(int)(temp^(temp>>>32)); returnresult; } 413 @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Facturaother=(Factura)obj; if(agencia==null){ if(other.agencia!=null) returnfalse; }elseif(!agencia.equals(other.agencia)) returnfalse; if(cliente==null){ if(other.cliente!=null) returnfalse; }elseif(!cliente.equals(other.cliente)) returnfalse; if(Double.doubleToLongBits(descuento)!=Double .doubleToLongBits(other.descuento)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(empleadoAgencia==null){ if(other.empleadoAgencia!=null) returnfalse; }elseif(!empleadoAgencia.equals(other.empleadoAgencia)) returnfalse; if(fecha==null){ if(other.fecha!=null) returnfalse; }elseif(!fecha.equals(other.fecha)) returnfalse; if(id!=other.id) returnfalse; if(Double.doubleToLongBits(iva)!=Double.doubleToLongBits(other.iva)) returnfalse; if(medioDePago==null){ if(other.medioDePago!=null) returnfalse; }elseif(!medioDePago.equals(other.medioDePago)) returnfalse; if(pagado!=other.pagado) returnfalse; if(pendiente!=other.pendiente) returnfalse; if(Double.doubleToLongBits(subtotal)!=Double .doubleToLongBits(other.subtotal)) returnfalse; if(Double.doubleToLongBits(total)!=Double .doubleToLongBits(other.total)) returnfalse; returntrue; } } 10.3.11 FACTURADETALLE.JAVA packagepfm.entidades; importjava.io.Serializable; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importorg.eclipse.persistence.annotations.Index; importorg.eclipse.persistence.annotations.Indexes; @XmlRootElement @NamedQueries({ 414 @NamedQuery(name="getFacturaDetalleByFactura",query="SELECT d FROM FacturaDetalle d WHERE d.factura = :factura AND d.eliminado = :eliminado"), @NamedQuery(name="getFacturaDetalleByBodDetAndFac",query="SELECT d FROM FacturaDetalle d WHERE d.factura = :factura AND d.bodegaDetalle = :bodegaDetalle")}) @Entity @Table(name="FACTURA_DETALLE") @Indexes({ @Index(name="FK_FACTURA_DETALLE_BODEGADETALLE_ID",columnNames={"BODEGADETALL E_ID"}), @Index(name="FK_FACTURA_DETALLE_FACTURA_ID",columnNames={"FACTURA_ID"}), @Index(name="UK_FACTURA_DETALLE",columnNames={"FACTURA_ID", "BODEGADETALLE_ID"},unique=true)}) publicclassFacturaDetalleimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(nullable=false) privateintcantidad; @Column(nullable=false) privatedoubleprecio; @Column(nullable=false) privatedoublesubtotal; @Column(nullable=false) privatedoubleiva; @Column(nullable=false) privatedoubledescuento; @Column(nullable=false) privatedoubletotal; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateFacturafactura; @ManyToOne @JoinColumn(nullable=false) privateBodegaDetallebodegaDetalle; privatestaticfinallongserialVersionUID=1L; publicFacturaDetalle(){ } publicFacturaDetalle(intid,intcantidad,doubleprecio,doublesubtotal, doubleiva,doubledescuento,doubletotal,booleaneliminado){ this.id=id; this.cantidad=cantidad; this.precio=precio; this.subtotal=subtotal; this.iva=iva; this.descuento=descuento; this.total=total; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicintgetCantidad(){ returnthis.cantidad; } 415 publicvoidsetCantidad(intcantidad){ this.cantidad=cantidad; } publicdoublegetPrecio(){ returnthis.precio; } publicvoidsetPrecio(doubleprecio){ this.precio=precio; } publicdoublegetSubtotal(){ returnthis.subtotal; } publicvoidsetSubtotal(doublesubtotal){ this.subtotal=subtotal; } publicdoublegetIva(){ returnthis.iva; } publicvoidsetIva(doubleiva){ this.iva=iva; } publicdoublegetDescuento(){ returnthis.descuento; } publicvoidsetDescuento(doubledescuento){ this.descuento=descuento; } publicdoublegetTotal(){ returnthis.total; } publicvoidsetTotal(doubletotal){ this.total=total; } publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicFacturagetFactura(){ returnfactura; } publicvoidsetFactura(Facturafactura){ this.factura=factura; } publicBodegaDetallegetBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(BodegaDetallebodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } 416 @Override publicStringtoString(){ return"FacturaDetalle [id="+id+", cantidad="+cantidad +", precio="+precio+", subtotal="+subtotal+", iva=" +iva+", descuento="+descuento+", total="+total +", eliminado="+eliminado+", factura="+factura +", bodegaDetalle="+bodegaDetalle+"]"; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((bodegaDetalle==null)?0:bodegaDetalle.hashCode()); result=prime*result+cantidad; longtemp; temp=Double.doubleToLongBits(descuento); result=prime*result+(int)(temp^(temp>>>32)); result=prime*result+(eliminado?1231:1237); result=prime*result+((factura==null)?0:factura.hashCode()); result=prime*result+id; temp=Double.doubleToLongBits(iva); result=prime*result+(int)(temp^(temp>>>32)); temp=Double.doubleToLongBits(precio); result=prime*result+(int)(temp^(temp>>>32)); temp=Double.doubleToLongBits(subtotal); result=prime*result+(int)(temp^(temp>>>32)); temp=Double.doubleToLongBits(total); result=prime*result+(int)(temp^(temp>>>32)); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; FacturaDetalleother=(FacturaDetalle)obj; if(bodegaDetalle==null){ if(other.bodegaDetalle!=null) returnfalse; }elseif(!bodegaDetalle.equals(other.bodegaDetalle)) returnfalse; if(cantidad!=other.cantidad) returnfalse; if(Double.doubleToLongBits(descuento)!=Double .doubleToLongBits(other.descuento)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(factura==null){ if(other.factura!=null) returnfalse; }elseif(!factura.equals(other.factura)) returnfalse; if(id!=other.id) returnfalse; if(Double.doubleToLongBits(iva)!=Double.doubleToLongBits(other.iva)) returnfalse; if(Double.doubleToLongBits(precio)!=Double .doubleToLongBits(other.precio)) returnfalse; if(Double.doubleToLongBits(subtotal)!=Double .doubleToLongBits(other.subtotal)) returnfalse; 417 if(Double.doubleToLongBits(total)!=Double .doubleToLongBits(other.total)) returnfalse; returntrue; } } 10.3.12 MARCA.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity publicclassMarcaimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatebooleaneliminado; @OneToMany(cascade=CascadeType.ALL,mappedBy="marca") privateSet<Producto>producto; privatestaticfinallongserialVersionUID=1L; publicMarca(){ } publicMarca(intid,Stringnombre,booleaneliminado){ this.id=id; this.nombre=nombre; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnthis.nombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } 418 @XmlTransient publicSet<Producto>getProducto(){ returnproducto; } publicvoidsetProducto(Set<Producto>producto){ this.producto=producto; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Marcaother=(Marca)obj; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; returntrue; } } 10.3.13 MEDIODEPAGO.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity @Table(name="MEDIO_PAGO") publicclassMedioDePagoimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatebooleaneliminado; 419 @OneToOne(cascade=CascadeType.ALL,mappedBy="medioDePago") privateFacturafactura; privatestaticfinallongserialVersionUID=1L; publicMedioDePago(){ } publicMedioDePago(intid,Stringnombre,booleaneliminado){ this.id=id; this.nombre=nombre; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnthis.nombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } @XmlTransient publicFacturagetFactura(){ returnfactura; } publicvoidsetFactura(Facturafactura){ this.factura=factura; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) 420 returnfalse; MedioDePagoother=(MedioDePago)obj; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; returntrue; } } 10.3.14 PRODUCTO.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.lang.String; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity publicclassProductoimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatebooleaneliminado; @ManyToOne @JoinColumn(nullable=false) privateMarcamarca; @ManyToOne @JoinColumn(nullable=false) privateCategoriacategoria; @OneToMany(cascade=CascadeType.ALL,mappedBy="producto") privateSet<BodegaDetalle>bodegaDetalle; @OneToMany(cascade=CascadeType.ALL,mappedBy="producto") privateSet<DescuentoProducto>descuentoProducto; privatestaticfinallongserialVersionUID=1L; publicProducto(){ } publicProducto(intid,Stringnombre,booleaneliminado){ this.id=id; this.nombre=nombre; this.eliminado=eliminado; } publicintgetId(){ returnthis.id; } publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ 421 returnthis.nombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicbooleangetEliminado(){ returnthis.eliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } publicMarcagetMarca(){ returnmarca; } publicvoidsetMarca(Marcamarca){ this.marca=marca; } publicCategoriagetCategoria(){ returncategoria; } publicvoidsetCategoria(Categoriacategoria){ this.categoria=categoria; } @XmlTransient publicSet<BodegaDetalle>getBodegaDetalle(){ returnbodegaDetalle; } publicvoidsetBodegaDetalle(Set<BodegaDetalle>bodegaDetalle){ this.bodegaDetalle=bodegaDetalle; } @XmlTransient publicSet<DescuentoProducto>getDescuentoProducto(){ returndescuentoProducto; } publicvoidsetDescuentoProducto(Set<DescuentoProducto>descuentoProducto){ this.descuentoProducto=descuentoProducto; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result +((categoria==null)?0:categoria.hashCode()); result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((marca==null)?0:marca.hashCode()); result=prime*result+((nombre==null)?0:nombre.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ 422 if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Productoother=(Producto)obj; if(categoria==null){ if(other.categoria!=null) returnfalse; }elseif(!categoria.equals(other.categoria)) returnfalse; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(marca==null){ if(other.marca!=null) returnfalse; }elseif(!marca.equals(other.marca)) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; returntrue; } } 10.3.15 ROL.JAVA packagepfm.entidades; importjava.io.Serializable; importjava.util.Set; importjavax.persistence.*; importjavax.xml.bind.annotation.XmlRootElement; importjavax.xml.bind.annotation.XmlTransient; @XmlRootElement @Entity publicclassRolimplementsSerializable{ @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) privateintid; @Column(unique=true,nullable=false) privateStringnombre; @Column(nullable=false) privatebooleaneliminado; @OneToMany(cascade=CascadeType.ALL,mappedBy="rol") privateSet<Usuario>usuario; privatestaticfinallongserialVersionUID=1L; publicRol(){ } publicRol(intid,Stringnombre,booleaneliminado){ this.id=id; this.nombre=nombre; this.eliminado=eliminado; } publicintgetId(){ returnid; } 423 publicvoidsetId(intid){ this.id=id; } publicStringgetNombre(){ returnnombre; } publicvoidsetNombre(Stringnombre){ this.nombre=nombre; } publicbooleanisEliminado(){ returneliminado; } publicvoidsetEliminado(booleaneliminado){ this.eliminado=eliminado; } @XmlTransient publicSet<Usuario>getUsuario(){ returnusuario; } publicvoidsetUsuario(Set<Usuario>usuario){ this.usuario=usuario; } @Override publicStringtoString(){ returnnombre; } @Override publicinthashCode(){ finalintprime=31; intresult=1; result=prime*result+(eliminado?1231:1237); result=prime*result+id; result=prime*result+((nombre==null)?0:nombre.hashCode()); returnresult; } @Override publicbooleanequals(Objectobj){ if(this==obj) returntrue; if(obj==null) returnfalse; if(getClass()!=obj.getClass()) returnfalse; Rolother=(Rol)obj; if(eliminado!=other.eliminado) returnfalse; if(id!=other.id) returnfalse; if(nombre==null){ if(other.nombre!=null) returnfalse; }elseif(!nombre.equals(other.nombre)) returnfalse; returntrue; } } 424 10.4 JPA 10.4.1 JPAUSUARIODAO.JAVA packagepfm.jpa; importjava.util.List; importjavax.persistence.Query; importpfm.dao.UsuarioDAO; importpfm.entidades.Rol; importpfm.entidades.Usuario; publicclassJPAUsuarioDAOextendsJPAGenericDAO<Usuario,Integer>implements UsuarioDAO{ publicJPAUsuarioDAO(){ super(Usuario.class); } @Override publicList<Usuario>getEmpleado(Rolrol,booleaneliminado){ Queryquery=em.createNamedQuery("getEmpleado"); query.setParameter("rol",rol); query.setParameter("eliminado",eliminado); @SuppressWarnings("unchecked") List<Usuario>resultado=query.getResultList(); returnresultado; } } 10.4.2 JPAAGENCIADAO.JAVA packagepfm.jpa; importpfm.dao.AgenciaDAO; importpfm.entidades.Agencia; publicclassJPAAgenciaDAOextendsJPAGenericDAO<Agencia,Integer>implements AgenciaDAO{ publicJPAAgenciaDAO(){ super(Agencia.class); } } 10.4.3 JPABODEGADAO.JAVA packagepfm.jpa; importpfm.dao.BodegaDAO; importpfm.entidades.Bodega; publicclassJPABodegaDAOextendsJPAGenericDAO<Bodega,Integer>implements BodegaDAO{ publicJPABodegaDAO(){ super(Bodega.class); } } 425 10.4.4 JPABODEGADETALLEDAO.JAVA packagepfm.jpa; importjava.util.List; importjavax.persistence.Query; importpfm.dao.BodegaDetalleDAO; importpfm.entidades.Bodega; importpfm.entidades.BodegaDetalle; importpfm.entidades.Producto; publicclassJPABodegaDetalleDAOextendsJPAGenericDAO<BodegaDetalle,Integer> implementsBodegaDetalleDAO{ publicJPABodegaDetalleDAO(){ super(BodegaDetalle.class); } @Override publicList<BodegaDetalle>getBodegaDetalleByBodegaAndProducto( Productoproducto,Bodegabodega){ Queryquery=em .createNamedQuery("getBodegaDetalleByBodegaAndProducto"); query.setParameter("producto",producto); query.setParameter("bodega",bodega); @SuppressWarnings("unchecked") List<BodegaDetalle>resultado=query.getResultList(); returnresultado; } @Override publicdoublegetPrecioByBodegaDetalle(intid,booleaneliminado){ try{ Queryquery=em.createNamedQuery("getPrecioByBodegaDetalle"); query.setParameter("id",id); query.setParameter("eliminado",eliminado); BodegaDetalleresultado=(BodegaDetalle)query.getSingleResult(); returnresultado.getPrecio(); }catch(Exceptione){ System.out.println("ERROR: getPrecioByBodegaDetalle "+e); return0; } } } 10.4.5 JPACATEGORIADAO.JAVA packagepfm.jpa; importpfm.dao.CategoriaDAO; importpfm.entidades.Categoria; publicclassJPACategoriaDAOextendsJPAGenericDAO<Categoria,Integer> implementsCategoriaDAO{ publicJPACategoriaDAO(){ super(Categoria.class); } } 10.4.6 JPADAOFACTORY.JAVA packagepfm.jpa; importjavax.faces.bean.ManagedBean; importjavax.faces.bean.SessionScoped; 426 importpfm.dao.AgenciaDAO; importpfm.dao.BodegaDAO; importpfm.dao.BodegaDetalleDAO; importpfm.dao.CategoriaDAO; importpfm.dao.DAOFactory; importpfm.dao.DescuentoDAO; importpfm.dao.DescuentoProductoDAO; importpfm.dao.EmpleadoAgenciaDAO; importpfm.dao.EmpresaDAO; importpfm.dao.FacturaDAO; importpfm.dao.FacturaDetalleDAO; importpfm.dao.MarcaDAO; importpfm.dao.MedioPagoDAO; importpfm.dao.ProductoDAO; importpfm.dao.RolDAO; importpfm.dao.UsuarioDAO; @ManagedBean(name="DAOFactory") @SessionScoped publicclassJPADAOFactoryextendsDAOFactory{ @Override publicAgenciaDAOgetAgenciaDAO(){ returnnewJPAAgenciaDAO(); } @Override publicBodegaDAOgetBodegaDAO(){ returnnewJPABodegaDAO(); } @Override publicBodegaDetalleDAOgetBodegaDetalleDAO(){ returnnewJPABodegaDetalleDAO(); } @Override publicCategoriaDAOgetCategoriaDAO(){ returnnewJPACategoriaDAO(); } @Override publicDescuentoDAOgetDescuentoDAO(){ returnnewJPADescuentoDAO(); } @Override publicDescuentoProductoDAOgetDescuentoProductoDAO(){ returnnewJPADescuentoProductoDAO(); } @Override publicEmpresaDAOgetEmpresaDAO(){ returnnewJPAEmpresaDAO(); } @Override publicFacturaDAOgetFacturaDAO(){ returnnewJPAFacturaDAO(); } @Override publicFacturaDetalleDAOgetFacturaDetalleDAO(){ returnnewJPAFacturaDetalleDAO(); } @Override publicMarcaDAOgetMarcaDAO(){ returnnewJPAMarcaDAO(); 427 } @Override publicMedioPagoDAOgetMedioPagoDAO(){ returnnewJPAMedioPagoDAO(); } @Override publicProductoDAOgetProductoDAO(){ returnnewJPAProductoDAO(); } @Override publicRolDAOgetRolDAO(){ returnnewJPARolDAO(); } @Override publicUsuarioDAOgetUsuarioDAO(){ returnnewJPAUsuarioDAO(); } @Override publicEmpleadoAgenciaDAOgetEmpleadoAgenciaDAO(){ returnnewJPAEmpleadoAgenciaDAO(); } } 10.4.7 JPADESCUENTODAO.JAVA packagepfm.jpa; importjava.util.Date; importjavax.persistence.Query; importpfm.dao.DescuentoDAO; importpfm.entidades.Descuento; publicclassJPADescuentoDAOextendsJPAGenericDAO<Descuento,Integer> implementsDescuentoDAO{ publicJPADescuentoDAO(){ super(Descuento.class); } @Override publicDescuentogetValorDescuentoByFecha(intid,booleaneliminado){ try{ Datefecha=newDate(); Queryquery=em.createNamedQuery("getValorDescuentoByFecha"); query.setParameter("id",id); query.setParameter("eliminado",eliminado); query.setParameter("fechaActual",fecha); Descuentoresultado=(Descuento)query.getSingleResult(); returnresultado; }catch(Exceptione){ //System.out.println("ERROR: getValorDescuentoByFecha " + e); returnnull; } } } 10.4.8 JPADESCUENTOPRODUCTODAO.JAVA packagepfm.jpa; 428 importjavax.persistence.Query; importpfm.dao.DescuentoProductoDAO; importpfm.entidades.DescuentoProducto; importpfm.entidades.Producto; publicclassJPADescuentoProductoDAOextends JPAGenericDAO<DescuentoProducto,Integer>implements DescuentoProductoDAO{ publicJPADescuentoProductoDAO(){ super(DescuentoProducto.class); } @Override publicintgetDescuentoId(Productoproducto,booleaneliminado){ try{ Queryquery=em.createNamedQuery("getDescuentoId"); query.setParameter("producto",producto); query.setParameter("eliminado",eliminado); DescuentoProductoresultado=(DescuentoProducto)query .getSingleResult(); returnresultado.getDescuento().getId(); }catch(Exceptione){ //System.out.println("ERROR: getDescuentoId " + e); return0; } } } 10.4.9 JPAEMPLEADOAGENCIADAO.JAVA packagepfm.jpa; importjavax.persistence.Query; importpfm.dao.EmpleadoAgenciaDAO; importpfm.entidades.EmpleadoAgencia; importpfm.entidades.Usuario; publicclassJPAEmpleadoAgenciaDAOextends JPAGenericDAO<EmpleadoAgencia,Integer>implementsEmpleadoAgenciaDAO{ publicJPAEmpleadoAgenciaDAO(){ super(EmpleadoAgencia.class); } @Override publicEmpleadoAgenciagetAgenciaByEmpleado(Usuarioempleado){ Queryquery=em.createNamedQuery("getAgenciaByEmpleado"); query.setParameter("empleado",empleado); EmpleadoAgenciaresultado=(EmpleadoAgencia)query.getSingleResult(); returnresultado; } } 10.4.10 JPAEMPRESADAO.JAVA packagepfm.jpa; importjavax.persistence.Query; importpfm.dao.EmpresaDAO; importpfm.entidades.Empresa; publicclassJPAEmpresaDAOextendsJPAGenericDAO<Empresa,Integer>implements EmpresaDAO{ 429 publicJPAEmpresaDAO(){ super(Empresa.class); } @Override publicdoublegetIvaByEmpresa(intid,booleaneliminado){ try{ Queryquery=em.createNamedQuery("getIvaByEmpresa"); query.setParameter("id",id); query.setParameter("eliminado",eliminado); Empresaresultado=(Empresa)query.getSingleResult(); returnresultado.getIva(); }catch(Exceptione){ System.out.println("ERROR: getIvaByEmpresa "+e); return0; } } } 10.4.11 JPAFACTURADAO.JAVA packagepfm.jpa; importjava.util.List; importjavax.persistence.Query; importpfm.dao.FacturaDAO; importpfm.entidades.Agencia; importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; importpfm.entidades.Usuario; publicclassJPAFacturaDAOextendsJPAGenericDAO<Factura,Integer>implements FacturaDAO{ publicJPAFacturaDAO(){ super(Factura.class); } @Override publicList<Factura>getFacturasPendientesByAgencia(Agenciaagencia,booleanpendiente){ Queryquery=em.createNamedQuery("getFacturasPendientesByAgencia"); query.setParameter("agencia",agencia); query.setParameter("pendiente",pendiente); @SuppressWarnings("unchecked") List<Factura>resultado=query.getResultList(); returnresultado; } @Override publicList<Factura>getFacturasPendientes(booleanpendiente){ Queryquery=em.createNamedQuery("getFacturasPendientes"); query.setParameter("pendiente",pendiente); @SuppressWarnings("unchecked") List<Factura>resultado=query.getResultList(); returnresultado; } @Override publicList<Factura>getFacturasPendientesByCliente(Usuariocliente){ Queryquery=em.createNamedQuery("getFacturasPendientesByCliente"); query.setParameter("cliente",cliente); @SuppressWarnings("unchecked") 430 List<Factura>resultado=query.getResultList(); returnresultado; } @Override publicList<Factura>getFacturasPendientesByClienteAndAgencia( Usuariocliente,Agenciaagencia){ Queryquery=em .createNamedQuery("getFacturasPendientesByClienteAndAgencia"); query.setParameter("cliente",cliente); query.setParameter("agencia",agencia); @SuppressWarnings("unchecked") List<Factura>resultado=query.getResultList(); returnresultado; } @Override publicvoidsetTotalesFactura(Facturafactura, List<FacturaDetalle>listaFacturaDetalle){ doubledescuento=0; doubleiva=0; doublesubtotal=0; doubletotal=0; for(FacturaDetalledet:listaFacturaDetalle){ descuento=Math.round((descuento+det.getDescuento())*100.0)/100.0; iva=Math.round((iva+det.getIva())*100.0)/100.0; subtotal=Math.round((subtotal+det.getSubtotal())*100.0)/100.0; total=Math.round((total+det.getTotal())*100.0)/100.0; } factura.setDescuento(descuento); factura.setIva(iva); factura.setSubtotal(subtotal); factura.setTotal(total); } @Override publicList<Factura>getFacturasGeneradasByEmpleado(Usuarioempleado){ Queryquery=em.createNamedQuery("getFacturasGeneradasByEmpleado"); query.setParameter("empleado",empleado); @SuppressWarnings("unchecked") List<Factura>resultado=query.getResultList(); returnresultado; } @Override publicList<Factura>getFacturasGeneradas(){ Queryquery=em.createNamedQuery("getFacturasGeneradas"); @SuppressWarnings("unchecked") List<Factura>resultado=query.getResultList(); returnresultado; } } 10.4.12 JPAFACTURADETALLEDAO.JAVA packagepfm.jpa; importjava.util.List; importjavax.persistence.Query; importpfm.dao.FacturaDetalleDAO; importpfm.entidades.BodegaDetalle; 431 importpfm.entidades.Factura; importpfm.entidades.FacturaDetalle; publicclassJPAFacturaDetalleDAOextends JPAGenericDAO<FacturaDetalle,Integer>implementsFacturaDetalleDAO{ publicJPAFacturaDetalleDAO(){ super(FacturaDetalle.class); } @Override publicList<FacturaDetalle>getFacturaDetalleByFactura(Facturafactura, booleaneliminado){ Queryquery=em.createNamedQuery("getFacturaDetalleByFactura"); query.setParameter("factura",factura); query.setParameter("eliminado",eliminado); @SuppressWarnings("unchecked") List<FacturaDetalle>resultado=query.getResultList(); returnresultado; } @Override publicFacturaDetallegetFacturaDetalleByBodDetAndFac(Facturafactura, BodegaDetallebodegaDetalle){ Queryquery=em.createNamedQuery("getFacturaDetalleByBodDetAndFac"); query.setParameter("factura",factura); query.setParameter("bodegaDetalle",bodegaDetalle); FacturaDetalleresultado=(FacturaDetalle)query.getSingleResult(); returnresultado; } @Override publicvoidsetPrecioByBodegaDetalle(FacturaDetallefacturaDetalle, doubleprecio){ facturaDetalle.setPrecio(precio); } @Override publicvoidsetTotalesFacturaDetalle(FacturaDetallefacturaDetalle, doublevalorDescuento,doublevalorIva){ doubledescuento=0; doubleiva=0; doublesubtotal=0; doubletotal=0; subtotal=Math.round((facturaDetalle.getCantidad()*facturaDetalle .getPrecio())*100.0)/100.0; descuento=Math.round(((subtotal*valorDescuento)/100)*100.0)/100.0; iva=Math.round(((subtotal*valorIva)/100)*100.0)/100.0; total=Math.round((subtotal-descuento+iva)*100.0)/100.0; facturaDetalle.setDescuento(descuento); facturaDetalle.setIva(iva); facturaDetalle.setSubtotal(subtotal); facturaDetalle.setTotal(total); } } 432 10.4.13 JPAGENERICDAO.JAVA packagepfm.jpa; importjava.sql.Connection; importjava.util.List; importjavax.persistence.EntityManager; importjavax.persistence.Persistence; importjavax.persistence.Query; importjavax.persistence.TypedQuery; importjavax.persistence.criteria.CriteriaBuilder; importjavax.persistence.criteria.CriteriaQuery; importjavax.persistence.criteria.Predicate; importjavax.persistence.criteria.Root; importorg.eclipse.persistence.exceptions.EclipseLinkException; importpfm.dao.GenericDAO; publicclassJPAGenericDAO<T,ID>implementsGenericDAO<T,ID>{ privateClass<T>persistentClass; protectedEntityManagerem; publicJPAGenericDAO(Class<T>persistentClass){ this.persistentClass=persistentClass; this.em=Persistence.createEntityManagerFactory("jpa").createEntityManager(); } @Override publicvoidcreate(Tentity){ em.getTransaction().begin(); try{ em.persist(entity); em.getTransaction().commit(); }catch(EclipseLinkExceptione){ try{ System.out.println(">>>> ERROR:JPAGenericDAO:create if(em.getTransaction().isActive()) em.getTransaction().rollback(); thrownewException(); }catch(Exceptione1){ e1.printStackTrace(); } "+e); } } @Override publicTread(IDid){ returnem.find(persistentClass,id); } @Override publicvoidupdate(Tentity){ em.getTransaction().begin(); try{ em.merge(entity); em.getTransaction().commit(); }catch(EclipseLinkExceptione){ try{ System.out.println(">>>> ERROR:JPAGenericDAO:update if(em.getTransaction().isActive()) em.getTransaction().rollback(); thrownewException(); }catch(Exceptione1){ e1.printStackTrace(); } } } "+e); 433 @Override publicvoiddelete(Tentity){ em.getTransaction().begin(); try{ em.remove(entity); em.getTransaction().commit(); }catch(EclipseLinkExceptione){ try{ System.out.println(">>>> ERROR:JPAGenericDAO:delete if(em.getTransaction().isActive()) em.getTransaction().rollback(); thrownewException(); }catch(Exceptione1){ e1.printStackTrace(); } "+e); } } @Override publicvoiddeleteByID(IDid){ Tentity=this.read(id); if(entity!=null) this.delete(entity); } @SuppressWarnings("unchecked") @Override publicList<T>find(String[]attributes,String[]values,Stringorder,intindex,intsize){ // Se crea un criterio de consulta CriteriaBuildercriteriaBuilder=em.getCriteriaBuilder(); CriteriaQuery<T>criteriaQuery=criteriaBuilder.createQuery(this.persistentClass); // Se establece la clausula FROM Root<T>root=criteriaQuery.from(this.persistentClass); // Se establece la clausula SELECT criteriaQuery.select(root);// criteriaQuery.multiselect(root.get(atr)) // // Se configuran los predicados, // combinados por AND Predicatepredicate=criteriaBuilder.conjunction(); for(inti=0;i<attributes.length;i++){ Predicatesig=criteriaBuilder.like(root.get(attributes[i]).as(String.class),values[i]); // Predicate sig = // criteriaBuilder.like(root.get(attributes[i]).as(String.class), // values[i]); predicate=criteriaBuilder.and(predicate,sig); } // Se establece el WHERE criteriaQuery.where(predicate); // Se establece el orden if(order!=null) criteriaQuery.orderBy(criteriaBuilder.asc(root.get(order)));// Se // crea // el // resultado if(index>=0&&size>0){ TypedQuery<T>tq=em.createQuery(criteriaQuery); tq.setFirstResult(index); tq.setMaxResults(size);// Se realiza la query returntq.getResultList(); }else{ // Se realiza la query Queryquery=em.createQuery(criteriaQuery); returnquery.getResultList(); } } 434 @Override publicConnectiongetConexion(){ em.getTransaction().begin(); java.sql.Connectionconnection=em.unwrap(java.sql.Connection.class); em.getTransaction().commit(); returnconnection; } } 10.4.14 JPAMARCADAO.JAVA packagepfm.jpa; importpfm.dao.MarcaDAO; importpfm.entidades.Marca; publicclassJPAMarcaDAOextendsJPAGenericDAO<Marca,Integer>implements MarcaDAO{ publicJPAMarcaDAO(){ super(Marca.class); } } 10.4.15 JPAMEDIOPAGODAO.JAVA packagepfm.jpa; importpfm.dao.MedioPagoDAO; importpfm.entidades.MedioDePago; publicclassJPAMedioPagoDAOextendsJPAGenericDAO<MedioDePago,Integer> implementsMedioPagoDAO{ publicJPAMedioPagoDAO(){ super(MedioDePago.class); } } 10.4.16 JPAPRODUCTODAO.JAVA packagepfm.jpa; importpfm.dao.ProductoDAO; importpfm.entidades.Producto; publicclassJPAProductoDAOextendsJPAGenericDAO<Producto,Integer>implements ProductoDAO{ publicJPAProductoDAO(){ super(Producto.class); } } 10.4.17 JPAROLDAO.JAVA packagepfm.jpa; importpfm.dao.RolDAO; importpfm.entidades.Rol; publicclassJPARolDAOextendsJPAGenericDAO<Rol,Integer>implementsRolDAO{ publicJPARolDAO(){ super(Rol.class); } 435 } 10.5 ARCHIVOS DE CONFIGURACION 10.5.1 FACES-CONFIG.XML <?xmlversion="1.0"encoding="UTF-8"?> <faces-configxmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.c om/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <navigation-rule> <from-view-id>/login/loginUsuario.xhtml</from-view-id> <navigation-case> <from-outcome>error</from-outcome> <to-view-id>error.xhtml</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/login/loginUsuario.xhtml</from-view-id> <navigation-case> <from-outcome>empleado</from-outcome> <to-view-id>/administracion/menu/menuEmpleado.xhtml</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>admin</display-name> <from-view-id>/login/loginUsuario.xhtml</from-view-id> <navigation-case> <from-outcome>admin</from-outcome> <to-view-id>/administracion/menu/menuAdmin.xhtml</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>*</from-view-id> <navigation-case> <from-outcome>logout</from-outcome> <to-view-id>/login/loginUsuario.xhtml</to-view-id> </navigation-case> </navigation-rule> <lifecycle> <phase-listener>pfm.beans.cicloVida.MyPhaseListener</phase-listener> </lifecycle> </faces-config> 10.5.2 WEB.XML <?xmlversion="1.0"encoding="UTF-8"?> <web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 436 xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.co m/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.c om/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>PFM</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <session-config> <session-timeout>15000</session-timeout> </session-config> <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> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <servlet> <servlet-name>JerseyREST</servlet-name> <servletclass>com.sun.jersey.spi.container.servlet.ServletContainer</servletclass> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>pfm.beans.rest</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>JerseyREST</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <filter> <description>Requiere que el usuario este logeado antes de acceder a cualquier pagina</description> <filter-name>ForzarLoginFilter</filter-name> <filter-class>pfm.beans.filters.ForzarLoginFilter</filter-class> </filter> <filter-mapping> <filter-name>ForzarLoginFilter</filter-name> 437 <url-pattern>/administracion/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <context-param> <param-name>primefaces.THEME</param-name> <param-value>cupertino</param-value> </context-param> </web-app> 10.5.3 PERSISTENCE.XML <?xmlversion="1.0"encoding="UTF-8"?> <persistenceversion="2.0" xmlns="http://java.sun.com/xml/ns/persistence"xmlns:xsi="http://www.w3 .org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistencehttp://java. sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unitname="jpa"transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>pfm.entidades.FacturaDetalle</class> <class>pfm.entidades.Bodega</class> <class>pfm.entidades.Rol</class> <class>pfm.entidades.Marca</class> <class>pfm.entidades.MedioDePago</class> <class>pfm.entidades.Producto</class> <class>pfm.entidades.BodegaDetalle</class> <class>pfm.entidades.DescuentoProducto</class> <class>pfm.entidades.Agencia</class> <class>pfm.entidades.Usuario</class> <class>pfm.entidades.Empresa</class> <class>pfm.entidades.Categoria</class> <class>pfm.entidades.Factura</class> <class>pfm.entidades.Descuento</class> <class>pfm.entidades.EmpleadoAgencia</class> <properties> <propertyname="eclipselink.ddl-generation"value="none"/> <propertyname="javax.persistence.jdbc.url"value="jdbc:mysql://localhos t:8889/pfm"/> <propertyname="javax.persistence.jdbc.user"value="root"/> <propertyname="javax.persistence.jdbc.password"value="root"/> <!-<property name="eclipselink.ddl-generation" value="drop-and-createtables" /> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/miw06" /> <property name="javax.persistence.jdbc.user" value="miw06" /> <property name="javax.persistence.jdbc.password" value="132212241" /> --> <propertyname="javax.persistence.jdbc.driver"value="com.mysql.jdbc.Dri ver"/> </properties> </persistence-unit> </persistence> 438 11 APENDICE: CODIGO FUENTE APLICACION ANDROID 11.1 COMPRAS 11.1.1 CONFIRMARCOMPRASACTIVITY.JAVA packagepfm.android.compras; importjava.util.ArrayList; importjava.util.HashMap; importjava.util.Iterator; importjava.util.List; importjava.util.Map; importpfm.android.R; importpfm.android.rest.RESTFactory; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.ArrayAdapter; importandroid.widget.EditText; importandroid.widget.ImageButton; importandroid.widget.Spinner; importandroid.widget.Toast; importandroid.annotation.SuppressLint; importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; publicclassConfirmarComprasActivityextendsActivity{ privateintidAgencia; privateStringnombreAgencia; privateintidFactura; privateintidCliente; privatedoubletotalFactura; privatedoubletotalFacturaActual; privateEditTexttotal; privateSpinnermedioPago; @SuppressLint("UseSparseArrays") privateMap<Integer,String>mapaMedioPago=newHashMap<Integer,String>(); privateList<String>listaMedioPagp=newArrayList<String>(); @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_confirmar_compras); // Recepcion de Parametros Bundleparametros=getIntent().getExtras(); this.idAgencia=parametros.getInt("idAgencia"); this.nombreAgencia=parametros.getString("nombreAgencia"); this.idFactura=parametros.getInt("idFactura"); this.idCliente=parametros.getInt("idCliente"); this.totalFactura=parametros.getDouble("totalFactura"); newListaMedioDePagosTask(this).execute(); total=(EditText)findViewById(R.id.confirmarCompras_total); total.setText(String.valueOf(totalFactura)); ImageButtonbtn_aceptar=(ImageButton)findViewById(R.id.btn_confirmarCompras_aceptar); ImageButtonbtn_cancelar=(ImageButton)findViewById(R.id.btn_confirmarCompras_cancelar); btn_aceptar.setOnClickListener(newView.OnClickListener(){ @Override 439 publicvoidonClick(Viewv){ confirmar(); } }); btn_cancelar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ cancelar(); } }); } privateclassListaMedioDePagosTaskextends AsyncTask<Void,Void,Map<Integer,String>>{ ProgressDialogpDialog; Contextcontext; publicListaMedioDePagosTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Medio de Pagos..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedMap<Integer,String>doInBackground(Void...params){ mapaMedioPago=newRESTFactory().getMedioPagoDAO() .listMedioPago(); returnmapaMedioPago; } @Override protectedvoidonPostExecute(Map<Integer,String>result){ super.onPostExecute(result); medioPago=(Spinner)findViewById(R.id.medioPago); for(Stringvalue:result.values()){ listaMedioPagp.add(value); } ArrayAdapter<String>adapter=newArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, listaMedioPagp); medioPago.setAdapter(adapter); pDialog.dismiss(); } } privateclassConfirmarTaskextendsAsyncTask<Void,Void,Integer>{ ProgressDialogpDialog; Contextcontext; publicConfirmarTask(Contextcontext){ this.context=context; } 440 @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Confirmando Compra..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ totalFacturaActual=newRESTFactory().getFacturaDAO() .ConfirmaTotal(idFactura,totalFactura); // confirma totales iguales if(totalFacturaActual==totalFactura){ // confirma compra intidMedioDePago=0; Iterator<Map.Entry<Integer,String>>entries=mapaMedioPago .entrySet().iterator(); while(entries.hasNext()){ Map.Entry<Integer,String>entry=entries.next(); if(entry.getValue().equals( medioPago.getSelectedItem().toString())){ idMedioDePago=entry.getKey(); } } intid=newRESTFactory().getFacturaDAO().ConfirmaCompra( idFactura,idMedioDePago); if(id==0){ // error en el servicio web return-1; }else{ // compra confirmada returnid; } }else{ // cambio de valores debe volver a confirmar totalFactura=totalFacturaActual; return0; } } @Override protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result==-2){ Toast.makeText(context,"No existe stock suficiente", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); }elseif(result==-1){ Toast.makeText(context,"Error Toast.LENGTH_SHORT).show(); }elseif(result==0){ al momento de confirmar", 441 Toast.makeText(context, "El total ha cambiado, porfavor vuelva a confirmar", Toast.LENGTH_SHORT).show(); total.setText(String.valueOf(totalFacturaActual)); }elseif(result>0){ Toast.makeText(context, "Compra confirmada, acercarse a la caja mas cercana", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",0); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); } pDialog.dismiss(); } } publicvoidconfirmar(){ newConfirmarTask(this).execute(); } publicvoidcancelar(){ Toast.makeText(this,"Pago cancelado",Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.1.2 COMPRASACTIVITY.JAVA packagepfm.android.compras; importjava.util.List; importcom.google.zxing.client.android.CaptureActivity; importpfm.android.R; importpfm.android.login.LogoutActivity; importpfm.android.rest.RESTFactory; importpfm.entidades.FacturaDetalle; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.app.ListActivity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; importandroid.view.Menu; importandroid.view.MenuItem; importandroid.view.View; importandroid.widget.AdapterView; importandroid.widget.Button; importandroid.widget.ListView; 442 importandroid.widget.TextView; importandroid.widget.Toast; publicclassComprasActivityextendsListActivity{ privateList<FacturaDetalle>listaProductos=null; privateButtonbtnConfirmar; privateButtonbtnAgregarProducto; privateButtonbtnCarro; privateButtonbtnCarros; privateButtonbtnEliminar; privateTextViewlblTotal; privateTextViewlblAgencia; privateintidAgencia; privateintidCliente; privateintidFactura; privatedoubletotalFactura; privateStringnombreAgencia="FALTA"; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_compras); // Recepcion de Parametros Bundleextra=getIntent().getExtras(); idAgencia=extra.getInt("idAgencia"); nombreAgencia=extra.getString("nombreAgencia"); idFactura=extra.getInt("idFactura"); idCliente=extra.getInt("idCliente"); // llama a tarea asincrona para rellenar el listado de productos si el // idFactura es mayor a 0 if(idFactura>0){ newListarProductosTask(this).execute(); } // CONTROLES DE LA VISTA lblTotal=(TextView)findViewById(R.id.lblTotal); lblTotal.setText("Total: "+0); lblAgencia=(TextView)findViewById(R.id.lblAgencia); lblAgencia.setText(nombreAgencia); // Creacion de botones con sus listener // btnAddProducto this.btnAgregarProducto=(Button)findViewById(R.id.btnAddProducto); this.btnAgregarProducto.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnAddProducto_onClick(); } }); // btnConfirmar this.btnConfirmar=(Button)findViewById(R.id.btnConfirmar); this.btnConfirmar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnConfirmar_onClick(); } }); // btnCarro this.btnCarro=(Button)findViewById(R.id.btnCarro); this.btnCarro.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnCarro_onClick(); 443 } }); // btnCarros this.btnCarros=(Button)findViewById(R.id.btnCarros); this.btnCarros.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnCarros_onClick(); } }); // btnEliminar this.btnEliminar=(Button)findViewById(R.id.btnEliminarCarro); this.btnEliminar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnEliminar_onClick(); } }); // creacion de listas ListViewlistView=getListView(); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(newAdapterView.OnItemClickListener(){ @Override publicvoidonItemClick(AdapterView<?>parent,Viewview, intposition,longid){ finalFacturaDetalleitem=(FacturaDetalle)parent .getItemAtPosition(position); Intentintento=newIntent(ComprasActivity.this, EditProductoActivity.class); intento.putExtra("idFacturaDetalle",item.getId()); intento.putExtra("idAgencia",ComprasActivity.this.idAgencia); intento.putExtra("nombreAgencia", ComprasActivity.this.nombreAgencia); intento.putExtra("idFactura",ComprasActivity.this.idFactura); intento.putExtra("idCliente",ComprasActivity.this.idCliente); // inicia la actividad startActivity(intento); finish(); } }); } publicvoidbtnConfirmar_onClick(){ if(totalFactura!=0){ Intentintento=newIntent(this,ConfirmarComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); intento.putExtra("totalFactura",totalFactura); // inicia la actividad startActivity(intento); finish(); }else{ Toast.makeText(this,"No .show(); } } existe productos",Toast.LENGTH_SHORT) 444 publicvoidbtnAddProducto_onClick(){ // se abre la vista del lector de codigo QR de la libreria ZXing Intentintento=newIntent(this,CaptureActivity.class); intento.putExtra("idAgencia",this.idAgencia); intento.putExtra("nombreAgencia",this.nombreAgencia); intento.putExtra("idFactura",this.idFactura); intento.putExtra("idCliente",this.idCliente); // inicia la actividad startActivity(intento); finish(); } publicvoidbtnCarro_onClick(){ // se encuntra en el carro de compras por lo que el boton no debe // realizar ninguna accion } publicvoidbtnCarros_onClick(){ Intentintento=newIntent(this,CarrosComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); } publicvoidbtnEliminar_onClick(){ newEliminarCarroTask(this).execute(); } privateclassEliminarCarroTaskextendsAsyncTask<Void,Void,Integer>{ ProgressDialogpDialog; Contextcontext; publicEliminarCarroTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Eliminando Carro de Compras..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ // valida si existe un carro de compras if(idFactura>0){ // devuelve el id de la factura eliminada returnnewRESTFactory().getFacturaDAO().EliminarFactura( idFactura); }else{ return-1; } } 445 @Override protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result>0){ Toast.makeText(context,"Carro de compras eliminado", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",0); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); }elseif(result==-1){ Toast.makeText(context,"No existe Toast.LENGTH_SHORT).show(); }elseif(result==0){ Toast.makeText(context,"Existe un Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); } } carro de compras", error en el servidor", privateclassListarProductosTaskextends AsyncTask<Void,Integer,List<FacturaDetalle>>{ ProgressDialogpDialog; Contextcontext; publicListarProductosTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Productos..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedList<FacturaDetalle>doInBackground(Void...params){ // obtiene la lista de Productos a traves del servicio REST listaProductos=newRESTFactory().getFacturaDetalleDAO() .getCarroActual(idFactura); if(listaProductos!=null){ returnlistaProductos; }else{ returnnull; } } @Override protectedvoidonPostExecute(List<FacturaDetalle>lista){ super.onPostExecute(lista); if(lista!=null){ lblTotal.setText("Total: " +lista.get(0).getFactura().getTotal()); 446 totalFactura=lista.get(0).getFactura().getTotal(); }else{ lblTotal.setText("Total: "+0); totalFactura=0; } // Seteamos el adaptador para llenar al ListView setListAdapter(newAdaptadorListaProductos(ComprasActivity.this, lista)); pDialog.dismiss(); } } @Override publicvoidonBackPressed(){ finish(); } @Override publicbooleanonCreateOptionsMenu(Menumenu){ getMenuInflater().inflate(R.menu.carros_compras,menu); returntrue; } @Override publicbooleanonMenuItemSelected(intfeatureId,MenuItemitem){ super.onMenuItemSelected(featureId,item); switch(item.getItemId()){ caseR.id.menu_logout: Intentintento=newIntent(this,LogoutActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); break; } returntrue; } } 11.1.3 CARROSCOMPRASACTIVITY.JAVA packagepfm.android.compras; importjava.util.List; importpfm.android.R; importpfm.android.rest.RESTFactory; importpfm.entidades.Factura; importandroid.app.ListActivity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.AdapterView; importandroid.widget.Button; importandroid.widget.ListView; importandroid.widget.TextView; importandroid.widget.Toast; publicclassCarrosComprasActivityextendsListActivity{ privateList<Factura>listaCarros=null; 447 privateButtonbtnCarro; privateButtonbtnCarros; privateTextViewlblTitulo; privateTextViewlblAgencia; privateintidAgencia; privateintidCliente; privateintidFactura; privateStringnombreAgencia; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_carros_compras); // Recepcion de Parametros Bundleparametros=getIntent().getExtras(); idAgencia=parametros.getInt("idAgencia"); idFactura=parametros.getInt("idFactura"); idCliente=parametros.getInt("idCliente"); nombreAgencia=parametros.getString("nombreAgencia"); // llama a tarea asincrona para rellenar la lista de carros newListarCarrosTask(this).execute(); // CONTROLES DE LA VISTA lblAgencia=(TextView)findViewById(R.id.lblAgencia_carros); lblAgencia.setText(nombreAgencia); lblTitulo=(TextView)findViewById(R.id.lblTitulo_carros); lblTitulo.setText("Mis Carros Pendientes"); // btnCarro btnCarro=(Button)findViewById(R.id.btnCarro_carro); btnCarro.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnCarro_onClick(); } }); // btnCarros btnCarros=(Button)findViewById(R.id.btnCarros_carro); btnCarros.setBackgroundColor(BIND_IMPORTANT); btnCarros.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ btnCarros_onClick(); } }); // lista de carros ListViewlistView=getListView(); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(newAdapterView.OnItemClickListener(){ @Override publicvoidonItemClick(AdapterView<?>parent,Viewview, intposition,longid){ finalFacturaitem=(Factura)parent .getItemAtPosition(position); Intentintento=newIntent(CarrosComprasActivity.this, ComprasActivity.class); intento.putExtra("idAgencia", CarrosComprasActivity.this.idAgencia); intento.putExtra("nombreAgencia", CarrosComprasActivity.this.nombreAgencia); 448 intento.putExtra("idFactura",item.getId()); intento.putExtra("idCliente", CarrosComprasActivity.this.idCliente); // inicia la actividad startActivity(intento); finish(); } }); } publicvoidbtnCarro_onClick(){ Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); } publicvoidbtnCarros_onClick(){ // se encuntra en el listado de carros de compras por lo que el boton no // debe realizar ninguna accion } privateclassListarCarrosTaskextendsAsyncTask<Void,Void,List<Factura>>{ ProgressDialogpDialog; Contextcontext; publicListarCarrosTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Carros de Compra..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedList<Factura>doInBackground(Void...params){ // obtiene la lista de Productos a traves del servicio REST listaCarros=newRESTFactory().getFacturaDAO().getCarrosCompra( idCliente,idAgencia); if(listaCarros!=null){ returnlistaCarros; }else{ returnnull; } } @Override protectedvoidonPostExecute(List<Factura>lista){ super.onPostExecute(lista); // Seteamos el adaptador para llenar al ListView 449 setListAdapter(newAdaptadorListaCarros(CarrosComprasActivity.this, lista)); pDialog.dismiss(); } } publicvoidcancelar(){ Toast.makeText(this,"Compras pendientes canceladas", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.1.4 ADDPRODUCTOACTIVITY.JAVA packagepfm.android.compras; importpfm.android.R; importpfm.android.rest.RESTFactory; importpfm.entidades.BodegaDetalle; importpfm.entidades.Descuento; importpfm.entidades.FacturaDetalle; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.EditText; importandroid.widget.ImageButton; importandroid.widget.NumberPicker; importandroid.widget.Toast; importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; publicclassAddProductoActivityextendsActivity{ privateEditTextnombre; privateEditTextprecio; privateEditTextsubtotal; privateEditTextdescuento; privateEditTextiva; privateEditTexttotal; privateNumberPickercantidad; privateintidBodegaDetalle; privateintidAgencia; privateStringnombreAgencia; privateintidFactura; privateintidCliente; privateBodegaDetallebodegaDetalle=newBodegaDetalle(); privateDescuentodes=newDescuento(); privateFacturaDetallefacturaDetalle=newFacturaDetalle(); @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); 450 setContentView(R.layout.activity_add_producto); nombre=(EditText)findViewById(R.id.addProducto_nombre); precio=(EditText)findViewById(R.id.addProducto_precio); subtotal=(EditText)findViewById(R.id.addProducto_subtotal); descuento=(EditText)findViewById(R.id.addProducto_descuento); iva=(EditText)findViewById(R.id.addProducto_iva); total=(EditText)findViewById(R.id.addProducto_total); cantidad=(NumberPicker)findViewById(R.id.addProducto_cantidad); // setea los avkores maximos y minimos del NumberPicker cantidad.setMaxValue(10); cantidad.setMinValue(1); // recupera datos enviados desde actividad anterio // @param: idBodegaDetalle -- bodegaDetalle de captura de codigo QR // @param: idAgencia // @param: idFactura Bundleextra=getIntent().getExtras(); idBodegaDetalle=extra.getInt("idBodegaDetalle"); idAgencia=extra.getInt("idAgencia"); nombreAgencia=extra.getString("nombreAgencia"); idFactura=extra.getInt("idFactura"); idCliente=extra.getInt("idCliente"); // obtiene botones de la pantalla ImageButtonbtn_aceptar=(ImageButton)findViewById(R.id.btn_addProducto_aceptar); ImageButtonbtn_cancelar=(ImageButton)findViewById(R.id.btn_addproducto_cancelar); btn_aceptar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ anadirProducto(); } }); btn_cancelar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ cancelar(); } }); cantidad.setOnValueChangedListener(newNumberPicker.OnValueChangeListener(){ @Override publicvoidonValueChange(NumberPickerpicker,intoldVal, intnewVal){ calcularTotales(); } }); // ejecuta la lectura del producto newReadFacturaDetalleTask(this).execute(); } privateclassReadFacturaDetalleTaskextends AsyncTask<Void,Void,FacturaDetalle>{ ProgressDialogpDialog; Contextcontext; publicReadFacturaDetalleTask(Contextcontext){ 451 this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Producto..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedFacturaDetalledoInBackground(Void...params){ bodegaDetalle=newRESTFactory().getBodegaDetalleDAO() .getBodegaDetalleById(idBodegaDetalle); if(bodegaDetalle!=null){ des=newRESTFactory().getDescuentoDAO() .getDescuentoByProducto( bodegaDetalle.getProducto().getId()); facturaDetalle=newRESTFactory().getFacturaDetalleDAO() .setTotales(bodegaDetalle,des,1); returnfacturaDetalle; }else{ returnnull; } } @Override protectedvoidonPostExecute(FacturaDetalleresult){ super.onPostExecute(result); if(result!=null){ if(idAgencia==result.getBodegaDetalle().getBodega() .getAgencia().getId()){ nombre.setText(result.getBodegaDetalle().getProducto() .getNombre()); precio.setText(String.valueOf(result.getPrecio())); subtotal.setText(String.valueOf(result.getSubtotal())); descuento.setText(String.valueOf(result.getDescuento())); iva.setText(String.valueOf(result.getIva())); total.setText(String.valueOf(result.getTotal())); cantidad.setValue(result.getCantidad()); }else{ Toast.makeText(context, "Producto no pertenece a la agencia seleccionada", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } }else{ Toast.makeText(context,"Producto no encontrado", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } pDialog.dismiss(); 452 } } publicvoidcalcularTotales(){ facturaDetalle=newRESTFactory().getFacturaDetalleDAO().setTotales( bodegaDetalle,des,cantidad.getValue()); nombre.setText(facturaDetalle.getBodegaDetalle().getProducto() .getNombre()); precio.setText(String.valueOf(facturaDetalle.getPrecio())); subtotal.setText(String.valueOf(facturaDetalle.getSubtotal())); descuento.setText(String.valueOf(facturaDetalle.getDescuento())); iva.setText(String.valueOf(facturaDetalle.getIva())); total.setText(String.valueOf(facturaDetalle.getTotal())); cantidad.setValue(facturaDetalle.getCantidad()); } privateclassAgregarProductoTaskextendsAsyncTask<Void,Void,Integer>{ Contextcontext; ProgressDialogpDialog; publicAgregarProductoTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Guardando Producto..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ booleanexisteProducto=false; if(idFactura!=0){ // validar que no exista el mismo producto en el carro de existeProducto=newRESTFactory().getFacturaDetalleDAO() .existeProductoByFacturaDetalle(idFactura, idBodegaDetalle); } if(existeProducto==false){ if(cantidad.getValue()<bodegaDetalle.getCantidad()){ intdescuentoId=0; if(des!=null){ descuentoId=des.getId(); }else{ descuentoId=0; } returnnewRESTFactory().getFacturaDetalleDAO() .anadirProducto(idFactura,idAgencia,idCliente, idBodegaDetalle,descuentoId, facturaDetalle.getCantidad()); }else{ return-1; } }else{ return-2; } } @Override protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result>0){ 453 Toast.makeText(context,"Producto guardado",Toast.LENGTH_SHORT) .show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",result); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); }elseif(result==0){ Toast.makeText(context,"Transaccion incorrecta", Toast.LENGTH_SHORT).show(); }elseif(result==-1){ Toast.makeText(context,"Stock insuficiente", Toast.LENGTH_SHORT).show(); }elseif(result==-2){ Toast.makeText(context, "El producto se encuentra en su carro de compras", Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); } } publicvoidanadirProducto(){ newAgregarProductoTask(this).execute(); } publicvoidcancelar(){ Toast.makeText(this,"Producto cancelado",Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.1.5 ADAPTADORLISTAPRODUCTOS.JAVA packagepfm.android.compras; importjava.util.List; importpfm.android.R; importpfm.entidades.FacturaDetalle; importandroid.app.Activity; importandroid.graphics.Color; importandroid.view.LayoutInflater; importandroid.view.View; importandroid.view.ViewGroup; importandroid.widget.BaseAdapter; importandroid.widget.TextView; publicclassAdaptadorListaProductosextendsBaseAdapter{ privatefinalActivityactividad; privatefinalList<FacturaDetalle>listaProductos; publicAdaptadorListaProductos(Activityactividad, List<FacturaDetalle>listaProductos){ 454 super(); this.actividad=actividad; this.listaProductos=listaProductos; } publicintgetCount(){ if(listaProductos!=null) returnlistaProductos.size(); else return0; } publicObjectgetItem(intarg0){ if(listaProductos!=null) returnlistaProductos.get(arg0); else returnnull; } publiclonggetItemId(intarg0){ returnarg0; } publicViewgetView(intposition,Viewarg1,ViewGrouparg2){ LayoutInflaterinflater=actividad.getLayoutInflater(); Viewview=inflater.inflate(R.layout.producto_lista,null,true); TextViewtextView=(TextView)view.findViewById(R.id.lblItemNombre); textView.setText(listaProductos.get(position).getBodegaDetalle() .getProducto().getNombre()); TextViewtxtCantidad=(TextView)view .findViewById(R.id.lblItemCantidad); if(listaProductos.get(position).getBodegaDetalle().getCantidad()<listaProductos .get(position).getCantidad()){ txtCantidad.setTextColor(Color.RED); txtCantidad.setText("Cantidad: Fuera de Stock"); }else{ txtCantidad .setText("Cantidad: " +String.valueOf(listaProductos.get(position) .getCantidad())); } TextViewtxtSubtotal=(TextView)view .findViewById(R.id.lblItemSubtotal); txtSubtotal.setText(String.valueOf(listaProductos.get(position) .getSubtotal())); TextViewtxtPrecio=(TextView)view.findViewById(R.id.lblItemPrecio); txtPrecio.setText("Valor Unitario: " +String.valueOf(listaProductos.get(position).getPrecio())); returnview; } } 11.1.6 ADAPTADORLISTACARROS.JAVA packagepfm.android.compras; importjava.text.SimpleDateFormat; importjava.util.List; importpfm.android.R; importpfm.entidades.Factura; importandroid.annotation.SuppressLint; 455 importandroid.app.Activity; importandroid.view.LayoutInflater; importandroid.view.View; importandroid.view.ViewGroup; importandroid.widget.BaseAdapter; importandroid.widget.TextView; publicclassAdaptadorListaCarrosextendsBaseAdapter{ privatefinalActivityactividad; privatefinalList<Factura>listaCarros; publicAdaptadorListaCarros(Activityactividad,List<Factura>listaCarros){ super(); this.actividad=actividad; this.listaCarros=listaCarros; } publicintgetCount(){ if(listaCarros!=null) returnlistaCarros.size(); else return0; } publicObjectgetItem(intarg0){ if(listaCarros!=null) returnlistaCarros.get(arg0); else returnnull; } publiclonggetItemId(intarg0){ returnarg0; } @SuppressLint("SimpleDateFormat") publicViewgetView(intposition,Viewarg1,ViewGrouparg2){ LayoutInflaterinflater=actividad.getLayoutInflater(); Viewview=inflater.inflate(R.layout.carro_lista,null,true); SimpleDateFormatformatoFecha=newSimpleDateFormat("yyyy-MM-dd"); Stringfecha=formatoFecha .format(listaCarros.get(position).getFecha()); TextViewtextView=(TextView)view .findViewById(R.id.lblItemNombreCarro); textView.setText("Carro : "+fecha); TextViewtxtCantidad=(TextView)view .findViewById(R.id.lblItemAgencia); txtCantidad.setText("Agencia: " +listaCarros.get(position).getAgencia().getNombre()); TextViewtxtSubtotal=(TextView)view.findViewById(R.id.lblItemTotal); txtSubtotal.setText("Total: " +String.valueOf(listaCarros.get(position).getTotal())); returnview; } } 11.1.7 EDITPRODUCTOACTIVITY.JAVA packagepfm.android.compras; importpfm.android.R; importpfm.android.rest.RESTFactory; importpfm.entidades.BodegaDetalle; 456 importpfm.entidades.Descuento; importpfm.entidades.FacturaDetalle; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.EditText; importandroid.widget.ImageButton; importandroid.widget.NumberPicker; importandroid.widget.Toast; importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; publicclassEditProductoActivityextendsActivity{ privateEditTextnombre; privateEditTextprecio; privateEditTextsubtotal; privateEditTextdescuento; privateEditTextiva; privateEditTexttotal; privateNumberPickercantidad; privateintidFacturaDetalle; privateintidAgencia; privateStringnombreAgencia; privateintidFactura; privateintidCliente; privateFacturaDetallefacturaDetalle=newFacturaDetalle(); privateBodegaDetallebodegaDetalle=newBodegaDetalle(); privateDescuentodes=newDescuento(); @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_producto); nombre=(EditText)findViewById(R.id.editProducto_nombre); precio=(EditText)findViewById(R.id.editProducto_precio); subtotal=(EditText)findViewById(R.id.editProducto_subtotal); descuento=(EditText)findViewById(R.id.editProducto_descuento); iva=(EditText)findViewById(R.id.editProducto_iva); total=(EditText)findViewById(R.id.editProducto_total); cantidad=(NumberPicker)findViewById(R.id.editProducto_cantidad); // setea los avkores maximos y minimos del NumberPicker cantidad.setMaxValue(10); cantidad.setMinValue(1); // recupera datos enviados desde actividad anterio // @param: idFacturaDetalle Bundleextra=getIntent().getExtras(); idFacturaDetalle=extra.getInt("idFacturaDetalle"); idAgencia=extra.getInt("idAgencia"); nombreAgencia=extra.getString("nombreAgencia"); idFactura=extra.getInt("idFactura"); idCliente=extra.getInt("idCliente"); ImageButtonbtn_editar=(ImageButton)findViewById(R.id.btn_editProducto_aceptar); ImageButtonbtn_cancelar=(ImageButton)findViewById(R.id.btn_editproducto_cancelar); ImageButtonbtn_eliminar=(ImageButton)findViewById(R.id.btn_editProducto_eliminar); btn_editar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ actualizar(); } }); btn_eliminar.setOnClickListener(newView.OnClickListener(){ 457 @Override publicvoidonClick(Viewv){ eliminar(); } }); btn_cancelar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ cancelar(); } }); cantidad.setOnValueChangedListener(newNumberPicker.OnValueChangeListener(){ @Override publicvoidonValueChange(NumberPickerpicker,intoldVal, intnewVal){ calcularTotales(); } }); // carga el producto seleccionado newReadFacturaDetalleTask(this).execute(); } privateclassReadFacturaDetalleTaskextends AsyncTask<Void,Void,FacturaDetalle>{ ProgressDialogpDialog; Contextcontext; publicReadFacturaDetalleTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Producto..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedFacturaDetalledoInBackground(Void...params){ // devuelve facturaDetalle facturaDetalle=newRESTFactory().getFacturaDetalleDAO() .getFacturaDetalleById(idFacturaDetalle); // setea para el calculo de totales, cuando cambie el valor de la // cantidad bodegaDetalle=newRESTFactory().getBodegaDetalleDAO() .getBodegaDetalleById( facturaDetalle.getBodegaDetalle().getId()); des=newRESTFactory().getDescuentoDAO().getDescuentoByProducto( bodegaDetalle.getProducto().getId()); returnfacturaDetalle; } @Override protectedvoidonPostExecute(FacturaDetalleresult){ super.onPostExecute(result); if(result!=null){ 458 nombre.setText(result.getBodegaDetalle().getProducto() .getNombre()); precio.setText(String.valueOf(result.getPrecio())); subtotal.setText(String.valueOf(result.getSubtotal())); descuento.setText(String.valueOf(result.getDescuento())); iva.setText(String.valueOf(result.getIva())); total.setText(String.valueOf(result.getTotal())); cantidad.setValue(result.getCantidad()); }else{ Toast.makeText(context,"Producto Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); } } no encontrado", publicvoidcalcularTotales(){ facturaDetalle=newRESTFactory().getFacturaDetalleDAO().setTotales( bodegaDetalle,des,cantidad.getValue()); nombre.setText(facturaDetalle.getBodegaDetalle().getProducto() .getNombre()); precio.setText(String.valueOf(facturaDetalle.getPrecio())); subtotal.setText(String.valueOf(facturaDetalle.getSubtotal())); descuento.setText(String.valueOf(facturaDetalle.getDescuento())); iva.setText(String.valueOf(facturaDetalle.getIva())); total.setText(String.valueOf(facturaDetalle.getTotal())); cantidad.setValue(facturaDetalle.getCantidad()); } privateclassActualizarProductoTaskextendsAsyncTask<Void,Void,Integer>{ Contextcontext; ProgressDialogpDialog; publicActualizarProductoTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Guardando Producto..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ if(cantidad.getValue()<bodegaDetalle.getCantidad()){ intdescuentoId=0; if(des!=null){ descuentoId=des.getId(); }else{ descuentoId=0; } returnnewRESTFactory().getFacturaDetalleDAO() .actualizarProducto(idFacturaDetalle,descuentoId, facturaDetalle.getCantidad()); }else{ return-1; } } @Override 459 protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result>0){ Toast.makeText(context,"Producto guardado",Toast.LENGTH_SHORT) .show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",result); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); }elseif(result==0){ Toast.makeText(context,"Transaccion incorrecta", Toast.LENGTH_SHORT).show(); }elseif(result==-1){ Toast.makeText(context,"Stock insuficiente", Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); } } publicvoidactualizar(){ newActualizarProductoTask(this).execute(); } privateclassEliminarProductoTaskextendsAsyncTask<Void,Void,Integer>{ Contextcontext; ProgressDialogpDialog; publicEliminarProductoTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Eliminando Producto..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ returnnewRESTFactory().getFacturaDetalleDAO().eliminarProducto( idFacturaDetalle); } @Override protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result>0){ Toast.makeText(context,"Producto eliminado", Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",result); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); 460 }elseif(result==0){ Toast.makeText(context,"Transaccion Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); incorrecta", } } publicvoideliminar(){ newEliminarProductoTask(this).execute(); } publicvoidcancelar(){ Toast.makeText(this,"Producto cancelado",Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.2 LOGIN 11.2.1 LOGOUTACTIVITY.JAVA packagepfm.android.login; importpfm.android.R; importpfm.android.compras.ComprasActivity; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.Button; importandroid.widget.Toast; importandroid.app.Activity; importandroid.content.Intent; publicclassLogoutActivityextendsActivity{ privateintidAgencia; privateintidCliente; privateintidFactura; privateStringnombreAgencia; @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_logout); // Recepcion de Parametros Bundleparametros=getIntent().getExtras(); idAgencia=parametros.getInt("idAgencia"); idFactura=parametros.getInt("idFactura"); idCliente=parametros.getInt("idCliente"); nombreAgencia=parametros.getString("nombreAgencia"); // obtiene los botones ButtonbtnAceptar=(Button)findViewById(R.id.btn_logout_aceptar); 461 ButtonbtnCancelar=(Button)findViewById(R.id.btn_logout_cancelar); // generamos los listener btnAceptar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ aceptar(); } }); btnCancelar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ cancelar(); } }); } publicvoidaceptar(){ Toast.makeText(this,"Cierre de sesion exitoso",Toast.LENGTH_SHORT) .show(); Intentintento=newIntent(this,LoginActivity.class); // inicia la actividad startActivity(intento); finish(); } publicvoidcancelar(){ Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); // inicia la actividad startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.2.2 LOGINACTIVITY.JAVA packagepfm.android.login; importjava.util.ArrayList; importjava.util.HashMap; importjava.util.Iterator; importjava.util.List; importjava.util.Map; importpfm.android.R; importpfm.android.compras.ComprasActivity; importpfm.android.rest.RESTFactory; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.annotation.SuppressLint; 462 importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; importandroid.view.View; importandroid.widget.ArrayAdapter; importandroid.widget.Button; importandroid.widget.EditText; importandroid.widget.Spinner; importandroid.widget.Toast; @SuppressLint("UseSparseArrays") publicclassLoginActivityextendsActivity{ privateEditTextusername; privateEditTextpassword; privateSpinneragencia; privateMap<Integer,String>mapaAgencias=newHashMap<Integer,String>(); privateList<String>listaAgencias=newArrayList<String>(); privatefinalintREQUEST_ACTIVITY=1; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); // llama a tarea asincrona para rellenar el spinner de agencuias newListaAgenciasTask(LoginActivity.this).execute(); // obtiene los parametros de username y password username=(EditText)findViewById(R.id.username); password=(EditText)findViewById(R.id.password); // obtiene los botones ButtonbtnAceptar=(Button)findViewById(R.id.btn_logout_aceptar); ButtonbtnNuevoUsuario=(Button)findViewById(R.id.btn_logout_cancelar); // agrega los listener de los botones btnAceptar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ login(); } }); btnNuevoUsuario.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ nuevoUsuario(); } }); } privateclassListaAgenciasTaskextends AsyncTask<Void,Void,Map<Integer,String>>{ ProgressDialogpDialog; Contextcontext; publicListaAgenciasTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ 463 super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Cargando Agencias..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedMap<Integer,String>doInBackground(Void...params){ // obtiene el id, nombre de las agencias a traves del servicio REST mapaAgencias=newRESTFactory().getAgenciaDAO().listAgencias(); returnmapaAgencias; } @Override protectedvoidonPostExecute(Map<Integer,String>result){ super.onPostExecute(result); // Genera el spinner a partir de las agencias obtenidas if(result!=null){ agencia=(Spinner)findViewById(R.id.agencias); for(Stringvalue:result.values()){ listaAgencias.add(value); } ArrayAdapter<String>adapter=newArrayAdapter<String>( context,android.R.layout.simple_spinner_dropdown_item, listaAgencias); agencia.setAdapter(adapter); }else{ Toast.makeText(context,"Existe Toast.LENGTH_SHORT).show(); un error en el servidor", } pDialog.dismiss(); } } privateclassLoginTaskextendsAsyncTask<Void,Void,Integer>{ ProgressDialogpDialog; Contextcontext; intidAgencia; StringnombreAgencia; publicLoginTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Comprobando Credenciales..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @Override protectedIntegerdoInBackground(Void...params){ // envia como resultado el id del usuario intid=newRESTFactory().getUsuarioDAO().login( username.getText().toString(), password.getText().toString()); 464 returnid; } @Override protectedvoidonPostExecute(Integerresult){ super.onPostExecute(result); if(result!=0){ // se ha logeado correctamente // obtiene el id y nombre de la agencia seleccionada Iterator<Map.Entry<Integer,String>>entries=mapaAgencias .entrySet().iterator(); while(entries.hasNext()){ Map.Entry<Integer,String>entry=entries.next(); if(entry.getValue().equals( agencia.getSelectedItem().toString())){ idAgencia=entry.getKey(); nombreAgencia=entry.getValue(); } } Toast.makeText(context, "Bienvenido: "+username.getText().toString(), Toast.LENGTH_SHORT).show(); Intentintento=newIntent(context,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",0); intento.putExtra("idCliente",result); // inicia la actividad startActivity(intento); finish(); }else{ // si existe un error en el servidor o los datos son erroneos Toast.makeText(context,"Inicio de sesion incorrecto", Toast.LENGTH_SHORT).show(); } pDialog.dismiss(); } } publicvoidlogin(){ // validar que ingresa los datos necesarios if(!password.getText().toString().isEmpty() &&!username.getText().toString().isEmpty()&&agencia!=null){ newLoginTask(this).execute(); }else{ Toast.makeText(this,"No ha Toast.LENGTH_SHORT).show(); } } ingresado los datos necesarios", publicvoidnuevoUsuario(){ // crea la nueva actividad espernado un resultado de la actividad creada Intentintento=newIntent(this,NuevoUsuarioActivity.class); startActivityForResult(intento,REQUEST_ACTIVITY); } 465 @Override publicvoidonActivityResult(intrequestCode,intresultCode,Intentdata){ // la respuesta de la actividad NuevoUsuarioActivity.class if(requestCode==REQUEST_ACTIVITY){ if(resultCode==RESULT_CANCELED){ Toast.makeText(this,data.getDataString(),Toast.LENGTH_SHORT) .show(); }elseif(resultCode==RESULT_OK){ Toast.makeText(this,data.getDataString(),Toast.LENGTH_SHORT) .show(); } } } @Override publicvoidonBackPressed(){ finish(); } } 11.2.3 NUEVOUSUARIOACTIVITY.JAVA packagepfm.android.login; importjava.text.SimpleDateFormat; importjava.util.Date; importpfm.android.R; importpfm.android.rest.RESTFactory; importandroid.net.Uri; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.annotation.SuppressLint; importandroid.app.Activity; importandroid.app.ProgressDialog; importandroid.content.Context; importandroid.content.Intent; importandroid.util.Log; importandroid.view.View; importandroid.widget.EditText; importandroid.widget.ImageButton; importandroid.widget.Toast; publicclassNuevoUsuarioActivityextendsActivity{ privateEditTextnombres; privateEditTextapellidos; privateEditTextdireccion; privateEditTexttelefono; privateEditTextfechaNacimiento; privateEditTextemail; privateEditTextusername; privateEditTextpassword; privateStringfc2=null; @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_nuevo_usuario); // recibe parametros nombres=(EditText)findViewById(R.id.usuario_nombres); apellidos=(EditText)findViewById(R.id.usuario_apellidos); direccion=(EditText)findViewById(R.id.usuario_direccion); telefono=(EditText)findViewById(R.id.usuario_telefono); fechaNacimiento=(EditText)findViewById(R.id.usuario_fechaNacimiento); email=(EditText)findViewById(R.id.usuario_email); username=(EditText)findViewById(R.id.usuario_username); password=(EditText)findViewById(R.id.usuario_password); 466 // recibe botones ImageButtonbtn_aceptar=(ImageButton)findViewById(R.id.btn_nuevo_usuario_aceptar); ImageButtonbtn_cancelar=(ImageButton)findViewById(R.id.btn_nuevo_usuario_cancelar); // genera el listener de los botones btn_aceptar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ nuevoUsuario(); } }); btn_cancelar.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ cancelar(); } }); } privateclassRegistroTaskextendsAsyncTask<Void,Void,Boolean>{ ProgressDialogpDialog; Contextcontext; publicRegistroTask(Contextcontext){ this.context=context; } @Override protectedvoidonPreExecute(){ super.onPreExecute(); // Genera un dialogo de espera mientras realiza la tarea asincrona pDialog=newProgressDialog(context); pDialog.setMessage("Registrando..."); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.show(); } @SuppressLint("SimpleDateFormat") @Override protectedBooleandoInBackground(Void...params){ // envia los atributos y valores para crear el nuevo usuario String[]atributos={"nombres","apellidos","direccion", "telefono","fechaNacimiento","email","username", "password"}; String[]values={nombres.getText().toString(), apellidos.getText().toString(), direccion.getText().toString(), telefono.getText().toString(),fc2, email.getText().toString(),username.getText().toString(), password.getText().toString()}; returnnewRESTFactory().getUsuarioDAO() .create(atributos,values); } @Override protectedvoidonPostExecute(Booleanresult){ super.onPostExecute(result); if(result){ Intentintento=newIntent(); intento.setData(Uri.parse("Registro Correcto")); setResult(RESULT_OK,intento); finish(); 467 }else{ Toast.makeText(context,"Registro Toast.LENGTH_SHORT).show(); } incorrecto", } } @SuppressLint("SimpleDateFormat") publicvoidnuevoUsuario(){ try{ // valida que esten ingresados todos los datos if(!nombres.getText().toString().isEmpty() &&!apellidos.getText().toString().isEmpty() &&!direccion.getText().toString().isEmpty() &&!telefono.getText().toString().isEmpty() &&!fechaNacimiento.getText().toString().isEmpty() &&!email.getText().toString().isEmpty() &&!username.getText().toString().isEmpty() &&!password.getText().toString().isEmpty()){ SimpleDateFormatformatoFecha1=newSimpleDateFormat( "yyyy-MM-dd"); Datefc1=null; fc1=formatoFecha1.parse(fechaNacimiento.getText().toString()); SimpleDateFormatformatoFecha2=newSimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss"); fc2=formatoFecha2.format(fc1); newRegistroTask(this).execute(); }else{ Toast.makeText(this,"No ha ingresado Toast.LENGTH_SHORT).show(); } }catch(Exceptionex){ Log.e("Error","doInBackground",ex); Toast.makeText(this,"Formato de fecha Toast.LENGTH_SHORT).show(); } los datos necesarios", incorrecto: (yyyy-MM-dd)", } publicvoidcancelar(){ Intentintento=newIntent(); intento.setData(Uri.parse("Registro setResult(RESULT_CANCELED,intento); super.onBackPressed(); } Cancelado")); @Override publicvoidonBackPressed(){ cancelar(); } } 11.3 REST 11.3.1 USUARIOREST.JAVA packagepfm.android.rest; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.client.methods.HttpPost; importorg.apache.http.entity.StringEntity; 468 importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONObject; importandroid.util.Log; publicclassUsuarioRESTextendsGenericREST{ publicUsuarioREST(){ super("autenticacion"); } publicintlogin(Stringusername,Stringpassword){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(this.uri+this.urlREST+"/login/" +username+"/"+password); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectrespJSON=newJSONObject(respStr); returnrespJSON.getInt("id"); }catch(Exceptionex){ Log.e("Error","JPAUsuarioDAO return0; } } <<login>>",ex); publicbooleancreate(String[]atributos,String[]values){ HttpClienthttpClient=newDefaultHttpClient(); HttpPostpost=newHttpPost(uri+urlREST+"/create"); post.setHeader("content-type","application/json"); try{ JSONObjectdato=newJSONObject(); for(inti=0;i<atributos.length;i++){ dato.put(atributos[i],values[i]); } StringEntityentity=newStringEntity(dato.toString()); post.setEntity(entity); HttpResponseresp=httpClient.execute(post); StringrespStr=EntityUtils.toString(resp.getEntity()); if(respStr.equals("1")) returntrue; else returnfalse; }catch(Exceptionex){ Log.e("Error","JPAGenericDAO returnfalse; } <<create>>",ex); } } 11.3.2 AGENCIAREST.JAVA packagepfm.android.rest; 469 importjava.util.HashMap; importjava.util.Map; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONArray; importorg.json.JSONObject; importandroid.annotation.SuppressLint; importandroid.util.Log; importpfm.entidades.Agencia; publicclassAgenciaRESTextendsGenericREST{ publicAgenciaREST(){ super("agencia"); } publicAgenciagetJSONParserAgencia(JSONObjectobjJSON){ try{ Agenciaagencia=newAgencia(); agencia.setId(objJSON.getInt("id")); agencia.setNombre(objJSON.getString("nombre")); agencia.setDireccion(objJSON.getString("direccion")); agencia.setEliminado(objJSON.getBoolean("eliminado")); agencia.setTelefono(objJSON.getString("telefono")); returnagencia; }catch(Exceptione){ returnnull; } } @SuppressLint("UseSparseArrays") publicMap<Integer,String>listAgencias(){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(this.uri+this.urlREST+"/listAgencias"); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); Map<Integer,String>lista=newHashMap<Integer,String>(); JSONArrayj=objJSON.optJSONArray("agencia"); if(j!=null){ JSONArrayarrJSON=objJSON.getJSONArray("agencia"); for(inti=0;i<arrJSON.length();i++){ JSONObjectobj=arrJSON.getJSONObject(i); intkey=obj.getInt("id"); Stringvalue=obj.getString("nombre"); lista.put(key,value); } }else{ JSONObjectobj=objJSON.getJSONObject("agencia"); lista.put(obj.getInt("id"),obj.getString("nombre")); } 470 returnlista; }catch(Exceptionex){ Log.e("Error","JPAAgenciaDAO returnnull; } } <<listAgencias>>",ex); } 11.3.3 BODEGADETALLEREST.JAVA packagepfm.android.rest; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONObject; importandroid.util.Log; importpfm.entidades.Agencia; importpfm.entidades.Bodega; importpfm.entidades.BodegaDetalle; importpfm.entidades.Categoria; importpfm.entidades.Empresa; importpfm.entidades.Marca; importpfm.entidades.Producto; publicclassBodegaDetalleRESTextendsGenericREST{ publicBodegaDetalleREST(){ super("bodegaDetalle"); } publicBodegaDetallegetJSONParserBodegaDetalle(JSONObjectobjJSON){ try{ BodegaDetallebodegaDetalle=newBodegaDetalle(); bodegaDetalle.setId(objJSON.getInt("id")); bodegaDetalle.setCantidad(objJSON.getInt("cantidad")); bodegaDetalle.setPrecio(objJSON.getDouble("precio")); bodegaDetalle.setEliminado(objJSON.getBoolean("eliminado")); JSONObjectbod=objJSON.getJSONObject("bodega"); JSONObjectpro=objJSON.getJSONObject("producto"); // genera la entidad bodega Bodegabodega=newBodega(); bodega.setDireccion(bod.getString("direccion")); bodega.setEliminado(bod.getBoolean("eliminado")); bodega.setId(bod.getInt("id")); bodega.setNombre(bod.getString("nombre")); bodega.setTelefono(bod.getString("telefono")); // genera la entidad agencia para agregarla a la bodega JSONObjectage=bod.getJSONObject("agencia"); Agenciaagencia=newAgencia(); agencia=newRESTFactory().getAgenciaDAO().getJSONParserAgencia( age); // genera la entidad empresa para agregarla a la agencia JSONObjectemp=age.getJSONObject("empresa"); Empresaempresa=newEmpresa(); empresa.setDireccion(emp.getString("direccion")); empresa.setEliminado(emp.getBoolean("eliminado")); empresa.setId(emp.getInt("id")); 471 empresa.setIva(emp.getDouble("iva")); empresa.setRazonSocial(emp.getString("razonSocial")); empresa.setRuc(emp.getString("ruc")); empresa.setTelefono(emp.getString("telefono")); // agrega la empresa a la agencia agencia.setEmpresa(empresa); // agrega la agencia a la bodega bodega.setAgencia(agencia); // agrega la bodega a bodegaDetalle bodegaDetalle.setBodega(bodega); // genera la entidad producto Productoproducto=newProducto(); producto.setEliminado(pro.getBoolean("eliminado")); producto.setId(pro.getInt("id")); producto.setNombre(pro.getString("nombre")); // genera la entidad categora para agregarla al producto JSONObjectcat=pro.getJSONObject("categoria"); Categoriacategoria=newCategoria(); categoria.setEliminado(cat.getBoolean("eliminado")); categoria.setId(cat.getInt("id")); categoria.setNombre("nombre"); // genera la entidad marca para agregara al producto JSONObjectmar=pro.getJSONObject("marca"); Marcamarca=newMarca(); marca.setEliminado(mar.getBoolean("eliminado")); marca.setId(mar.getInt("id")); marca.setNombre(mar.getString("nombre")); // agrega la categoria al producto producto.setCategoria(categoria); // agrega la marca al producto producto.setMarca(marca); // agrega el producto a bodegaDetalle bodegaDetalle.setProducto(producto); returnbodegaDetalle; }catch(Exceptione){ returnnull; } } publicBodegaDetallegetBodegaDetalleById(intid){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/getBodegaDetalleById/"+id); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); BodegaDetallebodegaDetalle=newBodegaDetalle(); bodegaDetalle=getJSONParserBodegaDetalle(objJSON); returnbodegaDetalle; }catch(Exceptionex){ Log.e("Error","JPABodegaDetalleDAO returnnull; } <<getBodegaDetalleById>>",ex); 472 } } 11.3.4 DESCUENTOREST.JAVA packagepfm.android.rest; importjava.util.Date; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONObject; importandroid.util.Log; importpfm.entidades.Descuento; publicclassDescuentoRESTextendsGenericREST{ publicDescuentoREST(){ super("descuento"); } publicDescuentogetJSONParserDescuento(JSONObjectobjJSON){ try{ // mapea la entidad descuento a partir del JSON Descuentodescuento=newDescuento(); descuento.setEliminado(objJSON.getBoolean("eliminado")); descuento.setFechaFin((Date)objJSON.get("fechaFin")); descuento.setFechaInicio((Date)objJSON.get("fechaFin")); descuento.setId(objJSON.getInt("id")); descuento.setNombre(objJSON.getString("nombre")); descuento.setValor(objJSON.getDouble("valor")); returndescuento; }catch(Exceptione){ returnnull; } } publicDescuentogetDescuentoByProducto(intidProducto){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/getDescuentoByProducto/" +idProducto); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); Descuentodescuento=newDescuento(); descuento=getJSONParserDescuento(objJSON); returndescuento; }catch(Exceptionex){ Log.e("Error","JPADescuentoDAO <<getDescuentoByProducto>>",ex); returnnull; } } } 11.3.5 FACTURADETALLEREST.JAVA packagepfm.android.rest; 473 importjava.util.ArrayList; importjava.util.List; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONArray; importorg.json.JSONObject; importandroid.util.Log; importpfm.entidades.BodegaDetalle; importpfm.entidades.Descuento; importpfm.entidades.FacturaDetalle; publicclassFacturaDetalleRESTextendsGenericREST{ publicFacturaDetalleREST(){ super("facturaDetalle"); } publicFacturaDetallegetJSONParserFacturaDetalle(JSONObjectobjJSON){ try{ // mapea la entidad facturaDetalle a partir del JSON FacturaDetallefacturaDetalle=newFacturaDetalle(); facturaDetalle.setId(objJSON.getInt("id")); facturaDetalle.setCantidad(objJSON.getInt("cantidad")); facturaDetalle.setPrecio(objJSON.getDouble("precio")); facturaDetalle.setSubtotal(objJSON.getDouble("subtotal")); facturaDetalle.setDescuento(objJSON.getDouble("descuento")); facturaDetalle.setIva(objJSON.getDouble("iva")); facturaDetalle.setTotal(objJSON.getDouble("total")); // genera la entidad bodegaDetalle JSONObjectbodDetJSON=objJSON.getJSONObject("bodegaDetalle"); facturaDetalle.setBodegaDetalle(newRESTFactory() .getBodegaDetalleDAO().getJSONParserBodegaDetalle( bodDetJSON)); // genera la entidad factura solo con su id JSONObjectfacJSON=objJSON.getJSONObject("factura"); facturaDetalle.setFactura(newRESTFactory().getFacturaDAO() .getJSONParserFactura(facJSON)); returnfacturaDetalle; }catch(Exceptione){ returnnull; } } publicFacturaDetallegetFacturaDetalleById(intid){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/getFacturaDetalleById/" +id); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); FacturaDetallefacturaDetalle=newFacturaDetalle(); facturaDetalle=getJSONParserFacturaDetalle(objJSON); returnfacturaDetalle; 474 }catch(Exceptionex){ Log.e("Error","JPAFacturaDetalleDAO returnnull; } } <<getFacturaDetalleById>>",ex); publicFacturaDetallesetTotales(BodegaDetallebodegaDetalle, Descuentodescuento,intcantidad){ doubledes=0; doubleiva=0; doublesub=0; doubletot=0; sub=Math.round((cantidad*bodegaDetalle.getPrecio())*100.0)/100.0; if(descuento!=null){ des=Math.round(((sub*descuento.getValor())/100)*100.0)/100.0; }else{ des=0.00; } iva=Math.round(((sub*bodegaDetalle.getBodega().getAgencia() .getEmpresa().getIva())/100)*100.0)/100.0; tot=Math.round((sub-des+iva)*100.0)/100.0; FacturaDetallefacturaDetalle=newFacturaDetalle(); facturaDetalle.setBodegaDetalle(bodegaDetalle); facturaDetalle.setCantidad(cantidad); facturaDetalle.setDescuento(des); facturaDetalle.setEliminado(false); facturaDetalle.setIva(iva); facturaDetalle.setPrecio(bodegaDetalle.getPrecio()); facturaDetalle.setSubtotal(sub); facturaDetalle.setTotal(tot); returnfacturaDetalle; } publicintanadirProducto(intidFactura,intidAgencia,intidCliente, intidBodegaDetalle,intidDescuento,intcantidad){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/create/"+idFactura+"/" +idAgencia+"/"+idCliente+"/"+idBodegaDetalle+"/" +idDescuento+"/"+cantidad); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); returnobjJSON.getInt("id"); }catch(Exceptionex){ Log.e("Error","JPAFacturaDetalleDAO return0; } } <<anadirProducto>>",ex); publicintactualizarProducto(intidFacturaDetalle,intidDescuento, intcantidad){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/update/"+idFacturaDetalle +"/"+idDescuento+"/"+cantidad); del.setHeader("content-type","application/json"); try{ 475 HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); returnobjJSON.getInt("id"); }catch(Exceptionex){ Log.e("Error","JPAFacturaDetalleDAO return0; } } <<actualizarProducto>>",ex); publicinteliminarProducto(intidFacturaDetalle){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/delete/"+idFacturaDetalle); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); returnobjJSON.getInt("id"); }catch(Exceptionex){ Log.e("Error","JPAFacturaDetalleDAO return0; } } <<eliminarProducto>>",ex); publicbooleanexisteProductoByFacturaDetalle(intidFactura, intidBodegaDetalle){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST +"/existeProductoByFacturaDetalle/"+idFactura+"/" +idBodegaDetalle); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); intid=objJSON.getInt("id"); if(id!=0){ returntrue; }else{ returnfalse; } }catch(Exceptionex){ Log.e("Error", "JPAFacturaDetalleDAO <<existeProductoByFacturaDetalle>>", ex); returnfalse; } } publicList<FacturaDetalle>getCarroActual(intidFactura){ List<FacturaDetalle>listaProductos=newArrayList<FacturaDetalle>(); HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(this.uri+this.urlREST +"/carroCompraActual/"+idFactura); del.setHeader("content-type","application/json"); 476 try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectrespJSON=newJSONObject(respStr); JSONObjectpJSON=newJSONObject(); JSONArrayj=respJSON.optJSONArray("facturaDetalle"); FacturaDetallefacturaDetalle=newFacturaDetalle(); if(j!=null){ JSONArraydetallesJSON=respJSON .getJSONArray("facturaDetalle"); for(inti=0;i<detallesJSON.length();i++){ pJSON=detallesJSON.getJSONObject(i); facturaDetalle=getJSONParserFacturaDetalle(pJSON); listaProductos.add(facturaDetalle); } }else{ pJSON=respJSON.getJSONObject("facturaDetalle"); facturaDetalle=getJSONParserFacturaDetalle(pJSON); listaProductos.add(facturaDetalle); } returnlistaProductos; }catch(Exceptionex){ returnnull; } } } 11.3.6 MEDIOPAGOREST.JAVA packagepfm.android.rest; importjava.util.HashMap; importjava.util.Map; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONArray; importorg.json.JSONObject; importandroid.annotation.SuppressLint; importandroid.util.Log; publicclassMedioPagoRESTextendsGenericREST{ publicMedioPagoREST(){ super("medioDePago"); } @SuppressLint("UseSparseArrays") publicMap<Integer,String>listMedioPago(){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(this.uri+this.urlREST+"/listMedioPago"); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); 477 Map<Integer,String>lista=newHashMap<Integer,String>(); JSONArrayj=objJSON.optJSONArray("medioDePago"); if(j!=null){ JSONArrayarrJSON=objJSON.getJSONArray("medioDePago"); for(inti=0;i<arrJSON.length();i++){ JSONObjectobj=arrJSON.getJSONObject(i); intkey=obj.getInt("id"); Stringvalue=obj.getString("nombre"); lista.put(key,value); } }else{ JSONObjectobj=objJSON.getJSONObject("medioDePago"); lista.put(obj.getInt("id"),obj.getString("nombre")); } returnlista; }catch(Exceptionex){ Log.e("Error","JPAMedioPagoDAO <<listMedioPago>>",ex); returnnull; } } } 11.3.7 GENERICREST.JAVA packagepfm.android.rest; publicclassGenericREST{ protectedStringurlREST; //protected String uri = "http://10.0.2.2:8080/PFM/rest/"; protectedStringuri="http://miw06.calamar.eui.upm.es:8080/PFM/rest/"; publicGenericREST(StringurlREST){ this.urlREST=urlREST; } publicStringgetUrlREST(){ returnurlREST; } publicvoidsetUrlREST(StringurlREST){ this.urlREST=urlREST; } publicStringgetUri(){ returnuri; } publicvoidsetUri(Stringuri){ this.uri=uri; } } 11.3.8 FACTURAREST.JAVA packagepfm.android.rest; importjava.text.SimpleDateFormat; importjava.util.ArrayList; importjava.util.Date; importjava.util.List; importorg.apache.http.HttpResponse; importorg.apache.http.client.HttpClient; importorg.apache.http.client.methods.HttpGet; importorg.apache.http.impl.client.DefaultHttpClient; importorg.apache.http.util.EntityUtils; importorg.json.JSONArray; 478 importorg.json.JSONObject; importandroid.annotation.SuppressLint; importandroid.util.Log; importpfm.entidades.Factura; publicclassFacturaRESTextendsGenericREST{ publicFacturaREST(){ super("factura"); } @SuppressLint("SimpleDateFormat") publicFacturagetJSONParserFactura(JSONObjectobjJSON){ try{ // mapea la entidad factura a partir del JSON Facturafactura=newFactura(); factura.setId(objJSON.getInt("id")); factura.setSubtotal(objJSON.getDouble("subtotal")); factura.setDescuento(objJSON.getDouble("descuento")); factura.setIva(objJSON.getDouble("iva")); factura.setTotal(objJSON.getDouble("total")); factura.setEliminado(objJSON.getBoolean("eliminado")); factura.setPagado(objJSON.getBoolean("pagado")); factura.setPendiente(objJSON.getBoolean("pendiente")); // obtiene fecha Stringfecha=objJSON.getString("fecha"); SimpleDateFormatformatoFecha1=newSimpleDateFormat("yyyy-MM-dd"); Datefc1=null; fc1=formatoFecha1.parse(fecha); factura.setFecha(fc1); // obtiene la entidad agencia del objeto JSON JSONObjectageJSON=objJSON.getJSONObject("agencia"); factura.setAgencia(newRESTFactory().getAgenciaDAO() .getJSONParserAgencia(ageJSON)); returnfactura; }catch(Exceptione){ returnnull; } } publicList<Factura>getCarrosCompra(intidUsuario,intidAgencia){ List<Factura>listaCarros=newArrayList<Factura>(); HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(this.uri+this.urlREST+"/carrosCompra/" +idUsuario+"/"+idAgencia); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectrespJSON=newJSONObject(respStr); JSONArrayj=respJSON.optJSONArray("factura"); Facturafactura=newFactura(); if(j!=null){ JSONArraycarrosJSON=respJSON.getJSONArray("factura"); for(inti=0;i<carrosJSON.length();i++){ JSONObjectcarroJSON=carrosJSON.getJSONObject(i); factura=newRESTFactory().getFacturaDAO() .getJSONParserFactura(carroJSON); listaCarros.add(factura); } }else{ 479 JSONObjectpJSON=respJSON.getJSONObject("factura"); factura=newRESTFactory().getFacturaDAO() .getJSONParserFactura(pJSON); listaCarros.add(factura); } returnlistaCarros; }catch(Exceptionex){ returnnull; } } publicintEliminarFactura(intid){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/delete/"+id); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); returnobjJSON.getInt("id"); }catch(Exceptionex){ Log.e("Error","JPAFacturaDAO return0; } } <<EliminarFactura>>",ex); publicdoubleConfirmaTotal(intid,doubletotalFatura){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/confirmaTotal/"+id+"/" +totalFatura); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); returnobjJSON.getDouble("total"); }catch(Exceptionex){ Log.e("Error","JPAFacturaDAO <<ConfirmaTotal>>",ex); return0; } } publicintConfirmaCompra(intidFactura,intidMedioDePago){ HttpClienthttpClient=newDefaultHttpClient(); HttpGetdel=newHttpGet(uri+urlREST+"/confirmaCompra/" +idFactura+"/"+idMedioDePago); del.setHeader("content-type","application/json"); try{ HttpResponseresp=httpClient.execute(del); StringrespStr=EntityUtils.toString(resp.getEntity()); JSONObjectobjJSON=newJSONObject(respStr); // comprobar si el JSON es FacturaDetalle o Factura JSONArrayarrFacDetJSON=objJSON.optJSONArray("facturaDetalle"); if(arrFacDetJSON==null){ JSONObjectobjfacDetJSON=objJSON .optJSONObject("facturaDetalle"); if(objfacDetJSON==null){ 480 // confirmacion correcta returnobjJSON.getInt("id"); }else{ // no hay stock para un producto return-2; } }else{ // no hay stock para varios productos return-2; } }catch(Exceptionex){ Log.e("Error","JPAFacturaDAO return0; } <<ConfirmaCompra>>",ex); } } 11.3.9 RESTFACTORY.JAVA packagepfm.android.rest; publicclassRESTFactory{ publicUsuarioRESTgetUsuarioDAO(){ returnnewUsuarioREST(); } publicAgenciaRESTgetAgenciaDAO(){ returnnewAgenciaREST(); } publicBodegaDetalleRESTgetBodegaDetalleDAO(){ returnnewBodegaDetalleREST(); } publicDescuentoRESTgetDescuentoDAO(){ returnnewDescuentoREST(); } publicFacturaDetalleRESTgetFacturaDetalleDAO(){ returnnewFacturaDetalleREST(); } publicFacturaRESTgetFacturaDAO(){ returnnewFacturaREST(); } publicMedioPagoRESTgetMedioPagoDAO(){ returnnewMedioPagoREST(); } } 11.4 CAPTUREACTIVITY.JAVA (ZXING) /* * * * * * * * * Copyright (C) 2008 ZXing authors Licensed 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 481 * 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. */ packagecom.google.zxing.client.android; importcom.google.zxing.BarcodeFormat; importcom.google.zxing.Result; importcom.google.zxing.client.android.camera.CameraManager; importcom.google.zxing.client.android.history.HistoryManager; importandroid.app.Activity; importandroid.app.AlertDialog; importandroid.content.Intent; importandroid.graphics.Bitmap; importandroid.os.Bundle; importandroid.os.Handler; importandroid.os.Message; importandroid.preference.PreferenceManager; importandroid.util.Log; importandroid.view.KeyEvent; importandroid.view.SurfaceHolder; importandroid.view.SurfaceView; importandroid.view.View; importandroid.view.Window; importandroid.view.WindowManager; importandroid.widget.TextView; importandroid.widget.Toast; importjava.io.IOException; importjava.util.Collection; importpfm.android.R; importpfm.android.compras.AddProductoActivity; importpfm.android.compras.ComprasActivity; /** * This activity opens the camera and does the actual scanning on a background * thread. It draws a viewfinder to help the user place the barcode correctly, * shows feedback as the image processing is happening, and then overlays the * results when a scan is successful. * * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen */ @SuppressWarnings("deprecation") publicfinalclassCaptureActivityextendsActivityimplements SurfaceHolder.Callback{ privatestaticfinalStringTAG=CaptureActivity.class.getSimpleName(); publicstaticfinalintHISTORY_REQUEST_CODE=0x0000bacc; privateCameraManagercameraManager; privateCaptureActivityHandlerhandler; privateResultsavedResultToShow; privateViewfinderViewviewfinderView; privateTextViewstatusView; privateViewresultView; 482 privateResultlastResult; privatebooleanhasSurface; privateIntentSourcesource; privateCollection<BarcodeFormat>decodeFormats; privateStringcharacterSet; privateHistoryManagerhistoryManager; privateInactivityTimerinactivityTimer; privateBeepManagerbeepManager; privateintidAgencia; privateStringnombreAgencia; privateintidCliente; privateintidFactura; ViewfinderViewgetViewfinderView(){ returnviewfinderView; } publicHandlergetHandler(){ returnhandler; } CameraManagergetCameraManager(){ returncameraManager; } @Override publicvoidonCreate(Bundleicicle){ super.onCreate(icicle); // obtiene parametros Bundleparametros=getIntent().getExtras(); this.idAgencia=parametros.getInt("idAgencia"); this.nombreAgencia=parametros.getString("nombreAgencia"); this.idFactura=parametros.getInt("idFactura"); this.idCliente=parametros.getInt("idCliente"); Windowwindow=getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.capture); hasSurface=false; historyManager=newHistoryManager(this); historyManager.trimHistory(); inactivityTimer=newInactivityTimer(this); beepManager=newBeepManager(this); PreferenceManager.setDefaultValues(this,R.xml.preferences,false); // showHelpOnFirstLaunch(); } @Override protectedvoidonResume(){ super.onResume(); // // // // // // // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't want to open the camera driver and measure the screen size if we're going to show the help on first launch. That led to bugs where the scanning rectangle was the wrong size and partially off screen. cameraManager=newCameraManager(getApplication()); viewfinderView=(ViewfinderView)findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); 483 resultView=findViewById(R.id.result_view); statusView=(TextView)findViewById(R.id.status_view); handler=null; lastResult=null; resetStatusView(); SurfaceViewsurfaceView=(SurfaceView)findViewById(R.id.preview_view); SurfaceHoldersurfaceHolder=surfaceView.getHolder(); if(hasSurface){ // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); }else{ // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } beepManager.updatePrefs(); inactivityTimer.onResume(); } @Override protectedvoidonPause(){ if(handler!=null){ handler.quitSynchronously(); handler=null; } inactivityTimer.onPause(); cameraManager.closeDriver(); if(!hasSurface){ SurfaceViewsurfaceView=(SurfaceView)findViewById(R.id.preview_view); SurfaceHoldersurfaceHolder=surfaceView.getHolder(); surfaceHolder.removeCallback(this); } super.onPause(); } @Override protectedvoidonDestroy(){ inactivityTimer.shutdown(); super.onDestroy(); } @Override publicbooleanonKeyDown(intkeyCode,KeyEventevent){ switch(keyCode){ caseKeyEvent.KEYCODE_BACK: if(source==IntentSource.NATIVE_APP_INTENT){ setResult(RESULT_CANCELED); finish(); returntrue; } if((source==IntentSource.NONE||source==IntentSource.ZXING_LINK) &&lastResult!=null){ restartPreviewAfterDelay(0L); returntrue; } break; caseKeyEvent.KEYCODE_FOCUS: caseKeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app returntrue; 484 // Use volume up/down to turn on light caseKeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); returntrue; caseKeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); returntrue; } returnsuper.onKeyDown(keyCode,event); } privatevoiddecodeOrStoreSavedBitmap(Bitmapbitmap,Resultresult){ // Bitmap isn't used yet -- will be used soon if(handler==null){ savedResultToShow=result; }else{ if(result!=null){ savedResultToShow=result; } if(savedResultToShow!=null){ Messagemessage=Message.obtain(handler, R.id.decode_succeeded,savedResultToShow); handler.sendMessage(message); } savedResultToShow=null; } } @Override publicvoidsurfaceCreated(SurfaceHolderholder){ if(holder==null){ Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!"); } if(!hasSurface){ hasSurface=true; initCamera(holder); } } @Override publicvoidsurfaceDestroyed(SurfaceHolderholder){ hasSurface=false; } @Override publicvoidsurfaceChanged(SurfaceHolderholder,intformat,intwidth, intheight){ } /** * A valid barcode has been found, so give an indication of success and show * the results. * * @param rawResult * The contents of the barcode. * @param barcode * A greyscale bitmap of the camera data which was decoded. */ publicvoidhandleDecode(ResultrawResult,Bitmapbarcode){ if(Integer.parseInt(rawResult.getText().toString())>0){ // llama a la actividad addProducto beepManager.playBeepSoundAndVibrate(); Toast.makeText(this,"Codigo QR leido",Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,AddProductoActivity.class); 485 intento.putExtra("idAgencia",this.idAgencia); intento.putExtra("nombreAgencia",this.nombreAgencia); intento.putExtra("idFactura",this.idFactura); intento.putExtra("idCliente",this.idCliente); intento.putExtra("idBodegaDetalle", Integer.parseInt(rawResult.getText().toString())); startActivity(intento); finish(); }else{ // muestra error y llama a la actividad compras Toast.makeText(this,"Codigo QR incompatible",Toast.LENGTH_SHORT) .show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",this.idAgencia); intento.putExtra("nombreAgencia",this.nombreAgencia); intento.putExtra("idFactura",this.idFactura); intento.putExtra("idCliente",this.idCliente); startActivity(intento); finish(); } } privatevoidinitCamera(SurfaceHoldersurfaceHolder){ if(surfaceHolder==null){ thrownewIllegalStateException("No SurfaceHolder } if(cameraManager.isOpen()){ Log.w(TAG, provided"); "initCamera() while already open -- late SurfaceView callback?"); return; } try{ cameraManager.openDriver(surfaceHolder); // Creating the handler starts the preview, which can also throw a // RuntimeException. if(handler==null){ handler=newCaptureActivityHandler(this,decodeFormats, characterSet,cameraManager); } decodeOrStoreSavedBitmap(null,null); }catch(IOExceptionioe){ Log.w(TAG,ioe); displayFrameworkBugMessageAndExit(); }catch(RuntimeExceptione){ // Barcode Scanner has seen crashes in the wild of this variety: // java.?lang.?RuntimeException: Fail to connect to camera service Log.w(TAG,"Unexpected error initializing camera",e); displayFrameworkBugMessageAndExit(); } } privatevoiddisplayFrameworkBugMessageAndExit(){ AlertDialog.Builderbuilder=newAlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name)); builder.setMessage(getString(R.string.msg_camera_framework_bug)); builder.setPositiveButton(R.string.button_ok,newFinishListener(this)); builder.setOnCancelListener(newFinishListener(this)); builder.show(); } publicvoidrestartPreviewAfterDelay(longdelayMS){ if(handler!=null){ handler.sendEmptyMessageDelayed(R.id.restart_preview,delayMS); } resetStatusView(); } privatevoidresetStatusView(){ 486 resultView.setVisibility(View.GONE); statusView.setText(R.string.msg_default_status); statusView.setVisibility(View.INVISIBLE); viewfinderView.setVisibility(View.VISIBLE); lastResult=null; } publicvoiddrawViewfinder(){ viewfinderView.drawViewfinder(); } publicvoidcancelar(){ Toast.makeText(this,"Producto cancelado",Toast.LENGTH_SHORT).show(); Intentintento=newIntent(this,ComprasActivity.class); intento.putExtra("idAgencia",idAgencia); intento.putExtra("nombreAgencia",nombreAgencia); intento.putExtra("idFactura",idFactura); intento.putExtra("idCliente",idCliente); startActivity(intento); finish(); } @Override publicvoidonBackPressed(){ cancelar(); } } 11.5 ARCHIVOS DE CONFIGURACION 11.5.1 ANDROIDMANIFEST.XML <?xmlversion="1.0"encoding="utf-8"?> <manifestxmlns:android="http://schemas.android.com/apk/res/android" package="pfm.android" android:versionCode="1" android:versionName="1.0"> <uses-featureandroid:name="android.hardware.camera"/> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-permissionandroid:name="android.permission.CAMERA"/> <uses-permissionandroid:name="android.permission.INTERNET"/> <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="17"/> <application android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name="pfm.android.login.LoginActivity" android:label="@string/app_name" android:screenOrientation="portrait"> 487 <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name="com.google.zxing.client.android.CaptureActivity" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:screenOrientation="landscape" android:stateNotNeeded="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name="pfm.android.login.NuevoUsuarioActivity" android:label="@string/title_activity_nuevo_usuario" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.compras.AddProductoActivity" android:label="@string/title_activity_add_producto" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.compras.EditProductoActivity" android:label="@string/title_activity_edit_producto" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.compras.ComprasActivity" android:label="@string/title_activity_carro" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.compras.CarrosComprasActivity" android:label="@string/title_activity_carros" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.compras.ConfirmarComprasActivity" android:label="@string/title_activity_medio_de_pago" android:screenOrientation="portrait"> </activity> <activity android:name="pfm.android.login.LogoutActivity" android:label="@string/title_activity_logout" android:screenOrientation="portrait"> </activity> </application> </manifest> 488