Merge back modularity branch to trunk.
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 12 Nov 2008 13:14:11 +0000
changeset 1929 ad0353d93b0f
parent 1928 34cae22c29f7
child 1930 ea71e4a5d3c9
Merge back modularity branch to trunk.

Due to svn problems it has been merged using patch after updating modularity
with trunk rev 9900. This means that the svn log info for the files modified
in modularity branch will not be available.
.classpath
.classpath.template
.project
.settings/org.eclipse.wst.common.component
build.xml
config/provider-config.xml
lib/build/hybridlabs-beautifier-1.1.9.jar
lib/build/jalopy-1.5-rc3p1.jar
lib/build/org.eclipse.emf.common_2.4.0.v200806091234.jar
lib/build/org.eclipse.emf.ecore.xmi_2.4.0.v200806091234.jar
lib/build/org.eclipse.emf.ecore_2.4.0.v200806091234.jar
lib/build/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
lib/build/org.eclipse.text_3.4.0.v20080605-1800.jar
lib/build/org.openarchitectureware.core.emftools_4.3.1.20080910-1400PRD.jar
lib/build/org.openarchitectureware.core.expressions_4.3.1.20080910-1400PRD.jar
lib/build/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar
lib/build/org.openarchitectureware.core.xpand2_4.3.1.20080910-1400PRD.jar
lib/runtime/ant-1.6.5.jar
lib/runtime/ant-launcher.jar
lib/runtime/ant-nodeps.jar
lib/runtime/commons-digester-1.7.jar
lib/runtime/hybridlabs-beautifier-1.1.9.jar
lib/runtime/jalopy-1.5-rc3p1.jar
lib/runtime/jasperreports-1.3.3.jar
lib/runtime/jcommon-1.0.0.jar
lib/runtime/jdbc3-postgresql.jar
lib/runtime/jfreechart-1.0.1.jar
lib/runtime/js.jar
lib/runtime/org.eclipse.emf.common_2.4.0.v200806091234.jar
lib/runtime/org.eclipse.emf.ecore.xmi_2.4.0.v200806091234.jar
lib/runtime/org.eclipse.emf.ecore_2.4.0.v200806091234.jar
lib/runtime/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
lib/runtime/org.eclipse.text_3.4.0.v20080605-1800.jar
lib/runtime/org.openarchitectureware.core.emftools_4.3.1.20080910-1400PRD.jar
lib/runtime/org.openarchitectureware.core.expressions_4.3.1.20080910-1400PRD.jar
lib/runtime/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar
lib/runtime/org.openarchitectureware.core.xpand2_4.3.1.20080910-1400PRD.jar
lib/runtime/postgresql-jdbc3-8.2.jar
lib/runtime/xmlrpc-client-3.0.jar
lib/runtime/xmlrpc-common-3.0.jar
src-core/build.xml
src-core/src/org/openbravo/base/ConnectionProviderContextListener.java
src-core/src/org/openbravo/base/HttpBaseServlet.java
src-core/src/org/openbravo/base/MultipartRequest.java
src-core/src/org/openbravo/data/Sqlc.java
src-core/src/org/openbravo/database/CPStandAlone.java
src-core/src/org/openbravo/database/ConnectionProvider.java
src-core/src/org/openbravo/database/ConnectionProviderImpl.java
src-core/src/org/openbravo/database/JNDIConnectionProvider.java
src-core/src/org/openbravo/database/StandAloneConnection.java
src-core/src/org/openbravo/exception/PoolNotFoundException.java
src-core/src/org/openbravo/uiTranslation/FieldGroupLabelsData.java
src-core/src/org/openbravo/uiTranslation/FieldLabelsData.java
src-core/src/org/openbravo/uiTranslation/FieldLabels_data.xsql
src-core/src/org/openbravo/uiTranslation/InterfaceInfo.java
src-core/src/org/openbravo/uiTranslation/InterfaceModuleInfoData.java
src-core/src/org/openbravo/uiTranslation/InterfaceModuleInfo_data.xsql
src-core/src/org/openbravo/uiTranslation/InterfaceTrlInfoData.java
src-core/src/org/openbravo/uiTranslation/ProcessLabelsData.java
src-core/src/org/openbravo/uiTranslation/TextInterfacesData.java
src-core/src/org/openbravo/uiTranslation/TranslationHandler.java
src-core/src/org/openbravo/uiTranslation/TranslationUtils.java
src-core/src/org/openbravo/uiTranslation/WindowLabel.java
src-core/src/org/openbravo/xmlEngine/DataValue.java
src-core/src/org/openbravo/xmlEngine/IDComponent.java
src-core/src/org/openbravo/xmlEngine/LabelTemplate.java
src-core/src/org/openbravo/xmlEngine/LabelValue.java
src-core/src/org/openbravo/xmlEngine/TemplateConfiguration.java
src-core/src/org/openbravo/xmlEngine/XmlDocument.java
src-core/src/org/openbravo/xmlEngine/XmlEngine.java
src-core/src/org/openbravo/xmlEngine/XmlTemplate.java
src-core/src/org/openbravo/xmlEngine/XmlVectorValue.java
src-db/build.xml
src-db/database/build-create.xml
src-db/database/build.xml
src-db/database/lib/dbsourcemanager.jar
src-db/database/lib/dbsourcemanagerlight.jar
src-db/database/model/functions/AD_LANGUAGE_CREATE.xml
src-db/database/model/functions/AD_MODULE_DEPENDENT.xml
src-db/database/model/functions/AD_ORGTYPE_ISTRANS_ALLOWED.xml
src-db/database/model/functions/AD_ORG_CHK_CALENDAR.xml
src-db/database/model/functions/AD_ORG_CHK_READY.xml
src-db/database/model/functions/AD_ORG_CHK_SCHEMAS.xml
src-db/database/model/functions/AD_ORG_GETCALENDAROWNER.xml
src-db/database/model/functions/AD_ORG_READY.xml
src-db/database/model/functions/AD_SYNCHRONIZE.xml
src-db/database/model/functions/AD_TABLE_IMPORT.xml
src-db/database/model/functions/AD_TAB_IMPORT.xml
src-db/database/model/functions/AD_UPDATE_ACCESS.xml
src-db/database/model/functions/A_AMORTIZATION_PROCESS.xml
src-db/database/model/functions/C_BANKSTATEMENT_POST.xml
src-db/database/model/functions/C_CASH_POST.xml
src-db/database/model/functions/C_DEBT_PAYMENT_CREATE.xml
src-db/database/model/functions/C_DP_MANAGEMENT_POST.xml
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/C_PERIOD_PROCESS.xml
src-db/database/model/functions/C_REMITTANCE_POST.xml
src-db/database/model/functions/C_SETTLEMENT_POST.xml
src-db/database/model/functions/FACT_ACCT_RESET.xml
src-db/database/model/functions/GL_JOURNAL_POST.xml
src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml
src-db/database/model/functions/M_INOUT_POST.xml
src-db/database/model/functions/M_INVENTORY_POST.xml
src-db/database/model/functions/M_MOVEMENT_POST.xml
src-db/database/model/functions/M_PRODUCTION_RUN.xml
src-db/database/model/postscript-Oracle.sql
src-db/database/model/postscript-PostgreSql.sql
src-db/database/model/tables/AD_CLIENTMODULE.xml
src-db/database/model/tables/AD_COLUMN.xml
src-db/database/model/tables/AD_DATASET.xml
src-db/database/model/tables/AD_DATASET_COLUMN.xml
src-db/database/model/tables/AD_DATASET_TABLE.xml
src-db/database/model/tables/AD_MODEL_OBJECT.xml
src-db/database/model/tables/AD_MODEL_OBJECT_PARA.xml
src-db/database/model/tables/AD_MODULE.xml
src-db/database/model/tables/AD_MODULE_DBPREFIX.xml
src-db/database/model/tables/AD_MODULE_DEPENDENCY.xml
src-db/database/model/tables/AD_MODULE_LOG.xml
src-db/database/model/tables/AD_MODULE_TRL.xml
src-db/database/model/tables/AD_ORG.xml
src-db/database/model/tables/AD_ORGMODULE.xml
src-db/database/model/tables/AD_ORGTYPE.xml
src-db/database/model/tables/AD_ORG_ACCTSCHEMA.xml
src-db/database/model/tables/AD_ORG_CLOSING.xml
src-db/database/model/tables/AD_PACKAGE.xml
src-db/database/model/tables/AD_REF_DATA_LOADED.xml
src-db/database/model/tables/AD_TABLE.xml
src-db/database/model/tables/C_ACCT_RPT.xml
src-db/database/model/tables/C_BANKSTATEMENTLINE.xml
src-db/database/model/tables/C_PERIOD.xml
src-db/database/model/tables/C_PERIODCONTROL_LOG.xml
src-db/database/model/tables/C_POC_EMAILDEFINITION.xml
src-db/database/model/triggers/AD_AUXILIARINPUT_MOD_TRG.xml
src-db/database/model/triggers/AD_CALLOUT_MOD_TRG.xml
src-db/database/model/triggers/AD_COLUMN_MOD_TRG.xml
src-db/database/model/triggers/AD_COLUMN_TRG2.xml
src-db/database/model/triggers/AD_DATASET_COLUMN_MOD_TRG.xml
src-db/database/model/triggers/AD_DATASET_MOD_TRG.xml
src-db/database/model/triggers/AD_DATASET_TABLE_MOD_TRG.xml
src-db/database/model/triggers/AD_ELEMENT_MOD_TRG.xml
src-db/database/model/triggers/AD_ELEMENT_TRG.xml
src-db/database/model/triggers/AD_ELEMENT_TRL_TRG.xml
src-db/database/model/triggers/AD_FIELDGROUP_MOD_TRG.xml
src-db/database/model/triggers/AD_FIELDGROUP_TRG.xml
src-db/database/model/triggers/AD_FIELD_MOD_TRG.xml
src-db/database/model/triggers/AD_FIELD_TRG.xml
src-db/database/model/triggers/AD_FORM_MOD_TRG.xml
src-db/database/model/triggers/AD_FORM_TRG.xml
src-db/database/model/triggers/AD_IMPFORMAT_MOD_TRG.xml
src-db/database/model/triggers/AD_IMPFORMAT_ROW_MOD_TRG.xml
src-db/database/model/triggers/AD_MENU_MOD_TRG.xml
src-db/database/model/triggers/AD_MENU_TRG.xml
src-db/database/model/triggers/AD_MESSAGE_MOD_TRG.xml
src-db/database/model/triggers/AD_MESSAGE_TRG.xml
src-db/database/model/triggers/AD_MODEL_OBJECT_MOD_TRG.xml
src-db/database/model/triggers/AD_MODOBJMAPPING_MOD_TRG.xml
src-db/database/model/triggers/AD_MODULE_DBPREFIX_MOD_TRG.xml
src-db/database/model/triggers/AD_MODULE_DBPREFIX_TRG.xml
src-db/database/model/triggers/AD_MODULE_DENPENDENCY_TRG.xml
src-db/database/model/triggers/AD_MODULE_DEPENDENCY_MOD_TRG.xml
src-db/database/model/triggers/AD_MODULE_TRG.xml
src-db/database/model/triggers/AD_ORGTYPE_TRG.xml
src-db/database/model/triggers/AD_ORG_STLE_TRG.xml
src-db/database/model/triggers/AD_ORG_TRG.xml
src-db/database/model/triggers/AD_PACKAGE_MOD_TRG.xml
src-db/database/model/triggers/AD_PROCESS_MOD_TRG.xml
src-db/database/model/triggers/AD_PROCESS_PARA_MOD_TRG.xml
src-db/database/model/triggers/AD_PROCESS_PARA_TRG.xml
src-db/database/model/triggers/AD_PROCESS_TRG.xml
src-db/database/model/triggers/AD_PROCESS_TRL_TRG.xml
src-db/database/model/triggers/AD_REFERENCE_MOD_TRG.xml
src-db/database/model/triggers/AD_REFERENCE_TRG.xml
src-db/database/model/triggers/AD_REFERENCE_TRG3.xml
src-db/database/model/triggers/AD_REF_LIST_MOD_TRG.xml
src-db/database/model/triggers/AD_REF_LIST_TRG.xml
src-db/database/model/triggers/AD_REF_SEARCH_COLUMN_MOD_TRG.xml
src-db/database/model/triggers/AD_REF_SEARCH_MOD_TRG.xml
src-db/database/model/triggers/AD_REF_TABLE_MOD_TRG.xml
src-db/database/model/triggers/AD_TABLE_MOD_TRG.xml
src-db/database/model/triggers/AD_TABLE_TRG.xml
src-db/database/model/triggers/AD_TAB_MOD_TRG.xml
src-db/database/model/triggers/AD_TAB_TRG.xml
src-db/database/model/triggers/AD_TAB_TRG2.xml
src-db/database/model/triggers/AD_TEXTINTERFACES_MOD_TRG.xml
src-db/database/model/triggers/AD_TEXTINTERFACES_TRG.xml
src-db/database/model/triggers/AD_TREENODE_MOD_TRG.xml
src-db/database/model/triggers/AD_TREENODE_TRG.xml
src-db/database/model/triggers/AD_VAL_RULE_MOD_TRG.xml
src-db/database/model/triggers/AD_WF_NODENEXT_MOD_TRG.xml
src-db/database/model/triggers/AD_WF_NODE_MOD_TRG.xml
src-db/database/model/triggers/AD_WF_NODE_TRG.xml
src-db/database/model/triggers/AD_WINDOW_MOD_TRG.xml
src-db/database/model/triggers/AD_WINDOW_TRG.xml
src-db/database/model/triggers/AD_WINDOW_TRG2.xml
src-db/database/model/triggers/AD_WINDOW_TRL_TRG.xml
src-db/database/model/triggers/AD_WORKFLOW_MOD_TRG.xml
src-db/database/model/triggers/AD_WORKFLOW_TRG.xml
src-db/database/model/triggers/A_ASSET_GROUP_TRG.xml
src-db/database/model/triggers/C_BANKACCOUNT_TRG.xml
src-db/database/model/triggers/C_BP_GROUP_TRG.xml
src-db/database/model/triggers/C_CASHBOOK_TRG.xml
src-db/database/model/triggers/C_CHARGE_TRG.xml
src-db/database/model/triggers/C_PERIOD_TRG.xml
src-db/database/model/triggers/C_PROJECT_TRG.xml
src-db/database/model/triggers/C_TAX_TRG.xml
src-db/database/model/triggers/C_WITHHOLDING_TRG.xml
src-db/database/model/triggers/M_PRODUCT_CATEGORY_TRG.xml
src-db/database/model/triggers/M_WAREHOUSE_TRG.xml
src-db/database/model/views/C_YEAR_V.xml
src-db/database/sampledata/AD_ORG.xml
src-db/database/sampledata/AD_ORG_ACCTSCHEMA.xml
src-db/database/sampledata/AD_WINDOW_ACCESS.xml
src-db/database/sampledata/C_ACCT_RPT.xml
src-db/database/sampledata/C_PERIODCONTROL.xml
src-db/database/sampledata/M_ATTRIBUTESET.xml
src-db/database/sampledata/M_ATTRIBUTESETINSTANCE.xml
src-db/database/sourcedata/AD_ALERTRULE_TRL.xml
src-db/database/sourcedata/AD_AUXILIARINPUT.xml
src-db/database/sourcedata/AD_CALLOUT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_DATASET.xml
src-db/database/sourcedata/AD_DATASET_COLUMN.xml
src-db/database/sourcedata/AD_DATASET_TABLE.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_ELEMENT_TRL.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_FIELDGROUP_TRL.xml
src-db/database/sourcedata/AD_FIELD_TRL.xml
src-db/database/sourcedata/AD_FORM.xml
src-db/database/sourcedata/AD_FORM_TRL.xml
src-db/database/sourcedata/AD_LANGUAGE.xml
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MENU_TRL.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MESSAGE_TRL.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
src-db/database/sourcedata/AD_MODEL_OBJECT_PARA.xml
src-db/database/sourcedata/AD_MODULE.xml
src-db/database/sourcedata/AD_MODULE_DBPREFIX.xml
src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml
src-db/database/sourcedata/AD_ORG.xml
src-db/database/sourcedata/AD_ORGTYPE.xml
src-db/database/sourcedata/AD_PACKAGE.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/AD_PROCESS_PARA.xml
src-db/database/sourcedata/AD_PROCESS_PARA_TRL.xml
src-db/database/sourcedata/AD_PROCESS_TRL.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REFERENCE_TRL.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_REF_LIST_TRL.xml
src-db/database/sourcedata/AD_REF_TABLE.xml
src-db/database/sourcedata/AD_ROLE_ORGACCESS.xml
src-db/database/sourcedata/AD_TAB.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/AD_TAB_TRL.xml
src-db/database/sourcedata/AD_TASK_TRL.xml
src-db/database/sourcedata/AD_TEXTINTERFACES.xml
src-db/database/sourcedata/AD_TEXTINTERFACES_TRL.xml
src-db/database/sourcedata/AD_TREENODE.xml
src-db/database/sourcedata/AD_USER_ROLES.xml
src-db/database/sourcedata/AD_VAL_RULE.xml
src-db/database/sourcedata/AD_WF_NODE_TRL.xml
src-db/database/sourcedata/AD_WINDOW.xml
src-db/database/sourcedata/AD_WINDOW_TRL.xml
src-db/database/sourcedata/AD_WORKFLOW_TRL.xml
src-db/src/com/openbravo/db/OpenbravoDataFilter.java
src-db/src/com/openbravo/db/OpenbravoExcludeFilter.java
src-db/src/com/openbravo/db/OpenbravoMetadataFilter.java
src-test/log4j.properties
src-test/org/openbravo/test/AllTests.java
src-test/org/openbravo/test/authorisations.txt
src-test/org/openbravo/test/base/BaseTest.java
src-test/org/openbravo/test/dal/AllTests.java
src-test/org/openbravo/test/dal/DalPerformanceInventoryLineTest.java
src-test/org/openbravo/test/dal/DalPerformanceProductTest.java
src-test/org/openbravo/test/dal/DalQueryTest.java
src-test/org/openbravo/test/dal/DalTest.java
src-test/org/openbravo/test/dal/DynamicEntityTest.java
src-test/org/openbravo/test/dal/HiddenUpdateTest.java
src-test/org/openbravo/test/dal/HqlTest.java
src-test/org/openbravo/test/dal/MappingGenerationTest.java
src-test/org/openbravo/test/dal/ValidationTest.java
src-test/org/openbravo/test/expression/EvaluationTest.java
src-test/org/openbravo/test/model/OneToManyTest.java
src-test/org/openbravo/test/model/RuntimeModelTest.java
src-test/org/openbravo/test/modularity/DatasetServiceTest.java
src-test/org/openbravo/test/security/AccessLevelTest.java
src-test/org/openbravo/test/security/AllowedOrganisationsTest.java
src-test/org/openbravo/test/security/EntityAccessTest.java
src-test/org/openbravo/test/security/WritableReadableOrganisationTest.java
src-test/org/openbravo/test/webservice/BaseWSTest.java
src-test/org/openbravo/test/webservice/WSReadTest.java
src-test/org/openbravo/test/webservice/WSUpdateTest.java
src-test/org/openbravo/test/xml/EntityXMLExportTest.java
src-test/org/openbravo/test/xml/EntityXMLImportTestBusinessObject.java
src-test/org/openbravo/test/xml/EntityXMLImportTestReference.java
src-test/org/openbravo/test/xml/EntityXMLImportTestSingle.java
src-test/org/openbravo/test/xml/EntityXMLImportTestWarning.java
src-test/org/openbravo/test/xml/XMLBaseTest.java
src-test/org/openbravo/test/xml/testdata/bp_import.xml
src-test/org/openbravo/test/xml/testdata/bp_list_1.xml
src-test/org/openbravo/test/xml/testdata/bp_list_2.xml
src-test/org/openbravo/test/xml/testdata/bp_list_3.xml
src-trl/.classpath
src-trl/build.xml
src-trl/src/org/openbravo/translate/Translate.java
src-trl/src/org/openbravo/translate/Translate_data.xsql
src-wad/.classpath
src-wad/build.xml
src-wad/src/org/openbravo/wad/ActionButton_Responser.javaxml
src-wad/src/org/openbravo/wad/Configuration_ActionButton.xml
src-wad/src/org/openbravo/wad/Configuration_ActionButton.xmlxml
src-wad/src/org/openbravo/wad/Configuration_Edition.xml
src-wad/src/org/openbravo/wad/Configuration_Edition.xmlxml
src-wad/src/org/openbravo/wad/Configuration_Relation.xmlxml
src-wad/src/org/openbravo/wad/EditionFields_data.xsql
src-wad/src/org/openbravo/wad/Fields_data.xsql
src-wad/src/org/openbravo/wad/Languages_data.xsql
src-wad/src/org/openbravo/wad/Tabs_data.xsql
src-wad/src/org/openbravo/wad/Template_ActionButton.html
src-wad/src/org/openbravo/wad/Template_ActionButton.xml
src-wad/src/org/openbravo/wad/Wad.java
src-wad/src/org/openbravo/wad/WadActionButton.java
src-wad/src/org/openbravo/wad/WadUtility.java
src-wad/src/org/openbravo/wad/Wad_data.xsql
src-wad/src/org/openbravo/wad/controls/WADButton.java
src-wad/src/org/openbravo/wad/controls/WADControl.java
src-wad/src/org/openbravo/wad/controls/WADLabelControl.java
src-wad/src/org/openbravo/wad/controls/WadControlLabelBuilder.java
src-wad/src/org/openbravo/wad/datasourceSortTab.xsqlxml
src-wad/src/org/openbravo/wad/javasource.javaxml
src-wad/src/org/openbravo/wad/javasource.xml
src-wad/src/org/openbravo/wad/javasourceSortTab.javaxml
src-wad/src/org/openbravo/wad/javasourceSortTab.xml
src-wad/src/org/openbravo/wad/web.xml
src-wad/src/org/openbravo/wad/webConf.xml
src-wad/src/org/openbravo/wad/webParams.xml
src-wad/src/org/openbravo/wad/webParamsxml.xml
src/build.xml
src/log4j.lcf
src/log4j.properties
src/org/openbravo/base/exception/OBException.java
src/org/openbravo/base/exception/OBSecurityException.java
src/org/openbravo/base/expression/Evaluator.java
src/org/openbravo/base/gen/GenerateEntitiesTask.java
src/org/openbravo/base/gen/ModelProviderComponent.java
src/org/openbravo/base/gen/base.xpt
src/org/openbravo/base/gen/entity.xpt
src/org/openbravo/base/gen/gen_entity.oaw
src/org/openbravo/base/gen/gen_util.ext
src/org/openbravo/base/gen/model.xpt
src/org/openbravo/base/model/AccessLevel.java
src/org/openbravo/base/model/BaseOBObjectDef.java
src/org/openbravo/base/model/Column.hbm.xml
src/org/openbravo/base/model/Column.java
src/org/openbravo/base/model/Entity.java
src/org/openbravo/base/model/ModelObject.java
src/org/openbravo/base/model/ModelProvider.java
src/org/openbravo/base/model/ModelSessionFactoryController.java
src/org/openbravo/base/model/Module.hbm.xml
src/org/openbravo/base/model/Module.java
src/org/openbravo/base/model/Package.hbm.xml
src/org/openbravo/base/model/Package.java
src/org/openbravo/base/model/Property.java
src/org/openbravo/base/model/RefList.java
src/org/openbravo/base/model/RefSearch.java
src/org/openbravo/base/model/RefTable.java
src/org/openbravo/base/model/Reference.java
src/org/openbravo/base/model/Table.hbm.xml
src/org/openbravo/base/model/Table.java
src/org/openbravo/base/provider/OBConfigFileProvider.java
src/org/openbravo/base/provider/OBModulePrefixRequired.java
src/org/openbravo/base/provider/OBNotSingleton.java
src/org/openbravo/base/provider/OBProvidable.java
src/org/openbravo/base/provider/OBProvider.java
src/org/openbravo/base/provider/OBProviderConfigReader.java
src/org/openbravo/base/provider/OBProviderException.java
src/org/openbravo/base/provider/OBSingleton.java
src/org/openbravo/base/secureApp/HtmlError.html
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
src/org/openbravo/base/secureApp/LoginUtils.java
src/org/openbravo/base/session/OBOracle10gDialect.java
src/org/openbravo/base/session/OBPropertiesProvider.java
src/org/openbravo/base/session/SessionFactoryController.java
src/org/openbravo/base/structure/ActiveEnabled.java
src/org/openbravo/base/structure/BaseOBObject.java
src/org/openbravo/base/structure/ClientEnabled.java
src/org/openbravo/base/structure/DynamicEnabled.java
src/org/openbravo/base/structure/DynamicOBObject.java
src/org/openbravo/base/structure/Identifiable.java
src/org/openbravo/base/structure/IdentifierProvider.java
src/org/openbravo/base/structure/OBDynamicPropertyHandler.java
src/org/openbravo/base/structure/OBFactory.java
src/org/openbravo/base/structure/OrganisationEnabled.java
src/org/openbravo/base/structure/OrganizationEnabled.java
src/org/openbravo/base/structure/Traceable.java
src/org/openbravo/base/util/ArgumentException.java
src/org/openbravo/base/util/Check.java
src/org/openbravo/base/util/CheckException.java
src/org/openbravo/base/util/ModelUtil.java
src/org/openbravo/base/util/NamingUtil.java
src/org/openbravo/base/util/OBClassLoader.java
src/org/openbravo/base/util/column_property_mapping.properties
src/org/openbravo/base/validation/AccessLevelChecker.java
src/org/openbravo/base/validation/BasePropertyValidator.java
src/org/openbravo/base/validation/EntityValidator.java
src/org/openbravo/base/validation/NumericPropertyValidator.java
src/org/openbravo/base/validation/PropertyValidator.java
src/org/openbravo/base/validation/StringPropertyValidator.java
src/org/openbravo/base/validation/ValidationException.java
src/org/openbravo/dal/core/DALUtil.java
src/org/openbravo/dal/core/DalContextListener.java
src/org/openbravo/dal/core/DalInitializingTask.java
src/org/openbravo/dal/core/DalLayerInitializer.java
src/org/openbravo/dal/core/DalMappingGenerator.java
src/org/openbravo/dal/core/DalRequestFilter.java
src/org/openbravo/dal/core/DalSessionFactoryController.java
src/org/openbravo/dal/core/DalThreadHandler.java
src/org/openbravo/dal/core/DalUtil.java
src/org/openbravo/dal/core/OBContext.java
src/org/openbravo/dal/core/OBDynamicPropertyHandler.java
src/org/openbravo/dal/core/OBInstantiator.java
src/org/openbravo/dal/core/OBInterceptor.java
src/org/openbravo/dal/core/OBTuplizer.java
src/org/openbravo/dal/core/OBYesNoType.java
src/org/openbravo/dal/core/SessionHandler.java
src/org/openbravo/dal/core/ThreadHandler.java
src/org/openbravo/dal/security/EntityAccessChecker.java
src/org/openbravo/dal/security/OrganisationStructureProvider.java
src/org/openbravo/dal/security/SecurityChecker.java
src/org/openbravo/dal/security/SecurityConstants.java
src/org/openbravo/dal/service/DalToXMLConverter.java
src/org/openbravo/dal/service/DalWebServiceServlet.java
src/org/openbravo/dal/service/DalWebServiceUtil.java
src/org/openbravo/dal/service/OBCriteria.java
src/org/openbravo/dal/service/OBDal.java
src/org/openbravo/dal/service/OBFilter.java
src/org/openbravo/dal/service/OBFilterQuery.java
src/org/openbravo/dal/service/OBQuery.java
src/org/openbravo/dal/service/OBWebServiceException.java
src/org/openbravo/dal/service/XMLImportMessage.java
src/org/openbravo/dal/service/XMLOptions.java
src/org/openbravo/dal/service/XMLToDalConverter.java
src/org/openbravo/dal/service/XMLTypeConverter.java
src/org/openbravo/dal/service/XMLUtil.java
src/org/openbravo/dal/service/bo.xslt
src/org/openbravo/dal/service/bolist.xslt
src/org/openbravo/dal/service/types.xslt
src/org/openbravo/dal/xml/EntityNotFoundException.java
src/org/openbravo/dal/xml/EntityResolver.java
src/org/openbravo/dal/xml/EntityXMLConverter.java
src/org/openbravo/dal/xml/EntityXMLException.java
src/org/openbravo/dal/xml/ModelXMLConverter.java
src/org/openbravo/dal/xml/XMLConstants.java
src/org/openbravo/dal/xml/XMLEntityConverter.java
src/org/openbravo/dal/xml/XMLTypeConverter.java
src/org/openbravo/dal/xml/XMLUtil.java
src/org/openbravo/erpCommon/ad_actionButton/CreateCloseFactAcct.html
src/org/openbravo/erpCommon/ad_actionButton/CreateCloseFactAcct.java
src/org/openbravo/erpCommon/ad_actionButton/CreateCloseFactAcct.xml
src/org/openbravo/erpCommon/ad_actionButton/CreateCloseFactAcct_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Bank.html
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Bank.xml
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Bank_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/CreateRegFactAcct.java
src/org/openbravo/erpCommon/ad_actionButton/CreateRegFactAcct_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/DropCloseFactAcct.html
src/org/openbravo/erpCommon/ad_actionButton/DropCloseFactAcct.java
src/org/openbravo/erpCommon/ad_actionButton/DropCloseFactAcct.xml
src/org/openbravo/erpCommon/ad_actionButton/DropCloseFactAcct_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/DropRegFactAcct.java
src/org/openbravo/erpCommon/ad_actionButton/DropRegFactAcct_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/ExportReferenceData.html
src/org/openbravo/erpCommon/ad_actionButton/ExportReferenceData.java
src/org/openbravo/erpCommon/ad_actionButton/ExportReferenceData.xml
src/org/openbravo/erpCommon/ad_actionButton/ExportReferenceData_data.xsql
src/org/openbravo/erpCommon/ad_actionButton/Posted.java
src/org/openbravo/erpCommon/ad_callouts/SE_PeriodNo.java
src/org/openbravo/erpCommon/ad_callouts/SE_PeriodNo_data.xsql
src/org/openbravo/erpCommon/ad_callouts/SL_IsDefault.java
src/org/openbravo/erpCommon/ad_combos/OrganizationCombo_data.xsql
src/org/openbravo/erpCommon/ad_forms/AccountingValueData.java
src/org/openbravo/erpCommon/ad_forms/AcctSchema.java
src/org/openbravo/erpCommon/ad_forms/AcctSchema_data.xsql
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
src/org/openbravo/erpCommon/ad_forms/AcctServer_data.xsql
src/org/openbravo/erpCommon/ad_forms/CallAcctServer.html
src/org/openbravo/erpCommon/ad_forms/CallAcctServer.java
src/org/openbravo/erpCommon/ad_forms/CallAcctServer.xml
src/org/openbravo/erpCommon/ad_forms/DocAmortization.java
src/org/openbravo/erpCommon/ad_forms/DocBank.java
src/org/openbravo/erpCommon/ad_forms/DocBank_data.xsql
src/org/openbravo/erpCommon/ad_forms/DocCash.java
src/org/openbravo/erpCommon/ad_forms/DocDPManagement.java
src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java
src/org/openbravo/erpCommon/ad_forms/DocInOut.java
src/org/openbravo/erpCommon/ad_forms/DocInventory.java
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
src/org/openbravo/erpCommon/ad_forms/DocLineBank_data.xsql
src/org/openbravo/erpCommon/ad_forms/DocLinePayment_data.xsql
src/org/openbravo/erpCommon/ad_forms/DocLine_Bank.java
src/org/openbravo/erpCommon/ad_forms/DocLine_Payment.java
src/org/openbravo/erpCommon/ad_forms/DocMovement.java
src/org/openbravo/erpCommon/ad_forms/DocOrder.java
src/org/openbravo/erpCommon/ad_forms/DocPayment.java
src/org/openbravo/erpCommon/ad_forms/DocPayment_data.xsql
src/org/openbravo/erpCommon/ad_forms/DocProduction.java
src/org/openbravo/erpCommon/ad_forms/FactLine.java
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.html
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.xml
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup_data.xsql
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.html
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.java
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup.xml
src/org/openbravo/erpCommon/ad_forms/InitialOrgSetup_data.xsql
src/org/openbravo/erpCommon/ad_forms/ModuleManagement.java
src/org/openbravo/erpCommon/ad_forms/ModuleManagementAdd.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagementAdd.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagementDetails.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagementDetails.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagementHistory.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagementHistory.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagementInstalled.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagementInstalled.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallLocal.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallLocal.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP1.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP1.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP2.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP2.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP4.html
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP4.xml
src/org/openbravo/erpCommon/ad_forms/ModuleManagement_data.xsql
src/org/openbravo/erpCommon/ad_forms/Role.java
src/org/openbravo/erpCommon/ad_forms/Translation.java
src/org/openbravo/erpCommon/ad_forms/TranslationHandler.java
src/org/openbravo/erpCommon/ad_forms/Translation_data.xsql
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.html
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.java
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData.xml
src/org/openbravo/erpCommon/ad_forms/UpdateReferenceData_data.xsql
src/org/openbravo/erpCommon/ad_process/AcctServerProcess.java
src/org/openbravo/erpCommon/ad_process/AcctServerProcess_data.xsql
src/org/openbravo/erpCommon/ad_process/ApplyModules.html
src/org/openbravo/erpCommon/ad_process/ApplyModules.java
src/org/openbravo/erpCommon/ad_process/ApplyModules.xml
src/org/openbravo/erpCommon/ad_process/ApplyModules_data.xsql
src/org/openbravo/erpCommon/ad_process/RegisterModule.html
src/org/openbravo/erpCommon/ad_process/RegisterModule.java
src/org/openbravo/erpCommon/ad_process/RegisterModule.xml
src/org/openbravo/erpCommon/ad_process/RegisterModule_data.xsql
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql
src/org/openbravo/erpCommon/ad_reports/ReportCashFlow.java
src/org/openbravo/erpCommon/ad_reports/ReportCashFlow_F1.html
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.xml
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal_data.xsql
src/org/openbravo/erpCommon/modules/ApplyModule.java
src/org/openbravo/erpCommon/modules/ApplyModuleTask.java
src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql
src/org/openbravo/erpCommon/modules/ExtractModule.java
src/org/openbravo/erpCommon/modules/ExtractModuleTask.java
src/org/openbravo/erpCommon/modules/ExtractModule_data.xsql
src/org/openbravo/erpCommon/modules/ImportModule.java
src/org/openbravo/erpCommon/modules/ImportModule_data.xsql
src/org/openbravo/erpCommon/modules/ModuleBox.srpt
src/org/openbravo/erpCommon/modules/ModuleBox.xml
src/org/openbravo/erpCommon/modules/ModuleReferenceDataClientTree.java
src/org/openbravo/erpCommon/modules/ModuleReferenceDataClientTree_data.xsql
src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree.java
src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree_data.xsql
src/org/openbravo/erpCommon/modules/ModuleTree.java
src/org/openbravo/erpCommon/modules/ModuleTreeDescription.srpt
src/org/openbravo/erpCommon/modules/ModuleTreeDescription.xml
src/org/openbravo/erpCommon/modules/ModuleTree_data.xsql
src/org/openbravo/erpCommon/modules/ModuleUtility_data.xsql
src/org/openbravo/erpCommon/modules/ModuleUtiltiy.java
src/org/openbravo/erpCommon/modules/UninstallModule.java
src/org/openbravo/erpCommon/modules/UninstallModule_data.xsql
src/org/openbravo/erpCommon/modules/VersionUtility.java
src/org/openbravo/erpCommon/modules/VersionUtility_data.xsql
src/org/openbravo/erpCommon/security/Organization_data.xsql
src/org/openbravo/erpCommon/utility/AntExecutor.java
src/org/openbravo/erpCommon/utility/FieldProviderFactory.java
src/org/openbravo/erpCommon/utility/GenericTree.java
src/org/openbravo/erpCommon/utility/GenericTree.srpt
src/org/openbravo/erpCommon/utility/GenericTree.xml
src/org/openbravo/erpCommon/utility/GenericTreeDescription.srpt
src/org/openbravo/erpCommon/utility/GenericTreeDescription.xml
src/org/openbravo/erpCommon/utility/GenericTreeHeader.srpt
src/org/openbravo/erpCommon/utility/GenericTreeHeader.xml
src/org/openbravo/erpCommon/utility/GenericTreeServlet.java
src/org/openbravo/erpCommon/utility/OBPrintStream.java
src/org/openbravo/erpCommon/utility/Utility.java
src/org/openbravo/erpCommon/utility/Utility_data.xsql
src/org/openbravo/erpCommon/utility/WindowTree.java
src/org/openbravo/erpCommon/utility/WindowTree_data.xsql
src/org/openbravo/erpCommon/utility/Zip.java
src/org/openbravo/service/OBServiceException.java
src/org/openbravo/service/db/DataExportService.java
src/org/openbravo/service/db/DataImportService.java
src/org/openbravo/service/db/DataSetService.java
src/org/openbravo/service/db/ImportResult.java
src/org/openbravo/service/rest/DalWebService.java
src/org/openbravo/service/rest/XMLImportMessage.java
src/org/openbravo/service/rest/bo.xslt
src/org/openbravo/service/rest/bolist.xslt
src/org/openbravo/service/rest/types.xslt
src/org/openbravo/service/web/BaseWebServiceServlet.java
src/org/openbravo/service/web/InvalidContentException.java
src/org/openbravo/service/web/InvalidRequestException.java
src/org/openbravo/service/web/ResourceNotFoundException.java
src/org/openbravo/service/web/UserContextCache.java
src/org/openbravo/service/web/WebService.java
src/org/openbravo/service/web/WebServiceServlet.java
src/org/openbravo/service/web/WebServiceUtil.java
src/org/openbravo/services/webservice/BusinessPartner.java
src/org/openbravo/services/webservice/Contact.java
src/org/openbravo/services/webservice/Customer.java
src/org/openbravo/services/webservice/Location.java
src/org/openbravo/services/webservice/Module.java
src/org/openbravo/services/webservice/ModuleDependency.java
src/org/openbravo/services/webservice/ModuleInstallDetail.java
src/org/openbravo/services/webservice/SimpleModule.java
src/org/openbravo/services/webservice/WebServiceImpl.java
src/org/openbravo/services/webservice/WebServiceImplService.java
src/org/openbravo/services/webservice/WebServiceImplServiceLocator.java
src/org/openbravo/services/webservice/WebServiceSoapBindingImpl.java
src/org/openbravo/services/webservice/WebServiceSoapBindingStub.java
src/org/openbravo/services/webservice/deploy.wsdd
src/org/openbravo/services/webservice/undeploy.wsdd
web/js/appStatus.js
web/js/genericTree.js
web/js/shortcuts.js
web/js/utils.js
web/js/windowKeyboard.js
web/skins/Default/Common/Button/iconScanUpdates.png
web/skins/Default/Popup/WindowLogo/iconModuleInstall.png
--- a/.classpath	Wed Nov 12 12:36:56 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
-	<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
-	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoTrl"/>
-	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoWAD"/>
-	<classpathentry including="**/*.ext|**/*.java|**/*.oaw|**/*.properties|**/*.xml|**/*.xpt|**/*.xslt" kind="src" path="src"/>
-	<classpathentry kind="src" path="src-gen"/>
-	<classpathentry including="**/*.java" kind="src" path="srcAD"/>
-	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/srcAD"/>
-	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="lib/build/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar"/>
-	<classpathentry kind="output" path="build/classes"/>
-</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath.template	Wed Nov 12 13:14:11 2008 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
+	<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoTrl"/>
+	<classpathentry combineaccessrules="false" exported="true" kind="src" path="/OpenbravoWAD"/>
+	<classpathentry including="**/*.ext|**/*.java|**/*.oaw|**/*.properties|**/*.xml|**/*.xpt|**/*.xslt" kind="src" path="src"/>
+	<classpathentry kind="src" path="src-test"/>
+	<classpathentry including="quartz.properties" kind="src" path="config"/>
+	<classpathentry kind="src" path="src-gen"/>
+	<classpathentry including="**/*.java" kind="src" path="srcAD"/>
+	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/srcAD"/>
+	<classpathentry including="**/*.java" kind="src" path="build/javasqlc/src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="lib/runtime/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar"/>
+	<classpathentry kind="lib" path="lib/build/junit.jar"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- a/.project	Wed Nov 12 12:36:56 2008 +0000
+++ b/.project	Wed Nov 12 13:14:11 2008 +0000
@@ -3,7 +3,6 @@
 	<name>openbravo</name>
 	<comment></comment>
 	<projects>
-		<project>OpenbravoCore</project>
 	</projects>
 	<buildSpec>
 		<buildCommand>
--- a/.settings/org.eclipse.wst.common.component	Wed Nov 12 12:36:56 2008 +0000
+++ b/.settings/org.eclipse.wst.common.component	Wed Nov 12 13:14:11 2008 +0000
@@ -6,6 +6,8 @@
 <wb-resource deploy-path="/WEB-INF/classes" source-path="/srcAD"/>
 <wb-resource deploy-path="/WEB-INF/classes" source-path="/build/javasqlc/srcAD"/>
 <wb-resource deploy-path="/WEB-INF/classes" source-path="/build/javasqlc/src"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src-gen"/>
+<wb-resource deploy-path="/WEB-INF/classes" source-path="/src-test"/>
 <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/OpenbravoCore/OpenbravoCore">
 <dependency-type>uses</dependency-type>
 </dependent-module>
--- a/build.xml	Wed Nov 12 12:36:56 2008 +0000
+++ b/build.xml	Wed Nov 12 13:14:11 2008 +0000
@@ -25,6 +25,8 @@
 compile: refer to compile target of src.
 compile.complete.development: refer to compile.complete.development target of src.
 compile.development: refer to compile.development target of src.
+compile.web: refer to compile.web: target of src.
+compile.web.development: refer to compile.web.development: target of src.
 eclipse.compile: refer to eclipse.compile target of src.
 eclipse.compile.complete: refer to eclipse.compile.complete target of src.
 compile.src: refer to compile.src target of src.
@@ -83,6 +85,7 @@
   <property name="base.context" location="WebContent"/>
   <property name="base.design" location="${base.context}/src-loc"/>
   <property name="base.lib" location="lib"/>
+  <property name="base.modules" location="modules"/>
   <property name="build" location="build/classes"/>
   <property name="build.AD" location="srcAD"/>
   <property name="build.sqlc" location="build/javasqlc"/>
@@ -91,6 +94,33 @@
   <property name="build.wad.lib" location="src-wad/lib"/>
   <property name="build.docs" location="docs/api"/>
   <property name="jakarta.home" location="${env.CATALINA_HOME}"/>
+  <property name="module" value="%"/>
+	<property name="apply.on.create" value="no"/>
+	<property name="obx.export.RD" value="false"/>
+	<property name="obx.export.DB" value="false"/>
+	<property name="obx.export.CS" value="false"/>
+	
+	<condition property="apply.modules.on.create">
+		<or>
+		  <equals arg1="yes" arg2="${apply.on.create}"/>
+			<equals arg1="true" arg2="${apply.on.create}"/>
+		</or>
+	</condition>
+	
+	<condition property="obx.exp.DB">
+		<or>
+	    <equals arg1="yes" arg2="${obx.export.DB}"/>
+			<equals arg1="true" arg2="${obx.export.DB}"/>
+		</or>
+	</condition>
+	
+	<condition property="obx.exp.CS">
+		<or>
+	    <equals arg1="yes" arg2="${obx.export.CS}"/>
+			<equals arg1="true" arg2="${obx.export.CS}"/>
+		</or>
+	</condition>
+	
   <condition property="jakarta.base" value="${env.CATALINA_BASE}" else="${jakarta.home}">
     <and>
       <isset property="env.CATALINA_BASE"/>
@@ -100,7 +130,6 @@
   <property name="lib" location="${jakarta.home}/common"/>
   <property name="jakarta.context" location="${jakarta.base}/webapps/${context.name}"/>
   <property name="build.maxmemory" value="512M"/>
-  <property name="debug.level" value="false"/>
 
   <condition property="no.java.home" value="true">
     <not>
@@ -126,7 +155,19 @@
     <fileset dir="${base.lib}">
       <include name="**/*.jar"/>
     </fileset>
+    <fileset dir="${base.db}/lib/">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${base.modules}">
+      <include name="*/lib/**"/>
+    </fileset>
   </path>
+	
+	<path id="tomcat.classpath">
+    <fileset file="${env.CATALINA_HOME}/server/lib/catalina-ant.jar"/>
+	</path>
+	
+	<taskdef resource="axis-tasks.properties" classpathref="project.class.path"/>
 
   <target name="init">
     <fail if="no.java.home" message="The environment variable JAVA_HOME is not set."/>
@@ -167,6 +208,14 @@
     <ant dir="${base.src}" target="compile.development" inheritAll="true" inheritRefs="true"/>
   </target>
 
+  <target name="compile.web" depends="init">
+    <ant dir="${base.src}" target="compile.web" inheritAll="true" inheritRefs="true"/>
+  </target>
+
+  <target name="compile.web.development" depends="init">
+    <ant dir="${base.src}" target="compile.web.development" inheritAll="true" inheritRefs="true"/>
+  </target>
+
   <target name="eclipse.compile" depends="init">
     <ant dir="${base.src.core}" target="build.jar" inheritAll="true" inheritRefs="true"/>
     <ant dir="${base.src.trl}" target="build.jar" inheritAll="true" inheritRefs="true"/>
@@ -271,7 +320,7 @@
 
   <target name="install.source" depends="init,code.rev">
     <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="create.database" inheritAll="true" inheritRefs="true"/>
+    <ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true"/>
     <antcall target="core.lib"/>
     <antcall target="wad.lib"/>
     <antcall target="trl.lib"/>
@@ -290,17 +339,20 @@
 
   <target name="create.database" depends="init,code.rev">
     <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="create.database" inheritAll="true" inheritRefs="true"/>
-  </target>
-
-  <target name="create.original.database" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="create.original.database" inheritAll="true" inheritRefs="true"/>
+    <ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true"/>
+  	<antcall target="db.apply.modules"/>
   </target>
 
   <target name="update.database" depends="init,code.rev">
     <antcall target="database.lib"/>
     <ant dir="${base.db}" target="update.database" inheritAll="true" inheritRefs="true"/>
+  	<antcall target="db.apply.modules"/>
+  </target>
+
+  <target name="update.database.mod" depends="init,code.rev">
+    <antcall target="database.lib"/>
+    <ant dir="${base.db}" target="update.database.mod" inheritAll="true" inheritRefs="true"/>
+  	<antcall target="db.apply.modules"/>
   </target>
 
   <target name="update.customized.database" depends="init,code.rev">
@@ -334,6 +386,10 @@
     <ant dir="${base.db}" target="export.database.structure" inheritAll="true" inheritRefs="true"/>
   </target>
 
+  <target name="export.config.script" depends="init,code.rev">
+    <ant dir="${base.db}" target="export.config.script" inheritAll="true" inheritRefs="true"/>
+  </target>
+
   <target name="export.database.data" depends="init,code.rev">
     <ant dir="${base.db}" target="export.database.data" inheritAll="true" inheritRefs="true"/>
   </target>
@@ -357,16 +413,90 @@
   <target name="import.database.masterdata" depends="init,code.rev">
     <ant dir="${base.db}" target="import.database.masterdata" inheritAll="true" inheritRefs="true"/>
   </target>
+	
+	<target name="db.apply.modules" if="apply.modules.on.create">
+    <taskdef name="applyModule"
+             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+      <classpath refid="project.class.path"/>
+    </taskdef>
+    <applyModule/>
+	</target>
+	
+	<target name="apply.modules">
+	  <echo>Applying ${module} modules...</echo>
+    <taskdef name="applyModule"
+             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+      <classpath refid="project.class.path"/>
+    </taskdef>
+    <antcall target="update.database.mod"/>
+    <antcall target="generate.entities"/>
+    <applyModule/>
+		<antcall target="compile"/>
+		<antcall target="war"/>
+		<!--antcall target="deploy.context"/-->
+	</target>
+  <target name="apply.modules.development">
+    <echo>Applying ${module} modules...</echo>
+    <taskdef name="applyModule"
+             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+      <classpath refid="project.class.path"/>
+    </taskdef>
+    <antcall target="update.database.mod"/>
+    <applyModule/>
+    <antcall target="compile.development"/>
+  </target>
+	<target name="tomcat.list">
+		<taskdef name="list"  classname="org.apache.catalina.ant.ListTask">
+		  <classpath refid="tomcat.classpath"/>
+		</taskdef>
+		<list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/>
+	</target>
+	
+	<target name="deploy.context">
+		<taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask">
+		  <classpath refid="tomcat.classpath"/>
+	  </taskdef>
+		<taskdef name="deploy.tomcat" classname="org.apache.catalina.ant.DeployTask">
+		  <classpath refid="tomcat.classpath"/>
+		</taskdef>
+		<taskdef name="start"    classname="org.apache.catalina.ant.StartTask">
+		  <classpath refid="tomcat.classpath"/>
+		</taskdef>
+		
+		<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
+      path="/${context.name}" failonerror="false"/>
+    <deploy.tomcat url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
+                path="/${context.name}" war="file:${base.lib}/${context.name}.war"/>
+		<start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
+		          path="/${context.name}"/>
+	</target>
+	
+	
+  <target name="generate-wsdd">
+            <ant dir="${base.src}" target="generate-wsdd" inheritAll="true" inheritRefs="true"/>
+    </target>
+	
+	<target name="obx.export.database" if="obx.exp.DB">
+	  <antcall target="export.database"/>
+	</target>
+	  
+  <target name="obx.export.config.script" if="obx.exp.CS">
+    <antcall target="export.config.script"/>
+  </target>
+	
+	<target name="extract.module">
+  	<taskdef name="extractModule"
+  	           classname="org.openbravo.erpCommon.modules.ExtractModuleTask">
+  	    <classpath refid="project.class.path"/>
+	  </taskdef>
+		
+    <antcall target="obx.export.database"/>
+    <antcall target="obx.export.config.script"/>
 
-  <target name="save.database.model" depends="init">
-    <ant dir="${base.db}" target="save.database.model" inheritAll="true" inheritRefs="true"/>
-  </target>
+		<extractModule moduleName="${module}"
+			  userId="0"
+			  propertiesFile="${base.config}/Openbravo.properties"
+			  exportRD="${obx.export.RD}"/>
+	</target>
 
-  <target name="compare.database.structure" depends="init">
-    <ant dir="${base.db}" target="compare.database.structure" inheritAll="true" inheritRefs="true"/>
-  </target>
-
-  <target name="compare.database.data" depends="init">
-    <ant dir="${base.db}" target="compare.database.data" inheritAll="true" inheritRefs="true"/>
-  </target>
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/provider-config.xml	Wed Nov 12 13:14:11 2008 +0000
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License 
+ * Version 1.1 (the "License"), being the Mozilla Public License 
+ * version 1.1  with a permitted attribution clause ; you may not use 
+ * this file except in compliance with the License. 
+ * You may obtain a copy of the License at  
+ * http://www.openbravo.com/legal/license.txt 
+ * Software distributed under the License is distributed on an 
+ * "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or 
+ * implied. See the License for the specific language governing rights 
+ * and  limitations under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2005-2008 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s): Openbravo S.L.
+ ************************************************************************
+-->
+
+<!-- 
+     This file configures the OBProvider ServiceLocator/Factory to 
+     use specific classes at runtime to implement certain functionality.
+     
+     Each runtime class is configured using a bean tag. The bean tag
+     contains the name of the bean, the runtime class which should be
+     used and if the bean is a singleton or not. 
+     The bean name is often equal to the name of the standard OpenBravo
+     class which is replaced by the bean configured here.
+-->
+
+<provider>
+
+	<bean>
+		<name>dal</name>
+		<class>org.openbravo.service.rest.DalWebService</class>
+		<singleton>true</singleton>
+	</bean>
+
+</provider>
Binary file lib/build/hybridlabs-beautifier-1.1.9.jar has changed
Binary file lib/build/jalopy-1.5-rc3p1.jar has changed
Binary file lib/build/org.eclipse.emf.common_2.4.0.v200806091234.jar has changed
Binary file lib/build/org.eclipse.emf.ecore.xmi_2.4.0.v200806091234.jar has changed
Binary file lib/build/org.eclipse.emf.ecore_2.4.0.v200806091234.jar has changed
Binary file lib/build/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar has changed
Binary file lib/build/org.eclipse.text_3.4.0.v20080605-1800.jar has changed
Binary file lib/build/org.openarchitectureware.core.emftools_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/build/org.openarchitectureware.core.expressions_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/build/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/build/org.openarchitectureware.core.xpand2_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/runtime/ant-1.6.5.jar has changed
Binary file lib/runtime/ant-launcher.jar has changed
Binary file lib/runtime/ant-nodeps.jar has changed
Binary file lib/runtime/commons-digester-1.7.jar has changed
Binary file lib/runtime/hybridlabs-beautifier-1.1.9.jar has changed
Binary file lib/runtime/jalopy-1.5-rc3p1.jar has changed
Binary file lib/runtime/jasperreports-1.3.3.jar has changed
Binary file lib/runtime/jcommon-1.0.0.jar has changed
Binary file lib/runtime/jdbc3-postgresql.jar has changed
Binary file lib/runtime/jfreechart-1.0.1.jar has changed
Binary file lib/runtime/js.jar has changed
Binary file lib/runtime/org.eclipse.emf.common_2.4.0.v200806091234.jar has changed
Binary file lib/runtime/org.eclipse.emf.ecore.xmi_2.4.0.v200806091234.jar has changed
Binary file lib/runtime/org.eclipse.emf.ecore_2.4.0.v200806091234.jar has changed
Binary file lib/runtime/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar has changed
Binary file lib/runtime/org.eclipse.text_3.4.0.v20080605-1800.jar has changed
Binary file lib/runtime/org.openarchitectureware.core.emftools_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/runtime/org.openarchitectureware.core.expressions_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/runtime/org.openarchitectureware.core.workflow_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/runtime/org.openarchitectureware.core.xpand2_4.3.1.20080910-1400PRD.jar has changed
Binary file lib/runtime/postgresql-jdbc3-8.2.jar has changed
Binary file lib/runtime/xmlrpc-client-3.0.jar has changed
Binary file lib/runtime/xmlrpc-common-3.0.jar has changed
--- a/src-core/build.xml	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/build.xml	Wed Nov 12 13:14:11 2008 +0000
@@ -44,7 +44,7 @@
   </target>
 
   <target name="compile" depends="clean, init">
-    <javac srcdir="${build.core.src}" destdir="${build.core}" deprecation="on" encoding="UTF-8" debug="${debug.level}">
+    <javac srcdir="${build.core.src}" destdir="${build.core}" deprecation="on" encoding="UTF-8" debug="true" debuglevel="lines,vars,source">
       <classpath refid="core.class.path"/>  
     </javac>
   </target>
--- a/src-core/src/org/openbravo/base/ConnectionProviderContextListener.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/base/ConnectionProviderContextListener.java	Wed Nov 12 13:14:11 2008 +0000
@@ -8,89 +8,127 @@
  * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
  * specific language governing permissions and limitations under the License.
  ************************************************************************************
-*/
+ */
 
 package org.openbravo.base;
 
-import org.openbravo.database.ConnectionProvider;
-import org.openbravo.database.ConnectionProviderImpl;
-import org.openbravo.exception.PoolNotFoundException;
-import org.apache.log4j.Logger;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
+import org.apache.log4j.Logger;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.database.ConnectionProviderImpl;
+import org.openbravo.database.JNDIConnectionProvider;
+import org.openbravo.exception.PoolNotFoundException;
+
 /**
  * Manage the creation and destruction of the db connection pool..
- *
+ * 
  * @author Ben Sommerville
  */
-public class ConnectionProviderContextListener implements ServletContextListener {
+public class ConnectionProviderContextListener implements
+	ServletContextListener {
     public static final String POOL_ATTRIBUTE = "openbravoPool";
-    private static Logger log4j = Logger.getLogger(ConnectionProviderContextListener.class);
-
-
+    private static Logger log4j = Logger
+	    .getLogger(ConnectionProviderContextListener.class);
 
     public void contextInitialized(ServletContextEvent event) {
-        ServletContext context = event.getServletContext();
-        ConfigParameters configParameters = ConfigParameters.retrieveFrom(context);
+	ServletContext context = event.getServletContext();
+	ConfigParameters configParameters = ConfigParameters
+		.retrieveFrom(context);
 
-        try {
-            ConnectionProvider pool = createPool(configParameters);
-            context.setAttribute(POOL_ATTRIBUTE, pool);
-        } catch (PoolNotFoundException e) {
-            log4j.error("Unable to create a connection pool", e);
-        }
+	try {
+	    ConnectionProvider pool = createPool(configParameters);
+	    context.setAttribute(POOL_ATTRIBUTE, pool);
+	} catch (PoolNotFoundException e) {
+	    log4j.error("Unable to create a connection pool", e);
+	}
 
     }
 
-
     public void contextDestroyed(ServletContextEvent event) {
-        ServletContext context = event.getServletContext();
-        destroyPool(getPool(context));
-        context.removeAttribute(POOL_ATTRIBUTE);
+	ServletContext context = event.getServletContext();
+	destroyPool(getPool(context));
+	context.removeAttribute(POOL_ATTRIBUTE);
     }
 
-
     public static ConnectionProvider getPool(ServletContext context) {
-         return (ConnectionProvider) context.getAttribute(POOL_ATTRIBUTE);
+	return (ConnectionProvider) context.getAttribute(POOL_ATTRIBUTE);
     }
 
     public static void reloadPool(ServletContext context) throws Exception {
-        ConnectionProvider pool = getPool(context);
-        if( pool instanceof ConnectionProviderImpl ) {
-            ConfigParameters configParameters = ConfigParameters.retrieveFrom(context);
-            String strPoolFile = configParameters.getPoolFilePath();
-            boolean isRelative = !strPoolFile.startsWith("/") && !strPoolFile.substring(1, 1).equals(":");
-            ((ConnectionProviderImpl)pool).reload(strPoolFile, isRelative, configParameters.strContext);;
-        }
+	ConnectionProvider pool = getPool(context);
+	if (pool instanceof ConnectionProviderImpl) {
+	    ConfigParameters configParameters = ConfigParameters
+		    .retrieveFrom(context);
+	    String strPoolFile = configParameters.getPoolFilePath();
+	    boolean isRelative = !strPoolFile.startsWith("/")
+		    && !strPoolFile.substring(1, 1).equals(":");
+	    ((ConnectionProviderImpl) pool).reload(strPoolFile, isRelative,
+		    configParameters.strContext);
+	    ;
+	}
     }
 
-    private ConnectionProvider createPool( ConfigParameters configParameters) throws PoolNotFoundException {
-        return createXmlPool(configParameters);
+    private ConnectionProvider createPool(ConfigParameters configParameters)
+	    throws PoolNotFoundException {
+	return createXmlPool(configParameters);
     }
 
+    private static ConnectionProvider createXmlPool(
+	    ConfigParameters configParameters) throws PoolNotFoundException {
+	try {
+	    String strPoolFile = configParameters.getPoolFilePath();
+	    boolean isRelative = !strPoolFile.startsWith("/")
+		    && !strPoolFile.substring(1, 1).equals(":");
+	    if (isJndiModeOn(strPoolFile)) {
+		return new JNDIConnectionProvider(strPoolFile, isRelative);
+	    } else {
+		return new ConnectionProviderImpl(strPoolFile, isRelative,
+			configParameters.strContext);
+	    }
 
-    private static ConnectionProvider createXmlPool(ConfigParameters configParameters) throws PoolNotFoundException {
-        try {
-            String strPoolFile = configParameters.getPoolFilePath();
-            boolean isRelative = !strPoolFile.startsWith("/") && !strPoolFile.substring(1, 1).equals(":");
-            return new ConnectionProviderImpl(strPoolFile, isRelative, configParameters.strContext);
-        } catch (Exception ex) {
-            throw new PoolNotFoundException(ex.getMessage());
-        }
+	} catch (Exception ex) {
+	    throw new PoolNotFoundException(ex.getMessage() );
+	}
     }
 
+    private static boolean isJndiModeOn(String strPoolFile) {
+	Properties properties = new Properties();
+	String jndiUsage = null;
+	try {
+	    properties.load(new FileInputStream(strPoolFile));
+	    jndiUsage = properties.getProperty("JNDI.usage");
+	} catch (FileNotFoundException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	} catch (IOException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
+	return ("yes".equals(jndiUsage) ? true : false);
+    }
 
     private static void destroyPool(ConnectionProvider pool) {
-        if( pool != null && pool instanceof ConnectionProviderImpl) {
-            try {
-                ((ConnectionProviderImpl)pool).destroy();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
+	if (pool != null && pool instanceof JNDIConnectionProvider) {
+	    try {
+		((JNDIConnectionProvider) pool).destroy();
+	    } catch (Exception e) {
+		e.printStackTrace();
+	    }
+	} else if (pool != null && pool instanceof ConnectionProvider) {
+	    try {
+		(pool).destroy();
+	    } catch (Exception e) {
+		e.printStackTrace();
+	    }
+	}
     }
 
 }
--- a/src-core/src/org/openbravo/base/HttpBaseServlet.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/base/HttpBaseServlet.java	Wed Nov 12 13:14:11 2008 +0000
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2006 Openbravo S.L.
+ * Copyright (C) 2001-2008 Openbravo S.L.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -11,22 +11,45 @@
 */
 package org.openbravo.base;
 
-import org.openbravo.xmlEngine.XmlEngine;
-import org.openbravo.data.FieldProvider;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.StringReader;
+import java.rmi.Naming;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
 
-import java.sql.*;
-import java.io.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import org.xml.sax.*;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
 import org.apache.fop.apps.Driver;
 import org.apache.log4j.Logger;
-import java.rmi.*;
-import rmi.*;
+import org.apache.log4j.PropertyConfigurator;
+import org.openbravo.data.FieldProvider;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.database.ConnectionProviderImpl;
+import org.openbravo.database.JNDIConnectionProvider;
+import org.openbravo.exception.NoConnectionAvailableException;
+import org.openbravo.exception.PoolNotFoundException;
 import org.openbravo.utils.FormatUtilities;
-import org.openbravo.database.*;
-import org.openbravo.exception.*;
-import javax.net.ssl.*;
+import org.openbravo.xmlEngine.XmlEngine;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+import rmi.RenderFoI;
 
 /**
  * This class is intended to be extended by the HttpSecureAppServlet
@@ -42,7 +65,12 @@
   public String strReplaceWith;
   public String strReplaceWithFull;
   protected String strDefaultServlet;
-  public XmlEngine xmlEngine=null;
+  public XmlEngine xmlEngine = null;
+  public String strBaseConfigPath;
+  protected static String strContext = null;
+  protected static String prefix = null;
+  protected static String stcFileProperties = null;
+  protected boolean isJNDIModeOn;
   public Logger log4j = Logger.getLogger(this.getClass());
   protected String PoolFileName;
 
@@ -57,6 +85,60 @@
   public void init (ServletConfig config) {
     try {
       super.init(config);
+      strBaseConfigPath = config.getServletContext().getInitParameter("BaseConfigPath");
+      if (prefix == null) {
+        prefix = config.getServletContext().getRealPath("/");
+        if (prefix == null || prefix.equals("")) {
+          // deployment in weblogic through ear file does not deploy phisically
+          // the files,
+          // so we need to obtain the path through getClass method
+          java.net.URL url = this.getClass().getResource("/");
+          String mSchemaPath = url.getFile();
+          if (mSchemaPath != null || !mSchemaPath.equals("")) {
+            String separator = "/";
+            int lastSlash = mSchemaPath.lastIndexOf(separator);
+            if (lastSlash == -1) {
+              separator = "\\";
+              lastSlash = mSchemaPath.lastIndexOf(separator);
+            }
+            prefix = mSchemaPath.substring(0, lastSlash);
+            prefix = prefix.substring(0, prefix.lastIndexOf(separator));
+            prefix = prefix.substring(0, prefix.lastIndexOf(separator) + 1);
+            // lastSlash = mSchemaPath.lastIndexOf(separator);
+            // mSchemaPath = mSchemaPath.substring(0, lastSlash);
+            // lastSlash = mSchemaPath.lastIndexOf(separator);
+            // prefix = mSchemaPath.substring(0, lastSlash+1);
+          }
+        }
+        if (log4j.isDebugEnabled())
+          log4j.debug("************************prefix: " + prefix);
+        if (strContext == null || strContext.equals("")) {
+          String path = "/";
+          int secondPath = -1;
+          int firstPath = prefix.lastIndexOf(path);
+          if (firstPath == -1) {
+            path = "\\";
+            firstPath = prefix.lastIndexOf(path);
+          }
+          if (firstPath != -1) {
+            secondPath = prefix.lastIndexOf(path, firstPath - 1);
+            strContext = prefix.substring(secondPath + 1, firstPath);
+          }
+        }
+        if (log4j.isDebugEnabled())
+          log4j.debug("context: " + strContext);
+        String file = config.getServletContext().getInitParameter("log4j-init-file");
+        if (log4j.isDebugEnabled())
+          log4j.debug("Log file: " + file);
+        // if the log4j-init-file is not set, then no point in trying
+        if (file != null) {
+          // PropertyConfigurator.configure(prefix+file);
+          PropertyConfigurator.configure(prefix + "/" + strBaseConfigPath + "/" + file);
+        }
+      }
+      stcFileProperties = prefix + "/" + strBaseConfigPath + "/" + "Openbravo.properties";
+//      OBProperties.getInstance(stcFileProperties);
+      
       globalParameters = ConfigParameters.retrieveFrom(config.getServletContext());
       strDefaultServlet = globalParameters.strDefaultServlet;
       xmlEngine = new XmlEngine();
@@ -69,8 +151,20 @@
       xmlEngine.initialize();
 
       log4j.debug("Text of divided by zero: " + XmlEngine.strTextDividedByZero);
+     
 
-      myPool = ConnectionProviderContextListener.getPool(config.getServletContext());
+      
+      if (myPool == null) {
+        try {
+          PoolFileName = config.getServletContext().getInitParameter("PoolFile");
+          String strPoolFile = prefix + "/" + strBaseConfigPath + "/" + PoolFileName;
+          isJNDIModeOn=isJndiModeOn(strPoolFile);
+          makeConnection();
+        } catch (Exception ex) {
+          ex.printStackTrace();
+        }
+      }
+     
     } catch (ServletException e) {
       e.printStackTrace();
     }
@@ -156,9 +250,9 @@
     log4j.info("*********************Base path: " + globalParameters.strBaseDesignPath);
     String strNewAddBase = globalParameters.strDefaultDesignPath;
     String strFinal = globalParameters.strBaseDesignPath;
-    if (!language.equals("") && !language.equals("en_US")) {
-      strNewAddBase = language;
-    }
+    //if (!language.equals("") && !language.equals("en_US")) {
+      //strNewAddBase = language;
+    //}
     if (!strFinal.endsWith("/" + strNewAddBase)) {
       strFinal += "/" + strNewAddBase;
     }
@@ -612,7 +706,55 @@
     return strArray;
   }
 
+  
+  public void makeConnection() throws PoolNotFoundException {
+    if (myPool != null) {
+      try {
+        myPool.destroy();
+      } catch (Exception ignored) {
+      }
+      myPool = null;
+    }
+    try {
+      String strPoolFile = prefix + "/" + strBaseConfigPath + "/" + PoolFileName;
+      // myPool = new ConnectionProviderImpl(strPoolFile,
+      // (!strPoolFile.startsWith("/") &&
+      // !strPoolFile.substring(1,1).equals(":")), strContext);
+      // Now pool take datasources from a JNDI resource file
+      if (isJNDIModeOn) {
+        myPool = new JNDIConnectionProvider(strPoolFile, (!strPoolFile.startsWith("/") && !strPoolFile.substring(1, 1).equals(":")));
+      } else {
+        myPool = new ConnectionProviderImpl(strPoolFile,(!strPoolFile.startsWith("/") && !strPoolFile.substring(1,1).equals(":")), strContext);
+      }
+    } catch (Exception e) {
+       e.printStackTrace();	
+      throw new PoolNotFoundException(e.getMessage());
+    }
+  }
+  
+  private static boolean isJndiModeOn(String strPoolFile) {
+    Properties properties = new Properties();
+    String jndiUsage = null;
+    try {
+      properties.load(new FileInputStream(strPoolFile));
+      jndiUsage = properties.getProperty("JNDI.usage");
+    } catch (FileNotFoundException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    } catch (IOException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    return ("yes".equals(jndiUsage)? true : false);
+  }
+  
+  public String getStatus() {
+    return myPool.getStatus();
+  }
+  
   public String getServletInfo() {
     return "This servlet adds some functions (connection to the database, xmlEngine, logging) over HttpServlet";
   }
+  
+  
 }
--- a/src-core/src/org/openbravo/base/MultipartRequest.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/base/MultipartRequest.java	Wed Nov 12 13:14:11 2008 +0000
@@ -34,6 +34,11 @@
     readSubmittedFile();
   }
 
+  public MultipartRequest(VariablesBase vars, InputStream in, boolean firstLineHeads, String format, FieldProvider[] data) throws IOException {
+    init(vars, "", firstLineHeads, format, data);
+    readSubmittedFile(in);
+  }
+  
   public String getField(String index) {
     int i = Integer.valueOf(index).intValue();
     if (i>=vector.size()) return null;
@@ -66,7 +71,7 @@
 
   public void init(VariablesBase vars, String filename, boolean firstLineHeads, String format, FieldProvider[] data) throws IOException {
     if (vars==null) throw new IllegalArgumentException("VariablesBase cannot be null");
-    if (filename==null || filename.equals("")) throw new IllegalArgumentException("filename cannot be null");
+    //if (filename==null || filename.equals("")) throw new IllegalArgumentException("filename cannot be null");
     this.vars = vars;
     this.filename = filename;
     this.firstRowHeads = firstLineHeads;
@@ -107,12 +112,8 @@
     return data;
   }
 
-
-  protected void readSubmittedFile() throws IOException {
-    FileItem fi = vars.getMultiFile(filename);
-    if (fi==null) throw new IOException("Invalid filename: " + filename);
-    InputStream in = fi.getInputStream();
-    if (in==null) throw new IOException("Corrupted filename: " + filename);
+  protected void readSubmittedFile(InputStream in) throws IOException{
+    
 
     Vector<FieldProvider> vector = new Vector<FieldProvider>();
     int result = 0;
@@ -154,4 +155,13 @@
     objectFieldProvider = new FieldProvider[vector.size()];
     vector.copyInto(objectFieldProvider);
   }
+
+  protected void readSubmittedFile() throws IOException {
+    FileItem fi = vars.getMultiFile(filename);
+    if (fi==null) throw new IOException("Invalid filename: " + filename);
+    InputStream in = fi.getInputStream();
+    if (in==null) throw new IOException("Corrupted filename: " + filename);
+    readSubmittedFile(in);
+  }
+    
 }
--- a/src-core/src/org/openbravo/data/Sqlc.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/data/Sqlc.java	Wed Nov 12 13:14:11 2008 +0000
@@ -8,1299 +8,1636 @@
  * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
  * specific language governing permissions and limitations under the License.
  ************************************************************************************
-*/
+ */
 package org.openbravo.data;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Stack;
 import java.util.StringTokenizer;
 import java.util.Vector;
-import java.util.Enumeration;
-import java.util.Stack;
-import java.util.Properties;
-import java.sql.*;
-
-import java.io.PrintWriter;
-import java.io.IOException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.OutputStreamWriter;
-import java.io.FileOutputStream;
-
-import org.openbravo.utils.DirFilter;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.SAXException;
-import org.apache.xerces.parsers.*;
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
-
+import org.apache.xerces.parsers.SAXParser;
+import org.openbravo.utils.DirFilter;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * Create a java file with functions based on sql sentences
- *
+ * 
  **/
 public class Sqlc extends DefaultHandler {
-  public static final String VERSION = "V1.O00-1";
-  String sqlcName;
-  String sqlcPackage = null;
-  Stack<String> stcElement;   // Stack of Elements
-  String strElement;
-  String strDriver;
-  String strURL;
-  String strDBUser;
-  String strDBPassword;
-  String javaDateFormat;
-  static String javaFileName;
-  Connection connection;
-  Sql sql;
-  String strComments;
-  PreparedStatement preparedStatement;
-  ResultSet result;
-  ResultSetMetaData rsmd;
-  int numCols;
-  boolean first = true;
-  OutputStreamWriter out;
-  StringBuffer out1; //to be fixed: out1 and out2 are two auxiliar buffers...
-  StringBuffer out2;
-  PrintWriter printWriterTxt;
-  Parameter parameterSql;
-  boolean error;
-  boolean importRDBMSIndependent = false;
-  boolean importJavaUtil = false;
-  boolean writeTxtFiles = false;
-  StringBuffer buffer;
+	public static final String VERSION = "V1.O00-1";
+	String sqlcName;
+	String sqlcPackage = null;
+	Stack<String> stcElement; // Stack of Elements
+	String strElement;
+	String strDriver;
+	String strURL;
+	String strDBUser;
+	String strDBPassword;
+	String javaDateFormat;
+	static String javaFileName;
+	Connection connection;
+	Sql sql;
+	String strComments;
+	PreparedStatement preparedStatement;
+	ResultSet result;
+	ResultSetMetaData rsmd;
+	int numCols;
+	boolean first = true;
+	OutputStreamWriter out;
+	StringBuffer out1; // to be fixed: out1 and out2 are two auxiliar buffers...
+	StringBuffer out2;
+	PrintWriter printWriterTxt;
+	Parameter parameterSql;
+	boolean error;
+	boolean importRDBMSIndependent = false;
+	boolean importJavaUtil = false;
+	boolean writeTxtFiles = false;
+	StringBuffer buffer;
+	static ArrayList<String> includeDirectories;
 
-  static Logger log4j = Logger.getLogger(Sqlc.class);  //log4j
+	static Logger log4j = Logger.getLogger(Sqlc.class); // log4j
 
-  public Sqlc () {
-    init();
-  }
+	public Sqlc() {
+		init();
+	}
 
-  public void init() {
-    sql = new Sql();
-    stcElement = new Stack<String>();
-    first = true;
-    sqlcPackage = null;
-  }
+	public void init() {
+		sql = new Sql();
+		stcElement = new Stack<String>();
+		first = true;
+		sqlcPackage = null;
+	}
 
-  public static void main(String argv[]) throws Exception {
-    PropertyConfigurator.configure("log4j.lcf");
-    String dirIni;
-    String dirFin;
-    boolean boolFilter;
-    String strFilter;
-    DirFilter dirFilter = null;
+	public static void main(String argv[]) throws Exception {
+		PropertyConfigurator.configure("log4j.lcf");
+		String dirIni;
+		String dirFin;
+		boolean boolFilter;
+		String strFilter;
+		DirFilter dirFilter = null;
 
-    if (argv.length < 1) {
-      log4j.error("Usage: java org.openbravo.data.Sqlc connection.xml [fileTermination [sourceDir destinyDir [write_txt_files]]]");
-      return;
-    }
+		if (argv.length < 1) {
+			log4j
+					.error("Usage: java org.openbravo.data.Sqlc connection.xml [fileTermination [sourceDir destinyDir [write_txt_files]]]");
+			return;
+		}
 
-    Sqlc sqlc = new Sqlc();
-    XMLReader parser;
-    parser = new SAXParser();
-    if (argv.length <= 4) sqlc.writeTxtFiles = false;
-    else sqlc.writeTxtFiles = argv[4].equalsIgnoreCase("true");
-    parser.setContentHandler(sqlc);
-    String strFileConnection = argv[0];
-    sqlc.readProperties(strFileConnection);
+		Sqlc sqlc = new Sqlc();
+		XMLReader parser;
+		parser = new SAXParser();
+		if (argv.length <= 4)
+			sqlc.writeTxtFiles = false;
+		else
+			sqlc.writeTxtFiles = argv[4].equalsIgnoreCase("true");
+		parser.setContentHandler(sqlc);
+		String strFileConnection = argv[0];
+		sqlc.readProperties(strFileConnection);
 
-    // the first parameter is the directory where the search is done
-    if(argv.length <= 2)
-      dirIni = ".";
-    else
-      dirIni = argv[2];
+		// the first parameter is the directory where the search is done
+		if (argv.length <= 2)
+			dirIni = ".";
+		else
+			dirIni = argv[2];
 
-    if(argv.length <= 3)
-      dirFin = dirIni;
-    else
-      dirFin = argv[3];
+		if (argv.length <= 3)
+			dirFin = dirIni;
+		else
+			dirFin = argv[3];
 
-    // the second parameter is the string-chain to make the filter
-    // the file must end with this string-chain in order to be recognized
-    boolFilter = true; // there always must be a termination
-    if(argv.length <= 1)
-      strFilter = ".xml";
-    else
-      strFilter = argv[1];
-    dirFilter = new  DirFilter(strFilter);
-    log4j.info("directory source: " + dirIni);
-    log4j.info("directory destiny: " + dirFin);
-    log4j.info("file termination: " + strFilter);
-    log4j.info("file connection: " + strFileConnection);
-    log4j.info("Write TXT Files: " + sqlc.writeTxtFiles);
-    
-    sqlc.connect(strFileConnection);
-    
-    File path = new File(dirIni);
-    if (!path.exists()) {
-      log4j.error("Directory does not exist: " + dirIni);
-      return;
-    }
-    File fileFin = new File(dirFin);
-    if (!fileFin.exists()) {
-      log4j.error("Directory does not exist: " + dirFin);
-      return;
-    }
-    listDir(path, boolFilter, dirFilter, sqlc, parser, strFilter, fileFin);
+		// include only directories (and sub-directories under this one) with
+		// this pattern, the packaging will be from this point, not from call
+		// point
+		if (argv.length <= 4)
+			includeDirectories = null;
+		else
+			includeDirectories = getDirectories(argv[4]);
 
-    sqlc.closeConnection();
-  }
+		// the second parameter is the string-chain to make the filter
+		// the file must end with this string-chain in order to be recognized
+		boolFilter = true; // there always must be a termination
+		if (argv.length <= 1)
+			strFilter = ".xml";
+		else
+			strFilter = argv[1];
+		dirFilter = new DirFilter(strFilter);
+		log4j.info("directory source: " + dirIni);
+		log4j.info("directory destiny: " + dirFin);
+		log4j.info("file termination: " + strFilter);
+		log4j.info("file connection: " + strFileConnection);
+		log4j.info("Write TXT Files: " + sqlc.writeTxtFiles);
 
-  // list of files and directories related to a File
-  public static void listDir(File file, boolean boolFilter, DirFilter dirFilter,
-      Sqlc sqlc, XMLReader parser, String strFilter, File fileFin) {
-    File[] list;
-    if(boolFilter)
-      list = file.listFiles(dirFilter);
-    else
-      list = file.listFiles();
-    for(int i = 0; i < list.length; i++) {
-      File fileItem = list[i];
-      if (fileItem.isDirectory()) {
-        // if it is a subdirectory then list recursively
-        listDir(fileItem, boolFilter, dirFilter, sqlc, parser, strFilter, fileFin);
-      } else {
-        try {
-          if (log4j.isDebugEnabled()) log4j.debug(list[i] + " Parent: " + fileItem.getParent() + " getName() " + fileItem.getName() + " canonical: " + fileItem.getCanonicalPath());
-          parseSqlFile(list[i], sqlc, parser, strFilter, fileFin);
-        } catch (IOException e) {
-          log4j.error("IOException: " + e);
-        }
-      }
-    }
-  }
+		sqlc.connect(strFileConnection);
 
-  /* replace dirIni.toString() with file
-     look for termination only at the end
-     */
+		File path = new File(dirIni);
+		if (!path.exists()) {
+			log4j.error("Directory does not exist: " + dirIni);
+			return;
+		}
+		File fileFin = new File(dirFin);
+		if (!fileFin.exists()) {
+			log4j.error("Directory does not exist: " + dirFin);
+			return;
+		}
+		listDir(path, boolFilter, dirFilter, sqlc, parser, strFilter, fileFin,
+				(includeDirectories == null), "", 0);
 
-  private static void parseSqlFile(File fileParsing, Sqlc sqlc, XMLReader parser, String strFilter, File fileFin) {
-    String strFileName = fileParsing.getName();
-    if (log4j.isDebugEnabled()) log4j.debug("Parsing of " + strFileName);
-    sqlc.init();
-    if (log4j.isDebugEnabled()) log4j.debug("new Sql");
-    int pos = strFileName.indexOf(strFilter);
-    if (pos == -1) {
-      log4j.error("File " + strFileName + " don't have termination " + strFilter);
-      return;
-    }
-    String strFileWithoutTermination = strFileName.substring(0, pos);
-    if (log4j.isDebugEnabled()) log4j.debug("File without termination: " + strFileWithoutTermination);
-    if (strFileWithoutTermination.equalsIgnoreCase("SQLC")) {
-      log4j.error("Name Sqlc not allowed for a file");
-      return;
-    }
-    try {
-      File dirJava = new File(fileFin, fileParsing.getParent());
-      dirJava.mkdirs();
-      javaFileName = TransformaNombreFichero(strFileWithoutTermination);
-      File fileJava = new File(dirJava, javaFileName + ".java");
-      File fileTxt = null;
-      if (sqlc.writeTxtFiles) fileTxt = new File(fileParsing.getParent(), strFileWithoutTermination + ".txt");
-      if ((!fileJava.exists())|| (fileParsing.lastModified() > fileJava.lastModified())) {
-        if (log4j.isDebugEnabled()) log4j.debug(" time file parsed: " + fileParsing.lastModified() +
-            " time file java: " + fileParsing.lastModified());
-        FileOutputStream resultsFile = new FileOutputStream(fileJava);
-        sqlc.out  = new OutputStreamWriter(resultsFile, "UTF-8");
-        sqlc.out1 = new StringBuffer();
-        sqlc.out2 = new StringBuffer();
-        /*FileWriter resultsFile = new FileWriter(fileJava);
-          sqlc.out = new PrintWriter(resultsFile);*/
-        FileWriter resultsFileTxt = null;
-        if (sqlc.writeTxtFiles) {
-          resultsFileTxt = new FileWriter(fileTxt);
-          sqlc.printWriterTxt = new PrintWriter(resultsFileTxt);
-        }
-        log4j.info("File: " + fileParsing + " \tprocessed");
-        java.util.Date date = new java.util.Date();  // there is date in java.sql.*
-        if (log4j.isDebugEnabled()) log4j.debug("Time: " + date.getTime()); 
+		sqlc.closeConnection();
+	}
 
-        sqlc.error = false;
-        try {
-          parser.parse(new InputSource(new FileReader(fileParsing)));
-        } catch (IOException e) {
-          e.printStackTrace();
-        } catch (SAXException e) {
-          e.printStackTrace();
-        } catch (Exception e) {
-          e.printStackTrace();
-        }
-        if (!sqlc.first) {
-          sqlc.printEndClass();
-        }
-        if (sqlc.importJavaUtil) {
-        	sqlc.out1.append("import java.util.*;\n");
-        }
-        if (sqlc.importRDBMSIndependent) {
-            sqlc.out1.append("import org.openbravo.database.RDBMSIndependent;\n");
-            sqlc.out1.append("import org.openbravo.exception.*;\n");
-        }
-        sqlc.out.write(sqlc.out1.toString());
-        sqlc.out.write(sqlc.out2.toString());
-        sqlc.out.flush();
-        sqlc.importJavaUtil = false;
-        sqlc.importRDBMSIndependent = false;
-        resultsFile.close();
-        if (resultsFileTxt!=null) resultsFileTxt.close();
-        if (sqlc.error) {
-          fileJava.delete();
-          if (fileTxt != null){
-            fileTxt.delete();
-          }
-        }
-      } else {
-        if (log4j.isDebugEnabled()) log4j.debug("File: " + fileParsing + " \tskipped");
-      }
-    } catch(IOException e) {
-      e.printStackTrace();
-      log4j.error("Problem at close of the file");
-    }
-  }
+	/**
+	 * Receives a list of directories and returns this list as an ArrayList
+	 * 
+	 * @param s
+	 * @return
+	 */
+	private static ArrayList<String> getDirectories(String s) {
+		ArrayList<String> l = new ArrayList<String>();
+		StringTokenizer tok = new StringTokenizer(s, "/");
+		while (tok.hasMoreTokens())
+			l.add(tok.nextToken());
+		return l;
+	}
 
-  private void pushElement(String name) {
-    stcElement.push(name);
-    strElement = name;
-  }
+	// list of files and directories related to a File
+	public static void listDir(File file, boolean boolFilter,
+			DirFilter dirFilter, Sqlc sqlc, XMLReader parser, String strFilter,
+			File fileFin, boolean parse, String parent, int level) {
 
-  private void popElement() {
-    strElement = stcElement.pop();
-    if (!stcElement.isEmpty()) strElement = stcElement.peek();
-  }
+		File[] list;
 
-  public void startElement(java.lang.String uri,
-      java.lang.String name,
-      java.lang.String qName,
-      Attributes amap) { //throws SAXException {
-    readBuffer();
-    pushElement(qName);
-    if (log4j.isDebugEnabled()) log4j.debug("Configuration: startElement is called: element  name=" + name);
-    if (log4j.isDebugEnabled()) log4j.debug("Configuration: startElement is called: element qName=" + qName);
-    if (name.equals("SqlMethod")) {
-      sql.sqlStatic = "true";
-      sql.sqlConnection = "false";
-      String sqlPackage = null;
-      int size = amap.getLength();
-      for (int i = 0; i < size; i++) {
-        if (amap.getQName(i).equals("name")) {
-          sql.sqlName = amap.getValue(i);
-        } else if (amap.getQName(i).equals("return")) {
-          sql.sqlReturn = amap.getValue(i).trim();
-          if (sql.sqlReturn.equalsIgnoreCase("STRING") || 
-              sql.sqlReturn.equalsIgnoreCase("BOOLEAN") || 
-              sql.sqlReturn.equalsIgnoreCase("DATE") || 
-              sql.sqlReturn.equalsIgnoreCase("SINGLE") || 
-              sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-            sql.executeType = "executeQuery";
-          } else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT") || 
-              sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
-            sql.executeType = "executeUpdate";
-          } else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
-            sql.executeType = "execute";
-          } else {
-            log4j.error("return not permited");
-          }
-        } else if (amap.getQName(i).equals("default")) {
-          sql.sqlDefaultReturn = amap.getValue(i);
-        } else if (amap.getQName(i).equals("static")) {
-          sql.sqlStatic = amap.getValue(i);
-        } else if (amap.getQName(i).equals("connection")) {  // it shows that the connection is sent through the window
-          sql.sqlConnection = amap.getValue(i);
-        } else if (amap.getQName(i).equals("type")) {
-          sql.sqlType = amap.getValue(i);
-        } else if (amap.getQName(i).equals("object")) {
-          sql.sqlObject = amap.getValue(i);
-        } else if (amap.getQName(i).equals("package")) {
-          sqlPackage = amap.getValue(i);
-        } else if (amap.getQName(i).equals("import")) {
-          sql.sqlImport = amap.getValue(i);
-        }
-      }
-      if (sqlPackage != null) sql.sqlClass = sqlPackage + "." + sql.sqlObject;
-      else sql.sqlClass = sql.sqlObject;
-    } else if (name.equals("SqlClass")) {
-      int size = amap.getLength();
-      for (int i = 0; i < size; i++) {
-        if (amap.getQName(i).equals("name")) {
-          sqlcName = amap.getValue(i);
-        } else if (amap.getQName(i).equals("package")) {
-          sqlcPackage = amap.getValue(i);
-        }
-      }
-    } else if (name.equals("Parameter")) {
-      String strName = null;
-      String strDefault = null;
-      String strInOut = "in";
-      String strOptional = null;
-      String strAfter = null;
-      String strText = null;
-      int size = amap.getLength();
-      for (int i = 0; i < size; i++) {     
-        if (amap.getQName(i).equals("name")) {
-          strName = amap.getValue(i);
-        } else if (amap.getQName(i).equals("default")) {
-          strDefault = amap.getValue(i);
-        } else if (amap.getQName(i).equals("type")) {
-          strInOut = amap.getValue(i);
-        } else if (amap.getQName(i).equals("optional")) {
-          strOptional = amap.getValue(i);
-        } else if (amap.getQName(i).equals("after")) {
-          strAfter = amap.getValue(i);
-        } else if (amap.getQName(i).equals("text")) {
-          strText = amap.getValue(i);
-        }
-      }
-      if (log4j.isDebugEnabled()) log4j.debug("Configuration: call to addParameter ");
-      parameterSql = sql.addParameter(false, strName, strDefault, strInOut, strOptional, strAfter, strText);
-    } else if (name.equals("Field")) {
-      FieldAdded field = null;
-      int size = amap.getLength();
-      for (int i = 0; i < size; i++) {
-        if (amap.getQName(i).equals("name")) {
-          field = new FieldAdded(amap.getValue(i));
-          sql.vecFieldAdded.addElement(field);
-        } else if (amap.getQName(i).equals("value")) {
-          field.strValue = amap.getValue(i);
-        }
-      }
-    } else if (name.equals("Sequence")) {
-      int size = amap.getLength();
-      for (int i = 0; i < size; i++) {     
-        if (amap.getQName(i).equals("name")) {
-          sql.strSequenceName = amap.getValue(i);
-        }
-      }
-      parameterSql = sql.addParameter(true, sql.strSequenceName, null, null, null, null, null);
-    }
-  }
+		if (boolFilter)
+			list = file.listFiles(dirFilter);
+		else
+			list = file.listFiles();
+		for (int i = 0; i < list.length; i++) {
+			File fileItem = list[i];
+			if (fileItem.isDirectory()) {
+				if (log4j.isDebugEnabled())
+					log4j
+							.debug("dir: "
+									+ fileItem.getName()
+									+ " - parse:"
+									+ parse
+									+ " - parent:"
+									+ parent
+									+ " - level:"
+									+ level
+									+ " - include:"
+									+ (includeDirectories != null
+											&& includeDirectories.size() > level ? includeDirectories
+											.get(level)
+											: "--"));
+				// if it is a subdirectory then list recursively
+				if (parse)
+					listDir(fileItem, boolFilter, dirFilter, sqlc, parser,
+							strFilter, fileFin, true, parent, level + 1);
+				else {
+					if ((includeDirectories.size() == level + 1)
+							&& (includeDirectories.get(level).equals("*") || includeDirectories
+									.get(level).equals(fileItem.getName())))
+						listDir(fileItem, boolFilter, dirFilter, sqlc, parser,
+								strFilter, fileFin, true, fileItem.getParent()
+										+ "/" + fileItem.getName(), level + 1);
+					else if (includeDirectories.size() > level
+							&& (includeDirectories.get(level).equals("*") || includeDirectories
+									.get(level).equals(fileItem.getName())))
+						listDir(fileItem, boolFilter, dirFilter, sqlc, parser,
+								strFilter, fileFin, false, parent, level + 1);
+					// other case don't follow deeping into the tree
+				}
+			} else {
+				try {
+					if (log4j.isDebugEnabled())
+						log4j.debug(list[i] + " Parent: "
+								+ fileItem.getParent() + " getName() "
+								+ fileItem.getName() + " canonical: "
+								+ fileItem.getCanonicalPath());
+					if (parse)
+						parseSqlFile(list[i], sqlc, parser, strFilter, fileFin,
+								parent);
+				} catch (IOException e) {
+					log4j.error("IOException: " + e);
+				}
+			}
+		}
+	}
 
-  public void endElement(java.lang.String uri,
-      java.lang.String name,
-      java.lang.String qName) { //throws SAXException {
-    readBuffer();
-    if (log4j.isDebugEnabled()) log4j.debug("Configuration: call to endElement: " + name);
-    if (log4j.isDebugEnabled()) log4j.debug("(before pop) Element: " + strElement);
-    popElement();
-    if (log4j.isDebugEnabled()) log4j.debug("(after pop) Element: " + strElement);
-    if (name.equals("SqlMethod")) {
-      if (sql.sqlType.equals("constant")) {
-        try {
-          printFunctionConstant();
-        } catch (IOException ex) {
-          ex.printStackTrace();
-        }
-      } else {
-        query();
-        if (first) {
-          first = false;
-          try {
-            printInitClass();
-          } catch (IOException ex) {
-            ex.printStackTrace();
-          }
-        }
-        try {
-          printFunctionSql();
-        } catch (IOException ex) {
-          ex.printStackTrace();
-        }
-      }
-      sql = new Sql();
-    }
-  }
+	/*
+	 * replace dirIni.toString() with file look for termination only at the end
+	 */
 
-  public void characters(char[] ch, int start, int lengthc) throws SAXException {
-    if (buffer == null) buffer = new StringBuffer();
-    buffer.append(ch, start, lengthc); 
-  }
-  public void readBuffer() {
-    if (buffer != null) {
-      String strBuffer = buffer.toString();
-      if (log4j.isDebugEnabled()) log4j.debug("Configuration("+strElement+"): characters are  called: " + strBuffer);
-      if (strElement.equals("Sql")) {
-        sql.strSQL = strBuffer;
-      } else if (strElement.equals("SqlClassComment")) {
-        strComments = strBuffer;
-      } else if (strElement.equals("SqlMethodComment")) {
-        sql.strSqlComments = strBuffer;
-      } else if (strElement.equals("Parameter")) {
-        parameterSql.strText = strBuffer.replaceAll("\\x0D"," ").replaceAll("\\x0A"," ");
-      }
-      buffer = null;
-    }
-  }
+	private static void parseSqlFile(File fileParsing, Sqlc sqlc,
+			XMLReader parser, String strFilter, File fileFin, String parent) {
+		String strFileName = fileParsing.getName();
+		if (log4j.isDebugEnabled())
+			log4j.debug("Parsing of " + strFileName);
+		sqlc.init();
+		if (log4j.isDebugEnabled())
+			log4j.debug("new Sql");
+		int pos = strFileName.indexOf(strFilter);
+		if (pos == -1) {
+			log4j.error("File " + strFileName + " don't have termination "
+					+ strFilter);
+			return;
+		}
+		String strFileWithoutTermination = strFileName.substring(0, pos);
+		if (log4j.isDebugEnabled())
+			log4j.debug("File without termination: "
+					+ strFileWithoutTermination);
+		if (strFileWithoutTermination.equalsIgnoreCase("SQLC")) {
+			log4j.error("Name Sqlc not allowed for a file");
+			return;
+		}
+		try {
 
-  public void connect(String file) throws ClassNotFoundException, SQLException {
-    Properties properties = new Properties();
-    try {
-      properties.load(new FileInputStream(file));
-      strDriver = properties.getProperty("bbdd.driver");
-      strURL = properties.getProperty("bbdd.url");
-      strDBUser = properties.getProperty("bbdd.user");
-      strDBPassword = properties.getProperty("bbdd.password");
-      if (properties.getProperty("bbdd.rdbms").equalsIgnoreCase("POSTGRE")) 
-          strURL += "/"+properties.getProperty("bbdd.sid");
-    } catch (IOException e) { 
-     e.printStackTrace();
-    }
-    
-    
-    log4j.info("Loading driver: " + strDriver);
-    Class.forName(strDriver);
-    log4j.info("Driver loaded");
-    if (strDBUser==null || strDBUser.equals("")) connection=DriverManager.getConnection(strURL);
-    else connection=DriverManager.getConnection(strURL, strDBUser, strDBPassword);
-    log4j.info("connect made");
-  }
+			String parentDir = fileParsing.getParent();
+			// In case includeDirectories has value remove parent from path to
+			// keep clean the package
+			if (includeDirectories != null && parentDir.startsWith(parent))
+				parentDir = parentDir.substring(parent.length());
 
-  public void closeConnection() {
-    try {
-      connection.close();
-    } catch(SQLException e){
-      log4j.error("SQL error in closeConnection: " + e);
-    }
-  }
+			File dirJava = new File(fileFin, parentDir);
+			if (log4j.isDebugEnabled())
+				log4j.debug("parentDir:" + parentDir + " - javadir:" + dirJava
+						+ " - parent:" + parent);
+			dirJava.mkdirs();
+			javaFileName = TransformaNombreFichero(strFileWithoutTermination);
+			File fileJava = new File(dirJava, javaFileName + ".java");
+			File fileTxt = null;
+			if (sqlc.writeTxtFiles)
+				fileTxt = new File(fileParsing.getParent(),
+						strFileWithoutTermination + ".txt");
+			if ((!fileJava.exists())
+					|| (fileParsing.lastModified() > fileJava.lastModified())) {
+				if (log4j.isDebugEnabled())
+					log4j.debug(" time file parsed: "
+							+ fileParsing.lastModified() + " time file java: "
+							+ fileParsing.lastModified());
+				FileOutputStream resultsFile = new FileOutputStream(fileJava);
+				sqlc.out = new OutputStreamWriter(resultsFile, "UTF-8");
+				sqlc.out1 = new StringBuffer();
+				sqlc.out2 = new StringBuffer();
+				/*
+				 * FileWriter resultsFile = new FileWriter(fileJava); sqlc.out =
+				 * new PrintWriter(resultsFile);
+				 */
+				FileWriter resultsFileTxt = null;
+				if (sqlc.writeTxtFiles) {
+					resultsFileTxt = new FileWriter(fileTxt);
+					sqlc.printWriterTxt = new PrintWriter(resultsFileTxt);
+				}
+				log4j.info("File: " + fileParsing + " \tprocessed");
+				java.util.Date date = new java.util.Date(); // there is date in
+															// java.sql.*
+				if (log4j.isDebugEnabled())
+					log4j.debug("Time: " + date.getTime());
 
-  public void query(){
-    try {
-      if (preparedStatement!=null) preparedStatement.close();
-      preparedStatement = connection.prepareStatement(sql.strSQL);
-      if (log4j.isDebugEnabled()) log4j.debug("Prepared statement: " + sql.strSQL);
-      /*    Commented because it is not a supported operation
-            ResultSetMetaData rsmdPS = preparedStatement.getMetaData ();
-      // Get the number of columns in the result set
-      int numColsPS = rsmdPS.getColumnCount ();
-      if (log4j.isDebugEnabled()) log4j.debug("number of columns in PS: " + numColsPS);
-      */
-      int i = 1;
-      for (Parameter parameter : sql.vecParameter) {
-        if (!parameter.boolOptional) {
-          if (parameter.type == java.sql.Types.INTEGER) {
-            if (parameter.strDefault == null) {
-              if (log4j.isDebugEnabled()) log4j.debug("setInt: " + i + " value: 0");
-              preparedStatement.setInt(i, 0);
-            } else {
-              if (log4j.isDebugEnabled()) log4j.debug("setInt: " + i + " value: " + parameter.strDefault);
-              preparedStatement.setInt(i, Integer.parseInt(parameter.strDefault));
-            }
-            preparedStatement.setInt(i, Integer.parseInt(parameter.strDefault));
-          } else if (parameter.type == java.sql.Types.VARCHAR) {
-            if (parameter.strDefault == null) {
-              if (log4j.isDebugEnabled()) log4j.debug("setString: " + i + " value: null");
-              preparedStatement.setNull(i, java.sql.Types.VARCHAR);
-            } else {
-              if (log4j.isDebugEnabled()) log4j.debug("setString: " + i + " value: " + parameter.strDefault);
-              preparedStatement.setString(i, parameter.strDefault);
-            }
-          }
-          i++;
-        }
-      }
-      // Get the ResultSetMetaData.  This will be used for
-      // the column headings
-      if (sql.executeType.equals("executeQuery")) {
-        result = preparedStatement.executeQuery();
-        if (log4j.isDebugEnabled()) log4j.debug("query done");
-        rsmd = result.getMetaData ();
-        // Get the number of columns in the result set
-        numCols = rsmd.getColumnCount ();
-        if (log4j.isDebugEnabled()) log4j.debug("number of columns: " + numCols);
-      } //else
-      //rsmd = preparedStatement.getMetaData ();
-    } catch(SQLException e){
-      error = true;
-      log4j.error("SQL error in query: " + sql.strSQL + "Exception:"+ e);
-      e.printStackTrace();
-    } catch(Exception e){
-      error = true;
-      log4j.error("Error in query. Exception:"+ e);
-      e.printStackTrace();
-    }
-  }
+				sqlc.error = false;
+				try {
+					parser.parse(new InputSource(new FileReader(fileParsing)));
+				} catch (IOException e) {
+					e.printStackTrace();
+				} catch (SAXException e) {
+					e.printStackTrace();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				if (!sqlc.first) {
+					sqlc.printEndClass();
+				}
+				if (sqlc.importJavaUtil) {
+					sqlc.out1.append("import java.util.*;\n");
+				}
+				if (sqlc.importRDBMSIndependent) {
+					sqlc.out1
+							.append("import org.openbravo.database.RDBMSIndependent;\n");
+					sqlc.out1.append("import org.openbravo.exception.*;\n");
+				}
+				sqlc.out.write(sqlc.out1.toString());
+				sqlc.out.write(sqlc.out2.toString());
+				sqlc.out.flush();
+				sqlc.importJavaUtil = false;
+				sqlc.importRDBMSIndependent = false;
+				resultsFile.close();
+				if (resultsFileTxt != null)
+					resultsFileTxt.close();
+				if (sqlc.error) {
+					fileJava.delete();
+					if (fileTxt != null) {
+						fileTxt.delete();
+					}
+				}
+			} else {
+				if (log4j.isDebugEnabled())
+					log4j.debug("File: " + fileParsing + " \tskipped");
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+			log4j.error("Problem at close of the file");
+		}
+	}
 
-  public void printInitClass() throws IOException {
-    if (this.writeTxtFiles) printTxtFile();
-    out1.append("//Sqlc generated " + VERSION + "\n"); // v0.011");
-    if (sqlcPackage != null) {
-    	out1.append("package " + sqlcPackage + ";\n");
-    }
-    out1.append("\n");
-    out1.append("import java.sql.*;\n");
-    out1.append("\n");
-    out1.append("import org.apache.log4j.Logger;\n");
-    out1.append("\n");
-    out1.append("import javax.servlet.ServletException;\n");
-    out1.append("\n");
-    out1.append("import org.openbravo.data.FieldProvider;\n");
-    out1.append("import org.openbravo.database.ConnectionProvider;\n");
-    out1.append("import org.openbravo.data.UtilSql;\n");
+	private void pushElement(String name) {
+		stcElement.push(name);
+		strElement = name;
+	}
 
-    if (sql.sqlImport != null) {
-      out2.append("import " + sql.sqlImport + ";\n");
-    }
-    out2.append("\n");
+	private void popElement() {
+		strElement = stcElement.pop();
+		if (!stcElement.isEmpty())
+			strElement = stcElement.peek();
+	}
 
-    String[] strCommentsVector = stringToVector(strComments, false);
-    for (int i=0; i<strCommentsVector.length; i++) {
-      if (i == 0) {
-        out2.append("/**\n" + strCommentsVector[i] + "\n");
-      } else {
-        out2.append(" *" + strCommentsVector[i] + "\n");
-      }
-      if (i == strCommentsVector.length - 1) {
-        out2.append(" */\n");
-      }
-    }
-    if (!javaFileName.equals(sqlcName)) throw new IOException("File name for xsql class " + javaFileName + " is different than the class name defined inside the file: " + sqlcName);
-    out2.append("public class " + sqlcName + " implements FieldProvider {\n");
-    out2.append("static Logger log4j = Logger.getLogger("+sqlcName+".class);\n");
-    try {
-      // Display column headings
-      if (log4j.isDebugEnabled()) log4j.debug("Number of columns: "+ numCols);
-      out2.append("  private String InitRecordNumber=\"0\";\n");
-      for (int i=1; i<=numCols; i++) {
-        out2.append("  public String ");
-        out2.append(TransformaNombreColumna(rsmd.getColumnLabel(i)));
-        out2.append(";\n");
-      }
-      for (Enumeration<Object> e = sql.vecFieldAdded.elements() ; e.hasMoreElements() ;) {
-        FieldAdded fieldAdded = (FieldAdded)e.nextElement();
-        out2.append("  public String ");
-        out2.append(fieldAdded.strName);
-        out2.append(";\n");
-      }
-    } catch(SQLException e){
-      log4j.error("SQL Exception error:"+ e);
-    }
-    out2.append("\n");
-    out2.append("  public String getInitRecordNumber() {\n");
-    out2.append("    return InitRecordNumber;\n");
-    out2.append("  }\n");
-    // the getField function
-    out2.append("\n");
-    out2.append("  public String getField(String fieldName) {\n");
-    try {
-      // Display column headings
-      if (log4j.isDebugEnabled()) log4j.debug("Number of columns in getField: "+ numCols);
-      for (int i=1; i<=numCols; i++) {
-        String columnLabel = rsmd.getColumnLabel(i);
-        String transformedColumnLabel = TransformaNombreColumna(columnLabel);
-        if (i == 1) {
-          out2.append("    if ");
-        } else {
-          out2.append("    else if ");
-        }
-        out2.append("(fieldName.equalsIgnoreCase(\"");
-        out2.append(columnLabel);
-        if (!columnLabel.equalsIgnoreCase(transformedColumnLabel))
-          out2.append("\") || fieldName.equals(\"" + transformedColumnLabel);
-        out2.append("\"))\n");
-        out2.append("      return " + transformedColumnLabel + ";\n");
-      }
-      for (Enumeration<Object> e = sql.vecFieldAdded.elements() ; e.hasMoreElements() ;) {
-        FieldAdded fieldAdded = (FieldAdded)e.nextElement();
-        out2.append("    else if ");
-        out2.append("(fieldName.equals(\"");
-        out2.append(fieldAdded.strName + "\"))\n");
-        out2.append("      return " + fieldAdded.strName + ";\n");
-      }
-    } catch(SQLException e){
-      log4j.error("SQL Exception error:"+ e);
-    }
-    out2.append("   else {\n");
-    out2.append("     log4j.debug(\"Field does not exist: \" + fieldName);\n");
-    out2.append("     return null;\n");
-    out2.append("   }\n");
-    out2.append(" }\n");
-  }
+	@Override
+	public void startElement(java.lang.String uri, java.lang.String name,
+			java.lang.String qName, Attributes amap) { // throws SAXException {
+		readBuffer();
+		pushElement(qName);
+		if (log4j.isDebugEnabled())
+			log4j.debug("Configuration: startElement is called: element  name="
+					+ name);
+		if (log4j.isDebugEnabled())
+			log4j.debug("Configuration: startElement is called: element qName="
+					+ qName);
+		if (name.equals("SqlMethod")) {
+			sql.sqlStatic = "true";
+			sql.sqlConnection = "false";
+			String sqlPackage = null;
+			int size = amap.getLength();
+			for (int i = 0; i < size; i++) {
+				if (amap.getQName(i).equals("name")) {
+					sql.sqlName = amap.getValue(i);
+				} else if (amap.getQName(i).equals("return")) {
+					sql.sqlReturn = amap.getValue(i).trim();
+					if (sql.sqlReturn.equalsIgnoreCase("STRING")
+							|| sql.sqlReturn.equalsIgnoreCase("BOOLEAN")
+							|| sql.sqlReturn.equalsIgnoreCase("DATE")
+							|| sql.sqlReturn.equalsIgnoreCase("SINGLE")
+							|| sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+						sql.executeType = "executeQuery";
+					} else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT")
+							|| sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
+						sql.executeType = "executeUpdate";
+					} else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
+						sql.executeType = "execute";
+					} else {
+						log4j.error("return not permited");
+					}
+				} else if (amap.getQName(i).equals("default")) {
+					sql.sqlDefaultReturn = amap.getValue(i);
+				} else if (amap.getQName(i).equals("static")) {
+					sql.sqlStatic = amap.getValue(i);
+				} else if (amap.getQName(i).equals("connection")) { // it shows
+																	// that the
+																	// connection
+																	// is sent
+																	// through
+																	// the
+																	// window
+					sql.sqlConnection = amap.getValue(i);
+				} else if (amap.getQName(i).equals("type")) {
+					sql.sqlType = amap.getValue(i);
+				} else if (amap.getQName(i).equals("object")) {
+					sql.sqlObject = amap.getValue(i);
+				} else if (amap.getQName(i).equals("package")) {
+					sqlPackage = amap.getValue(i);
+				} else if (amap.getQName(i).equals("import")) {
+					sql.sqlImport = amap.getValue(i);
+				}
+			}
+			if (sqlPackage != null)
+				sql.sqlClass = sqlPackage + "." + sql.sqlObject;
+			else
+				sql.sqlClass = sql.sqlObject;
+		} else if (name.equals("SqlClass")) {
+			int size = amap.getLength();
+			for (int i = 0; i < size; i++) {
+				if (amap.getQName(i).equals("name")) {
+					sqlcName = amap.getValue(i);
+				} else if (amap.getQName(i).equals("package")) {
+					sqlcPackage = amap.getValue(i);
+				}
+			}
+		} else if (name.equals("Parameter")) {
+			String strName = null;
+			String strDefault = null;
+			String strInOut = "in";
+			String strOptional = null;
+			String strAfter = null;
+			String strText = null;
+			int size = amap.getLength();
+			for (int i = 0; i < size; i++) {
+				if (amap.getQName(i).equals("name")) {
+					strName = amap.getValue(i);
+				} else if (amap.getQName(i).equals("default")) {
+					strDefault = amap.getValue(i);
+				} else if (amap.getQName(i).equals("type")) {
+					strInOut = amap.getValue(i);
+				} else if (amap.getQName(i).equals("optional")) {
+					strOptional = amap.getValue(i);
+				} else if (amap.getQName(i).equals("after")) {
+					strAfter = amap.getValue(i);
+				} else if (amap.getQName(i).equals("text")) {
+					strText = amap.getValue(i);
+				}
+			}
+			if (log4j.isDebugEnabled())
+				log4j.debug("Configuration: call to addParameter ");
+			parameterSql = sql.addParameter(false, strName, strDefault,
+					strInOut, strOptional, strAfter, strText);
+		} else if (name.equals("Field")) {
+			FieldAdded field = null;
+			int size = amap.getLength();
+			for (int i = 0; i < size; i++) {
+				if (amap.getQName(i).equals("name")) {
+					field = new FieldAdded(amap.getValue(i));
+					sql.vecFieldAdded.addElement(field);
+				} else if (amap.getQName(i).equals("value")) {
+					field.strValue = amap.getValue(i);
+				}
+			}
+		} else if (name.equals("Sequence")) {
+			int size = amap.getLength();
+			for (int i = 0; i < size; i++) {
+				if (amap.getQName(i).equals("name")) {
+					sql.strSequenceName = amap.getValue(i);
+				}
+			}
+			parameterSql = sql.addParameter(true, sql.strSequenceName, null,
+					null, null, null, null);
+		}
+	}
 
-  void printTxtFile() {
-    try {
-      // Display column headings
-      if (log4j.isDebugEnabled()) log4j.debug("Printing txt File: "+ numCols);
-      for (int i=1; i<=numCols; i++) {
-        printWriterTxt.print(rsmd.getColumnLabel(i));
-        if (i == numCols) {
-          printWriterTxt.println("");
-        } else {
-          printWriterTxt.print(", ");
-        }
-      }
-      printWriterTxt.println("");
-      for (int i=1; i<=numCols; i++) {
-        printWriterTxt.println("<FIELD id=\"" +
-            TransformaNombreColumna("field_" + rsmd.getColumnLabel(i)) + "\">" +
-            TransformaNombreColumna(rsmd.getColumnLabel(i)) + "</FIELD>");
-      }
-      printWriterTxt.println("");
-      for (int i=1; i<=numCols; i++) {
-        printWriterTxt.println("      <Parameter name=\"" + 
-            TransformaNombreColumna(rsmd.getColumnLabel(i)) + "\"/>");
-      }
-      printWriterTxt.println("");
-      printWriterTxt.println("  " + sqlcName + " getEditVariables(VariablesSapp vars) {");
-      printWriterTxt.println("    " + sqlcName + " data = new " + sqlcName + "();");
-      for (int i=1; i<=numCols; i++) {
-        printWriterTxt.println("    data." +
-            TransformaNombreColumna(rsmd.getColumnLabel(i)) +
-            " = vars.getStringParameter(\"" +
-            TransformaNombreColumna("inp_" + rsmd.getColumnLabel(i)) + "\");");
-      }
-      printWriterTxt.println("    data.a1Usuario = vars.getUser();");
-      printWriterTxt.println("    data.a1Rol = vars.getRole();");
-      printWriterTxt.println("    return data;");
-      printWriterTxt.println("  }");
-    } catch(SQLException e){
-      log4j.error("SQL Exception error:"+ e);
-    }
-  }
+	@Override
+	public void endElement(java.lang.String uri, java.lang.String name,
+			java.lang.String qName) { // throws SAXException {
+		readBuffer();
+		if (log4j.isDebugEnabled())
+			log4j.debug("Configuration: call to endElement: " + name);
+		if (log4j.isDebugEnabled())
+			log4j.debug("(before pop) Element: " + strElement);
+		popElement();
+		if (log4j.isDebugEnabled())
+			log4j.debug("(after pop) Element: " + strElement);
+		if (name.equals("SqlMethod")) {
+			if (sql.sqlType.equals("constant")) {
+				try {
+					printFunctionConstant();
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			} else {
+				query();
+				if (first) {
+					first = false;
+					try {
+						printInitClass();
+					} catch (IOException ex) {
+						ex.printStackTrace();
+					}
+				}
+				try {
+					printFunctionSql();
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+			sql = new Sql();
+		}
+	}
 
-  public void printFunctionConstant() throws IOException {
-    printHeadFunctionSql(false, false, false);
-    out2.append("    " + sqlcName + " object" + sqlcName + "[] = new " + sqlcName + "[1];\n");
-    out2.append("    object" + sqlcName + "[0] = new " + sqlcName + "();\n");
-    try {
-      for (int i=1; i<=numCols; i++) {
-        String strNameLabel = rsmd.getColumnLabel(i);
-        out2.append("    object" + sqlcName + "[0]." +
-            TransformaNombreColumna(strNameLabel) + " = ");
-        boolean printedParameter = false;
-        for (Parameter parameter : sql.vecParameter) {
-          if (parameter.strName.equals(TransformaNombreColumna(strNameLabel)) && !printedParameter) {
-            out2.append(TransformaNombreColumna(strNameLabel) + ";\n");
-            printedParameter = true;
-          }
-        }
-        if (!printedParameter) {
-          out2.append("\"\";\n");
-        }
-      }
-    } catch(SQLException e){
-      log4j.error("SQL Exception error:"+ e);
-    }
-    out2.append("    return object" + sqlcName + ";\n");
-    out2.append("  }\n");
-  }
+	@Override
+	public void characters(char[] ch, int start, int lengthc)
+			throws SAXException {
+		if (buffer == null)
+			buffer = new StringBuffer();
+		buffer.append(ch, start, lengthc);
+	}
 
-  public void printSQLBody() throws IOException {
-    // codigo para imprimir trozos de Sql opcionales
-    int posSQL = 0;
-    out2.append("    String strSql = \"\";\n");
-    for (Parameter parameter : sql.vecParameter) {
-      if (parameter.boolOptional){
-        if (parameter.strAfter == null) {
-          parameter.strAfter = "WHERE";
-          parameter.strText = parameter.strName + " = ? AND";
-        }
-        if (parameter.strName != null && // se deben imprimir los repetidos, quitar: !parameter.boolRepeated &&
-            !parameter.strInOut.equals("out")) {
-          int posFinalAfter = posFinal(sql.strSQL, parameter.strAfter);
-          if (posFinalAfter != -1) {
-            imprimirSubstring(sql.strSQL, posSQL, posFinalAfter, out);
-            posSQL = posFinalAfter + (parameter.strInOut.equals("replace")?parameter.strText.length():0);
-            if (parameter.strInOut.equals("none")) {
-              out2.append("    strSql = strSql + ((" +
-                  parameter.strName + ".equals(\"" + parameter.strName + "\"))?\" " +
-                  parameter.strText + " \":\"\");\n");
-            } else if (parameter.strInOut.equals("argument")) {
-              out2.append("    strSql = strSql + ((" + parameter.strName + "==null || " +
-                  parameter.strName + ".equals(\"\"))?\"\":\" " +
-                  parameter.strText + "\" + " + parameter.strName + ");\n");
-            } else if (parameter.strInOut.equals("replace")) {
-              out2.append("    strSql = strSql + ((" + parameter.strName + "==null || " +
-                  parameter.strName + ".equals(\"\"))?\"\":" + parameter.strName + ");\n");
-            } else {
-              out2.append("    strSql = strSql + ((" + parameter.strName + "==null || " +
-                  parameter.strName + ".equals(\"\"))?\"\":\" " +
-                  parameter.strText + " \");\n");
-            }
-          } else if (parameter.strInOut.equals("replace")) {
-            posFinalAfter=0;
-            out2.append("    strSql = strSql + ((" + parameter.strName + "==null || " +
-                parameter.strName + ".equals(\"\"))?\"\":" + parameter.strName + ");\n");
-          }
-            }
-      }
-    }
-    imprimirSubstring(sql.strSQL, posSQL, sql.strSQL.length(), out);
+	public void readBuffer() {
+		if (buffer != null) {
+			String strBuffer = buffer.toString();
+			if (log4j.isDebugEnabled())
+				log4j.debug("Configuration(" + strElement
+						+ "): characters are  called: " + strBuffer);
+			if (strElement.equals("Sql")) {
+				sql.strSQL = strBuffer;
+			} else if (strElement.equals("SqlClassComment")) {
+				strComments = strBuffer;
+			} else if (strElement.equals("SqlMethodComment")) {
+				sql.strSqlComments = strBuffer;
+			} else if (strElement.equals("Parameter")) {
+				parameterSql.strText = strBuffer.replaceAll("\\x0D", " ")
+						.replaceAll("\\x0A", " ");
+			}
+			buffer = null;
+		}
+	}
 
-    out2.append("\n");
+	public void connect(String file) throws ClassNotFoundException,
+			SQLException {
+		Properties properties = new Properties();
+		try {
+			properties.load(new FileInputStream(file));
+			strDriver = properties.getProperty("bbdd.driver");
+			strURL = properties.getProperty("bbdd.url");
+			strDBUser = properties.getProperty("bbdd.user");
+			strDBPassword = properties.getProperty("bbdd.password");
+			if (properties.getProperty("bbdd.rdbms")
+					.equalsIgnoreCase("POSTGRE"))
+				strURL += "/" + properties.getProperty("bbdd.sid");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
 
-    if (sql.executeType.equals("executeQuery")) {
-      out2.append("    ResultSet result;\n");
-    }
-    if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-      importJavaUtil = true;
-      out2.append("    Vector<Object> vector = new Vector<Object>(0);\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
-      out2.append("    " + sqlcName + " object" + sqlcName + " = new " + sqlcName + "();\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
-      out2.append("    String strReturn = ");
-      if (sql.sqlDefaultReturn != null) {
-        out2.append("\"" + sql.sqlDefaultReturn + "\";\n");
-      } else {
-        out2.append("null;\n");  // if the return value is not specified then set to null
-      }
-    } else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
-      out2.append("    boolean boolReturn = ");
-      if (sql.sqlDefaultReturn != null) {
-        out2.append(sql.sqlDefaultReturn + ";\n");
-      } else {
-        out2.append("false;\n");  // if the return value is not specified then set to false
-      }
-    } else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
-      out2.append("    String dateReturn = ");
-      if (sql.sqlDefaultReturn != null) {
-        out2.append(sql.sqlDefaultReturn + ";\n");
-      } else {
-        out2.append("null;\n");  // if the return value is not specified then set to null
-      }
-    } else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
-      //      out2.append("    SqlRespuestaCS objectSqlRespuestaCS = new SqlRespuestaCS();");
-      out2.append("    " + sql.sqlClass + " object" + sql.sqlObject + " = new " + sql.sqlClass + "();\n");
-    }
-    if (sql.executeType.equals("executeUpdate")) {
-      out2.append("    int updateCount = 0;\n");
-    }
+		log4j.info("Loading driver: " + strDriver);
+		Class.forName(strDriver);
+		log4j.info("Driver loaded");
+		if (strDBUser == null || strDBUser.equals(""))
+			connection = DriverManager.getConnection(strURL);
+		else
+			connection = DriverManager.getConnection(strURL, strDBUser,
+					strDBPassword);
+		log4j.info("connect made");
+	}
 
-    if (sql.sqlType.equals("preparedStatement")) {
-      out2.append("    PreparedStatement st = null;\n");
-    } else if (sql.sqlType.equals("statement")) {
-      out2.append("    Statement st = null;\n");
-    } else if (sql.sqlType.equals("callableStatement")) {
-      out2.append("    CallableStatement st = null;\n");
-      out2.append("    if (connectionProvider.getRDBMS().equalsIgnoreCase(\"ORACLE\")) {\n");
-    }
-    out2.append("\n");
-  }
+	public void closeConnection() {
+		try {
+			connection.close();
+		} catch (SQLException e) {
+			log4j.error("SQL error in closeConnection: " + e);
+		}
+	}
 
-  public void printSQLParameters() throws IOException {
-    StringBuffer aux = new StringBuffer();
-    boolean declareiParameter = false;
+	public void query() {
+		try {
+			if (preparedStatement != null)
+				preparedStatement.close();
+			preparedStatement = connection.prepareStatement(sql.strSQL);
+			if (log4j.isDebugEnabled())
+				log4j.debug("Prepared statement: " + sql.strSQL);
+			/*
+			 * Commented because it is not a supported operation
+			 * ResultSetMetaData rsmdPS = preparedStatement.getMetaData (); //
+			 * Get the number of columns in the result set int numColsPS =
+			 * rsmdPS.getColumnCount (); if (log4j.isDebugEnabled())
+			 * log4j.debug("number of columns in PS: " + numColsPS);
+			 */
+			int i = 1;
+			for (Parameter parameter : sql.vecParameter) {
+				if (!parameter.boolOptional) {
+					if (parameter.type == java.sql.Types.INTEGER) {
+						if (parameter.strDefault == null) {
+							if (log4j.isDebugEnabled())
+								log4j.debug("setInt: " + i + " value: 0");
+							preparedStatement.setInt(i, 0);
+						} else {
+							if (log4j.isDebugEnabled())
+								log4j.debug("setInt: " + i + " value: "
+										+ parameter.strDefault);
+							preparedStatement.setInt(i, Integer
+									.parseInt(parameter.strDefault));
+						}
+						preparedStatement.setInt(i, Integer
+								.parseInt(parameter.strDefault));
+					} else if (parameter.type == java.sql.Types.VARCHAR) {
+						if (parameter.strDefault == null) {
+							if (log4j.isDebugEnabled())
+								log4j.debug("setString: " + i + " value: null");
+							preparedStatement
+									.setNull(i, java.sql.Types.VARCHAR);
+						} else {
+							if (log4j.isDebugEnabled())
+								log4j.debug("setString: " + i + " value: "
+										+ parameter.strDefault);
+							preparedStatement
+									.setString(i, parameter.strDefault);
+						}
+					}
+					i++;
+				}
+			}
+			// Get the ResultSetMetaData. This will be used for
+			// the column headings
+			if (sql.executeType.equals("executeQuery")) {
+				result = preparedStatement.executeQuery();
+				if (log4j.isDebugEnabled())
+					log4j.debug("query done");
+				rsmd = result.getMetaData();
+				// Get the number of columns in the result set
+				numCols = rsmd.getColumnCount();
+				if (log4j.isDebugEnabled())
+					log4j.debug("number of columns: " + numCols);
+			} // else
+			// rsmd = preparedStatement.getMetaData ();
+		} catch (SQLException e) {
+			error = true;
+			log4j.error("SQL error in query: " + sql.strSQL + "Exception:" + e);
+			e.printStackTrace();
+		} catch (Exception e) {
+			error = true;
+			log4j.error("Error in query. Exception:" + e);
+			e.printStackTrace();
+		}
+	}
 
-    aux.append("    try {\n");
-    if (sql.sqlType.equals("preparedStatement")) {
-      aux.append("    st = connectionProvider.getPreparedStatement(");
-      if (sql.sqlConnection.equals("true")) aux.append("conn, ");
-      aux.append("strSql);\n");
-    } else if (sql.sqlType.equals("statement")) {
-      aux.append("    st = connectionProvider.getStatement(");
-      if (sql.sqlConnection.equals("true")) aux.append("conn");
-      aux.append(");\n");
-    } else if (sql.sqlType.equals("callableStatement")) {
-      aux.append("      st = connectionProvider.getCallableStatement(");
-      if (sql.sqlConnection.equals("true")) aux.append("conn, ");
-      aux.append("strSql);\n");
-    }
-    // set value of parameters
-    for (Parameter parameter : sql.vecParameter) {
-      if (parameter.boolSequence){
-        declareiParameter = true;
-        aux.append("      iParameter++; st.setLong(iParameter, keySequence);\n");
-      } else if (parameter.strName != null) {
-        if (parameter.strInOut.equals("out") || parameter.strInOut.equals("inOut")) {
-          declareiParameter = true;
-          aux.append("      int iParameter" + parameter.strName + " = iParameter + 1;\n");
-        }
-        if (parameter.boolOptional) {
-          aux.append("      if (" + parameter.strName + " != null && !(" + parameter.strName + ".equals(\"\"))) {\n");
-          aux.append("  ");
-        }
-        if (parameter.strInOut.equals("in") || parameter.strInOut.equals("inOut")) {
-          declareiParameter = true;
-          aux.append("      iParameter++; UtilSql.setValue(st, iParameter, " + parameter.type + ", ");
-          if (parameter.strDefault == null) {
-            aux.append("null, ");
-          } else {
-            aux.append("\"" + parameter.strDefault + "\", ");
-          }
-          aux.append(parameter.strName + ");\n");
-        }
-        if (parameter.strInOut.equals("out")) {
-          declareiParameter = true;
-          aux.append("      iParameter++; st.registerOutParameter(iParameter, " + parameter.type+ ");\n");
-        } else if (parameter.strInOut.equals("inOut")) {   // in this case iParamter is increased;
-          declareiParameter = true;
-          aux.append("      st.registerOutParameter(iParameter, " + parameter.type+ ");\n");
-        }
-        if (parameter.boolOptional) {
-          aux.append("      }\n");
-        }
-      }
-    }
+	public void printInitClass() throws IOException {
+		if (this.writeTxtFiles)
+			printTxtFile();
+		out1.append("//Sqlc generated " + VERSION + "\n"); // v0.011");
+		if (sqlcPackage != null) {
+			out1.append("package " + sqlcPackage + ";\n");
+		}
+		out1.append("\n");
+		out1.append("import java.sql.*;\n");
+		out1.append("\n");
+		out1.append("import org.apache.log4j.Logger;\n");
+		out1.append("\n");
+		out1.append("import javax.servlet.ServletException;\n");
+		out1.append("\n");
+		out1.append("import org.openbravo.data.FieldProvider;\n");
+		out1.append("import org.openbravo.database.ConnectionProvider;\n");
+		out1.append("import org.openbravo.data.UtilSql;\n");
 
-    aux.append("\n");
-    if (declareiParameter) out2.append("    int iParameter = 0;\n");
-    out2.append(aux.toString());
-  }
+		if (sql.sqlImport != null) {
+			out2.append("import " + sql.sqlImport + ";\n");
+		}
+		out2.append("\n");
 
-  public void printFunctionSql() throws IOException {
-    boolean boolSequence = false;
-    //*** Call to the argument-less creation header, who calls the header with them 
-    if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {  // parameters por paging the output  && 1==2 
-      printHeadFunctionSql(true, false, false);
-      out2.append("    return ");
-      printCallFunctionSql(true);
-      out2.append(";\n");
-      out2.append("  }\n");
-      boolSequence = true;
-    }
+		String[] strCommentsVector = stringToVector(strComments, false);
+		for (int i = 0; i < strCommentsVector.length; i++) {
+			if (i == 0) {
+				out2.append("/**\n" + strCommentsVector[i] + "\n");
+			} else {
+				out2.append(" *" + strCommentsVector[i] + "\n");
+			}
+			if (i == strCommentsVector.length - 1) {
+				out2.append(" */\n");
+			}
+		}
+		if (!javaFileName.equals(sqlcName))
+			throw new IOException(
+					"File name for xsql class "
+							+ javaFileName
+							+ " is different than the class name defined inside the file: "
+							+ sqlcName);
+		out2.append("public class " + sqlcName
+				+ " implements FieldProvider {\n");
+		out2.append("static Logger log4j = Logger.getLogger(" + sqlcName
+				+ ".class);\n");
+		try {
+			// Display column headings
+			if (log4j.isDebugEnabled())
+				log4j.debug("Number of columns: " + numCols);
+			out2.append("  private String InitRecordNumber=\"0\";\n");
+			for (int i = 1; i <= numCols; i++) {
+				out2.append("  public String ");
+				out2.append(TransformaNombreColumna(rsmd.getColumnLabel(i)));
+				out2.append(";\n");
+			}
+			for (Enumeration<Object> e = sql.vecFieldAdded.elements(); e
+					.hasMoreElements();) {
+				FieldAdded fieldAdded = (FieldAdded) e.nextElement();
+				out2.append("  public String ");
+				out2.append(fieldAdded.strName);
+				out2.append(";\n");
+			}
+		} catch (SQLException e) {
+			log4j.error("SQL Exception error:" + e);
+		}
+		out2.append("\n");
+		out2.append("  public String getInitRecordNumber() {\n");
+		out2.append("    return InitRecordNumber;\n");
+		out2.append("  }\n");
+		// the getField function
+		out2.append("\n");
+		out2.append("  public String getField(String fieldName) {\n");
+		try {
+			// Display column headings
+			if (log4j.isDebugEnabled())
+				log4j.debug("Number of columns in getField: " + numCols);
+			for (int i = 1; i <= numCols; i++) {
+				String columnLabel = rsmd.getColumnLabel(i);
+				String transformedColumnLabel = TransformaNombreColumna(columnLabel);
+				if (i == 1) {
+					out2.append("    if ");
+				} else {
+					out2.append("    else if ");
+				}
+				out2.append("(fieldName.equalsIgnoreCase(\"");
+				out2.append(columnLabel);
+				if (!columnLabel.equalsIgnoreCase(transformedColumnLabel))
+					out2.append("\") || fieldName.equals(\""
+							+ transformedColumnLabel);
+				out2.append("\"))\n");
+				out2.append("      return " + transformedColumnLabel + ";\n");
+			}
+			for (Enumeration<Object> e = sql.vecFieldAdded.elements(); e
+					.hasMoreElements();) {
+				FieldAdded fieldAdded = (FieldAdded) e.nextElement();
+				out2.append("    else if ");
+				out2.append("(fieldName.equals(\"");
+				out2.append(fieldAdded.strName + "\"))\n");
+				out2.append("      return " + fieldAdded.strName + ";\n");
+			}
+		} catch (SQLException e) {
+			log4j.error("SQL Exception error:" + e);
+		}
+		out2.append("   else {\n");
+		out2
+				.append("     log4j.debug(\"Field does not exist: \" + fieldName);\n");
+		out2.append("     return null;\n");
+		out2.append("   }\n");
+		out2.append(" }\n");
+	}
 
-    printHeadFunctionSql(true, boolSequence, false);
-    // Sequences
-    if (sql.strSequenceName != null) {
-      out2.append("    long keySequence = 0;\n");
-      out2.append("    String strSql1 = \"SELECT " + sql.strSequenceName);
-      out2.append(".NEXTVAL AS KEY_" + sql.strSequenceName.replace(".", "_") + " FROM DUAL\";\n");
-      out2.append("    PreparedStatement psl = null;\n");
-      out2.append("    try {\n");
-      out2.append("      psl = connectionProvider.getPreparedStatement(");
-      if (sql.sqlConnection.equals("true")) out2.append("conn, ");
-      out2.append("strSql1);\n");
-      out2.append("      ResultSet resultKey;\n");
-      out2.append("      resultKey = psl.executeQuery();\n");
-      out2.append("      if(resultKey.next()){\n");
-      out2.append("        keySequence = resultKey.getLong(\"KEY_" + sql.strSequenceName.replace(".", "_") + "\");\n");
-      out2.append("      }\n");
-      out2.append("      resultKey.close();\n");
-      out2.append("    } catch(SQLException e){\n");
-      out2.append("      log4j.error(\"SQL error in query: \" + strSql1 + \"Exception:\"+ e);\n");
-      out2.append("      throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
-      out2.append("    } catch(Exception ex){\n");
-      out2.append("      log4j.error(\"Exception in query: \" + strSql1 + \"Exception:\"+ ex);\n");
-      out2.append("      throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
-      out2.append("    } finally {\n");
-      out2.append("      try {\n");
-      if (!sql.sqlConnection.equals("true")) {
-        if (sql.sqlType.equals("statement")) out2.append("        connectionProvider.releaseStatement(psl);\n");
-        else out2.append("        connectionProvider.releasePreparedStatement(psl);\n");
-      } else {
-        if (sql.sqlType.equals("statement")) out2.append("       connectionProvider.releaseTransactionalStatement(psl);\n");
-        else if (sql.sqlType.equalsIgnoreCase("preparedstatement")) out2.append("        connectionProvider.releaseTransactionalPreparedStatement(psl);\n");
-      }
-      out2.append("      } catch(Exception ignore){\n");
-      out2.append("        ignore.printStackTrace();\n");
-      out2.append("      }\n");
-      out2.append("    }\n");
-      out2.append("\n");
-    }
+	void printTxtFile() {
+		try {
+			// Display column headings
+			if (log4j.isDebugEnabled())
+				log4j.debug("Printing txt File: " + numCols);
+			for (int i = 1; i <= numCols; i++) {
+				printWriterTxt.print(rsmd.getColumnLabel(i));
+				if (i == numCols) {
+					printWriterTxt.println("");
+				} else {
+					printWriterTxt.print(", ");
+				}
+			}
+			printWriterTxt.println("");
+			for (int i = 1; i <= numCols; i++) {
+				printWriterTxt.println("<FIELD id=\""
+						+ TransformaNombreColumna("field_"
+								+ rsmd.getColumnLabel(i)) + "\">"
+						+ TransformaNombreColumna(rsmd.getColumnLabel(i))
+						+ "</FIELD>");
+			}
+			printWriterTxt.println("");
+			for (int i = 1; i <= numCols; i++) {
+				printWriterTxt.println("      <Parameter name=\""
+						+ TransformaNombreColumna(rsmd.getColumnLabel(i))
+						+ "\"/>");
+			}
+			printWriterTxt.println("");
+			printWriterTxt.println("  " + sqlcName
+					+ " getEditVariables(VariablesSapp vars) {");
+			printWriterTxt.println("    " + sqlcName + " data = new "
+					+ sqlcName + "();");
+			for (int i = 1; i <= numCols; i++) {
+				printWriterTxt.println("    data."
+						+ TransformaNombreColumna(rsmd.getColumnLabel(i))
+						+ " = vars.getStringParameter(\""
+						+ TransformaNombreColumna("inp_"
+								+ rsmd.getColumnLabel(i)) + "\");");
+			}
+			printWriterTxt.println("    data.a1Usuario = vars.getUser();");
+			printWriterTxt.println("    data.a1Rol = vars.getRole();");
+			printWriterTxt.println("    return data;");
+			printWriterTxt.println("  }");
+		} catch (SQLException e) {
+			log4j.error("SQL Exception error:" + e);
+		}
+	}
 
-    printSQLBody();
-    printSQLParameters();
+	public void printFunctionConstant() throws IOException {
+		printHeadFunctionSql(false, false, false);
+		out2.append("    " + sqlcName + " object" + sqlcName + "[] = new "
+				+ sqlcName + "[1];\n");
+		out2
+				.append("    object" + sqlcName + "[0] = new " + sqlcName
+						+ "();\n");
+		try {
+			for (int i = 1; i <= numCols; i++) {
+				String strNameLabel = rsmd.getColumnLabel(i);
+				out2.append("    object" + sqlcName + "[0]."
+						+ TransformaNombreColumna(strNameLabel) + " = ");
+				boolean printedParameter = false;
+				for (Parameter parameter : sql.vecParameter) {
+					if (parameter.strName
+							.equals(TransformaNombreColumna(strNameLabel))
+							&& !printedParameter) {
+						out2.append(TransformaNombreColumna(strNameLabel)
+								+ ";\n");
+						printedParameter = true;
+					}
+				}
+				if (!printedParameter) {
+					out2.append("\"\";\n");
+				}
+			}
+		} catch (SQLException e) {
+			log4j.error("SQL Exception error:" + e);
+		}
+		out2.append("    return object" + sqlcName + ";\n");
+		out2.append("  }\n");
+	}
 
-    if (sql.executeType.equals("executeQuery")) {
-      out2.append("      result = st." + sql.executeType + "(");
-      if (sql.sqlType.equals("statement")) out2.append("strSql");
-      out2.append(");\n");
-      if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-        out2.append("      long countRecord = 0;\n");
-        //paging
-        out2.append("      long countRecordSkip = 1;\n");
-        out2.append("      boolean continueResult = true;\n");
-        out2.append("      while(countRecordSkip < firstRegister && continueResult) {\n");
-        out2.append("        continueResult = result.next();\n");
-        out2.append("        countRecordSkip++;\n");
-        out2.append("      }\n");
-        //paging
-        out2.append("      while(continueResult && result.next()) {\n");
-        out2.append("        countRecord++;\n");
-        out2.append("        " + sqlcName + " object" + sqlcName + " = new " + sqlcName + "();\n");
-      } else {
-        out2.append("      if(result.next()) {\n");
-      }
-      try {
-        if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
-          out2.append("        strReturn = UtilSql.getValue(result, \"" + rsmd.getColumnLabel(1) +"\");\n");
-        } else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
-          // getBoolean works different in ORACLE and PostgreSQL (2 is true for Oracle and false for PostgreSQL), 
-          // so we make the comparation here as strings with true if the result is different of 0. 
-          //out2.append("        boolReturn = result.getBoolean(\"" + rsmd.getColumnLabel(1) +"\");\n");
-          out2.append("        boolReturn = !UtilSql.getValue(result, \"" + rsmd.getColumnLabel(1) +"\").equals(\"0\");\n");
-        } else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
-          out2.append("        dateReturn = UtilSql.getDateValue(result, \"" + rsmd.getColumnLabel(1) +"\", \""+javaDateFormat+"\");\n");
-        } else {
-          for (int i=1; i<=numCols; i++) {
-            if (log4j.isDebugEnabled()) log4j.debug("Columna: " + rsmd.getColumnName(i) + " tipo: " + rsmd.getColumnType(i));
-            if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP || rsmd.getColumnType(i) == 91 ) {
-              out2.append("        object" + sqlcName + "." + TransformaNombreColumna(rsmd.getColumnLabel(i)) + " = UtilSql.getDateValue(result, \"" + rsmd.getColumnLabel(i) +"\", \""+javaDateFormat+"\");\n");
-            } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) {
-              out2.append("        object" + sqlcName + "." + TransformaNombreColumna(rsmd.getColumnLabel(i)) + " = UtilSql.getBlobValue(result, \"" + rsmd.getColumnLabel(i) +"\");\n");
-            } else {
-              out2.append("        object" + sqlcName + "." + TransformaNombreColumna(rsmd.getColumnLabel(i)) + " = UtilSql.getValue(result, \"" + rsmd.getColumnLabel(i) +"\");\n");
-            }
-          }
-          for (Enumeration<Object> e = sql.vecFieldAdded.elements() ; e.hasMoreElements() ;) {
-            FieldAdded fieldAdded = (FieldAdded)e.nextElement();
-            if (fieldAdded.strValue.equals("count"))
-              out2.append("        object" + sqlcName + "." + fieldAdded.strName + " = Long.toString(countRecord);\n");
-            else if (fieldAdded.strValue.equals("void"))
-              out2.append("        object" + sqlcName + "." + fieldAdded.strName + " = \"\";\n");
-          }
-          if(sql.sqlReturn.equalsIgnoreCase("MULTIPLE"))
-            out2.append("        object" + sqlcName + ".InitRecordNumber = Integer.toString(firstRegister);\n");
-        }
-      } catch(SQLException e){
-        log4j.error("SQL Exception error:"+ e);
-        e.printStackTrace();
-      }
-      if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-        out2.append("        vector.addElement(object" + sqlcName + ");\n");
-        //paging
-        out2.append("        if (countRecord >= numberRegisters && numberRegisters != 0) {\n");
-        out2.append("          continueResult = false;\n");
-        out2.append("        }\n");
-        //paging
-      }
-      out2.append("      }\n");
-      out2.append("      result.close();\n");
-    } else if (sql.executeType.equals("executeUpdate")) {
-      out2.append("      updateCount = st." + sql.executeType + "(");
-      if (sql.sqlType.equals("statement")) out2.append("strSql");
-      out2.append(");\n");
-    } else if (sql.executeType.equals("execute")) {
-      out2.append("      st." + sql.executeType + "();\n");
-      if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
-        for (Parameter parameter : sql.vecParameter) {
-          if (!parameter.boolSequence && parameter.strName != null) {
-            if (parameter.strInOut.equals("out") || parameter.strInOut.equals("inOut")) {
-              out2.append("      object" + sql.sqlObject + "." + parameter.strName);
-              //              out2.append(" = st.getString(" + jParameter + ");"); //", " + parameter.type+ ");");
-              //              out2.append(" = st.getString( iParameter" + parameter.strName + ");"); //", " + parameter.type+ ");");
-              out2.append("= UtilSql.getStringCallableStatement(st, iParameter" + parameter.strName + ");\n");
-            }
-          }
-        }
-      }
-    }
-    out2.append("    } catch(SQLException e){\n");
-    out2.append("      log4j.error(\"SQL error in query: \" + strSql + \"Exception:\"+ e);\n");
-    out2.append("      throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
-    out2.append("    } catch(Exception ex){\n");
-    out2.append("      log4j.error(\"Exception in query: \" + strSql + \"Exception:\"+ ex);\n");
-    out2.append("      throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
-    out2.append("    } finally {\n");
-    out2.append("      try {\n");
-    if (!sql.sqlConnection.equals("true")) {
-      if (sql.sqlType.equals("statement")) out2.append("        connectionProvider.releaseStatement(st);\n");
-      else out2.append("        connectionProvider.releasePreparedStatement(st);\n");
-    } else {
-      if (sql.sqlType.equals("statement")) out2.append("        connectionProvider.releaseTransactionalStatement(st);\n");
-      else if (sql.sqlType.equalsIgnoreCase("preparedstatement")) out2.append("        connectionProvider.releaseTransactionalPreparedStatement(st);\n");
-    }
-    out2.append("      } catch(Exception ignore){\n");
-    out2.append("        ignore.printStackTrace();\n");
-    out2.append("      }\n");
-    out2.append("    }\n");
-    if (sql.sqlType.equals("callableStatement")) {
-      out2.append("    }\n");
-      out2.append("    else {\n");
-      importJavaUtil = true;
-      out2.append("      Vector<String> parametersData = new Vector<String>();\n");
-      out2.append("      Vector<String> parametersTypes = new Vector<String>();\n");
-      int outParams = 0;
-      String outParamName = "";
-      StringBuffer paramsReceipt = new StringBuffer();
-      for (Parameter parameter : sql.vecParameter) {
-        if (!parameter.strInOut.equals("none") && !parameter.strInOut.equals("argument") && !parameter.strInOut.equals("replace")) {
-          out2.append("      parametersData.addElement(" + (parameter.strInOut.equalsIgnoreCase("out")?"\"" + parameter.strName + "\"":parameter.strName) + ");\n");
-          out2.append("      parametersTypes.addElement(\"" + parameter.strInOut + "\");\n");
-          if (parameter.strInOut.equals("out")) {
-            outParamName = parameter.strName;
-            paramsReceipt.append("      object").append(sql.sqlObject).append(".").append(outParamName).append(" = (String) vecTotal.elementAt(").append(outParams).append(");\n");
-            outParams++;
-          }
-        }
-      }
-      if (outParams>0) out2.append("      Vector<String> vecTotal = new Vector<String>();\n");
-      out2.append("      try {\n");
-      if (outParams>0) out2.append("        vecTotal = ");
-      importRDBMSIndependent = true;
-      out2.append("      RDBMSIndependent.getCallableResult(" + (sql.sqlConnection.equals("true")?"conn":"null") + ", connectionProvider, strSql, parametersData, parametersTypes, " + outParams + ");\n");
-      if (outParams>0) out2.append(paramsReceipt.toString());
-      out2.append("      } catch(SQLException e){\n");
-      out2.append("        log4j.error(\"SQL error in query: \" + strSql + \"Exception:\"+ e);\n");
-      out2.append("        throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
-      out2.append("      } catch(NoConnectionAvailableException ec){\n");
-      out2.append("        log4j.error(\"Connection error in query: \" + strSql + \"Exception:\"+ ec);\n");
-      out2.append("        throw new ServletException(\"@CODE=NoConnectionAvailable\");\n");
-      out2.append("      } catch(PoolNotFoundException ep){\n");
-      out2.append("        log4j.error(\"Pool error in query: \" + strSql + \"Exception:\"+ ep);\n");
-      out2.append("        throw new ServletException(\"@CODE=NoConnectionAvailable\");\n");
-      out2.append("      } catch(Exception ex){\n");
-      out2.append("        log4j.error(\"Exception in query: \" + strSql + \"Exception:\"+ ex);\n");
-      out2.append("        throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
-      out2.append("      }\n");
-      out2.append("    }\n");
-    }
+	public void printSQLBody() throws IOException {
+		// codigo para imprimir trozos de Sql opcionales
+		int posSQL = 0;
+		out2.append("    String strSql = \"\";\n");
+		for (Parameter parameter : sql.vecParameter) {
+			if (parameter.boolOptional) {
+				if (parameter.strAfter == null) {
+					parameter.strAfter = "WHERE";
+					parameter.strText = parameter.strName + " = ? AND";
+				}
+				if (parameter.strName != null && // se deben imprimir los
+													// repetidos, quitar:
+													// !parameter.boolRepeated
+													// &&
+						!parameter.strInOut.equals("out")) {
+					int posFinalAfter = posFinal(sql.strSQL, parameter.strAfter);
+					if (posFinalAfter != -1) {
+						imprimirSubstring(sql.strSQL, posSQL, posFinalAfter,
+								out);
+						posSQL = posFinalAfter
+								+ (parameter.strInOut.equals("replace") ? parameter.strText
+										.length()
+										: 0);
+						if (parameter.strInOut.equals("none")) {
+							out2.append("    strSql = strSql + (("
+									+ parameter.strName + ".equals(\""
+									+ parameter.strName + "\"))?\" "
+									+ parameter.strText + " \":\"\");\n");
+						} else if (parameter.strInOut.equals("argument")) {
+							out2.append("    strSql = strSql + (("
+									+ parameter.strName + "==null || "
+									+ parameter.strName
+									+ ".equals(\"\"))?\"\":\" "
+									+ parameter.strText + "\" + "
+									+ parameter.strName + ");\n");
+						} else if (parameter.strInOut.equals("replace")) {
+							out2.append("    strSql = strSql + (("
+									+ parameter.strName + "==null || "
+									+ parameter.strName
+									+ ".equals(\"\"))?\"\":"
+									+ parameter.strName + ");\n");
+						} else {
+							out2.append("    strSql = strSql + (("
+									+ parameter.strName + "==null || "
+									+ parameter.strName
+									+ ".equals(\"\"))?\"\":\" "
+									+ parameter.strText + " \");\n");
+						}
+					} else if (parameter.strInOut.equals("replace")) {
+						posFinalAfter = 0;
+						out2.append("    strSql = strSql + (("
+								+ parameter.strName + "==null || "
+								+ parameter.strName + ".equals(\"\"))?\"\":"
+								+ parameter.strName + ");\n");
+					}
+				}
+			}
+		}
+		imprimirSubstring(sql.strSQL, posSQL, sql.strSQL.length(), out);
 
-    if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-      out2.append("    " + sqlcName + " object" + sqlcName + "[] = new " + sqlcName + "[vector.size()];\n");
-      out2.append("    vector.copyInto(object" + sqlcName + ");\n");
-    }
+		out2.append("\n");
 
-    if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-      out2.append("    return(object" + sqlcName + ");\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
-      out2.append("    return(object" + sqlcName + ");\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
-      out2.append("    return(strReturn);\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
-      out2.append("    return(boolReturn);\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
-      out2.append("    return(dateReturn);\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT")) {
-      out2.append("    return(updateCount);\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
-      out2.append("    return(Long.toString(keySequence));\n");
-    } else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
-      out2.append("    return(object" + sql.sqlObject + ");\n");
-    }
-    out2.append("  }\n");
-  }
+		if (sql.executeType.equals("executeQuery")) {
+			out2.append("    ResultSet result;\n");
+		}
+		if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+			importJavaUtil = true;
+			out2
+					.append("    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
+			out2.append("    " + sqlcName + " object" + sqlcName + " = new "
+					+ sqlcName + "();\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
+			out2.append("    String strReturn = ");
+			if (sql.sqlDefaultReturn != null) {
+				out2.append("\"" + sql.sqlDefaultReturn + "\";\n");
+			} else {
+				out2.append("null;\n"); // if the return value is not specified
+										// then set to null
+			}
+		} else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
+			out2.append("    boolean boolReturn = ");
+			if (sql.sqlDefaultReturn != null) {
+				out2.append(sql.sqlDefaultReturn + ";\n");
+			} else {
+				out2.append("false;\n"); // if the return value is not specified
+											// then set to false
+			}
+		} else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
+			out2.append("    String dateReturn = ");
+			if (sql.sqlDefaultReturn != null) {
+				out2.append(sql.sqlDefaultReturn + ";\n");
+			} else {
+				out2.append("null;\n"); // if the return value is not specified
+										// then set to null
+			}
+		} else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
+			// out2.append(
+			// "    SqlRespuestaCS objectSqlRespuestaCS = new SqlRespuestaCS();"
+			// );
+			out2.append("    " + sql.sqlClass + " object" + sql.sqlObject
+					+ " = new " + sql.sqlClass + "();\n");
+		}
+		if (sql.executeType.equals("executeUpdate")) {
+			out2.append("    int updateCount = 0;\n");
+		}
 
-  public void printHeadFunctionSql(boolean printProviderConnection, boolean boolPagin, boolean boolSequence) throws IOException {
-    out2.append("\n");
-    String[] strSqlCommentsVector = stringToVector(sql.strSqlComments, false);
-    for (int i=0; i<strSqlCommentsVector.length; i++) {
-      if (i == 0) {
-        out2.append("/**\n" + strSqlCommentsVector[i] + "\n");
-      } else {
-        out2.append(" *" + strSqlCommentsVector[i] + "\n");
-      }
-      if (i == strSqlCommentsVector.length - 1) {
-        out2.append(" */\n");
-      }
-    }
-    out2.append("  public ");
-    if (sql.sqlStatic.equals("true")) {
-      out2.append("static ");
-    }
-    if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
-      out2.append(sqlcName + "[] ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
-      out2.append(sqlcName + " ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
-      out2.append("String ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
-      out2.append("boolean ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
-      out2.append("String ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
-      out2.append("String ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT")) {
-      out2.append("int ");
-    } else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
-      out2.append(sql.sqlClass + " ");
-    }
-    out2.append(sql.sqlName + "(");
-    boolean firstParameter = true;
-    if (sql.sqlConnection.equals("true")) {
-      firstParameter = false;
-      out2.append("Connection conn");
-    }
-    if (printProviderConnection) {
-      if (firstParameter) {
-        firstParameter = false;
-      } else {
-        out2.append(", ");
-      }
-      out2.append("ConnectionProvider connectionProvider");
-    }
-    if (log4j.isDebugEnabled()) log4j.debug("Parameters numbering");
-    for (Parameter parameter : sql.vecParameter) {
-      if (sql.sqlStatic.equals("true")) {
-        if (parameter.strName != null && !parameter.boolRepeated && !parameter.boolSequence && !parameter.strInOut.equals("out")) {
-          if (firstParameter) {
-            firstParameter = false;
-          } else {
-            out2.append(", ");
-          }
-          out2.append("String " + parameter.strName);
-        }
-      }
-    }
-    if (boolPagin) {  // parameters por paging the output
-      if (firstParameter) {
-        firstParameter = false;
-      } else {
-        out2.append(", ");
-      }
-      out2.append("int firstRegister, int numberRegisters");
-    } // parameters por paging the output
+		if (sql.sqlType.equals("preparedStatement")) {
+			out2.append("    PreparedStatement st = null;\n");
+		} else if (sql.sqlType.equals("statement")) {
+			out2.append("    Statement st = null;\n");
+		} else if (sql.sqlType.equals("callableStatement")) {
+			out2.append("    CallableStatement st = null;\n");
+			out2
+					.append("    if (connectionProvider.getRDBMS().equalsIgnoreCase(\"ORACLE\")) {\n");
+		}
+		out2.append("\n");
+	}
 
-    if (boolSequence) {
-      if (firstParameter) {
-        firstParameter = false;
-      } else {
-        out2.append(", ");
-      }
-      out2.append("String keyValue, String keyName, int numberRegisters");
-    }
-    out2.append(")");
-    out2.append("    throws ServletException {\n");
-  }
+	public void printSQLParameters() throws IOException {
+		StringBuffer aux = new StringBuffer();
+		boolean declareiParameter = false;
 
-  public void printCallFunctionSql(boolean printProviderConnection) throws IOException {
-    out2.append(sql.sqlName + "(");
-    boolean firstParameter = true;
-    if (sql.sqlConnection.equals("true")) {
-      firstParameter = false;
-      out2.append("conn");
-    }
-    if (printProviderConnection) {
-      if (firstParameter) {
-        firstParameter = false;
-      } else {
-        out2.append(", ");
-      }
-      out2.append("connectionProvider");
-    }
-    if (log4j.isDebugEnabled()) log4j.debug("Parameters numbering");
-    for (Parameter parameter : sql.vecParameter) {
-      if (sql.sqlStatic.equals("true")) {
-        if (parameter.strName != null && !parameter.boolRepeated && !parameter.boolSequence && !parameter.strInOut.equals("out")) {
-          if (firstParameter) {
-            firstParameter = false;
-          } else {
-            out2.append(", ");
-          }
-          out2.append(parameter.strName);
-        }
-      }
-    }
-    if (firstParameter) {
-      firstParameter = false;
-    } else {
-      out2.append(", ");
-    }
-    out2.append("0, 0");
-    out2.append(")");
-  }
+		aux.append("    try {\n");
+		if (sql.sqlType.equals("preparedStatement")) {
+			aux.append("    st = connectionProvider.getPreparedStatement(");
+			if (sql.sqlConnection.equals("true"))
+				aux.append("conn, ");
+			aux.append("strSql);\n");
+		} else if (sql.sqlType.equals("statement")) {
+			aux.append("    st = connectionProvider.getStatement(");
+			if (sql.sqlConnection.equals("true"))
+				aux.append("conn");
+			aux.append(");\n");
+		} else if (sql.sqlType.equals("callableStatement")) {
+			aux.append("      st = connectionProvider.getCallableStatement(");
+			if (sql.sqlConnection.equals("true"))
+				aux.append("conn, ");
+			aux.append("strSql);\n");
+		}
+		// set value of parameters
+		for (Parameter parameter : sql.vecParameter) {
+			if (parameter.boolSequence) {
+				declareiParameter = true;
+				aux
+						.append("      iParameter++; st.setLong(iParameter, keySequence);\n");
+			} else if (parameter.strName != null) {
+				if (parameter.strInOut.equals("out")
+						|| parameter.strInOut.equals("inOut")) {
+					declareiParameter = true;
+					aux.append("      int iParameter" + parameter.strName
+							+ " = iParameter + 1;\n");
+				}
+				if (parameter.boolOptional) {
+					aux.append("      if (" + parameter.strName
+							+ " != null && !(" + parameter.strName
+							+ ".equals(\"\"))) {\n");
+					aux.append("  ");
+				}
+				if (parameter.strInOut.equals("in")
+						|| parameter.strInOut.equals("inOut")) {
+					declareiParameter = true;
+					aux
+							.append("      iParameter++; UtilSql.setValue(st, iParameter, "
+									+ parameter.type + ", ");
+					if (parameter.strDefault == null) {
+						aux.append("null, ");
+					} else {
+						aux.append("\"" + parameter.strDefault + "\", ");
+					}
+					aux.append(parameter.strName + ");\n");
+				}
+				if (parameter.strInOut.equals("out")) {
+					declareiParameter = true;
+					aux
+							.append("      iParameter++; st.registerOutParameter(iParameter, "
+									+ parameter.type + ");\n");
+				} else if (parameter.strInOut.equals("inOut")) { // in this case
+																	// iParamter
+																	// is
+																	// increased
+																	// ;
+					declareiParameter = true;
+					aux.append("      st.registerOutParameter(iParameter, "
+							+ parameter.type + ");\n");
+				}
+				if (parameter.boolOptional) {
+					aux.append("      }\n");
+				}
+			}
+		}
 
-  public void printEndClass() throws IOException {
-    out2.append("}\n");
-  }
+		aux.append("\n");
+		if (declareiParameter)
+			out2.append("    int iParameter = 0;\n");
+		out2.append(aux.toString());
+	}
 
-  public int posFinal(String strSQL, String strPattern) {
-    int index = sql.strSQL.indexOf(strPattern);
-    if (index != -1) index = index + strPattern.length();
-    return index;
-  }
+	public void printFunctionSql() throws IOException {
+		boolean boolSequence = false;
+		// *** Call to the argument-less creation header, who calls the header
+		// with them
+		if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) { // parameters por
+															// paging the output
+															// && 1==2
+			printHeadFunctionSql(true, false, false);
+			out2.append("    return ");
+			printCallFunctionSql(true);
+			out2.append(";\n");
+			out2.append("  }\n");
+			boolSequence = true;
+		}
 
-  public void imprimirSubstring(String strSQL, int posIni, int posFin, OutputStreamWriter out) throws IOException {
-    String[] strSqlVector = stringToVector(strSQL.substring(posIni, posFin), true);
-    for (int i=0; i<strSqlVector.length; i++) {
-      if (i == 0) {
-        out2.append("    strSql = strSql + \n");
-      }
-      if (i<strSqlVector.length-1) {
-        out2.append("      \"" + strSqlVector[i] + "\" +\n");
-      } else {
-        out2.append("      \"" + strSqlVector[i] + "\";\n");
-      }
-    }
-  }
+		printHeadFunctionSql(true, boolSequence, false);
+		// Sequences
+		if (sql.strSequenceName != null) {
+			out2.append("    long keySequence = 0;\n");
+			out2.append("    String strSql1 = \"SELECT " + sql.strSequenceName);
+			out2
+					.append(".NEXTVAL AS KEY_"
+							+ sql.strSequenceName.replace(".", "_")
+							+ " FROM DUAL\";\n");
+			out2.append("    PreparedStatement psl = null;\n");
+			out2.append("    try {\n");
+			out2.append("      psl = connectionProvider.getPreparedStatement(");
+			if (sql.sqlConnection.equals("true"))
+				out2.append("conn, ");
+			out2.append("strSql1);\n");
+			out2.append("      ResultSet resultKey;\n");
+			out2.append("      resultKey = psl.executeQuery();\n");
+			out2.append("      if(resultKey.next()){\n");
+			out2.append("        keySequence = resultKey.getLong(\"KEY_"
+					+ sql.strSequenceName.replace(".", "_") + "\");\n");
+			out2.append("      }\n");
+			out2.append("      resultKey.close();\n");
+			out2.append("    } catch(SQLException e){\n");
+			out2
+					.append("      log4j.error(\"SQL error in query: \" + strSql1 + \"Exception:\"+ e);\n");
+			out2
+					.append("      throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
+			out2.append("    } catch(Exception ex){\n");
+			out2
+					.append("      log4j.error(\"Exception in query: \" + strSql1 + \"Exception:\"+ ex);\n");
+			out2
+					.append("      throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
+			out2.append("    } finally {\n");
+			out2.append("      try {\n");
+			if (!sql.sqlConnection.equals("true")) {
+				if (sql.sqlType.equals("statement"))
+					out2
+							.append("        connectionProvider.releaseStatement(psl);\n");
+				else
+					out2
+							.append("        connectionProvider.releasePreparedStatement(psl);\n");
+			} else {
+				if (sql.sqlType.equals("statement"))
+					out2
+							.append("       connectionProvider.releaseTransactionalStatement(psl);\n");
+				else if (sql.sqlType.equalsIgnoreCase("preparedstatement"))
+					out2
+							.append("        connectionProvider.releaseTransactionalPreparedStatement(psl);\n");
+			}
+			out2.append("      } catch(Exception ignore){\n");
+			out2.append("        ignore.printStackTrace();\n");
+			out2.append("      }\n");
+			out2.append("    }\n");
+			out2.append("\n");
+		}
 
-  /**
-   * Convert a string with the character 0A (10 decimal) in an array
-   * of the text separated by this character
-   **/
-  public String[] stringToVector(String strSQL, boolean suppressBlankLines) {
-    byte tab[] = {10};
-    String strTab = new String(tab);
-    Vector<String> vector = new Vector<String>();
-    if (strSQL == null) {
-      return new String[0];
-    }
-    StringTokenizer tok = new StringTokenizer(strSQL, strTab);
-    while (tok.hasMoreTokens()) {
-      String sql = tok.nextToken();
-      if (suppressBlankLines && sql.trim().equals("")) {
-        continue;
-      }
-      vector.addElement(sql);
-    }
-    String[] strSqlVector = new String[vector.size()];
-    vector.copyInto(strSqlVector);
-    return strSqlVector;
-  }
+		printSQLBody();
+		printSQLParameters();
 
-  static public String TransformaNombreColumna(String strColumn){
-    return TransformaNombreColumna(strColumn, false);
-  }
+		if (sql.executeType.equals("executeQuery")) {
+			out2.append("      result = st." + sql.executeType + "(");
+			if (sql.sqlType.equals("statement"))
+				out2.append("strSql");
+			out2.append(");\n");
+			if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+				out2.append("      long countRecord = 0;\n");
+				// paging
+				out2.append("      long countRecordSkip = 1;\n");
+				out2.append("      boolean continueResult = true;\n");
+				out2
+						.append("      while(countRecordSkip < firstRegister && continueResult) {\n");
+				out2.append("        continueResult = result.next();\n");
+				out2.append("        countRecordSkip++;\n");
+				out2.append("      }\n");
+				// paging
+				out2.append("      while(continueResult && result.next()) {\n");
+				out2.append("        countRecord++;\n");
+				out2.append("        " + sqlcName + " object" + sqlcName
+						+ " = new " + sqlcName + "();\n");
+			} else {
+				out2.append("      if(result.next()) {\n");
+			}
+			try {
+				if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
+					out2
+							.append("        strReturn = UtilSql.getValue(result, \""
+									+ rsmd.getColumnLabel(1) + "\");\n");
+				} else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
+					// getBoolean works different in ORACLE and PostgreSQL (2 is
+					// true for Oracle and false for PostgreSQL),
+					// so we make the comparation here as strings with true if
+					// the result is different of 0.
+					// out2.append("        boolReturn = result.getBoolean(\"" +
+					// rsmd.getColumnLabel(1) +"\");\n");
+					out2
+							.append("        boolReturn = !UtilSql.getValue(result, \""
+									+ rsmd.getColumnLabel(1)
+									+ "\").equals(\"0\");\n");
+				} else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
+					out2
+							.append("        dateReturn = UtilSql.getDateValue(result, \""
+									+ rsmd.getColumnLabel(1)
+									+ "\", \""
+									+ javaDateFormat + "\");\n");
+				} else {
+					for (int i = 1; i <= numCols; i++) {
+						if (log4j.isDebugEnabled())
+							log4j.debug("Columna: " + rsmd.getColumnName(i)
+									+ " tipo: " + rsmd.getColumnType(i));
+						if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP
+								|| rsmd.getColumnType(i) == 91) {
+							out2.append("        object"
+									+ sqlcName
+									+ "."
+									+ TransformaNombreColumna(rsmd
+											.getColumnLabel(i))
+									+ " = UtilSql.getDateValue(result, \""
+									+ rsmd.getColumnLabel(i) + "\", \""
+									+ javaDateFormat + "\");\n");
+						} else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) {
+							out2.append("        object"
+									+ sqlcName
+									+ "."
+									+ TransformaNombreColumna(rsmd
+											.getColumnLabel(i))
+									+ " = UtilSql.getBlobValue(result, \""
+									+ rsmd.getColumnLabel(i) + "\");\n");
+						} else {
+							out2.append("        object"
+									+ sqlcName
+									+ "."
+									+ TransformaNombreColumna(rsmd
+											.getColumnLabel(i))
+									+ " = UtilSql.getValue(result, \""
+									+ rsmd.getColumnLabel(i) + "\");\n");
+						}
+					}
+					for (Enumeration<Object> e = sql.vecFieldAdded.elements(); e
+							.hasMoreElements();) {
+						FieldAdded fieldAdded = (FieldAdded) e.nextElement();
+						if (fieldAdded.strValue.equals("count"))
+							out2.append("        object" + sqlcName + "."
+									+ fieldAdded.strName
+									+ " = Long.toString(countRecord);\n");
+						else if (fieldAdded.strValue.equals("void"))
+							out2.append("        object" + sqlcName + "."
+									+ fieldAdded.strName + " = \"\";\n");
+					}
+					if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE"))
+						out2
+								.append("        object"
+										+ sqlcName
+										+ ".InitRecordNumber = Integer.toString(firstRegister);\n");
+				}
+			} catch (SQLException e) {
+				log4j.error("SQL Exception error:" + e);
+				e.printStackTrace();
+			}
+			if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+				out2.append("        vector.addElement(object" + sqlcName
+						+ ");\n");
+				// paging
+				out2
+						.append("        if (countRecord >= numberRegisters && numberRegisters != 0) {\n");
+				out2.append("          continueResult = false;\n");
+				out2.append("        }\n");
+				// paging
+			}
+			out2.append("      }\n");
+			out2.append("      result.close();\n");
+		} else if (sql.executeType.equals("executeUpdate")) {
+			out2.append("      updateCount = st." + sql.executeType + "(");
+			if (sql.sqlType.equals("statement"))
+				out2.append("strSql");
+			out2.append(");\n");
+		} else if (sql.executeType.equals("execute")) {
+			out2.append("      st." + sql.executeType + "();\n");
+			if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
+				for (Parameter parameter : sql.vecParameter) {
+					if (!parameter.boolSequence && parameter.strName != null) {
+						if (parameter.strInOut.equals("out")
+								|| parameter.strInOut.equals("inOut")) {
+							out2.append("      object" + sql.sqlObject + "."
+									+ parameter.strName);
+							// out2.append(" = st.getString(" + jParameter +
+							// ");"); //", " + parameter.type+ ");");
+							// out2.append(" = st.getString( iParameter" +
+							// parameter.strName + ");"); //", " +
+							// parameter.type+ ");");
+							out2
+									.append("= UtilSql.getStringCallableStatement(st, iParameter"
+											+ parameter.strName + ");\n");
+						}
+					}
+				}
+			}
+		}
+		out2.append("    } catch(SQLException e){\n");
+		out2
+				.append("      log4j.error(\"SQL error in query: \" + strSql + \"Exception:\"+ e);\n");
+		out2
+				.append("      throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
+		out2.append("    } catch(Exception ex){\n");
+		out2
+				.append("      log4j.error(\"Exception in query: \" + strSql + \"Exception:\"+ ex);\n");
+		out2
+				.append("      throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
+		out2.append("    } finally {\n");
+		out2.append("      try {\n");
+		if (!sql.sqlConnection.equals("true")) {
+			if (sql.sqlType.equals("statement"))
+				out2
+						.append("        connectionProvider.releaseStatement(st);\n");
+			else
+				out2
+						.append("        connectionProvider.releasePreparedStatement(st);\n");
+		} else {
+			if (sql.sqlType.equals("statement"))
+				out2
+						.append("        connectionProvider.releaseTransactionalStatement(st);\n");
+			else if (sql.sqlType.equalsIgnoreCase("preparedstatement"))
+				out2
+						.append("        connectionProvider.releaseTransactionalPreparedStatement(st);\n");
+		}
+		out2.append("      } catch(Exception ignore){\n");
+		out2.append("        ignore.printStackTrace();\n");
+		out2.append("      }\n");
+		out2.append("    }\n");
+		if (sql.sqlType.equals("callableStatement")) {
+			out2.append("    }\n");
+			out2.append("    else {\n");
+			importJavaUtil = true;
+			out2
+					.append("      Vector<String> parametersData = new Vector<String>();\n");
+			out2
+					.append("      Vector<String> parametersTypes = new Vector<String>();\n");
+			int outParams = 0;
+			String outParamName = "";
+			StringBuffer paramsReceipt = new StringBuffer();
+			for (Parameter parameter : sql.vecParameter) {
+				if (!parameter.strInOut.equals("none")
+						&& !parameter.strInOut.equals("argument")
+						&& !parameter.strInOut.equals("replace")) {
+					out2
+							.append("      parametersData.addElement("
+									+ (parameter.strInOut
+											.equalsIgnoreCase("out") ? "\""
+											+ parameter.strName + "\""
+											: parameter.strName) + ");\n");
+					out2.append("      parametersTypes.addElement(\""
+							+ parameter.strInOut + "\");\n");
+					if (parameter.strInOut.equals("out")) {
+						outParamName = parameter.strName;
+						paramsReceipt.append("      object").append(
+								sql.sqlObject).append(".").append(outParamName)
+								.append(" = (String) vecTotal.elementAt(")
+								.append(outParams).append(");\n");
+						outParams++;
+					}
+				}
+			}
+			if (outParams > 0)
+				out2
+						.append("      Vector<String> vecTotal = new Vector<String>();\n");
+			out2.append("      try {\n");
+			if (outParams > 0)
+				out2.append("        vecTotal = ");
+			importRDBMSIndependent = true;
+			out2
+					.append("      RDBMSIndependent.getCallableResult("
+							+ (sql.sqlConnection.equals("true") ? "conn"
+									: "null")
+							+ ", connectionProvider, strSql, parametersData, parametersTypes, "
+							+ outParams + ");\n");
+			if (outParams > 0)
+				out2.append(paramsReceipt.toString());
+			out2.append("      } catch(SQLException e){\n");
+			out2
+					.append("        log4j.error(\"SQL error in query: \" + strSql + \"Exception:\"+ e);\n");
+			out2
+					.append("        throw new ServletException(\"@CODE=\" + Integer.toString(e.getErrorCode()) + \"@\" + e.getMessage());\n");
+			out2.append("      } catch(NoConnectionAvailableException ec){\n");
+			out2
+					.append("        log4j.error(\"Connection error in query: \" + strSql + \"Exception:\"+ ec);\n");
+			out2
+					.append("        throw new ServletException(\"@CODE=NoConnectionAvailable\");\n");
+			out2.append("      } catch(PoolNotFoundException ep){\n");
+			out2
+					.append("        log4j.error(\"Pool error in query: \" + strSql + \"Exception:\"+ ep);\n");
+			out2
+					.append("        throw new ServletException(\"@CODE=NoConnectionAvailable\");\n");
+			out2.append("      } catch(Exception ex){\n");
+			out2
+					.append("        log4j.error(\"Exception in query: \" + strSql + \"Exception:\"+ ex);\n");
+			out2
+					.append("        throw new ServletException(\"@CODE=@\" + ex.getMessage());\n");
+			out2.append("      }\n");
+			out2.append("    }\n");
+		}
 
-  static public String TransformaNombreFichero(String strFile){
-    return TransformaNombreColumna(strFile, true);
-  }
+		if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+			out2.append("    " + sqlcName + " object" + sqlcName + "[] = new "
+					+ sqlcName + "[vector.size()];\n");
+			out2.append("    vector.copyInto(object" + sqlcName + ");\n");
+		}
 
-  static public String TransformaNombreColumna(String strName, boolean isFile){
-    int numChars = strName.length();
-    StringBuilder result = new StringBuilder(numChars);
-    boolean underscore = false;
-    for (int i=0; i<numChars; i++){
-      char curr = strName.charAt(i);
-      if (i==0) {
-        if (isFile) {
-          result.append(Character.toUpperCase(curr));
-        } else {
-          result.append(Character.toLowerCase(curr));
-        }
-      } else {
-        if (curr == '_') underscore = true;
-        else{
-          if (underscore){
-            result.append(Character.toUpperCase(curr));
-            underscore = false;
-          } else {
-            if (isFile) {
-              result.append(curr);
-            } else {
-              result.append(Character.toLowerCase(curr));
-            }
-          }
-        }
-      }
-    }
-    return result.toString();
-  }
+		if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+			out2.append("    return(object" + sqlcName + ");\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
+			out2.append("    return(object" + sqlcName + ");\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
+			out2.append("    return(strReturn);\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
+			out2.append("    return(boolReturn);\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
+			out2.append("    return(dateReturn);\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT")) {
+			out2.append("    return(updateCount);\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
+			out2.append("    return(Long.toString(keySequence));\n");
+		} else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
+			out2.append("    return(object" + sql.sqlObject + ");\n");
+		}
+		out2.append("  }\n");
+	}
 
-  public void readProperties(String strFileProperties) {
-    //  Read properties file.
-    Properties properties = new Properties();
-    try {
-      log4j.info("strFileProperties: " + strFileProperties);
-      properties.load(new FileInputStream(strFileProperties));
-      javaDateFormat = properties.getProperty("dateFormat.java");
-      log4j.info("javaDateFormat: " + javaDateFormat);
-    } catch (IOException e) { 
-      // catch possible io errors from readLine()
-      e.printStackTrace();
-    }
-  }
-  }
+	public void printHeadFunctionSql(boolean printProviderConnection,
+			boolean boolPagin, boolean boolSequence) throws IOException {
+		out2.append("\n");
+		String[] strSqlCommentsVector = stringToVector(sql.strSqlComments,
+				false);
+		for (int i = 0; i < strSqlCommentsVector.length; i++) {
+			if (i == 0) {
+				out2.append("/**\n" + strSqlCommentsVector[i] + "\n");
+			} else {
+				out2.append(" *" + strSqlCommentsVector[i] + "\n");
+			}
+			if (i == strSqlCommentsVector.length - 1) {
+				out2.append(" */\n");
+			}
+		}
+		out2.append("  public ");
+		if (sql.sqlStatic.equals("true")) {
+			out2.append("static ");
+		}
+		if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
+			out2.append(sqlcName + "[] ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
+			out2.append(sqlcName + " ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
+			out2.append("String ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("BOOLEAN")) {
+			out2.append("boolean ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("DATE")) {
+			out2.append("String ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("SEQUENCE")) {
+			out2.append("String ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("ROWCOUNT")) {
+			out2.append("int ");
+		} else if (sql.sqlReturn.equalsIgnoreCase("OBJECT")) {
+			out2.append(sql.sqlClass + " ");
+		}
+		out2.append(sql.sqlName + "(");
+		boolean firstParameter = true;
+		if (sql.sqlConnection.equals("true")) {
+			firstParameter = false;
+			out2.append("Connection conn");
+		}
+		if (printProviderConnection) {
+			if (firstParameter) {
+				firstParameter = false;
+			} else {
+				out2.append(", ");
+			}
+			out2.append("ConnectionProvider connectionProvider");
+		}
+		if (log4j.isDebugEnabled())
+			log4j.debug("Parameters numbering");
+		for (Parameter parameter : sql.vecParameter) {
+			if (sql.sqlStatic.equals("true")) {
+				if (parameter.strName != null && !parameter.boolRepeated
+						&& !parameter.boolSequence
+						&& !parameter.strInOut.equals("out")) {
+					if (firstParameter) {
+						firstParameter = false;
+					} else {
+						out2.append(", ");
+					}
+					out2.append("String " + parameter.strName);
+				}
+			}
+		}
+		if (boolPagin) { // parameters por paging the output
+			if (firstParameter) {
+				firstParameter = false;
+			} else {
+				out2.append(", ");
+			}
+			out2.append("int firstRegister, int numberRegisters");
+		} // parameters por paging the output
 
+		if (boolSequence) {
+			if (firstParameter) {
+				firstParameter = false;
+			} else {
+				out2.append(", ");
+			}
+			out2.append("String keyValue, String keyName, int numberRegisters");
+		}
+		out2.append(")");
+		out2.append("    throws ServletException {\n");
+	}
 
-  /*
-   *- names from Oracle to Java
-   *- distintos type="preparedStatement, callableStatement, statement" 
-   - treat statement
-   *- distintos return="string, boolean, void, single(?), multiple" >
-   *- inserts and updates with their return values
-   *- parameters in sequences: sequence="nombreSecuencia"
-   *-      <parameter type="Long" name="strExpediente" default="0" inOut="in, out, inout">
-   No        valor
-   *      </parameter>
-   *- function names
-   *- convert the SQL chain in various lines: strSql = strSql + " " the linebreak character is 0A (10 decimal)
-   *- write commentaries to the functions and classes
-   *- read type 
-   *- read sequence in parameters
-   - read connection parameters of getConnection
-   *- return value when it is the value of a sequence
-   - commentaries for the parameters
-   *- do not write repeated parameters
-   */
+	public void printCallFunctionSql(boolean printProviderConnection)
+			throws IOException {
+		out2.append(sql.sqlName + "(");
+		boolean firstParameter = true;
+		if (sql.sqlConnection.equals("true")) {
+			firstParameter = false;
+			out2.append("conn");
+		}
+		if (printProviderConnection) {
+			if (firstParameter) {
+				firstParameter = false;
+			} else {
+				out2.append(", ");
+			}
+			out2.append("connectionProvider");
+		}
+		if (log4j.isDebugEnabled())
+			log4j.debug("Parameters numbering");
+		for (Parameter parameter : sql.vecParameter) {
+			if (sql.sqlStatic.equals("true")) {
+				if (parameter.strName != null && !parameter.boolRepeated
+						&& !parameter.boolSequence
+						&& !parameter.strInOut.equals("out")) {
+					if (firstParameter) {
+						firstParameter = false;
+					} else {
+						out2.append(", ");
+					}
+					out2.append(parameter.strName);
+				}
+			}
+		}
+		if (firstParameter) {
+			firstParameter = false;
+		} else {
+			out2.append(", ");
+		}
+		out2.append("0, 0");
+		out2.append(")");
+	}
+
+	public void printEndClass() throws IOException {
+		out2.append("}\n");
+	}
+
+	public int posFinal(String strSQL, String strPattern) {
+		int index = sql.strSQL.indexOf(strPattern);
+		if (index != -1)
+			index = index + strPattern.length();
+		return index;
+	}
+
+	public void imprimirSubstring(String strSQL, int posIni, int posFin,
+			OutputStreamWriter out) throws IOException {
+		String[] strSqlVector = stringToVector(
+				strSQL.substring(posIni, posFin), true);
+		for (int i = 0; i < strSqlVector.length; i++) {
+			if (i == 0) {
+				out2.append("    strSql = strSql + \n");
+			}
+			if (i < strSqlVector.length - 1) {
+				out2.append("      \"" + strSqlVector[i] + "\" +\n");
+			} else {
+				out2.append("      \"" + strSqlVector[i] + "\";\n");
+			}
+		}
+	}
+
+	/**
+	 * Convert a string with the character 0A (10 decimal) in an array of the
+	 * text separated by this character
+	 **/
+	public String[] stringToVector(String strSQL, boolean suppressBlankLines) {
+		byte tab[] = { 10 };
+		String strTab = new String(tab);
+		Vector<String> vector = new Vector<String>();
+		if (strSQL == null) {
+			return new String[0];
+		}
+		StringTokenizer tok = new StringTokenizer(strSQL, strTab);
+		while (tok.hasMoreTokens()) {
+			String sql = tok.nextToken();
+			if (suppressBlankLines && sql.trim().equals("")) {
+				continue;
+			}
+			vector.addElement(sql);
+		}
+		String[] strSqlVector = new String[vector.size()];
+		vector.copyInto(strSqlVector);
+		return strSqlVector;
+	}
+
+	static public String TransformaNombreColumna(String strColumn) {
+		return TransformaNombreColumna(strColumn, false);
+	}
+
+	static public String TransformaNombreFichero(String strFile) {
+		return TransformaNombreColumna(strFile, true);
+	}
+
+	static public String TransformaNombreColumna(String strName, boolean isFile) {
+		int numChars = strName.length();
+		StringBuilder result = new StringBuilder(numChars);
+		boolean underscore = false;
+		for (int i = 0; i < numChars; i++) {
+			char curr = strName.charAt(i);
+			if (i == 0) {
+				if (isFile) {
+					result.append(Character.toUpperCase(curr));
+				} else {
+					result.append(Character.toLowerCase(curr));
+				}
+			} else {
+				if (curr == '_')
+					underscore = true;
+				else {
+					if (underscore) {
+						result.append(Character.toUpperCase(curr));
+						underscore = false;
+					} else {
+						if (isFile) {
+							result.append(curr);
+						} else {
+							result.append(Character.toLowerCase(curr));
+						}
+					}
+				}
+			}
+		}
+		return result.toString();
+	}
+
+	public void readProperties(String strFileProperties) {
+		// Read properties file.
+		Properties properties = new Properties();
+		try {
+			log4j.info("strFileProperties: " + strFileProperties);
+			properties.load(new FileInputStream(strFileProperties));
+			javaDateFormat = properties.getProperty("dateFormat.java");
+			log4j.info("javaDateFormat: " + javaDateFormat);
+		} catch (IOException e) {
+			// catch possible io errors from readLine()
+			e.printStackTrace();
+		}
+	}
+}
+
+/*
+ * - names from Oracle to Java- distintos
+ * type="preparedStatement, callableStatement, statement" - treat statement-
+ * distintos return="string, boolean, void, single(?), multiple" >- inserts and
+ * updates with their return values- parameters in sequences:
+ * sequence="nombreSecuencia"- <parameter type="Long" name="strExpediente"
+ * default="0" inOut="in, out, inout"> No valor </parameter>- function names-
+ * convert the SQL chain in various lines: strSql = strSql + " " the linebreak
+ * character is 0A (10 decimal)- write commentaries to the functions and classes
+ * - read type- read sequence in parameters - read connection parameters of
+ * getConnection- return value when it is the value of a sequence - commentaries
+ * for the parameters- do not write repeated parameters
+ */
--- a/src-core/src/org/openbravo/database/CPStandAlone.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/database/CPStandAlone.java	Wed Nov 12 13:14:11 2008 +0000
@@ -130,4 +130,8 @@
     } catch (Exception ex) {
     }
   }
+  public String getStatus() {
+    // TODO Auto-generated method stub
+    return null;
+  }
 }
--- a/src-core/src/org/openbravo/database/ConnectionProvider.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/database/ConnectionProvider.java	Wed Nov 12 13:14:11 2008 +0000
@@ -34,4 +34,6 @@
   public CallableStatement getCallableStatement(String strSql) throws Exception;
   public CallableStatement getCallableStatement(Connection conn, String strSql) throws SQLException;
   public void releaseCallableStatement(CallableStatement callableStatement) throws SQLException;
+  public void destroy() throws Exception;
+  public String getStatus();
 }
--- a/src-core/src/org/openbravo/database/ConnectionProviderImpl.java	Wed Nov 12 12:36:56 2008 +0000
+++ b/src-core/src/org/openbravo/database/ConnectionProviderImpl.java	Wed Nov 12 13:14:11 2008 +0000
@@ -8,345 +8,421 @@
  * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
  * specific language governing permissions and limitations under the License.
  ************************************************************************************
-*/
+ */
 package org.openbravo.database;
 
-import org.apache.log4j.Logger;
-import org.apache.commons.pool.ObjectPool;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
 import org.apache.commons.dbcp.ConnectionFactory;
 import org.apache.commons.dbcp.PoolableConnectionFactory;
+import org.apache.commons.dbcp.PoolingDriver;
 import org.apache.commons.pool.KeyedObjectPoolFactory;
+import org.apache.commons.pool.ObjectPool;
+import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.commons.pool.impl.StackKeyedObjectPoolFactory;
-import org.apache.commons.pool.impl.GenericObjectPool;
-import org.apache.commons.dbcp.PoolingDriver;
-import org.openbravo.exception.*;
-
-import java.sql.*;
-import java.util.Properties;
-import java.io.*;
-
+import org.apache.log4j.Logger;
+import org.openbravo.exception.NoConnectionAvailableException;
+import org.openbravo.exception.PoolNotFoundException;
 
 public class ConnectionProviderImpl implements ConnectionProvider {
-  static Logger log4j = Logger.getLogger(ConnectionProviderImpl.class);
-  String defaultPoolName = "";
-  String bbdd = "";
-  String rdbms = "";
-  String contextName = "openbravo";
+    static Logger log4j = Logger.getLogger(ConnectionProviderImpl.class);
+    String defaultPoolName = "";
+    String bbdd = "";
+    String rdbms = "";
+    String contextName = "openbravo";
 
-  public ConnectionProviderImpl (String file) throws PoolNotFoundException {
-    this(file, false, "openbravo");
-  }
-
-  public ConnectionProviderImpl (String file, String _context) throws PoolNotFoundException {
-    this(file, false, _context);
-  }
-
-
-  public ConnectionProviderImpl (String file, boolean isRelative, String _context) throws PoolNotFoundException {
-    create(file, isRelative, _context);
-  }
-
-  private void create(String file, boolean isRelative, String _context) throws PoolNotFoundException {
-    if (log4j.isDebugEnabled()) log4j.debug("Creating ConnectionProviderImpl");
-    if (_context!=null && !_context.equals("")) contextName = _context;
-
-    String poolName = null;
-    String dbDriver = null;
-    String dbServer = null;
-    String dbLogin = null;
-    String dbPassword = null;
-    int minConns = 1;
-    int maxConns = 10;
-    double maxConnTime = 0.5;
-    String dbSessionConfig = null;
-    String rdbms = null;
-
-    Properties properties = new Properties();
-    try {
-      properties.load(new FileInputStream(file));
-      poolName = properties.getProperty("bbdd.poolName","myPool");
-      dbDriver = properties.getProperty("bbdd.driver");
-      dbServer = properties.getProperty("bbdd.url");
-      dbLogin = properties.getProperty("bbdd.user");
-      dbPassword = properties.getProperty("bbdd.password");
-      minConns = new Integer(properties.getProperty("bbdd.minConns","1"));
-      maxConns = new Integer(properties.getProperty("bbdd.maxConns","10"));
-      maxConnTime = new Double(properties.getProperty("maxConnTime","0.5"));
-      dbSessionConfig = properties.getProperty("bbdd.sessionConfig");
-      rdbms = properties.getProperty("bbdd.rdbms");
-      if (rdbms.equalsIgnoreCase("POSTGRE"))
-        dbServer += "/"+properties.getProperty("bbdd.sid");
-    } catch (IOException e) {
-     e.printStackTrace();
+    public ConnectionProviderImpl(String file) throws PoolNotFoundException {
+	this(file, false, "openbravo");
     }
 
-    if (log4j.isDebugEnabled()) {
-      log4j.debug("poolName: " + poolName);
-      log4j.debug("dbDriver: " + dbDriver);
-      log4j.debug("dbServer: " + dbServer);
-      log4j.debug("dbLogin: " + dbLogin);
-      log4j.debug("dbPassword: " + dbPassword);
-      log4j.debug("minConns: " + minConns);
-      log4j.debug("maxConns: " + maxConns);
-      log4j.debug("maxConnTime: " + Double.toString(maxConnTime));
-      log4j.debug("dbSessionConfig: " + dbSessionConfig);
-      log4j.debug("rdbms: " + rdbms);
+    public ConnectionProviderImpl(String file, String _context)
+	    throws PoolNotFoundException {
+	this(file, false, _context);
     }
 
-    try {
-        addNewPool(dbDriver,dbServer,dbLogin,dbPassword, minConns,maxConns,maxConnTime,dbSessionConfig, rdbms, poolName);
-    }catch (Exception e) {
-      log4j.error(e);
-      throw new PoolNotFoundException("Failed when creating database connections pool");
+    public ConnectionProviderImpl(String file, boolean isRelative,
+	    String _context) throws PoolNotFoundException {
+	create(file, isRelative, _context);
     }
-  }
 
-  public void destroy(String name) throws Exception {
-    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
-    driver.closePool(name);
-  }
+    private void create(String file, boolean isRelative, String _context)
+	    throws PoolNotFoundException {
+	if (log4j.isDebugEnabled())
+	    log4j.debug("Creating ConnectionProviderImpl");
+	if (_context != null && !_context.equals(""))
+	    contextName = _context;
 
-  public void reload(String file, boolean isRelative, String _context) throws Exception {
-      destroy();
-      create(file, isRelative, _context);
-  }
+	String poolName = null;
+	String dbDriver = null;
+	String dbServer = null;
+	String dbLogin = null;
+	String dbPassword = null;
+	int minConns = 1;
+	int maxConns = 10;
+	double maxConnTime = 0.5;
+	String dbSessionConfig = null;
+	String rdbms = null;
 
-  public void destroy() throws Exception {
-    destroy(defaultPoolName);
-  }
+	Properties properties = new Properties();
+	try {
+	    properties.load(new FileInputStream(file));
+	    poolName = properties.getProperty("bbdd.poolName", "myPool");
+	    dbDriver = properties.getProperty("bbdd.driver");
+	    dbServer = properties.getProperty("bbdd.url");
+	    dbLogin = properties.getProperty("bbdd.user");
+	    dbPassword = properties.getProperty("bbdd.password");
+	    minConns = new Integer(properties.getProperty("bbdd.minConns", "1"));
+	    maxConns = new Integer(properties
+		    .getProperty("bbdd.maxConns", "10"));
+	    maxConnTime = new Double(properties.getProperty("maxConnTime",
+		    "0.5"));
+	    dbSessionConfig = properties.getProperty("bbdd.sessionConfig");
+	    rdbms = properties.getProperty("bbdd.rdbms");
+	    if (rdbms.equalsIgnoreCase("POSTGRE"))
+		dbServer += "/" + properties.getProperty("bbdd.sid");
+	} catch (IOException e) {
+	    e.printStackTrace();
+	}
 
-  public void addNewPool(String dbDriver, String dbServer, String dbLogin, String dbPassword, int minConns, int maxConns, double maxConnTime, String dbSessionConfig, String rdbms, String name) throws Exception {
-    if (log4j.isDebugEnabled()) log4j.debug("Loading underlying JDBC driver.");
-    try {
-      Class.forName(dbDriver);
-    } catch (ClassNotFoundException e) {
-      throw new Exception(e);
+	if (log4j.isDebugEnabled()) {
+	    log4j.debug("poolName: " + poolName);
+	    log4j.debug("dbDriver: " + dbDriver);
+	    log4j.debug("dbServer: " + dbServer);
+	    log4j.debug("dbLogin: " + dbLogin);
+	    log4j.debug("dbPassword: " + dbPassword);
+	    log4j.debug("minConns: " + minConns);
+	    log4j.debug("maxConns: " + maxConns);
+	    log4j.debug("maxConnTime: " + Double.toString(maxConnTime));
+	    log4j.debug("dbSessionConfig: " + dbSessionConfig);
+	    log4j.debug("rdbms: " + rdbms);
+	}
+
+	try {
+	    addNewPool(dbDriver, dbServer, dbLogin, dbPassword, minConns,
+		    maxConns, maxConnTime, dbSessionConfig, rdbms, poolName);
+	} catch (Exception e) {
+	    log4j.error(e);
+	    throw new PoolNotFoundException(
+		    "Failed when creating database connections pool", e);
+	}
     }
-    if (log4j.isDebugEnabled()) log4j.debug("Done.");
 
+    public void destroy(String name) throws Exception {
+	PoolingDriver driver = (PoolingDriver) DriverManager
+		.getDriver("jdbc:apache:commons:dbcp:");
+	driver.closePool(name);
+    }
 
-    GenericObjectPool connectionPool = new GenericObjectPool(null);
-    connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
-    connectionPool.setMaxActive(maxConns);
-    connectionPool.setTestOnBorrow(false);
-    connectionPool.setTestOnReturn(false);
-    connectionPool.setTestWhileIdle(false);
+    public void reload(String file, boolean isRelative, String _context)
+	    throws Exception {
+	destroy();
+	create(file, isRelative, _context);
+    }
 
-    KeyedObjectPoolFactory keyedObject = new StackKeyedObjectPoolFactory();
-    ConnectionFactory connectionFactory = new OpenbravoDriverManagerConnectionFactory(dbServer, dbLogin, dbPassword, dbSessionConfig);
-    @SuppressWarnings("unused") //required by dbcp
-	PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,keyedObject,null,false,true);
+    public void destroy() throws Exception {
+	destroy(defaultPoolName);
+    }
 
-    Class.forName("org.apache.commons.dbcp.PoolingDriver");
-    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
-    driver.registerPool(contextName + "_" + name, connectionPool);
+    public void addNewPool(String dbDriver, String dbServer, String dbLogin,
+	    String dbPassword, int minConns, int maxConns, double maxConnTime,
+	    String dbSessionConfig, String rdbms, String name) throws Exception {
+	if (log4j.isDebugEnabled())
+	    log4j.debug("Loading underlying JDBC driver.");
+	try {
+	    Class.forName(dbDriver);
+	} catch (ClassNotFoundException e) {
+	    throw new Exception(e);
+	}
+	if (log4j.isDebugEnabled())
+	    log4j.debug("Done.");
 
-    if (this.defaultPoolName==null || this.defaultPoolName.equals("")) {
-      this.defaultPoolName = name;
-      this.bbdd = dbServer;
-      this.rdbms = rdbms;
+	GenericObjectPool connectionPool = new GenericObjectPool(null);
+	connectionPool
+		.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
+	connectionPool.setMaxActive(maxConns);
+	connectionPool.setTestOnBorrow(false);
+	connectionPool.setTestOnReturn(false);
+	connectionPool.setTestWhileIdle(false);
+
+	KeyedObjectPoolFactory keyedObject = new StackKeyedObjectPoolFactory();
+	ConnectionFactory connectionFactory = new OpenbravoDriverManagerConnectionFactory(
+		dbServer, dbLogin, dbPassword, dbSessionConfig);
+	@SuppressWarnings("unused")
+	// required by dbcp
+	PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
+		connectionFactory, connectionPool, keyedObject, null, false,
+		true);
+
+	Class.forName("org.apache.commons.dbcp.PoolingDriver");
+	PoolingDriver driver = (PoolingDriver) DriverManager
+		.getDriver("jdbc:apache:commons:dbcp:");
+	driver.registerPool(contextName + "_" + name, connectionPool);
+
+	if (this.defaultPoolName == null || this.defaultPoolName.equals("")) {
+	    this.defaultPoolName = name;
+	    this.bbdd = dbServer;
+	    this.rdbms = rdbms;
+	}
     }
-  }
 
-  public ObjectPool getPool(String poolName) throws PoolNotFoundException {
-    if (poolName==null || poolName.equals("")) throw new PoolNotFoundException("Couldn´t get an unnamed pool");
-    ObjectPool connectionPool = null;
-    try {
-      PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
-      connectionPool = driver.getConnectionPool(contextName + "_" + poolName);
-    } catch (SQLException ex) {
-      log4j.error(ex);
+    public ObjectPool getPool(String poolName) throws PoolNotFoundException {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException("Couldn´t get an unnamed pool");
+	ObjectPool connectionPool = null;
+	try {
+	    PoolingDriver driver = (PoolingDriver) DriverManager
+		    .getDriver("jdbc:apache:commons:dbcp:");
+	    connectionPool = driver.getConnectionPool(contextName + "_"
+		    + poolName);
+	} catch (SQLException ex) {
+	    log4j.error(ex);
+	}
+	if (connectionPool == null)
+	    throw new PoolNotFoundException(poolName + " not found");
+	else
+	    return connectionPool;
     }
-    if (connectionPool == null)
-      throw new PoolNotFoundException(poolName + " not found");
-    else
-      return connectionPool;
-  }
 
-  public ObjectPool getPool() throws PoolNotFoundException {
-    return getPool(defaultPoolName);
-  }
+    public ObjectPool getPool() throws PoolNotFoundException {
+	return getPool(defaultPoolName);
+    }
 
-  public Connection getConnection() throws NoConnectionAvailableException {
-    return getConnection(defaultPoolName);
-  }
+    public Connection getConnection() throws NoConnectionAvailableException {
+	return getConnection(defaultPoolName);
+    }
 
-  public Connection getConnection(String poolName) throws NoConnectionAvailableException {
-    if (poolName==null || poolName.equals("")) throw new NoConnectionAvailableException("Couldn´t get a connection for an unnamed pool");
-    Connection conn=null;
-    try {
-      conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:" + contextName + "_" + poolName);
-    } catch (SQLException ex) {
-      log4j.error(ex);
-      throw new NoConnectionAvailableException("There are no connections available in jdbc:apache:commons:dbcp:" + contextName + "_" + poolName);
+    public Connection getConnection(String poolName)
+	    throws NoConnectionAvailableException {
+	if (poolName == null || poolName.equals(""))
+	    throw new NoConnectionAvailableException(
+		    "Couldn´t get a connection for an unnamed pool");
+	Connection conn = null;
+	try {
+	    conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:"
+		    + contextName + "_" + poolName);
+	} catch (SQLException ex) {
+	    log4j.error(ex);
+	    throw new NoConnectionAvailableException(
+		    "There are no connections available in jdbc:apache:commons:dbcp:"
+			    + contextName + "_" + poolName);
+	}
+	return conn;
     }
-    return conn;
-  }
 
-  public String getRDBMS() {
-    return rdbms;
-  }
+    public String getRDBMS() {
+	return rdbms;
+    }
 
-  public boolean releaseConnection(Connection conn) {
-    if (conn==null) return false;
-    try {
-      conn.setAutoCommit(true);
-      conn.close();
-    } catch (Exception ex) {
-      ex.printStackTrace();
-      return false;
+    public boolean releaseConnection(Connection conn) {
+	if (conn == null)
+	    return false;
+	try {
+	    conn.setAutoCommit(true);
+	    conn.close();
+	} catch (Exception ex) {
+	    ex.printStackTrace();
+	    return false;
+	}
+	return true;
     }
-    return true;
-  }
 
-  public Connection getTransactionConnection() throws NoConnectionAvailableException, SQLException {
-    Connection conn = getConnection();
-    if (conn==null) throw new NoConnectionAvailableException("Couldn´t get an available connection");
-    conn.setAutoCommit(false);
-    return conn;
-  }
+    public Connection getTransactionConnection()
+	    throws NoConnectionAvailableException, SQLException {
+	Connection conn = getConnection();
+	if (conn == null)
+	    throw new NoConnectionAvailableException(
+		    "Couldn´t get an available connection");
+	conn.setAutoCommit(false);
+	return conn;
+    }
 
-  public void releaseCommitConnection(Connection conn) throws SQLException {
-    if (conn==null) return;
-    conn.commit();
-    releaseConnection(conn);
-  }
+    public void releaseCommitConnection(Connection conn) throws SQLException {
+	if (conn == null)
+	    return;
+	conn.commit();
+	releaseConnection(conn);
+    }
 
-  public void releaseRollbackConnection(Connection conn) throws SQLException {
-    if (conn==null) return;
-    conn.rollback();
-    releaseConnection(conn);
-  }
+    public void releaseRollbackConnection(Connection conn) throws SQLException {
+	if (conn == null)
+	    return;
+	conn.rollback();
+	releaseConnection(conn);
+    }
 
-  public PreparedStatement getPreparedStatement(String SQLPreparedStatement) throws Exception {
-    return getPreparedStatement(defaultPoolName, SQLPreparedStatement);
-  }
+    public PreparedStatement getPreparedStatement(String SQLPreparedStatement)
+	    throws Exception {
+	return getPreparedStatement(defaultPoolName, SQLPreparedStatement);
+    }
 
-  public PreparedStatement getPreparedStatement(String poolName, String SQLPreparedStatement) throws Exception {
-    if (poolName == null || poolName.equals("")) throw new PoolNotFoundException("Can't get the pool. No pool name specified");
-    if (log4j.isDebugEnabled()) log4j.debug("connection requested");
-    Connection conn = getConnection(poolName);
-    if (log4j.isDebugEnabled()) log4j.debug("connection established");
-    return getPreparedStatement(conn, SQLPreparedStatement);
-  }
+    public PreparedStatement getPreparedStatement(String poolName,
+	    String SQLPreparedStatement) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	if (log4j.isDebugEnabled())
+	    log4j.debug("connection requested");
+	Connection conn = getConnection(poolName);
+	if (log4j.isDebugEnabled())
+	    log4j.debug("connection established");
+	return getPreparedStatement(conn, SQLPreparedStatement);
+    }
 
-  public PreparedStatement getPreparedStatement(Connection conn, String SQLPreparedStatement) throws SQLException {
-    if (conn == null || SQLPreparedStatement==null || SQLPreparedStatement.equals("")) return null;
-    PreparedStatement ps = null;
-    try {
-      if (log4j.isDebugEnabled()) log4j.debug("preparedStatement requested");
-      ps = conn.prepareStatement(SQLPreparedStatement, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
-      if (log4j.isDebugEnabled()) log4j.debug("preparedStatement received");
-    } catch(SQLException e) {
-      log4j.error("getPreparedStatement: " + SQLPreparedStatement + "\n" + e);
-      releaseConnection(conn);
-      throw e;
+    public PreparedStatement getPreparedStatement(Connection conn,
+	    String SQLPreparedStatement) throws SQLException {
+	if (conn == null || SQLPreparedStatement == null
+		|| SQLPreparedStatement.equals(""))
+	    return null;
+	PreparedStatement ps = null;
+	try {
+	    if (log4j.isDebugEnabled())
+		log4j.debug("preparedStatement requested");
+	    ps = conn.prepareStatement(SQLPreparedStatement,
+		    ResultSet.TYPE_SCROLL_INSENSITIVE,
+		    ResultSet.CONCUR_READ_ONLY);
+	    if (log4j.isDebugEnabled())
+		log4j.debug("preparedStatement received");
+	} catch (SQLException e) {
+	    log4j.error("getPreparedStatement: " + SQLPreparedStatement + "\n"
+		    + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
+	return (ps);
     }
-    return(ps);
-  }
 
-  public CallableStatement getCallableStatement(String SQLCallableStatement) throws Exception {
-    return getCallableStatement(defaultPoolName, SQLCallableStatement);
-  }
+    public CallableStatement getCallableStatement(String SQLCallableStatement)
+	    throws Exception {
+	return getCallableStatement(defaultPoolName, SQLCallableStatement);
+    }
 
-  public CallableStatement getCallableStatement(String poolName, String SQLCallableStatement) throws Exception {
-    if (poolName == null || poolName.equals("")) throw new PoolNotFoundException("Can't get the pool. No pool name specified");
-    Connection conn = getConnection(poolName);
-    return getCallableStatement(conn, SQLCallableStatement);
-  }
+    public CallableStatement getCallableStatement(String poolName,
+	    String SQLCallableStatement) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	Connection conn = getConnection(poolName);
+	return getCallableStatement(conn, SQLCallableStatement);
+    }
 
-  public CallableStatement getCallableStatement(Connection conn, String SQLCallableStatement) throws SQLException {
-    if (conn==null || SQLCallableStatement==null || SQLCallableStatement.equals("")) return null;
-    CallableStatement cs = null;
-    try {
-      cs = conn.prepareCall(SQLCallableStatement);
-    } catch(SQLException e) {
-      log4j.error("getCallableStatement: " + SQLCallableStatement + "\n" + e);
-      releaseConnection(conn);
-      throw e;
+    public CallableStatement getCallableStatement(Connection conn,
+	    String SQLCallableStatement) throws SQLException {
+	if (conn == null || SQLCallableStatement == null
+		|| SQLCallableStatement.equals(""))
+	    return null;
+	CallableStatement cs = null;
+	try {
+	    cs = conn.prepareCall(SQLCallableStatement);
+	} catch (SQLException e) {
+	    log4j.error("getCallableStatement: " + SQLCallableStatement + "\n"
+		    + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
+	return (cs);
     }
-    return(cs);
-  }
 
-  public Statement getStatement() throws Exception {
-    return getStatement(defaultPoolName);
-  }
+    public Statement getStatement() throws Exception {
+	return getStatement(defaultPoolName);
+    }
 
-  public Statement getStatement(String poolName) throws Exception {
-    if (poolName == null || poolName.equals("")) throw new PoolNotFoundException("Can't get the pool. No pool name specified");
-    Connection conn = getConnection(poolName);
-    return getStatement(conn);
-  }
+    public Statement getStatement(String poolName) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	Connection conn = getConnection(poolName);
+	return getStatement(conn);
+    }
 
-  public Statement getStatement(Connection conn) throws SQLException {
-    if (conn == null) return null;
-    try {
-      return(conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY));
-    } catch(SQLException e) {
-      log4j.error("getStatement: " + e);
-      releaseConnection(conn);
-      throw e;
+    public Statement getStatement(Connection conn) throws SQLException {
+	if (conn == null)
+	    return null;
+	try {
+	    return (conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+		    ResultSet.CONCUR_READ_ONLY));
+	} catch (SQLException e) {
+	    log4j.error("getStatement: " + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
     }
-  }
 
-  public void releasePreparedStatement(PreparedStatement preparedStatement) throws SQLException {
-    if (preparedStatement == null) return;
-    Connection conn = null;
-    try {
-      conn = preparedStatement.getConnection();
-      preparedStatement.close();
-      releaseConnection(conn);
-    } catch (SQLException e) {
-      log4j.error("releasePreparedStatement: " + e);
-      releaseConnection(conn);
-      throw e;
+    public void releasePreparedStatement(PreparedStatement preparedStatement)
+	    throws SQLException {
+	if (preparedStatement == null)
+	    return;
+	Connection conn = null;
+	try {
+	    conn = preparedStatement.getConnection();
+	    preparedStatement.close();
+	    releaseConnection(conn);
+	} catch (SQLException e) {
+	    log4j.error("releasePreparedStatement: " + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
     }
-  }
 
-  public void releaseCallableStatement(CallableStatement callableStatement) throws SQLException {
-    if (callableStatement == null) return;
-    Connection conn = null;
-    try {
-      conn = callableStatement.getConnection();
-      callableStatement.close();
-      releaseConnection(conn);
-    } catch (SQLException e) {
-      log4j.error("releaseCallableStatement: " + e);
-      releaseConnection(conn);
-      throw e;
+    public void releaseCallableStatement(CallableStatement callableStatement)
+	    throws SQLException {
+	if (callableStatement == null)
+	    return;
+	Connection conn = null;
+	try {
+	    conn = callableStatement.getConnection();
+	    callableStatement.close();
+	    releaseConnection(conn);
+	} catch (SQLException e) {
+	    log4j.error("releaseCallableStatement: " + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
     }
-  }
 
-  public void releaseStatement(Statement statement) throws SQLException {
-    if (statement == null) return;
-    Connection conn = null;
-    try {
-      conn = statement.getConnection();
-      statement.close();
-      releaseConnection(conn);
-    } catch (SQLException e) {
-      log4j.error("releaseStatement: " + e);
-      releaseConnection(conn);
-      throw e;
+    public void releaseStatement(Statement statement) throws SQLException {
+	if (statement == null)
+	    return;
+	Connection conn = null;
+	try {
+	    conn = statement.getConnection();
+	    statement.close();
+	    releaseConnection(conn);
+	} catch (SQLException e) {
+	    log4j.error("releaseStatement: " + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
     }
-  }
 
-  public void releaseTransactionalStatement(Statement statement) throws SQLException {
-    if (statement == null) return;
-    statement.close();
-  }
+    public void releaseTransactionalStatement(Statement statement)
+	    throws SQLException {
+	if (statement == null)
+	    return;
+	statement.close();
+    }
 
-  public void releaseTransactionalPreparedStatement(PreparedStatement preparedStatement) throws SQLException {
-    if (preparedStatement==null) return;
-    preparedStatement.close();
-  }
+    public void releaseTransactionalPreparedStatement(
+	    PreparedStatement preparedStatement) throws SQLException {
+	if (preparedStatement == null)
+	    return;
+	preparedStatement.close();
+    }
 
-  /**
-   * Returns the actual status of the dynamic pool.
-   */
-  public String getStatus() {
-    StringBuffer strResultado = new StringBuffer();
-    strResultado.append("Not implemented yet");
-    return strResultado.toString();
-  }//End getStatus()
+    /**
+     * Returns the actual status of the dynamic pool.
+     */
+    public String getStatus() {
+	StringBuffer strResultado = new StringBuffer();
+	strResultado.append("Not implemented yet");
+	return strResultado.toString();
+    }// End getStatus()
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/database/JNDIConnectionProvider.java	Wed Nov 12 13:14:11 2008 +0000
@@ -0,0 +1,354 @@
+/*
+ * 
+ * Copyright (C) 2001-2006 Openbravo S.L. Licensed under the Apache Software
+ * License version 2.0 You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.openbravo.database;
+
+import java.io.FileInputStream;
+import java.io.Serializable;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.apache.log4j.Logger;
+import org.openbravo.exception.NoConnectionAvailableException;
+import org.openbravo.exception.PoolNotFoundException;
+
+public class JNDIConnectionProvider implements ConnectionProvider {
+    protected static Logger log4j = Logger
+	    .getLogger(JNDIConnectionProvider.class);
+    protected static Map<String, PoolInfo> pools = new HashMap<String, PoolInfo>();
+    protected String defaultPoolName = "";
+
+    protected class PoolInfo implements Serializable {
+	public String name = null;
+	public DataSource ds = null;
+	public String rdbms = null;
+	public String dbSession = null;
+
+	public PoolInfo(String name, DataSource ds, String rdbms,
+		String dbSession) {
+	    this.name = name;
+	    this.ds = ds;
+	    this.rdbms = rdbms;
+	    this.dbSession = dbSession;
+	}
+    }
+
+    public JNDIConnectionProvider(String file, boolean isRelative)
+	    throws PoolNotFoundException {
+	if (log4j.isDebugEnabled()) {
+	    log4j
+		    .debug("Creating JNDIConnectionProviderImpl from file "
+			    + file);
+	}
+
+	try {
+	    Properties properties = new Properties();
+	    properties.load(new FileInputStream(file));
+	    String poolName = properties.getProperty("bbdd.poolName", "myPool");
+	    if (log4j.isDebugEnabled())
+		log4j.debug("poolName: " + poolName);
+
+	    String jndiResourceName = properties
+		    .getProperty("JNDI.resourceName");
+	    if (log4j.isDebugEnabled())
+		log4j.debug("jndiResourceName: " + jndiResourceName);
+	    String dbSessionConfig = properties
+		    .getProperty("bbdd.sessionConfig");
+	    if (log4j.isDebugEnabled())
+		log4j.debug("dbSessionConfig: " + dbSessionConfig);
+	    String rdbms = properties.getProperty("bbdd.rdbms");
+	    if (log4j.isDebugEnabled())
+		log4j.debug("rdbms: " + rdbms);
+
+	    // Add the new pool to the list of available pools
+	    Context initctx = new InitialContext();
+	    Context ctx = (Context) initctx.lookup("java:/comp/env");
+	    if (log4j.isDebugEnabled())
+		log4j.debug("Connected to java:/comp/env");
+	    DataSource ds = (DataSource) ctx.lookup(jndiResourceName);
+	    if (log4j.isDebugEnabled())
+		log4j.debug("Datasource retrieved from JNDI server. Resource "
+			+ jndiResourceName);
+	    pools.put(poolName, new PoolInfo(poolName, ds, rdbms,
+		    dbSessionConfig));
+	    if (log4j.isDebugEnabled())
+		log4j.debug("Added to pools");
+
+	    // First defined pool is the default pool
+	    if ("".equals(defaultPoolName)) {
+		defaultPoolName = poolName;
+	    }
+
+	    // initialize the pool with dbSessionConfig
+	    Connection con = null;
+	    try {
+		log4j.info( "Initializing connection...");
+		con = ds.getConnection();
+		log4j.info(" Got connection" + con.toString());
+		PreparedStatement pstmt = con.prepareStatement(dbSessionConfig);
+		log4j
+			.debug("Prepared statement with query: "
+				+ dbSessionConfig);
+		pstmt.executeQuery();
+		log4j.debug("Connection initialized");
+	    } finally {
+		if (con != null)
+		    con.close();
+	    }
+	    log4j.debug("Created JNDI ConnectionProvider");
+
+	} catch (Exception e) {
+	    log4j.error(e);
+	    throw new PoolNotFoundException( "Failed when creating database connections pool: " + e.getMessage());
+	}
+
+    }
+
+    public Connection getConnection() throws NoConnectionAvailableException {
+	return getConnection(defaultPoolName);
+    }
+
+    public Connection getConnection(String poolName)
+	    throws NoConnectionAvailableException {
+	try {
+	    return pools.get(poolName).ds.getConnection();
+	} catch (SQLException e) {
+	    throw new NoConnectionAvailableException(e.getMessage());
+	}
+    }
+
+    public String getRDBMS() {
+	return getRDBMS(defaultPoolName);
+    }
+
+    public String getRDBMS(String poolName) {
+	return pools.get(poolName).rdbms;
+    }
+
+    protected boolean releaseConnection(Connection conn) {
+	if (conn == null) {
+	    return false;
+	}
+
+	try {
+	    conn.close();
+	} catch (Exception ex) {
+	    ex.printStackTrace();
+	    return false;
+	}
+	return true;
+    }
+
+    public Connection getTransactionConnection()
+	    throws NoConnectionAvailableException, SQLException {
+	Connection conn = getConnection();
+	if (conn == null) {
+	    throw new NoConnectionAvailableException(
+		    "Couldn´t get an available connection");
+	}
+	conn.setAutoCommit(false);
+	return conn;
+    }
+
+    public void releaseCommitConnection(Connection conn) throws SQLException {
+	if (conn != null) {
+	    conn.commit();
+	    releaseConnection(conn);
+	}
+    }
+
+    public void releaseRollbackConnection(Connection conn) throws SQLException {
+	if (conn != null) {
+	    conn.rollback();
+	    releaseConnection(conn);
+	}
+    }
+
+    public PreparedStatement getPreparedStatement(String SQLPreparedStatement)
+	    throws Exception {
+	return getPreparedStatement(defaultPoolName, SQLPreparedStatement);
+    }
+
+    public PreparedStatement getPreparedStatement(String poolName,
+	    String SQLPreparedStatement) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	if (log4j.isDebugEnabled())
+	    log4j.debug("connection requested");
+	Connection conn = getConnection(poolName);
+	if (log4j.isDebugEnabled())
+	    log4j.debug("connection established");
+	return getPreparedStatement(conn, SQLPreparedStatement);
+    }
+
+    public PreparedStatement getPreparedStatement(Connection conn,
+	    String SQLPreparedStatement) throws SQLException {
+	if (conn == null || SQLPreparedStatement == null
+		|| SQLPreparedStatement.equals(""))
+	    return null;
+	PreparedStatement ps = null;
+	try {
+	    if (log4j.isDebugEnabled())
+		log4j.debug("preparedStatement requested");
+	    ps = conn.prepareStatement(SQLPreparedStatement,
+		    ResultSet.TYPE_SCROLL_INSENSITIVE,
+		    ResultSet.CONCUR_READ_ONLY);
+	    if (log4j.isDebugEnabled())
+		log4j.debug("preparedStatement received");
+	} catch (SQLException e) {
+	    log4j.error("getPreparedStatement: " + SQLPreparedStatement + "\n"
+		    + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
+	return (ps);
+    }
+
+    public CallableStatement getCallableStatement(String SQLCallableStatement)
+	    throws Exception {
+	return getCallableStatement(defaultPoolName, SQLCallableStatement);
+    }
+
+    public CallableStatement getCallableStatement(String poolName,
+	    String SQLCallableStatement) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	Connection conn = getConnection(poolName);
+	return getCallableStatement(conn, SQLCallableStatement);
+    }
+
+    public CallableStatement getCallableStatement(Connection conn,
+	    String SQLCallableStatement) throws SQLException {
+	if (conn == null || SQLCallableStatement == null
+		|| SQLCallableStatement.equals(""))
+	    return null;
+	CallableStatement cs = null;
+	try {
+	    cs = conn.prepareCall(SQLCallableStatement);
+	} catch (SQLException e) {
+	    log4j.error("getCallableStatement: " + SQLCallableStatement + "\n"
+		    + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
+	return (cs);
+    }
+
+    public Statement getStatement() throws Exception {
+	return getStatement(defaultPoolName);
+    }
+
+    public Statement getStatement(String poolName) throws Exception {
+	if (poolName == null || poolName.equals(""))
+	    throw new PoolNotFoundException(
+		    "Can't get the pool. No pool name specified");
+	Connection conn = getConnection(poolName);
+	return getStatement(conn);
+    }
+
+    public Statement getStatement(Connection conn) throws SQLException {
+	if (conn == null)
+	    return null;
+	try {
+	    return (conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+		    ResultSet.CONCUR_READ_ONLY));
+	} catch (SQLException e) {
+	    log4j.error("getStatement: " + e);
+	    releaseConnection(conn);
+	    throw e;
+	}
+    }
+
+    public void releasePreparedStatement(PreparedStatement preparedStatement)
+	    throws SQLException {
+	if (preparedStatement == null)
+	    return;
+	Connection conn = null;
+	try {
+	    conn = preparedStatement.getConnection();
+	    preparedStatement.close();
+	    releaseConnection(conn);
+	} catch (SQLException e) {
+	    log4j.