Subiendo el proyecto

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-7-openjdk-amd64"/>
<classpathentry kind="lib" path="lib/jdom-2.0.5.jar"/>
<classpathentry kind="lib" path="forms-1.3.0.jar" sourcepath="forms-1.3.0-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
o Directories #
/build/
/bin/
target/
# OS Files #
.DS_Store
*.class
# Package Files #
#*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Eclipse
######################
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
####################
#IVY
####################
ivy.xml.MD5
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ParserFormsConnector</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
# Parseador del proyecto para la automatización de trámites
Esta herramienta convierte el modelado del proceso de negocios en
codigo ``Modelo-Vista-Controlador`` MVC
## Parseador Modelo Vista Controlador
Está desarrollado en ``Java``, descargue el proyecto en su repositorio local,
genere la aplicación ``.jar`` desde eclipse, y convierta la aplicación generada
por BonitaSoft ``.bar`` a código MVC para java, el cual se debe asignar en el
poyecto de la bandeja-tramites-web, para ser copilado en aplicación web ``.war``.
## Documentación
Revise la wiki para la información de la implementación.
[Wiki] (http://desarrollo.softwarepublico.gob.ve/tramites-todos/bandeja-tramites-web/wikis/home>)
O descargue el manual oficial:
[Manual de Instalación] (http://desarrollo.softwarepublico.gob.ve/tramites/01-bandeja-tramites-web/raw/master/Manual-Instalacion-Maquina-Tramite.odt)
File added
XML_FILE=resources/inputs/forms/forms.xml
ROOT_VIEW=resources/outputs/views/
ROOT_CONTROLLER=resources/outputs/beansANDcontrollers/
ROOT_BEAN=resources/outputs/beansANDcontrollers/
ROOT_SNIPPET=resources/snippets/
NAME_PACKAGE_BEAN=ve.gob.%{institucion}.%{processName}.model
NAME_PACKAGE_CONTROLLER=ve.gob.%{institucion}.%{processName}.controller
DIR_INSTITUCION=vicepresidencia
PATH_DIR_FORM_VIEW=/tramites/forms/
<?xml version="1.0" encoding="UTF-8"?>
<process>
<tasks>
<carga>
<vars>
<var>
<name>Nombre</name>
<varName>nombre</varName>
<type>java.lang.String</type>
</var>
<var>
<name>Apellido</name>
<varName>apellido</varName>
<type>java.lang.String</type>
</var>
<var>
<name>Correo Electrónico</name>
<varName>email</varName>
<type>java.lang.String</type>
</var>
<var>
<name>Nacionalidad</name>
<varName>nacionalidad</varName>
<type>java.lang.String</type>
</var>
<var>
<name>Cédula</name>
<varName>cedula</varName>
<type>java.lang.Integer</type>
</var>
<var>
<name>Sexo</name>
<varName>sexo</varName>
<type>java.lang.String</type>
</var>
<var>
<name>Fecha de Nacimiento</name>
<varName>f_nacimiento</varName>
<type>java.util.Date</type>
</var>
<var>
<name>Estado Civil</name>
<varName>edo_civil</varName>
<type>java.lang.String</type>
</var>
</vars>
</carga>
<revision>
<vars>
<var>
<name>Causas de devolución</name>
<varName>causasDevolucion</varName>
<type>java.util.List</type>
</var>
<var>
<name>Revisión</name>
<varName>revision</varName>
<type>java.lang.String</type>
</var>
</vars>
</revision>
<notificacion>
<vars>
<var>
<name>Causas de devolución</name>
<varName>causasDevolucion</varName>
<type>java.util.List</type>
</var>
<var>
<name>Fecha de Cita</name>
<varName>f_cita</varName>
<type>java.util.Date</type>
</var>
<var>
<name>Documento de Decisión</name>
<varName>_FILE_decision</varName>
<type>java.util.List</type>
</var>
</vars>
</notificacion>
</tasks>
<pool>
<vars>
<var>
<name>Datos Básicos</name>
<varName>_FILE_datosBasicos</varName>
<type>java.lang.String</type>
</var>
</vars>
</pool>
</process>
\ No newline at end of file
package %{packages};
%{imports}
import java.util.Arrays;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.util.List;
import ve.gob.cnti.gestion.utils.Utils;
import ve.gob.cnti.gestion.utils.annotations.*;
%{anotacion}
@ManagedBean(name = "%{nameBean}", eager = true)
@RequestScoped
public class %{NameBean} {
%{attributes}
public %{NameBean}() {}
%{setAndGetMethods}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head></h:head>
<h:body>
<c:if test="#{userManager.insertCiudadanoComponentsOnView()}">
<ui:include src="/views/layout/headerCiudadano.xhtml" />
</c:if>
<c:if test="#{userManager.insertFuncionarioComponentsOnView()}">
<ui:include src="/views/layout/headerFuncionario.xhtml" />
</c:if>
<p:messages id="messagesConsulTab" showDetail="true" autoUpdate="true" closable="true" />
<b:container id="container">
<h3>
<b:row>
<h:outputText
value="#{ProcessController.getProcessDisplayName(TaskController.task.processId)}" />
</b:row>
<b:row>
<h:outputText value="Caso N° #{TaskController.task.caseId}" />
</b:row>
</h3>
%{tabsElements}
</b:container>
<b:row>
<b:column span='12' style="height:100px;">
<ui:include src="/views/layout/footer.xhtml"/>
</b:column>
</b:row>
<h:outputStylesheet library="css" name="datatablecolor.css" />
</h:body>
</f:view>
\ No newline at end of file
package %{packages};
%{imports}
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import java.util.Map;
import javax.annotation.PostConstruct;
import java.io.Serializable;
%{anotacion}
@ManagedBean(name = "%{nameBean}", eager = true)
@ViewScoped
public class %{NameBean} implements Serializable {
@PostConstruct
public void init() {
}
%{attributes}
public %{NameBean}() {}
%{setAndGetMethods}
}
\ No newline at end of file
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<p:tab id="%{tabId}" title="%{namePage}">
%{messages}
<b:row>
%{inputsElements}
</b:row>
%{dataTable}
</p:tab>
</ui:composition>
\ No newline at end of file
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<p:tab id="tabResumen" title="Resumen">
<h:outputScript library="js" name="modalConfirmacion.js" />
<p:blockUI block="confirmacion" widgetVar="blockUI">
<p:graphicImage value="#{resource['images/ajax_loader.gif']}"></p:graphicImage>
<br />
<p:outputLabel>Por favor espere mientras se procesa su petición...</p:outputLabel>
</p:blockUI>
<b:row>
<h2>
<h:outputText
value="Datos Básicos" />
</h2>
</b:row>
<h:panelGroup>
<h:panelGrid styleClass="table table-bordered table-striped" columns="2">
%{outputsElements}
</h:panelGrid>
</h:panelGroup>
%{dataTable}
<div align="right">
<p:commandButton value="Enviar Datos" type="button"
onclick="PF('blockUI').hide(); PF('confirmDialog').show();" />
</div>
<p:confirmDialog message="¿Estás seguro de enviar los datos?"
header="Inciando envio de datos" severity="alert"
widgetVar="confirmDialog" id="confirmacion">
<p:commandButton value="Si" update="panelC"
action="#{%{nameTask}.executeTask}"
oncomplete="PF('confirmDialog').hide()" widgetVar="saveButton"
onclick="PF('blockUI').show()"
styleClass="ui-confirmdialog-yes" icon="ui-icon-check">
<f:param name="idTask" value="#{TaskController.task.id}" />
<f:param name="idCase" value="#{TaskController.task.caseId}" />
<f:param name="processId" value="#{TaskController.task.processId}" />
</p:commandButton>
<p:commandButton value="No" widgetVar="cancelButton"
onclick="PF('confirmDialog').hide();" type="button"
styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</p:tab>
</ui:composition>
\ No newline at end of file
package %{packages};
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@FacesValidator("%{nameBean}")
public class %{NameBean} implements Validator {
@Override
public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head>
<h:outputScript library="js" name="datePickerTraduccion.js" />
</h:head>
<h:body>
#{FacesHandler.removeBeanFromSessionScoped("%{nameTask}")}
#{%{nameTask}.setBean(%{nameTask}.getBeanToBPM(TaskController.task.caseId,TaskController.dbn,TaskController.isHistoryConsult))}
#{%{nameTask}.setTask(TaskController.task)}
<c:if test="#{userManager.insertCiudadanoComponentsOnView()}">
<ui:include src="/views/layout/headerCiudadano.xhtml" />
</c:if>
<c:if test="#{userManager.insertFuncionarioComponentsOnView()}">
<ui:include src="/views/layout/headerFuncionario.xhtml" />
</c:if>
<p:tooltip />
<b:container id="panelC">
<h:form enctype="multipart/form-data" id="form">
<b:row>
<h2>
<h:outputText
value="#{ProcessController.getProcessDisplayName(TaskController.task.processId)}" />
</h2>
</b:row>
<b:row>
<h3>
<h:outputText
value="#{TaskController.task.displayName} - Caso N° #{TaskController.task.caseId}" />
</h3>
</b:row>
<b:panel>
<p:wizard nextLabel="Siguiente" backLabel="Anterior"
flowListener="#{%{nameTask}.onFlowProcess}" >
<ui:include src="#{TaskController.caseConsultTab(ProcessController.getProcessName(TaskController.task.processId))}"/>
%{tabsElements}
</p:wizard>
%{filesInTabs}
</b:panel>
</h:form>
</b:container>
<b:row>
<b:column span='12' style="height:100px;">
<ui:include src="/views/layout/footer.xhtml"/>
</b:column>
</b:row>
</h:body>
</f:view>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head>
</h:head>
<h:body>
<c:if test="#{userManager.insertCiudadanoComponentsOnView()}">
<f:event listener="#{userManager.isCiudadano}" type="preRenderView"/>
<ui:include src="/views/layout/headerCiudadano.xhtml" />
</c:if>
<c:if test="#{userManager.insertFuncionarioComponentsOnView()}">
<f:event listener="#{userManager.isFuncionario}" type="preRenderView"/>
<ui:include src="/views/layout/headerFuncionario.xhtml" />
</c:if>
<b:container>
<h:form>
<h2><h:outputText value="El Envío de su solicitud se ha procesado exitosamente."
rendered="#{TaskController.task.name == 'carga'}" /></h2>
<p:outputLabel rendered="#{TaskController.dbn.sexo == 'F'}" value="Estimada: "/>
<p:outputLabel rendered="#{TaskController.dbn.sexo == 'M'}" value="Estimado: "/>
#{TaskController.dbn.primerNombre} #{TaskController.dbn.segundoNombre}
#{TaskController.dbn.primerApellido} #{TaskController.dbn.segundoApellido},
Se ha creado un nuevo caso n° #{TaskController.task.caseId} por concepto de
#{TaskController.task.displayName}, en los próximos días será notificado sobre los avances del caso.
<h2>
<h:outputText
value="El Envío de su formulario se ha procesado exitosamente. La actividad de #{TaskController.task.displayName}, se ha realizado exitosamente."
rendered="#{TaskController.task.name != 'carga'}" />
</h2>
</h:form>
</b:container>
<b:row>
<b:column span='12' style="height:100px;">
<ui:include src="/views/layout/footer.xhtml"/>
</b:column>
</b:row>
</h:body>
</f:view>
\ No newline at end of file
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:tab id="tab1" title="Notificación">
<h:outputScript library="js" name="modalConfirmacion.js" />
<p:blockUI block="confirmacion" widgetVar="blockUI">
<p:graphicImage value="#{resource['images/ajax_loader.gif']}"></p:graphicImage>
<br />
<p:outputLabel>Por favor espere mientras se procesa su petición...</p:outputLabel>
</p:blockUI>
<br/><br/>
<h:panelGrid columns="4" id="panelDialog">
<p:confirmDialog message="¿Estás seguro de enviar los resultados del trámite?"
header="Inciando envio de datos" severity="alert"
widgetVar="confirmDialog" id="confirmacion" >
<p:commandButton value="Si"
action="#{%{nameTask}.executeTask}"
oncomplete="PF('confirmDialog').hide()" widgetVar="saveButton"
onclick="PF('blockUI').show()" styleClass="ui-confirmdialog-yes"
icon="ui-icon-check">
<f:param name="idTask" value="#{TaskController.task.id}" />
<f:param name="idCase" value="#{TaskController.task.caseId}" />
<f:param name="processId" value="#{TaskController.task.processId}" />
</p:commandButton>
<p:commandButton value="No" widgetVar="cancelButton"
onclick="PF('confirmDialog').hide();" type="button"
styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</h:panelGrid>
<h:panelGrid columns="4" styleClass="gestorTramiteGrid">
<p:outputLabel value="El tramite con el caso N° #{TaskController.task.caseId} fue rechazado por: "
rendered="#{%{nameTask}.bean.causasDevolucion!=null and %{nameTask}.bean.causasDevolucion!='[]'}"/>
<p:outputLabel value="#{%{nameTask}.bean.causasDevolucion}"
rendered="#{%{nameTask}.bean.causasDevolucion!=null and %{nameTask}.bean.causasDevolucion!='[]'}"/>
<p:outputLabel value="El caso N° #{TaskController.task.caseId} fue aprobado y la cita fue asignada para:"
rendered="#{%{nameTask}.bean.f_cita!=null}"/>
<p:outputLabel value="#{%{nameTask}.bean.f_cita}"
rendered="#{%{nameTask}.bean.f_cita!=null}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:outputLabel>
<p:outputLabel value="El caso N° #{TaskController.task.caseId} fue aprobado. El documento generado es el siguiente:"
rendered="#{%{nameTask}.bean._FILE_decision!=null}"/>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<p:dataTable var="archivos" rowIndexVar="index"
value="#{%{nameTask}.bean._FILE_decision}"
rendered="#{%{nameTask}.bean._FILE_decision!=null}"
>
<p:column>
<p:commandButton value="Documento"
onclick="PF('_FILE_constancias').show();" ></p:commandButton>
<p:dialog position="top" header="Visor PDF" id="_FILE_constancias"
widgetVar="_FILE_constancias" resizable="false">
<p:media width="900px" height="500px" player="pdf"
value="#{%{nameTask}._FILE}">
<f:param name="id" value="#{archivos}" />
<p:outputPanel layout="block">
<h:form> Su navegador es incompatible para la visualización de documentos PDF. Para poder
examinar el documento, debe actualizar su navegador a una versión que pemita visualizar
archivos de extensión pdf directamente en el navegador o descargue el documento y utilice el visor de su sistema operativo.
archivos de extensión pdf directamente en el navegador o descargue el documento y utilice el visor de su sistema operativo.
<p:commandButton value="Bajar Archivo" ajax="false"
icon="ui-icon-arrowthick-1-s">
<p:fileDownload
value="#{%{nameTask}.getDownloadFile()}" />
<f:param name="id" value="#{archivos}" />
</p:commandButton>
</h:form>
</p:outputPanel>
</p:media>
</p:dialog>
</p:column>
</p:dataTable>
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" rendered="#{%{nameTask}.bean._FILE_decision!=null}" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<div align="right">
<p:commandButton value="Aceptar" type="button"
onclick="PF('confirmDialog').show(); confirmDialog.content.parent().css('position', 'fixed');
confirmDialog.content.parent().css('left', '25%');" />
</div>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
</h:panelGrid>
</p:tab>
</ui:composition>
\ No newline at end of file
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<p:tab id="tab1" title="Revisión">
<h:outputScript library="js" name="modalConfirmacion.js" />
<p:blockUI block="confirmacion" widgetVar="blockUI">
<p:graphicImage value="#{resource['images/ajax_loader.gif']}"></p:graphicImage>
<br />
<p:outputLabel>Por favor espere mientras se procesa su petición...</p:outputLabel>
</p:blockUI>
<h:panelGrid columns="4" id="panelDialog">
<p:confirmDialog message="¿Estás seguro de enviar los resultados del trámite?"
header="Inciando envio de datos" severity="alert"
widgetVar="confirmDialog" id="confirmacion">
<p:commandButton value="Si" update="panelC"
action="#{%{nameTask}.executeTask}"
oncomplete="PF('confirmDialog').hide()" widgetVar="saveButton"
onclick="PF('blockUI').show()" styleClass="ui-confirmdialog-yes"
icon="ui-icon-check">
<f:param name="idTask" value="#{TaskController.task.id}" />
<f:param name="idCase" value="#{TaskController.task.caseId}" />
<f:param name="processId" value="#{TaskController.task.processId}" />
</p:commandButton>
<p:commandButton value="No" widgetVar="cancelButton"
onclick="PF('confirmDialog').hide();" type="button"
styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</h:panelGrid>
<h:panelGrid columns="4" styleClass="gestorTramiteGrid"
id="panelRevision">
<h:panelGrid columns="4">
<p:outputLabel for="revision" value="Decisión:" />
<p:selectOneRadio id="revision"
value="#{%{nameTask}.bean.revision}">
<f:selectItems
value="#{%{nameTask}.bean.revisionOption}"
itemLabel="#{revision}" itemValue="#{revision}" />
<p:ajax update="panelRevision" />
</p:selectOneRadio>
</h:panelGrid>
<p:message for="revision" id="revisionMessage" style="color:red" />
<p:tooltip id="toolTipRevision" for="revision" value="revision1" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:panelGrid columns="4">
<h:outputLabel for="causasDevolucion" value="Causas de devolución"
rendered="#{%{nameTask}.bean.revision == 'Rechazado'}" />
<b:selectMultiMenu id="causasDevolucion"
value="#{%{nameTask}.bean.causasDevolucion}"
rendered="#{%{nameTask}.bean.revision == 'Rechazado'}"
required="#{%{nameTask}.bean.revision == 'Rechazado'}"
requiredMessage="Requerido"
allSelectedText="Todos los Elementos Seleccionados"
nSelectedText="Elementos Seleccionados"
nonSelectedText="Seleccione los motivos">
<f:selectItems
value="#{%{nameTask}.bean.causasDevolucionOption}" />
</b:selectMultiMenu>
</h:panelGrid>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<p:message for="causasDevolucion" id="causasDevolucionMessage"
style="color:red"
rendered="#{%{nameTask}.bean.revision == 'Rechazado'}" />
<p:tooltip id="toolTipCausasDevolucion" for="causasDevolucion"
value="CheckboxList1"
rendered="#{%{nameTask}.bean.revision == 'Rechazado'}"
/>
</h:panelGrid>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<div align="right">
<h:panelGrid columns="4">
<p:commandButton value="Aceptar" type="button"
onclick="PF('blockUI').hide(); PF('confirmDialog').show(); confirmDialog.content.parent().css('position', 'fixed');
confirmDialog.content.parent().css('left', '25%');" />
</h:panelGrid>
</div>
</p:tab>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:tab id="tabResumen" title="Resumen">
<h:outputScript library="js" name="modalConfirmacion.js" />
<p:blockUI block="confirmacion" widgetVar="blockUI">
<p:graphicImage value="#{resource['images/ajax_loader.gif']}"></p:graphicImage>
<br />
<p:outputLabel>Por favor espere mientras se procesa su petición...</p:outputLabel>
</p:blockUI>
<p:confirmDialog message="¿Estás seguro de enviar los datos?"
header="Inciando envio de datos" severity="alert"
widgetVar="confirmDialog" id="confirmacion1" tyle="position:fixed;"
appendToBody="true">
<p:commandButton value="Si"
action="#{%{nameProcessBean}Controller.executeTask}"
oncomplete="PF('confirmDialog').hide()" widgetVar="saveButton"
onclick="PF('blockUI').show()" styleClass="ui-confirmdialog-yes"
icon="ui-icon-check">
<f:param name="idTask" value="#{TaskController.task.id}" />
<f:param name="idCase" value="#{TaskController.task.caseId}" />
</p:commandButton>
<p:commandButton value="No" widgetVar="cancelButton"
onclick="PF('confirmDialog').hide();" type="button"
styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
<p:panel header="Datos básicos">
<h:panelGrid columns="4" styleClass="gestorTramiteGrid">
<p:outputLabel for="revision_info" value="Revision:" />
<p:outputLabel id="revision_info"
value="#{%{nameProcessBean}Controller.bean.revision}" />
<p:outputLabel for="causasDevolucion_info"
value="Causas de devolución"
rendered="#{%{nameProcessBean}Controller.bean.revision == 'Rechazado'}" />
<p:outputLabel id="causasDevolucion_info"
value="#{%{nameProcessBean}Controller.bean.causasDevolucion}"
rendered="#{%{nameProcessBean}Controller.bean.revision == 'Rechazado'}" />
<p:outputLabel for="emailSGI_info" value="Enviar a:"
rendered="#{%{nameProcessBean}Controller.bean.revision == 'Aprobado'}" />
<p:outputLabel id="emailSGI_info"
value="#{%{nameProcessBean}Controller.bean.emailSGI}"
rendered="#{%{nameProcessBean}Controller.bean.revision == 'Aprobado'}" />
</h:panelGrid>
</p:panel>
<p:dataTable id="tTabResumen" var="list"
rendered="#{%{nameProcessBean}Controller.beanFiles.size()>0}"
value="#{%{nameProcessBean}Controller.beanFiles}"
rowIndexVar="index">
<f:facet name="header">Documentos anexos</f:facet>
<p:column headerText="Nombre del documento">
<h:outputText value="#{list.nombreOficial}" />
</p:column>
<p:column headerText="Archivos">
<p:dataTable var="archivos" value="#{list.fileNames}"
rowIndexVar="index2">
<p:column>
<h:outputText value="#{archivos}"></h:outputText>
</p:column>
</p:dataTable>
</p:column>
</p:dataTable>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputText value="&lt;br /&gt;" escape="false" />
<div align="right">
<h:panelGrid columns="4">
<p:commandButton value="Aceptar" type="button"
onclick="PF('blockUI').hide(); PF('confirmDialog').show(); confirmDialog.content.parent().css('position', 'fixed');
confirmDialog.content.parent().css('left', '25%');" />
</h:panelGrid>
</div>
</p:tab>
</ui:composition>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:tab id="tabconsulta" title="Consulta" rendered="#{TaskController.isStartCase==null}">
#{FacesHandler.removeBeanFromSessionScoped("%{nameTask}")}
#{%{nameTask}.setBean(%{nameTask}.getBeanToBPM(TaskController.task.caseId,TaskController.dbn,TaskController.isHistoryConsult))}
#{%{nameTask}.setTask(TaskController.task)}
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:outputLabel for="process" value="La solicitud esta siendo procesada"/>
<h:outputText value="&lt;br /&gt;" escape="false" />
<h:form>
<p:tooltip />
<h:panelGroup>
<h:panelGrid styleClass="table table-bordered table-striped" columns="2">
%{outputsElements}
%{documentElements}
</h:panelGrid>
</h:panelGroup>
</h:form>
</p:tab>
</ui:composition>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
td{
padding-bottom: 5px;
padding-left: 5px;
}
.small {font-size: xx-small;}
.line{border-bottom: 1px solid black}
#page-header {
display: inline;
}
#page-footer{
text-align: right;
}
@page {
size: letter; /*letter landscape*/
background: white;
padding-top: 50px;
@top-center {
content: element(current);
}
@bottom-right {
content: element(footer);
}
}
.page-start { -fs-page-sequence: start; }
table {-fs-table-paginate: paginate;page-break-inside: avoid;}
/* forces a page break */
.break {page-break-after:always}
span.page:before { content: counter(page); }
span.pagecount:before { content: counter(pages); }
#header_logo{
width:720px;
height:65px;
background-size: cover;
}
#content{
}
</style>
</head>
<body>
<div style="-fs-page-sequence: start;">
<div style="position: running(current);">
<div id="page-header" class="small">
<div id="header_logo"></div>
</div>
</div>
<div style="position: running(footer);">
<div id="page-footer" class="small">
Página <span class="page" /> de <span class="pagecount" />
</div>
</div>
<div id="content">
<h1>Resumen de la Solicitud</h1>
<br/><b>Tipo de Solicitud: </b> %{ProcessDisplayName}
<br/><b>N° de Caso: </b> %{idCase}
<h3><u>Datos de la solicitud</u></h3>
<table>
%{outputsTableElements}
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head></h:head>
<h:body>
#{FacesHandler.removeBeanFromSessionScoped("%{nameTask}")}
#{%{nameTask}.setBean(%{nameTask}.getBeanToBPM(TaskController.task.caseId,TaskController.dbn,TaskController.isHistoryConsult))}
#{%{nameTask}.setTask(TaskController.task)}
<c:if test="#{userManager.insertCiudadanoComponentsOnView()}">
<ui:include src="/views/layout/headerCiudadano.xhtml" />
</c:if>
<c:if test="#{userManager.insertFuncionarioComponentsOnView()}">
<ui:include src="/views/layout/headerFuncionario.xhtml" />
</c:if>
<p:tooltip />
<b:container id="panelC">
<h:form enctype="multipart/form-data" id="form">
<b:row>
<h2>
<h:outputText
value="#{ProcessController.getProcessDisplayName(TaskController.task.processId)}" />
</h2>
</b:row>
<b:row>
<h3>
<h:outputText
value="#{TaskController.task.displayName} - Caso N° #{TaskController.task.caseId}" />
</h3>
</b:row>
<b:panel>
<p:wizard nextLabel="Siguiente" backLabel="Anterior"
flowListener="#{%{nameTask}.onFlowProcess}">
<ui:include src="#{TaskController.caseConsultTab(ProcessController.getProcessName(TaskController.task.processId))}"/>
%{tabsElements}
</p:wizard>
</b:panel>
</h:form>
</b:container>
<b:row>
<b:column span='12' style="height:100px;">
<ui:include src="/views/layout/footer.xhtml"/>
</b:column>
</b:row>
</h:body>
</f:view>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head></h:head>
<h:body>
#{FacesHandler.removeBeanFromSessionScoped("%{nameTask}")}
#{%{nameTask}.setBean(%{nameTask}.getBeanToBPM(TaskController.task.caseId,TaskController.dbn,TaskController.isHistoryConsult))}
#{%{nameTask}.setTask(TaskController.task)}
<c:if test="#{userManager.insertCiudadanoComponentsOnView()}">
<ui:include src="/views/layout/headerCiudadano.xhtml" />
</c:if>
<c:if test="#{userManager.insertFuncionarioComponentsOnView()}">
<ui:include src="/views/layout/headerFuncionario.xhtml" />
</c:if>
<p:tooltip />
<b:container id="panelC">
<h:form enctype="multipart/form-data" id="form">
<b:row>
<h2>
<h:outputText
value="#{ProcessController.getProcessDisplayName(TaskController.task.processId)}" />
</h2>
</b:row>
<b:row>
<h3>
<h:outputText
value="#{TaskController.task.displayName} - Caso N° #{TaskController.task.caseId}" />
</h3>
</b:row>
<b:panel>
<p:wizard nextLabel="Siguiente" backLabel="Anterior"
flowListener="#{%{nameTask}.onFlowProcess}">
<ui:include src="#{TaskController.caseConsultTab(ProcessController.getProcessName(TaskController.task.processId))}"/>
%{tabsElements}
</p:wizard>
</b:panel>
</h:form>
</b:container>
<b:row>
<b:column span='12' style="height:100px;">
<ui:include src="/views/layout/footer.xhtml"/>
</b:column>
</b:row>
</h:body>
</f:view>
\ No newline at end of file
XML_FILE=resources/inputs/forms/forms.xml
ROOT_VIEW=resources/outputs/views/
ROOT_CONTROLLER=resources/outputs/beansANDcontrollers/
ROOT_BEAN=resources/outputs/beansANDcontrollers/
ROOT_VALIDATOR=resources/outputs/validators/
ROOT_DEPENDENT=resources/outputs/dependents/
ROOT_SNIPPET=resources/snippets/
NAME_PACKAGE_BEAN=ve.gob.tramites.%{processName}.model
NAME_PACKAGE_CONTROLLER=ve.gob.tramites.%{processName}.controller
PATH_DIR_FORM_VIEW=/%{processName}/forms/
NAME_PACKAGE_VALIDATOR=ve.gob.tramites.%{processName}.validator
NAME_PACKAGE_DEPENDENT=ve.gob.tramites.%{processName}.dependent
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.swing;
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
/**
* Cyclic focus traversal policy based on array of components.
* <p>
* This class may be freely distributed as part of any application or plugin.
*
* @author scheglov_ke
*/
public class FocusTraversalOnArray extends FocusTraversalPolicy {
private final Component m_Components[];
////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public FocusTraversalOnArray(Component components[]) {
m_Components = components;
}
////////////////////////////////////////////////////////////////////////////
//
// Utilities
//
////////////////////////////////////////////////////////////////////////////
private int indexCycle(int index, int delta) {
int size = m_Components.length;
int next = (index + delta + size) % size;
return next;
}
private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
}
}
// try to find enabled component in "delta" direction
int initialIndex = index;
while (true) {
int newIndex = indexCycle(index, delta);
if (newIndex == initialIndex) {
break;
}
index = newIndex;
//
Component component = m_Components[newIndex];
if (component.isEnabled() && component.isVisible() && component.isFocusable()) {
return component;
}
}
// not found
return currentComponent;
}
////////////////////////////////////////////////////////////////////////////
//
// FocusTraversalPolicy
//
////////////////////////////////////////////////////////////////////////////
public Component getComponentAfter(Container container, Component component) {
return cycle(component, 1);
}
public Component getComponentBefore(Container container, Component component) {
return cycle(component, -1);
}
public Component getFirstComponent(Container container) {
return m_Components[0];
}
public Component getLastComponent(Container container) {
return m_Components[m_Components.length - 1];
}
public Component getDefaultComponent(Container container) {
return getFirstComponent(container);
}
}
\ No newline at end of file
package ve.gob.cnti;
import java.util.List;
import java.util.Map;
import ve.gob.cnti.helper.form.Application;
import ve.gob.cnti.helper.form.Field;
import ve.gob.cnti.helper.form.Form;
import ve.gob.cnti.helper.form.Page;
import ve.gob.cnti.helper.form.Validator;
import ve.gob.cnti.helper.input.ReadFile;
import ve.gob.cnti.helper.output.WriteFile;
import ve.gob.cnti.helper.util.LibUtils;
public class Test {
public Test() {
}
public void showListOutput(Application app){
System.out.println("\nNombre de aplicacion: "+app.getAppName());
Map<String, Form> mapForms = app.getMapForms();
for (String key : mapForms.keySet()) {
Form formE = mapForms.get(key);
System.out.println("Nombres de formularios: "+key);
List<Page> pages = formE.getListPages();
for(int i = 0; i < pages.size(); i++){
Page page = pages.get(i);
System.out.println("\t id page: "+page.getId());
System.out.println("\t name Page: "+page.getName());
System.out.println("\t next Page: "+page.getNextPage());
List<Field> fields = page.getListField();
System.out.println("=====================================================");
for(int j = 0; j < fields.size(); j++){
Field field = fields.get(j);
System.out.println("\t\t Label Field: "+field.getLabelField());
System.out.println("\t\t Name Field: "+field.getNameField());
System.out.println("\t\t Type Field: "+field.getTypeField());
System.out.println("\t\t Return Type Field: "+LibUtils.changeToPrimitiveType(field.getReturnType().substring(field.getReturnType().lastIndexOf(".")+1)));
System.out.println("\t\t Var Field: "+field.getVarName());
System.out.println("\t\t description Field: "+field.getDescription());
List<Validator> validators = field.getListValidators();
System.out.println("");
for(int k = 0; k < validators.size(); k++){
Validator validator = validators.get(k);
System.out.println("\t\t\t Name Validator: "+validator.getNameValidator());
}
List<String> options = field.getOptionValue();
System.out.println("");
for(int k = 0; k < options.size(); k++){
String option = options.get(k);
System.out.println("\t\t\t Name Options: "+option);
}
System.out.println("=====================================================");
}
}
}
}
public void testReadFile(){
ReadFile rf = new ReadFile();
WriteFile wf = new WriteFile();
String textFile = rf.readFile("resources/snippets/ModelController.snippet");
textFile = textFile.replaceAll("%\\{nameController\\}", "nuevoController");
textFile = textFile.replaceAll("%\\{NameController\\}", LibUtils.firstLetterUpper("nuevoController"));
String pathPackage = "ve.gob.tramite.controller".replaceAll("\\.", "/");
LibUtils.createDirs("resources/outputs/controllers/"+pathPackage);
String file = "resources/outputs/controllers/"+pathPackage+"/replace.java";
wf.writeFile(file, textFile);
}
}
\ No newline at end of file
package ve.gob.cnti.core;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import ve.gob.cnti.helper.form.Application;
import ve.gob.cnti.helper.form.Field;
import ve.gob.cnti.helper.form.Form;
import ve.gob.cnti.helper.form.Page;
import ve.gob.cnti.helper.form.Validator;
public class PaserXmltoForm {
private String xmlFile = "resources/inputs/forms/forms.xml";
private Document jdomDocument = null;
private Map<String, Form> mapForms = null;
public PaserXmltoForm() throws JDOMException, IOException {
SAXBuilder jdomBuilder = new SAXBuilder();
jdomDocument = jdomBuilder.build(new File(this.xmlFile));
}
public PaserXmltoForm(String xmlFile) throws JDOMException, IOException {
SAXBuilder jdomBuilder = new SAXBuilder();
// jdomDocument = jdomBuilder.build(xmlSource);
jdomDocument = jdomBuilder.build(new File(xmlFile));
}
private Map<String, Element> processForm(List<Element> forms) {
Map<String, Element> mapFormElemets = new HashMap<String, Element>();
Pattern p = Pattern.compile("\\w+--\\d\\.\\d--(.+)\\$entry");
for (int i = 0; i < forms.size(); i++) {
Element form = forms.get(i);
Matcher m = p.matcher(form.getAttributeValue("id"));
while (m.find()) {
mapFormElemets.put(m.group(1), form);
}
}
return mapFormElemets;
}
public Application parse() {
Element rootElement = jdomDocument.getRootElement();
String appName = rootElement.getChild("application").getAttributeValue("name").replaceAll(" ", "");
List<Element> forms = rootElement.getChild("application").getChild("forms").getChildren("form");
Map<String, Element> mapFormElemets = processForm(forms);
mapForms = new HashMap<String, Form>();
String idPage = null;
String labelField = null;
String nameField = null;
String typeField = null;
String varName = null;
String returnType = null;
String namePage = null;
String nextPage = null;
List<String> optionValue = new ArrayList<String>();
String stringValue = null;
String[] stringValueOptions = null;
String description = null;
String validatorClassName = null;
for (String nameForm : mapFormElemets.keySet()) {
Element formE = mapFormElemets.get(nameForm);
Form form = new Form();
form.setNameForm(nameForm);
List<Element> pages = formE.getChild("pages").getChildren("page");
for (int i = 0; i < pages.size(); i++) {
Element pageElem = pages.get(i);
Page page = new Page();
idPage = pageElem.getAttributeValue("id");
page.setId(idPage);
namePage = pageElem.getChild("page-label").getChild("expression").getChild("name").getValue();
page.setName(namePage);
if (pageElem.getChild("next-page") != null) {
nextPage = pageElem.getChild("next-page").getChild("expression").getChild("name").getValue();
} else {
nextPage = "";
}
page.setNextPage(nextPage);
List<Element> widgets = pageElem.getChild("widgets").getChildren("widget");
for (int j = 0; j < widgets.size(); j++) {
Element widget = widgets.get(j);
if (widget.getChild("initial-value") != null) {
varName = widget.getChild("initial-value").getChild("expression").getChild("name").getValue();
returnType = widget.getChild("initial-value").getChild("expression").getChild("return-type").getValue();
} else {
varName = "";
returnType = "";
}
if (widget.getChild("label") != null) {
labelField = widget.getChild("label").getChild("expression").getChild("name").getValue();
} else {
labelField = widget.getAttributeValue("id");
}
if (widget.getChild("title") != null) {
description = widget.getChild("title").getChild("expression").getChild("name").getValue();
} else {
description = widget.getAttributeValue("id");
}
optionValue = new ArrayList<String>();
if (widget.getAttributeValue("type").equals("LISTBOX_SIMPLE") || widget.getAttributeValue("type").equals("RADIOBUTTON_GROUP") || widget.getAttributeValue("type").equals("CHECKBOX_GROUP")) {
stringValue = widget.getChild("available-values").getChild("expression").getChild("expression-content").getValue();
stringValue = stringValue.replace("[", "");
stringValue = stringValue.replace("]", "");
stringValue = stringValue.replace("\"", "");
stringValueOptions = stringValue.split(",");
for (int y = 0; y < stringValueOptions.length; y++) {
optionValue.add(stringValueOptions[y]);
}
}
if (widget.getAttributeValue("type").equals("LISTBOX_MULTIPLE")) {
if (!widget.getChild("initial-value").getChild("expression").getChild("name").getValue().equals("<empty-name>")) {
stringValue = widget.getChild("available-values").getChild("expression").getChild("expression-content").getValue();
stringValue = stringValue.replace("[", "");
stringValue = stringValue.replace("]", "");
stringValue = stringValue.replace("\"", "");
stringValueOptions = stringValue.split(",");
for (int y = 0; y < stringValueOptions.length; y++) {
optionValue.add(stringValueOptions[y]);
}
} else {
varName = widget.getChild("available-values").getChild("expression").getChild("expression-content").getValue();
optionValue.clear();
}
// revisar cuando es MFILE o FILE
}
nameField = widget.getAttributeValue("id");
typeField = widget.getAttributeValue("type");
Field field = new Field();
field.setLabelField(labelField);
field.setNameField(nameField);
field.setTypeField(typeField);
field.setVarName(varName);
field.setDescription(description);
field.setReturnType(returnType);
field.setOptionValue(optionValue);
if (widget.getChild("mandatory") != null) {
if (Boolean.valueOf(widget.getChild("mandatory").getValue().trim()).booleanValue()) {
Validator val = new Validator();
val.setNameValidator("mandatory");
field.addValidator(val);
}
}
if (widget.getChild("readonly") != null) {
if (Boolean.valueOf(widget.getChild("readonly").getValue().trim()).booleanValue()) {
Validator val = new Validator();
val.setNameValidator("readonly");
field.addValidator(val);
field.setIsActuation(false);
}
}
if (widget.getChild("validators") != null) {
List<Element> validators = widget.getChild("validators").getChildren("validator");
for (int k = 0; k < validators.size(); k++) {
Element validator = validators.get(k);
validatorClassName = validator.getChild("classname").getValue();
String classType=validatorClassName;
String max="0";
String size = null,min="0";
validatorClassName = validatorClassName.substring(validatorClassName.lastIndexOf(".") + 1);
if(validatorClassName.contentEquals("LengthValidator")){
size=validator.getChild("parameter")
.getChild("expression").getChild("expression-content").getValue();
if(size.indexOf(",")>0){
String[] sizeValues=size.split(",");
min=sizeValues[0];
max=sizeValues[1];
}else{
max=size;
}
}
if(validatorClassName.contentEquals("GroovyFieldValidator")){
validatorClassName=validator.getAttributeValue("id");
}
Validator val = new Validator();
val.setNameValidator(validatorClassName);
val.setMinimun(min);
val.setMaximun(max);
val.setClassType(classType);
field.addValidator(val);
}
}
page.addField(field);
}
form.addPage(page);
}
mapForms.put(nameForm, form);
}
Application app = new Application();
app.setAppName(appName);
app.setMapForms(mapForms);
return app;
}
}
package ve.gob.cnti.helper.form;
import java.util.HashMap;
import java.util.Map;
public class Application {
private String appName;
private Map<String, Form> mapForms;
public Application() {
this.appName = null;
this.mapForms = new HashMap<String, Form>();
}
public String getAppName() {
return this.appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public Map<String, Form> getMapForms() {
return this.mapForms;
}
public void setMapForms(Map<String, Form> mapForms) {
this.mapForms = mapForms;
}
@Override
public String toString() {
return "Application [appName=" + appName + ", mapForms=" + mapForms + "]";
}
}
package ve.gob.cnti.helper.form;
import java.util.ArrayList;
import java.util.List;
public class Field {
private String labelField;
private String nameField;
private String typeField;
private String varName;
private String returnType;
private boolean isActuation;
private List<Validator> listValidators;
private List<String> optionValue;
private String description;
public Field() {
this.labelField = null;
this.nameField = null;
this.typeField = null;
this.varName = null;
this.returnType = null;
this.isActuation = true;
this.listValidators = new ArrayList<Validator>();
}
public boolean isActuation() {
return isActuation;
}
public void setIsActuation(boolean isActuation) {
this.isActuation = isActuation;
}
public String getLabelField() {
return labelField;
}
public void setLabelField(String labelField) {
this.labelField = labelField;
}
public String getNameField() {
return nameField;
}
public void setNameField(String nameField) {
this.nameField = nameField;
}
public String getTypeField() {
return typeField;
}
public void setTypeField(String typeField) {
this.typeField = typeField;
}
public String getVarName() {
return varName;
}
public void setVarName(String varName) {
this.varName = varName;
}
public String getReturnType() {
return returnType;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public List<Validator> getListValidators() {
return this.listValidators;
}
public void addValidator(Validator validator){
this.listValidators.add(validator);
}
public void removeValidator(int index){
this.listValidators.remove(index);
}
public Validator getValidator(int index){
return this.listValidators.get(index);
}
public List<String> getOptionValue() {
return optionValue;
}
public void setOptionValue(List<String> optionValue) {
this.optionValue = optionValue;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "Field [labelField=" + labelField + ", nameField=" + nameField + ", typeField=" + typeField + ", varName=" + varName + ", returnType=" + returnType + ", isActuation=" + isActuation + ", listValidators=" + listValidators + ", optionValue=" + optionValue + ", description="
+ description + "]";
}
}
package ve.gob.cnti.helper.form;
import java.util.ArrayList;
import java.util.List;
public class Form {
private String nameForm;
private String actionForm;
private List<Page> listPages;
public Form() {
this.nameForm = null;
this.actionForm = null;
this.listPages = new ArrayList<Page>();
}
public String getNameForm() {
return this.nameForm;
}
public void setNameForm(String nameForm) {
this.nameForm = nameForm;
}
public String getActionForm() {
return this.actionForm;
}
public void setActionForm(String actionForm) {
this.actionForm = actionForm;
}
public List<Page> getListPages() {
return this.listPages;
}
public void addPage(Page page){
this.listPages.add(page);
}
public void removePage(int index){
this.listPages.remove(index);
}
public Page getPage(int index){
return this.listPages.get(index);
}
@Override
public String toString() {
return "Form [nameForm=" + nameForm + ", actionForm=" + actionForm + ", listPages=" + listPages + "]";
}
}
package ve.gob.cnti.helper.form;
import java.util.ArrayList;
import java.util.List;
public class Page {
private String id;
private List<Field> listFields;
private String name;
private String nextPage;
public Page() {
this.id = null;
this.listFields = new ArrayList<Field>();
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public List<Field> getListField() {
return this.listFields;
}
public void addField(Field field){
this.listFields.add(field);
}
public void removeField(int index){
this.listFields.remove(index);
}
public Field getField(int index){
return this.listFields.get(index);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNextPage() {
return nextPage;
}
public void setNextPage(String nextPage) {
this.nextPage = nextPage;
}
@Override
public String toString() {
return "Page [id=" + id + ", listFields=" + listFields + ", name=" + name + ", nextPage=" + nextPage + "]";
}
}
package ve.gob.cnti.helper.form;
public class Validator {
private String nameValidator;
private String classType;
private String minimun;
private String maximun;
public Validator() {
this.nameValidator = null;
}
public String getNameValidator() {
return this.nameValidator;
}
public void setNameValidator(String nameValidator) {
this.nameValidator = nameValidator;
}
public String getClassType() {
return classType;
}
public void setClassType(String classType) {
this.classType = classType;
}
public String getMinimun() {
return minimun;
}
public void setMinimun(String minimun) {
this.minimun = minimun;
}
public String getMaximun() {
return maximun;
}
public void setMaximun(String maximun) {
this.maximun = maximun;
}
@Override
public String toString() {
return "Validator [nameValidator=" + nameValidator + ", classType=" + classType + ", minimun=" + minimun + ", maximun=" + maximun + "]";
}
}
\ No newline at end of file
package ve.gob.cnti.helper.input;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class ReadFile {
public ReadFile() {
}
public String readFile(String pathFile){
pathFile=pathFile.replaceAll("resources", "");
String HoldsText= null;
InputStream is = getClass().getResourceAsStream(pathFile);
InputStreamReader fr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(fr);
StringBuilder sb = new StringBuilder();
try {
while((HoldsText = br.readLine())!= null){
sb.append(HoldsText)
.append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
public File streamTofile(InputStream in) throws IOException {
final File tempFile = File.createTempFile("cntiTempTransversalVarsfile", ".tmp");
tempFile.deleteOnExit();
try (FileOutputStream out = new FileOutputStream(tempFile)) {
int read = 0;
byte[] bytes = new byte[1024];
while ((read = in.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
}
return tempFile;
}
}
package ve.gob.cnti.helper.output;
import java.io.FileWriter;
import java.io.PrintWriter;
public class WriteFile {
private FileWriter fichero;
private PrintWriter pw;
public WriteFile(){
this.fichero = null;
this.pw = null;
}
public void writeFile(String file, String text) {
try {
this.fichero = new FileWriter(file);
this.pw = new PrintWriter(fichero);
this.pw.print(text);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != this.fichero) {
this.fichero.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
package ve.gob.cnti.helper.util;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import ve.gob.cnti.helper.input.ReadFile;
public class LibUtils {
public LibUtils() {
}
public static String firstLetterUpper(String word) {
return Character.toUpperCase(word.charAt(0)) + word.substring(1);
}
public static String firstLetterLower(String word) {
return Character.toLowerCase(word.charAt(0)) + word.substring(1);
}
public static String readSnippetFile(String pathFile) {
ReadFile rf = new ReadFile();
String textFile = rf.readFile(pathFile);
return textFile;
}
public static boolean createDirs(String path) {
File dir = new File(path);
return dir.mkdirs();
}
public static String convertPackage2Dirs(String packages) {
return packages.replaceAll("\\.", "/");
}
public static boolean cretePackagesDirs(String packages) {
return createDirs(packages);
}
public static String replacePattern(String pattern, String replacement, String text) {
return text.replaceAll(pattern, replacement);
}
public static Properties loadFileProperties(String file) {
Properties props = new Properties();
try {
props.load(LibUtils.class.getResourceAsStream("/"+file));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return props;
}
public static String changeToPrimitiveType(String objectType) {
String primitiveType = null;
if ("Byte".equals(objectType)) {
primitiveType = "byte";
} else if ("Short".equals(objectType)) {
primitiveType = "short";
} else if ("List".equals(objectType)) {
primitiveType = "List<String>";
} else if ("Integer".equals(objectType)) {
primitiveType = "int";
} else if ("Long".equals(objectType)) {
primitiveType = "long";
} else if ("Float".equals(objectType)) {
primitiveType = "float";
} else if ("Double".equals(objectType)) {
primitiveType = "double";
} else if ("Character".equals(objectType)) {
primitiveType = "char";
} else if ("Boolean".equals(objectType)) {
primitiveType = "boolean";
} else {
primitiveType = objectType;
}
return primitiveType;
}
}
package ve.gob.cnti.helper.util;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class ReadPropertiesFile {
Properties propiedades;
InputStream entrada = null;
public ReadPropertiesFile(String file) {
this.propiedades = new Properties();
try {
this.entrada = new FileInputStream(file);
// cargamos el archivo de propiedades
this.propiedades.load(entrada);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getProperty(String property) {
return this.propiedades.getProperty(property);
}
}
package ve.gob.cnti.helper.util;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class ReadXml {
public boolean isVarPresentIntoXML(TransversalVar tv,String processDesignXml){
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File(processDesignXml));
doc.getDocumentElement().normalize();
NodeList listOfDataDefinition = doc.getElementsByTagName("textDataDefinition");
for(int s=0; s<listOfDataDefinition.getLength() ; s++){
Node dataDefinition = listOfDataDefinition.item(s);
if(dataDefinition.getNodeType() == Node.ELEMENT_NODE){
Element element = (Element)dataDefinition;
if(element.getAttribute("name").contentEquals(tv.getVarName()))
return true;
}
}
listOfDataDefinition = doc.getElementsByTagName("dataDefinition");
for(int s=0; s<listOfDataDefinition.getLength() ; s++){
Node dataDefinition = listOfDataDefinition.item(s);
if(dataDefinition.getNodeType() == Node.ELEMENT_NODE){
Element element = (Element)dataDefinition;
if(element.getAttribute("name").contentEquals(tv.getVarName()))
return true;
}
}
}catch (SAXParseException err) {
System.out.println ("** Parsing error" + ", line "
+ err.getLineNumber () + ", uri " + err.getSystemId ());
System.out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
}
return false;
}
public boolean isDescriptionPresentIntoBar(String processDesignXml){
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File(processDesignXml));
doc.getDocumentElement().normalize();
if(doc.getDocumentElement().getAttribute("description").length()>0)
return true;
}catch (SAXParseException err) {
System.out.println ("** Parsing error" + ", line "
+ err.getLineNumber () + ", uri " + err.getSystemId ());
System.out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
}
return false;
}
}
package ve.gob.cnti.helper.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import ve.gob.cnti.helper.input.ReadFile;
public class TransversalVar {
private String name;
private String varName;
private String type;
private static final String XML_TRANSVERSAL_VARS = "/inputs/transversal/vars/transversalVars.xml";
private static Document jdomDocument = null;
public List<TransversalVar> getTranversalsVarsIntoTask(String nameTask){
List<TransversalVar> variables = new ArrayList<TransversalVar>();
try {
SAXBuilder jdomBuilder = new SAXBuilder();
jdomDocument = jdomBuilder.build(new ReadFile().streamTofile(getClass().getResourceAsStream(XML_TRANSVERSAL_VARS)));
Element rootNode = jdomDocument.getRootElement();
Element carga = rootNode.getChild("tasks").getChild(nameTask);
List<Element> vars = carga.getChild("vars").getChildren("var");
for(Element var:vars){
TransversalVar tv = new TransversalVar();
tv.setName(var.getChildText("name"));
tv.setVarName(var.getChildText("varName"));
tv.setType(var.getChildText("type"));
variables.add(tv);
}
} catch (JDOMException | IOException e) {
e.printStackTrace();
}
return variables;
}
public List<TransversalVar> getTranversalsVarsIntoPool(){
List<TransversalVar> variables = new ArrayList<TransversalVar>();
try {
SAXBuilder jdomBuilder = new SAXBuilder();
jdomDocument = jdomBuilder.build(new ReadFile().streamTofile(getClass().getResourceAsStream(XML_TRANSVERSAL_VARS)));
Element rootNode = jdomDocument.getRootElement();
List<Element> vars = rootNode.getChild("pool").getChild("vars").getChildren("var");
for(Element var:vars){
TransversalVar tv = new TransversalVar();
tv.setName(var.getChildText("name"));
tv.setVarName(var.getChildText("varName"));
tv.setType(var.getChildText("type"));
variables.add(tv);
}
} catch (JDOMException | IOException e) {
e.printStackTrace();
}
return variables;
}
public boolean isPresentVarIntoPool(TransversalVar tv,String processDesignXml){
return new ReadXml().isVarPresentIntoXML(tv, processDesignXml);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getVarName() {
return varName;
}
public void setVarName(String varName) {
this.varName = varName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "TransversalVar [name=" + name + ", varName=" + varName + ", type=" + type + "]";
}
}
package ve.gob.cnti.output.bean;
import java.util.List;
import ve.gob.cnti.helper.form.Field;
import ve.gob.cnti.helper.output.WriteFile;
import ve.gob.cnti.helper.util.LibUtils;
public class GenerateBean {
protected String snippetFile = null;
protected String origSnippetFile = null;
protected WriteFile wf = null;
protected String pathOutputFile = null;
protected String imports = null;
protected String attributes = null;
protected String values = null;
protected String setAndGetMethods = null;
protected String nameApp = null;
public GenerateBean(String pathFile, String pathOutputFile, String nameApp) {
this.origSnippetFile = LibUtils.readSnippetFile(pathFile);
this.pathOutputFile = pathOutputFile;
this.wf = new WriteFile();
this.nameApp = nameApp;
}
public void setImports(String imports) {
this.imports = imports;
}
public void setValues(String values) {
this.values = values;
}
public void setAttributes(String attributes) {
this.attributes = attributes;
}
public void setSetAndGetMethods(String setAndGetMethods) {
this.setAndGetMethods = setAndGetMethods;
}
public void replaceNameBeanAndNameClassBean(String nameBean) {
// Para colocar la variable con el snippet original en la siguiente iteración
this.snippetFile = this.origSnippetFile;
if (!Character.isLowerCase(nameBean.charAt(0))) {
this.snippetFile = LibUtils.replacePattern("%\\{nameBean\\}", this.nameApp + "_" + LibUtils.firstLetterLower(nameBean), this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{NameBean\\}", nameBean, this.snippetFile);
} else {
this.snippetFile = LibUtils.replacePattern("%\\{nameBean\\}", this.nameApp + "_" + nameBean, this.snippetFile);
nameBean = LibUtils.firstLetterUpper(nameBean);
this.snippetFile = LibUtils.replacePattern("%\\{NameBean\\}", nameBean, this.snippetFile);
}
if(nameBean.contentEquals("Carga")){
this.snippetFile = LibUtils.replacePattern("%\\{anotacion\\}", "@BeanIsInitCase",this.snippetFile);
}else{
this.snippetFile = LibUtils.replacePattern("%\\{anotacion\\}", "",this.snippetFile);
}
}
public void replacePackagesNameBean(String packagesName) {
packagesName = LibUtils.replacePattern("%\\{processName\\}", this.nameApp, packagesName);
this.snippetFile = LibUtils.replacePattern("%\\{packages\\}", packagesName, this.snippetFile);
}
public void createImpAttAndMethos(Field field) {
if (!"".equals(field.getReturnType())) {
if (!field.getReturnType().matches("java\\.lang\\..*") && !this.imports.contains(field.getReturnType())) {
this.imports += createImports(field.getReturnType());
}
String nameField = field.getVarName();
String typeField = field.getTypeField();
String returnTypes = field.getReturnType().substring(field.getReturnType().lastIndexOf(".") + 1);
List<String> nameOptions = field.getOptionValue();
if(nameOptions != null)
this.values += createMethodSelectValue(nameOptions) + "\n";
this.attributes += createAttribute(nameField, returnTypes, typeField, field.isActuation(), nameOptions);
this.setAndGetMethods += createSetMethod(nameField, returnTypes, typeField) + "\n";
this.setAndGetMethods += createGetMethod(nameField, returnTypes, typeField) + "\n";
}
}
public void replaceVaraiablesAndWriteFile(String nameBean) {
this.snippetFile = LibUtils.replacePattern("%\\{imports\\}", this.imports, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{attributes\\}", this.attributes, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{values\\}", this.values, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{setAndGetMethods\\}", this.setAndGetMethods, snippetFile);
this.wf.writeFile(this.pathOutputFile + "/" + LibUtils.firstLetterUpper(nameBean) + ".java", this.snippetFile);
}
// Convierte el nombre del paquetre definido en el configuracion.properties en una ruta de directorio valida
/*
* Ejemplo: entrada ve.gob.vicepresidencia.jubilacionespecial.model salida /ve/gob/vicepresidencia/jubilacionespecial/model
*/
public boolean createPackageDirsBean(String packages) {
packages = LibUtils.replacePattern("%\\{processName\\}", this.nameApp, packages);
String pathPackage = LibUtils.convertPackage2Dirs(packages);
this.pathOutputFile += pathPackage;
return LibUtils.createDirs(pathOutputFile);
}
private String createImports(String imports) {
return "import " + imports + ";\n";
}
private String createAttribute(String name, String type, String typeInput, boolean isReadOnly, List<String> options) {
if (isReadOnly) {
if (type.equals("List") && !name.matches("^_FILE_.*$")) {
return "@FieldIsActuacion\nprivate " + "String" + " " + name + ";\n" + "private " + "List<String> " + name + "Option" + " = Arrays.asList(" + this.createMethodSelectValue(options) + ");\n";
}else if(typeInput.equals("LISTBOX_SIMPLE")&&name.startsWith("c_")){
return "@FieldIsActuacion\nprivate " + "String" + " " + name + ";\n";
}else if (typeInput.equals("LISTBOX_SIMPLE") || typeInput.equals("RADIOBUTTON_GROUP") || typeInput.equals("CHECKBOX_GROUP")) {
return "@FieldIsActuacion\nprivate " + "String" + " " + name + ";\n" + "private " + "List<String> " + name + "Option" + " = Arrays.asList(" + this.createMethodSelectValue(options) + ");\n";
} else {
return "@FieldIsActuacion\nprivate " + LibUtils.changeToPrimitiveType(type) + " " + name + ";\n";
}
} else {
if (type.equals(LibUtils.changeToPrimitiveType("List<String>")) && !name.matches("^_FILE_.*$")) {
return "private " + "String[]" + " " + name + ";\n";
}
else {
return "private " + LibUtils.changeToPrimitiveType(type) + " " + name + ";\n";
}
}
}
public String createMethodSelectValue(List<String> nameOptions) {
String option = "";
for (int k = 0; k < nameOptions.size(); k++) {
option += "\"" + nameOptions.get(k) + "\"";
if (k < (nameOptions.size() - 1)) {
option += ",";
}
}
return option;
}
/*
* "LISTBOX_SIMPLE"
*
* "LISTBOX_MULTIPLE" RADIOBUTTON_GROUP
*/
public String createSetMethod(String name, String type, String typeInput) {
String method = null;
if (type.equals("List") && !name.matches("^_FILE_.*$")) {
method = "public void set" + LibUtils.firstLetterUpper(name) + "(" + "String" + " " + name + " ) {\n" + "\t this." + name + " = " + name + ";\n" + "}\n";
method += "public void set" + LibUtils.firstLetterUpper(name) + "Option" + "(" + "List<String> " + name + "Option" + " ) {\n" + "\t this." + name + "Option" + "= " + name + "Option" + ";\n" + "}\n";
}else if(typeInput.equals("LISTBOX_SIMPLE")&&name.startsWith("c_")){
method = "public void set" + LibUtils.firstLetterUpper(name) + "(" + "String" + " " + name + " ) {\n" + "\t this." + name + " = " + name + ";\n" + "}\n";
} else if (typeInput.equals("LISTBOX_SIMPLE") || typeInput.equals("RADIOBUTTON_GROUP") || typeInput.equals("CHECKBOX_GROUP")) {
method = "public void set" + LibUtils.firstLetterUpper(name) + "(" + "String" + " " + name + " ) {\n" + "\t this." + name + " = " + name + ";\n" + "}\n";
method += "public void set" + LibUtils.firstLetterUpper(name) + "Option" + "(" + "List<String> " + name + "Option" + " ) {\n" + "\t this." + name + "Option" + "= " + name + "Option" + ";\n" + "}\n";
} else {
method = "public void set" + LibUtils.firstLetterUpper(name) + "(" + LibUtils.changeToPrimitiveType(type) + " " + name + " ) {\n" + "\t this." + name + " = " + name + ";\n" + "}\n";
}
return method;
}
public String createGetMethod(String name, String type, String typeInput) {
String method = null;
if (type.equals("List") && !name.matches("^_FILE_.*$")) {
method = "public " + "String" + " get" + LibUtils.firstLetterUpper(name) + "() {\n" + "\t return this." + name + ";\n" + "}\n";
method += "public " + "List<String>" + " get" + LibUtils.firstLetterUpper(name) + "Option" + "() {\n" + "\t "
+ "return new Utils().convertlistStringToListStringUTF8(this." + name + "Option" + ");\n" + "}\n";
}else if(typeInput.equals("LISTBOX_SIMPLE")&&name.startsWith("c_")){
method = "public " + "String" + " get" + LibUtils.firstLetterUpper(name) + "() {\n" + "\t return this." + name + ";\n" + "}\n";
}else if (typeInput.equals("LISTBOX_SIMPLE") || typeInput.equals("RADIOBUTTON_GROUP") || typeInput.equals("CHECKBOX_GROUP")) {
method = "public " + "String" + " get" + LibUtils.firstLetterUpper(name) + "() {\n" + "\t return this." + name + ";\n" + "}\n";
method += "public " + "List<String>" + " get" + LibUtils.firstLetterUpper(name) + "Option" + "() {\n" + "\t "
+ "return new Utils().convertlistStringToListStringUTF8(this." + name + "Option" + ");\n" + "}\n";
} else {
method = "public " + LibUtils.changeToPrimitiveType(type) + " get" + LibUtils.firstLetterUpper(name) + "() {\n" + "\t return this." + name + ";\n" + "}\n";
}
return method;
}
}
package ve.gob.cnti.output.controller;
import java.util.List;
import ve.gob.cnti.helper.form.Field;
import ve.gob.cnti.helper.output.WriteFile;
import ve.gob.cnti.helper.util.LibUtils;
public class GenerateController {
private String snippetFile = null;
private String origSnippetFile = null;
private WriteFile wf = null;
private String pathOutputFile = null;
private String nameApp = null;
public GenerateController(String pathFile, String pathOutputFile, String nameApp) {
this.origSnippetFile = LibUtils.readSnippetFile(pathFile);
this.pathOutputFile = pathOutputFile;
this.wf = new WriteFile();
this.nameApp = nameApp;
}
public void replaceNameBeanAndNameClassBeanController(String nameBean) {
// Para colocar la variable con el snippet original en la siguiete iteración
this.snippetFile = this.origSnippetFile;
if (!Character.isLowerCase(nameBean.charAt(0))) {
this.snippetFile = LibUtils.replacePattern("%\\{NameBean\\}", nameBean, this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{nameController\\}", this.nameApp + "_" + LibUtils.firstLetterLower(nameBean) + "Controller", this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{NameController\\}", nameBean + "Controller", this.snippetFile);
} else {
this.snippetFile = LibUtils.replacePattern("%\\{NameBean\\}", LibUtils.firstLetterUpper(nameBean), this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{nameController\\}", this.nameApp + "_" + nameBean + "Controller", this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{NameController\\}", LibUtils.firstLetterUpper(nameBean) + "Controller", this.snippetFile);
}
}
public void replaceDirViewSuccess(String dir) {
dir = "/views/" + dir + "success.xhtml?faces-redirect=true";
this.snippetFile = LibUtils.replacePattern("%\\{DirViewSuccess\\}", dir, this.snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{processName\\}", this.nameApp, this.snippetFile);
}
public void replaceInstitucion(String ins){
this.snippetFile = LibUtils.replacePattern("%\\{institucion\\}", ins, this.snippetFile);
}
// Convierte el nombre del paquete definido en el configuracion.properties en una ruta de directorio valida
/*
* Ejemplo: entrada ve.gob.vicepresidencia.jubilacionespecial.controller salida /ve/gob/vicepresidencia/jubilacionespecial/controller
*/
public boolean createPackageDirsController(String packages) {
packages = LibUtils.replacePattern("%\\{processName\\}", this.nameApp, packages);
String pathPackage = LibUtils.convertPackage2Dirs(packages);
this.pathOutputFile += pathPackage;
return LibUtils.createDirs(pathOutputFile);
}
public void replacePackagesNameBeanController(String packageBean) {
// Para colocar la variable con el snippet original en la siguiete
// iteración
this.snippetFile = LibUtils.replacePattern("%\\{packageBean\\}", packageBean, this.snippetFile);
}
public void replacePackagesNameController(String packagesName) {
// Para colocar la variable con el snippet original en la siguiete
// iteración
this.snippetFile = LibUtils.replacePattern("%\\{packages\\}", packagesName, this.snippetFile);
}
public void writeFileConroller(String nameController) {
this.wf.writeFile(this.pathOutputFile + "/" + LibUtils.firstLetterUpper(nameController) + "Controller.java", this.snippetFile);
}
private void replaceFilesAttributes(String files) {
this.snippetFile = LibUtils.replacePattern("%\\{files\\}", files, this.snippetFile);
}
private void insertSetAndGetFile(String value) {
this.snippetFile = LibUtils.replacePattern("%\\{set_get_file_decision\\}", value, this.snippetFile);
}
public void insertFilesInController(List<Field> fields) {
String files = "";
boolean containFileDecision =false;
for (int j = 0; j < fields.size(); j++) {
Field field = fields.get(j);
if (field.isActuation() && (field.getVarName().matches("^_FILE_.*$") || field.getVarName().matches("^_MFILE_.*$"))) {
files += "private List<UploadedFile> " +field.getVarName() + ";\n";
if(field.getVarName().contentEquals("_FILE_decision")){
containFileDecision =true;
}
}
}
if(containFileDecision){
String value = "public List<UploadedFile> get_FILE_decision() {\n";
value += "return _FILE_decision;\n}\npublic void set_FILE_decision(List<UploadedFile> _FILE_decision) {\n";
value += "this._FILE_decision = _FILE_decision;\n}\n";
this.insertSetAndGetFile(value);
}else
this.insertSetAndGetFile("");
this.replaceFilesAttributes(files);
}
}
package ve.gob.cnti.output.dependent;
import java.io.File;
import java.util.List;
import ve.gob.cnti.helper.form.Field;
import ve.gob.cnti.helper.util.LibUtils;
import ve.gob.cnti.output.bean.GenerateBean;
public class GenerateDependent extends GenerateBean{
public GenerateDependent(String pathFile, String pathOutputFile, String nameApp) {
super(pathFile, pathOutputFile, nameApp);
// TODO Auto-generated constructor stub
}
public String createGetMethod(String name, String type, String typeInput) {
String method = null;
method = "public " + "Map<String,String>" + " get" + LibUtils.firstLetterUpper(name) + "() {\n" + "\t return this." + name + ";\n" + "}\n";
method += "public " + "void" + " getFind" +name +"(String "+name+") {\n" + "\t "
+ "}\n";
return method;
}
public void createImpAttAndMethos(Field field) {
if (!"".equals(field.getReturnType())) {
String nameField = field.getVarName();
String typeField = field.getTypeField();
String returnTypes = field.getReturnType().substring(field.getReturnType().lastIndexOf(".") + 1);
List<String> nameOptions = field.getOptionValue();
if(nameOptions != null)
this.values += createMethodSelectValue(nameOptions) + "\n";
this.attributes += createAttribute(nameField, returnTypes, typeField, field.isActuation(), nameOptions);
this.setAndGetMethods += createSetMethod(nameField, returnTypes, typeField) + "\n";
this.setAndGetMethods += createGetMethod(nameField, returnTypes, typeField) + "\n";
}
}
@SuppressWarnings("unused")
private String createAttribute(String name, String type, String typeInput, boolean isReadOnly, List<String> options) {
return "private " + "Map<String,String>" + " " + name + ";\n";
}
public String createSetMethod(String name, String type, String typeInput) {
String method = null;
method = "public void set" + LibUtils.firstLetterUpper(name) + "(" + "Map<String,String>" + " " + name + " ) {\n" + "\t this." + name + " = " + name + ";\n" + "}\n";
return method;
}
public void replaceVaraiablesAndWriteFile(String nameBean,String packageNameDependent,String appPath) {
this.snippetFile = LibUtils.replacePattern("%\\{imports\\}", this.imports, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{attributes\\}", this.attributes, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{values\\}", this.values, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{setAndGetMethods\\}", this.setAndGetMethods, snippetFile);
if (!this.validatorExist(nameBean,packageNameDependent, appPath))
this.wf.writeFile(this.pathOutputFile + "/" + LibUtils.firstLetterUpper(nameBean) + ".java", this.snippetFile);
}
public Boolean validatorExist( String nameBean,String packageNameDependent,String appPath){
String pathClass=appPath+ packageNameDependent
.replace("%{processName}", this.nameApp)
.replace(".","/");
pathClass+="/"+LibUtils.firstLetterUpper(nameBean)+".java";
File f = new File(pathClass);
return f.exists();
}
}
package ve.gob.cnti.output.validator;
import java.io.File;
import ve.gob.cnti.helper.util.LibUtils;
import ve.gob.cnti.output.bean.GenerateBean;
public class GenerateValidator extends GenerateBean{
public GenerateValidator(String pathFile, String pathOutputFile, String nameApp) {
super(pathFile, pathOutputFile, nameApp);
// TODO Auto-generated constructor stub
}
public void replaceVaraiablesAndWriteFile(String nameBean,String packageNameValidator,String appPath) {
//nameBean=this.nameApp + "_" + LibUtils.firstLetterLower(nameBean);
this.snippetFile = LibUtils.replacePattern("%\\{imports\\}", this.imports, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{attributes\\}", this.attributes, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{values\\}", this.values, snippetFile);
this.snippetFile = LibUtils.replacePattern("%\\{setAndGetMethods\\}", this.setAndGetMethods, snippetFile);
if (!this.validatorExist(nameBean,packageNameValidator, appPath))
this.wf.writeFile(this.pathOutputFile + "/" + LibUtils.firstLetterUpper(nameBean) + ".java", this.snippetFile);
}
public Boolean validatorExist( String nameBean,String packageNameValidator,String appPath){
String pathClass=appPath+ packageNameValidator
.replace("%{processName}", this.nameApp)
.replace(".","/");
pathClass+="/"+nameBean+".java";
File f = new File(pathClass);
return f.exists();
}
/*public void replaceNameBeanAndNameClassBean(String nameBean) {
// Para colocar la variable con el snippet original en la siguiente iteración
this.snippetFile = this.origSnippetFile;
this.snippetFile = LibUtils.replacePattern("%\\{nameBean\\}", nameBean, this.snippetFile);
nameBean = LibUtils.firstLetterUpper(nameBean);
this.snippetFile = LibUtils.replacePattern("%\\{NameBean\\}", nameBean, this.snippetFile);
}*/
/* public void replaceNameBeanAndNameClassBean(String nameBean) {
// Para colocar la variable con el snippet original en la siguiente iteración
this.snippetFile = this.origSnippetFile;
this.snippetFile = LibUtils.replacePattern("%\\{nameBean\\}", this.nameApp + "_" + LibUtils.firstLetterLower(nameBean), this.snippetFile);
}*/
}
package ve.gob.cnti.utils;
import java.io.IOException;
import java.io.OutputStream;
import javax.swing.JTextArea;
public class CustomOutputStream extends OutputStream {
private JTextArea textArea;
public CustomOutputStream(JTextArea textArea) {
this.textArea = textArea;
}
@Override
public void write(byte[] buffer, int offset, int length) throws IOException
{
final String text = new String (buffer, offset, length);
textArea.append (text);
textArea.setCaretPosition(textArea.getDocument().getLength());
}
@Override
public void write(int b) throws IOException
{
write (new byte [] {(byte)b}, 0, 1);
}
}
package ve.gob.cnti.utils;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
public class JTextFieldLimit extends PlainDocument {
private static final long serialVersionUID = 1L;
private int limit;
public JTextFieldLimit(int limit) {
super();
this.limit = limit;
}
public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
if (str == null)
return;
if ((getLength() + str.length()) <= limit) {
super.insertString(offset, str, attr);
}
}
}
package ve.gob.cnti.utils;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import javax.swing.JOptionPane;
import ve.gob.cnti.windows.swing.Config;
import ve.gob.cnti.windows.swing.ConfigForm;
public class Utils {
private static final String HOMECONFIG = System.getProperty("user.home")+"/.config.obj";
/**
* Ubica el componente dentro de la vista
*
* @param x
* @param y
* @param w
* @param h
* @return GridBagConstraints
*/
public GridBagConstraints limitarComponente(int x, int y, int w, int h) {
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = x;
constraints.gridy = y;
constraints.gridwidth = w;
constraints.gridheight = h;
return constraints;
}
/**
* Ventana de mensaje
*
* @param comp
* Ventana
* @param msj
* Mensaje de la ventana
* @param title
* Titulo de la ventana
* @param opc
* Tipo de mensaje [0=Error, 1=Informacion, 2=Advertencia]
*/
public void ventanaDeMensaje(Component comp, String msj, String title, short opc) {
short type = 0;
switch (opc) {
case 1:
type = JOptionPane.INFORMATION_MESSAGE;
break;
case 2:
type = JOptionPane.WARNING_MESSAGE;
}
JOptionPane.showMessageDialog(comp, msj, title, type);
}
public void executeCommand(String command) {
String s = null;
try {
Process p = Runtime.getRuntime().exec(command);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
}
}
public String MD5(String md5) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(md5.getBytes());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
}
return sb.toString();
} catch (java.security.NoSuchAlgorithmException e) {
}
return null;
}
public void copyFile_Java7(String origen, String destino) throws IOException {
Path FROM = Paths.get(origen);
Path TO = Paths.get(destino);
//sobreescribir el fichero de destino, si existe, y copiar
// los atributos, incluyendo los permisos rwx
CopyOption[] options = new CopyOption[]{
StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.COPY_ATTRIBUTES
};
Files.copy(FROM, TO, options);
}
public void writeConfig(Config cfg) throws IOException{
File file = new File(HOMECONFIG);
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(cfg);
oos.close();
}
@SuppressWarnings("resource")
public Config readConfig() throws ClassNotFoundException, IOException{
System.out.println();
ObjectInputStream ois = null;
Config cfg = null;
try {
File file = new File(HOMECONFIG);
if(file.isFile()){
FileInputStream fis = new FileInputStream(file);
ois = new ObjectInputStream(fis);
cfg = (Config) ois.readObject();
if(!formIsValid(cfg.getRutaBandeja())){
cfg = null;
new ConfigForm();
}
}else
new ConfigForm();
} catch (Exception e) {
@SuppressWarnings("unused")
ConfigForm cfgForm = new ConfigForm();
}
return cfg;
}
private boolean formIsValid(String rutaPorleth) {
if (rutaPorleth.isEmpty()) {
return false;
} else if (!this.pathExist(rutaPorleth)) {
return false;
}
return true;
}
private boolean pathExist(String rootPath) {
String path = rootPath + "/src/ve/gob/cnti/gestion/resources";
if (new File(path).isDirectory()) {
return true;
}
return false;
}
}
package ve.gob.cnti.windows.swing;
import java.io.Serializable;
public class Config implements Serializable{
private static final long serialVersionUID = 1L;
private String rutaBandeja;
public Config(String rutaBandeja) {
super();
this.rutaBandeja = rutaBandeja;
}
public Config() {
super();
}
public String getRutaBandeja() {
return rutaBandeja;
}
public void setRutaBandeja(String rutaBandeja) {
this.rutaBandeja = rutaBandeja;
}
}
package ve.gob.cnti.windows.swing;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.JTextField;
import ve.gob.cnti.utils.Utils;
public class ConfigForm extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
// Variables para el parseo
private String rutaPorleth = "";
private JPanel contentPane;
private JTextField textRutaPorlet;
private JButton btnGuardar, btnRutaPortlet;
public ConfigForm() {
super("Configuración Inicial");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 590, 175);
this.definirVentana();
}
public ConfigForm(String rutaPorleth) throws HeadlessException {
super("Configuración Inicial");
this.rutaPorleth = rutaPorleth;
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
Config cfg;
try {
cfg = new Utils().readConfig();
ParserForm pf = new ParserForm(cfg.getRutaBandeja());
pf.setVisible(true);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
setBounds(100, 100, 590, 175);
this.definirVentana();
textRutaPorlet.setText(rutaPorleth);
}
private void definirVentana() {
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnRutaPortlet = new JButton("Ruta a la Bandeja");
btnRutaPortlet.setBounds(392, 22, 184, 25);
contentPane.add(btnRutaPortlet);
btnGuardar = new JButton("Guardar Configuración");
btnGuardar.setBounds(165, 71, 246, 25);
contentPane.add(btnGuardar);
textRutaPorlet = new JTextField();
textRutaPorlet.setEditable(false);
textRutaPorlet.setColumns(10);
textRutaPorlet.setBounds(12, 25, 361, 19);
contentPane.add(textRutaPorlet);
btnRutaPortlet.addActionListener(this);
btnGuardar.addActionListener(this);
setLocationRelativeTo(null);
setResizable(false);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnRutaPortlet) {
this.obtenerRutaPortlet();
}
if (e.getSource() == btnGuardar) {
if (this.formIsValid()) {
try {
new Utils().writeConfig(new Config(this.rutaPorleth));
this.startAplication();
} catch (ClassNotFoundException | IOException e1) {
e1.printStackTrace();
}
setVisible(false);
}
}
}
private boolean formIsValid() {
if (this.rutaPorleth.isEmpty()) {
new Utils().ventanaDeMensaje(this, "Indique la ruta al portlet", "Error!!", (short) 0);
return false;
} else if (!this.pathExist(rutaPorleth)) {
new Utils().ventanaDeMensaje(this, "La ruta indicada no contiene el portlet, por favor indique la ruta correcta.", "Error!!", (short) 0);
return false;
}
return true;
}
private void startAplication() throws ClassNotFoundException, IOException {
Config cfg = new Utils().readConfig();
if (cfg != null) {
new Utils().ventanaDeMensaje(this, "Configuración registrada.", "Configuración Inicial", (short) 1);
ParserForm pf = new ParserForm(cfg.getRutaBandeja());
pf.setVisible(true);
}
}
private void obtenerRutaPortlet() {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
chooser.showOpenDialog(this);
rutaPorleth = chooser.getSelectedFile().getAbsolutePath();
textRutaPorlet.setText(rutaPorleth);
}
private boolean pathExist(String rootPath) {
String path = rootPath + "/src/ve/gob/cnti/gestion/resources";
if (new File(path).isDirectory()) {
return true;
}
return false;
}
}
package ve.gob.cnti.windows.swing;
import java.io.IOException;
import ve.gob.cnti.utils.Utils;
public class Main {
public static void main(String[] args) throws ClassNotFoundException, IOException {
Config cfg = new Utils().readConfig();
if(cfg!=null){
ParserForm pf = new ParserForm(cfg.getRutaBandeja());
pf.setVisible(true);
}
}
}
package ve.gob.cnti.windows.swing;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.JFileChooser;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JSeparator;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import ve.gob.cnti.utils.Utils;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
public class ParserForm extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
// Variables para el parseo
private String rutaPorleth = "";
private File[] archivos;
private JPanel contentPane;
private JTextField textRutaPorlet;
private final String[] titulos = { "Nombre", "Archivos" };
private DefaultTableModel dtm = new DefaultTableModel();
private JTable table = new JTable(dtm);
private JScrollPane scroll;
private JButton btnObtenerArchivos, btnParsear, btnResetConfig;
private Utils util = new Utils();
public ParserForm(String rutaPorlet) {
super("Generador MVC de trámites");
this.rutaPorleth = rutaPorlet;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 590, 350);
this.definirVentana();
textRutaPorlet.setText(this.rutaPorleth);
JLabel lblRutaDelPortlet = new JLabel("Ruta del Portlet");
lblRutaDelPortlet.setBounds(391, 26, 184, 15);
contentPane.add(lblRutaDelPortlet);
}
private void definirVentana() {
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnResetConfig = new JButton("Cambiar Configuración");
btnResetConfig.setBounds(12, 277, 214, 25);
contentPane.add(btnResetConfig);
btnParsear = new JButton("Generar MVC");
btnParsear.setBounds(391, 277, 184, 25);
contentPane.add(btnParsear);
textRutaPorlet = new JTextField();
textRutaPorlet.setEditable(false);
textRutaPorlet.setColumns(10);
textRutaPorlet.setBounds(12, 24, 361, 19);
contentPane.add(textRutaPorlet);
dtm.setColumnIdentifiers(titulos);
scroll = new JScrollPane(table);
scroll.setBounds(12, 63, 361, 188);
contentPane.add(scroll);
JSeparator separator = new JSeparator();
separator.setBounds(12, 263, 563, 15);
contentPane.add(separator);
btnObtenerArchivos = new JButton("Obtener archivos");
btnObtenerArchivos.setBounds(391, 136, 184, 25);
contentPane.add(btnObtenerArchivos);
contentPane.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[] {btnResetConfig, btnObtenerArchivos }));
btnObtenerArchivos.addActionListener(this);
btnParsear.addActionListener(this);
btnResetConfig.addActionListener(this);
setLocationRelativeTo(null);
setResizable(false);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnObtenerArchivos) {
this.obtenerArchivos();
}
if (e.getSource() == btnResetConfig) {
this.setVisible(false);
new ConfigForm(this.rutaPorleth);
}
if (e.getSource() == btnParsear) {
if(this.isFormValid()){
this.setVisible(false);
this.generarMVC();
}
}
}
private void generarMVC() {
ParserProcessing pp = new ParserProcessing(rutaPorleth, archivos);
pp.setVisible(true);
}
private void obtenerArchivos() {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Bar Proccess", "bar");
chooser.setFileFilter(filter);
chooser.setAcceptAllFileFilterUsed(false);
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(this);
archivos = chooser.getSelectedFiles();
boolean contieneArchivosInvalidos = false;
for (File archivo : archivos) {
if (archivo.getName().toLowerCase().endsWith("bar")) {
Object[] aux = { archivo.getName(), archivo.getAbsolutePath() };
dtm.addRow(aux);
} else
contieneArchivosInvalidos = true;
}
if (contieneArchivosInvalidos)
util.ventanaDeMensaje(this, "Los archivos a parsear deben ser de extencion bar", "Error", (short) 0);
}
private boolean isFormValid(){
if(this.archivos==null){
util.ventanaDeMensaje(this, "Debe seleccionar al menos un archivo bar para procesar", "Error", (short) 0);
return false;
}
return true;
}
}
package ve.gob.cnti.windows.swing;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JTextArea;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JLabel;
import org.jdom2.JDOMException;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser;
import ve.gob.cnti.App;
import ve.gob.cnti.utils.CustomOutputStream;
import ve.gob.cnti.utils.Utils;
public class ParserProcessing extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
JTextArea textArea = new JTextArea();
JScrollPane outScroll = new JScrollPane(textArea);
JButton btnCerrar = new JButton("Cerrar");
JButton btnIniciar = new JButton("Iniciar Proceso");
JLabel lblProcesar;
private Utils util = new Utils();
// Variables para el parseo
private String rutaPorleth = "";
private File[] archivos;
private String pathTemp;
private PrintStream standardOut;
public ParserProcessing(){
}
public ParserProcessing(String rutaPorleth, File[] archivos) {
super("Ventana de Procesamiento");
this.rutaPorleth = rutaPorleth;
this.archivos = archivos;
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
Config cfg;
try {
cfg = new Utils().readConfig();
ParserForm pf = new ParserForm(cfg.getRutaBandeja());
pf.setVisible(true);
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
setBounds(100, 100, 850, 500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
textArea.setEditable(false);
textArea.setBackground(Color.BLACK);
textArea.setForeground(Color.GREEN);
outScroll.setBounds(12, 35, 820, 394);
contentPane.add(outScroll);
PrintStream printStream;
try {
printStream = new PrintStream(new CustomOutputStream(textArea),true, "UTF-8");
System.setOut(printStream);
System.setErr(printStream);
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
standardOut = System.out;
btnCerrar.setBounds(719, 436, 117, 25);
contentPane.add(btnCerrar);
btnCerrar.addActionListener(this);
btnIniciar.setBounds(569, 436, 138, 25);
contentPane.add(btnIniciar);
btnIniciar.addActionListener(this);
lblProcesar = new JLabel();
lblProcesar.setBounds(296, -2, 192, 25);
contentPane.add(lblProcesar);
setResizable(false);
setLocationRelativeTo(null);
this.updateTextArea("\nRuta del Proyecto de Bandeja = " + this.rutaPorleth);
this.updateTextArea("\nCreación de carpetas temporales");
this.createPathTemp();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnCerrar) {
Config cfg;
try {
cfg = new Utils().readConfig();
ParserForm pf = new ParserForm(cfg.getRutaBandeja());
pf.setVisible(true);
this.dispose();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (e.getSource() == btnIniciar) {
this.startProcess(this);
}
}
private void startProcess(final ParserProcessing pp) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
pp.procesar();
}
});
thread.start();
}
public void procesar() {
lblProcesar.setText("Procesando la petición...");
for (int i = 0; i < archivos.length; i++) {
this.unzipFileBarAndParserApp(archivos[i].getAbsolutePath(), i + 1);
}
btnIniciar.setVisible(false);
util.executeCommand("rm -R " + pathTemp);
}
private void unzipFileBarAndParserApp(String archivo, int n) {
App paser = new App(pathTemp + "MVC_APPS/",rutaPorleth + "/src/");
util.executeCommand("mkdir " + pathTemp + "MVC_APPS");
util.executeCommand("mkdir " + pathTemp + "MVC_APPS/beansANDcontrollers");
util.executeCommand("mkdir " + pathTemp + "MVC_APPS/views");
util.executeCommand("mkdir " + pathTemp + "MVC_APPS/validators");
util.executeCommand("mkdir " + pathTemp + "MVC_APPS/dependents");
// copiando bar a carpeta temporal
this.updateTextArea("\nCopiando " + archivo + " a carpeta temporal " + pathTemp + "bars/file" + n);
this.copyFile(archivo, pathTemp + "bars/file" + n);
// Descomprimiendo bar
this.updateTextArea("\nDescomprimiendo " + pathTemp + "bars/file" + n + " a carpeta temporal " + pathTemp + "bars/bar" + n);
util.executeCommand("mkdir " + pathTemp + "bars/bar" + n);
util.executeCommand("unzip " + pathTemp + "bars/file" + n + " -d " + pathTemp + "bars/bar" + n);
// Parseando Aplicación
if(paser.isFormValid(pathTemp + "bars/bar" + n + "/resources/forms/forms.xml",(pathTemp + "bars/bar" + n + "/process-design.xml"),this)){
this.updateTextArea("\n\nParseando archivo bar\n");
try {
paser.generateFiles((pathTemp + "bars/bar" + n + "/resources/forms/forms.xml"));
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// moviendo las vistas
this.updateTextArea("\nCopiando las vistas");
util.executeCommand("cp -r " + pathTemp + "MVC_APPS/views/tramites/ " + rutaPorleth + "/WebContent/views/");
// moviendo los modelos y controladores
this.updateTextArea("\nCopiando los modelos y controladores");
util.executeCommand("cp -r " + pathTemp + "MVC_APPS/beansANDcontrollers/ve/ " + rutaPorleth + "/src/");
// VERIFICO SI FUERON GENERADO VALIDADORES SI ES ASI LOS COPIA EN LA APLICACION
File d = new File(pathTemp + "MVC_APPS/validators/ve");
if(d.list()!=null&&d.list().length>0) {
this.updateTextArea("\nCopiando los validadores");
util.executeCommand("cp -r " + pathTemp + "MVC_APPS/validators/ve/ " + rutaPorleth + "/src/");
}
d = new File(pathTemp + "MVC_APPS/dependents/ve");
if(d.list()!=null&&d.list().length>0) {
this.updateTextArea("\nCopiando los combos");
util.executeCommand("cp -r " + pathTemp + "MVC_APPS/dependents/ve/ " + rutaPorleth + "/src/");
}
util.ventanaDeMensaje(this, "El procesamiento ha terminado exitosamente", "Generación de MVC", (short) 1);
}
}
public void saveLogErrors(String log,ParserProcessing pp,String name) throws IOException {
util.ventanaDeMensaje(pp, "El procesamiento se ha detenido, verifique los mensajes de error en la consola..", "Error en Generación de MVC", (short) 0);
JFileChooser chooser = new JFileChooser("Guardar log de errores");
File f = new File(new File("ERRORS_LOG_"+name+".txt").getCanonicalPath());
FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos de texto", "txt");
chooser.setFileFilter(filter);
chooser.setAcceptAllFileFilterUsed(false);
chooser.setSelectedFile(f);
chooser.setDialogTitle("Guardar log de errores");
int retrival = chooser.showSaveDialog(null);
if (retrival == JFileChooser.APPROVE_OPTION) {
try {
PrintWriter writer = new PrintWriter(chooser.getSelectedFile()+".txt", "UTF-8");
writer.append(log);
writer.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private void createPathTemp() {
this.pathTemp = "/tmp/cntiParserApp/";
util.executeCommand("mkdir " + pathTemp);
this.pathTemp += util.MD5(new Date().toString()) + "/";
util.executeCommand("mkdir " + pathTemp);
util.executeCommand("mkdir " + pathTemp + "bars");
}
private void copyFile(String origen, String destino) {
try {
util.copyFile_Java7(origen, destino);
} catch (IOException e) {
e.printStackTrace();
}
}
private void updateTextArea(final String text) {
System.out.println(text);
}
@Override
public String toString() {
return "ParserProcessing [contentPane=" + contentPane + ", textArea=" + textArea + ", outScroll=" + outScroll + ", btnCerrar=" + btnCerrar + ", btnIniciar=" + btnIniciar + ", lblProcesar=" + lblProcesar + ", util=" + util + ", rutaPorleth=" + rutaPorleth + ", archivos="
+ Arrays.toString(archivos) + ", pathTemp=" + pathTemp + ", standardOut=" + standardOut + "]";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment