Added support for Export and Import client data, made changes to build.xml's for making this available as tasks and as processes
authorMartin Taal <martin.taal@openbravo.com>
Tue, 09 Dec 2008 05:54:24 +0000
changeset 2245 b5d0e21ab2d1
parent 2244 684a6b9aa0fe
child 2246 81bc9cb9a003
Added support for Export and Import client data, made changes to build.xml's for making this available as tasks and as processes
build.xml
src-db/database/model/tables/C_CASHLINE.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/AD_PROCESS_PARA.xml
src-db/database/sourcedata/AD_TREENODE.xml
src/build.xml
src/org/openbravo/base/model/Property.java
src/org/openbravo/service/db/ClientImportEntityResolver.java
src/org/openbravo/service/db/ClientImportProcessor.java
src/org/openbravo/service/db/DataExportService.java
src/org/openbravo/service/db/DataImportService.java
src/org/openbravo/service/db/ExportClientProcess.java
src/org/openbravo/service/db/ExportReferenceDataTask.java
src/org/openbravo/service/db/ImportClientProcess.java
src/org/openbravo/service/db/ImportReferenceDataTask.java
src/org/openbravo/service/db/ReferenceDataTask.java
--- a/build.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/build.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -272,6 +272,10 @@
     <ant dir="${base.src}" target="generate.entities" inheritAll="true" inheritRefs="true"/>
   </target>
 
+  <target name="export.reference.data">
+  	<ant dir="${base.src}" target="export.reference.data" inheritAll="true" inheritRefs="true"/>
+  </target>
+
   <target name="compile.src" depends="init">
     <ant dir="${base.src}" target="compile.src" inheritAll="true" inheritRefs="true"/>
   </target>
--- a/src-db/database/model/tables/C_CASHLINE.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/model/tables/C_CASHLINE.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -119,7 +119,6 @@
       <unique name="C_CASHLINE_DEBT_PAYMENT">
         <unique-column name="C_DEBT_PAYMENT_ID"/>
       </unique>
-      <check name="CASHTYPE_CH_PAYMENT"><![CDATA[(CASHTYPE <> 'P') OR (C_DEBT_PAYMENT_ID IS NOT NULL)]]></check>
       <check name="CCASHLINE_CHARGE_CHECK"><![CDATA[(CASHTYPE <> 'C') OR (C_CHARGE_ID IS NOT NULL)]]></check>
       <check name="CCASHLINE_GLITEM_CHECK"><![CDATA[(CASHTYPE <> 'G') OR (C_GLITEM_ID IS NOT NULL)]]></check>
       <check name="CCASHLINE_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -5305,8 +5305,6 @@
 <!--212-->              <AD_REFERENCE_ID><![CDATA[13]]></AD_REFERENCE_ID>
 <!--212 FIELDLENGTH-->
 <!--212-->              <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
-<!--212 DEFAULTVALUE-->
-<!--212-->              <DEFAULTVALUE><![CDATA[-1]]></DEFAULTVALUE>
 <!--212 ISKEY-->
 <!--212-->              <ISKEY><![CDATA[Y]]></ISKEY>
 <!--212 ISPARENT-->
@@ -356164,8 +356162,6 @@
 <!--800657-->              <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--800657 ISENCRYPTED-->
 <!--800657-->              <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--800657 VALUEMIN-->
-<!--800657-->              <VALUEMIN><![CDATA[10]]></VALUEMIN>
 <!--800657 ISSELECTIONCOLUMN-->
 <!--800657-->              <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--800657 AD_ELEMENT_ID-->
@@ -356233,8 +356229,6 @@
 <!--800658-->              <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--800658 ISENCRYPTED-->
 <!--800658-->              <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--800658 VALUEMIN-->
-<!--800658-->              <VALUEMIN><![CDATA[10]]></VALUEMIN>
 <!--800658 ISSELECTIONCOLUMN-->
 <!--800658-->              <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--800658 AD_ELEMENT_ID-->
@@ -356300,8 +356294,6 @@
 <!--800659-->              <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
 <!--800659 ISENCRYPTED-->
 <!--800659-->              <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
-<!--800659 VALUEMIN-->
-<!--800659-->              <VALUEMIN><![CDATA[10]]></VALUEMIN>
 <!--800659 ISSELECTIONCOLUMN-->
 <!--800659-->              <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--800659 AD_ELEMENT_ID-->
--- a/src-db/database/sourcedata/AD_MENU.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_MENU.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -13003,6 +13003,8 @@
 <!--1E5FB50EFD5D43BDA4AB1879707D9003-->              <NAME><![CDATA[Import Client]]></NAME>
 <!--1E5FB50EFD5D43BDA4AB1879707D9003 UPDATEDBY-->
 <!--1E5FB50EFD5D43BDA4AB1879707D9003-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--1E5FB50EFD5D43BDA4AB1879707D9003 DESCRIPTION-->
+<!--1E5FB50EFD5D43BDA4AB1879707D9003-->              <DESCRIPTION><![CDATA[Import a client from xml]]></DESCRIPTION>
 <!--1E5FB50EFD5D43BDA4AB1879707D9003 ISSUMMARY-->
 <!--1E5FB50EFD5D43BDA4AB1879707D9003-->              <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
 <!--1E5FB50EFD5D43BDA4AB1879707D9003 ACTION-->
@@ -13071,6 +13073,37 @@
 <!--5DFCDFE962144B12A6279E9A1E9DC0AC-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--5DFCDFE962144B12A6279E9A1E9DC0AC**************--></AD_MENU>
 
+<!--8BA14A552EA84AB19A33F3F2C3002790**************--><AD_MENU>
+<!--8BA14A552EA84AB19A33F3F2C3002790 AD_MENU_ID-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <AD_MENU_ID><![CDATA[8BA14A552EA84AB19A33F3F2C3002790]]></AD_MENU_ID>
+<!--8BA14A552EA84AB19A33F3F2C3002790 AD_CLIENT_ID-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8BA14A552EA84AB19A33F3F2C3002790 AD_ORG_ID-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8BA14A552EA84AB19A33F3F2C3002790 ISACTIVE-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8BA14A552EA84AB19A33F3F2C3002790 CREATED-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <CREATED><![CDATA[2008-12-09 00:47:18.0]]></CREATED>
+<!--8BA14A552EA84AB19A33F3F2C3002790 CREATEDBY-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--8BA14A552EA84AB19A33F3F2C3002790 UPDATED-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <UPDATED><![CDATA[2008-12-09 00:47:18.0]]></UPDATED>
+<!--8BA14A552EA84AB19A33F3F2C3002790 NAME-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <NAME><![CDATA[Export Client]]></NAME>
+<!--8BA14A552EA84AB19A33F3F2C3002790 UPDATEDBY-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--8BA14A552EA84AB19A33F3F2C3002790 DESCRIPTION-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <DESCRIPTION><![CDATA[Export a client to xml]]></DESCRIPTION>
+<!--8BA14A552EA84AB19A33F3F2C3002790 ISSUMMARY-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+<!--8BA14A552EA84AB19A33F3F2C3002790 ACTION-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <ACTION><![CDATA[P]]></ACTION>
+<!--8BA14A552EA84AB19A33F3F2C3002790 AD_PROCESS_ID-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <AD_PROCESS_ID><![CDATA[D85D5B5E368A49B1A6293BA4AE15F0F9]]></AD_PROCESS_ID>
+<!--8BA14A552EA84AB19A33F3F2C3002790 AD_MODULE_ID-->
+<!--8BA14A552EA84AB19A33F3F2C3002790-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8BA14A552EA84AB19A33F3F2C3002790**************--></AD_MENU>
+
 <!--B73A1BE38C6F4F4BB17A3B6FA8C3293E**************--><AD_MENU>
 <!--B73A1BE38C6F4F4BB17A3B6FA8C3293E AD_MENU_ID-->
 <!--B73A1BE38C6F4F4BB17A3B6FA8C3293E-->              <AD_MENU_ID><![CDATA[B73A1BE38C6F4F4BB17A3B6FA8C3293E]]></AD_MENU_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -41921,6 +41921,35 @@
 <!--E11F44F0F1384CBEBA4425B16198A1AB-->              <SEQNO><![CDATA[30]]></SEQNO>
 <!--E11F44F0F1384CBEBA4425B16198A1AB**************--></AD_MODEL_OBJECT>
 
+<!--E656BA54FAED4AC2885DDC63F9748C5D**************--><AD_MODEL_OBJECT>
+<!--E656BA54FAED4AC2885DDC63F9748C5D AD_MODEL_OBJECT_ID-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <AD_MODEL_OBJECT_ID><![CDATA[E656BA54FAED4AC2885DDC63F9748C5D]]></AD_MODEL_OBJECT_ID>
+<!--E656BA54FAED4AC2885DDC63F9748C5D AD_CLIENT_ID-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E656BA54FAED4AC2885DDC63F9748C5D AD_ORG_ID-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E656BA54FAED4AC2885DDC63F9748C5D ISACTIVE-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E656BA54FAED4AC2885DDC63F9748C5D CREATED-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <CREATED><![CDATA[2008-12-09 00:34:09.0]]></CREATED>
+<!--E656BA54FAED4AC2885DDC63F9748C5D CREATEDBY-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--E656BA54FAED4AC2885DDC63F9748C5D UPDATED-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <UPDATED><![CDATA[2008-12-09 00:34:10.0]]></UPDATED>
+<!--E656BA54FAED4AC2885DDC63F9748C5D UPDATEDBY-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--E656BA54FAED4AC2885DDC63F9748C5D ACTION-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <ACTION><![CDATA[P]]></ACTION>
+<!--E656BA54FAED4AC2885DDC63F9748C5D CLASSNAME-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <CLASSNAME><![CDATA[org.openbravo.service.db.ExportClientProcess]]></CLASSNAME>
+<!--E656BA54FAED4AC2885DDC63F9748C5D ISDEFAULT-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--E656BA54FAED4AC2885DDC63F9748C5D AD_PROCESS_ID-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <AD_PROCESS_ID><![CDATA[D85D5B5E368A49B1A6293BA4AE15F0F9]]></AD_PROCESS_ID>
+<!--E656BA54FAED4AC2885DDC63F9748C5D OBJECT_TYPE-->
+<!--E656BA54FAED4AC2885DDC63F9748C5D-->              <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--E656BA54FAED4AC2885DDC63F9748C5D**************--></AD_MODEL_OBJECT>
+
 <!--EF8E7CE2324E425FB840AD1DCBD8054B**************--><AD_MODEL_OBJECT>
 <!--EF8E7CE2324E425FB840AD1DCBD8054B AD_MODEL_OBJECT_ID-->
 <!--EF8E7CE2324E425FB840AD1DCBD8054B-->              <AD_MODEL_OBJECT_ID><![CDATA[EF8E7CE2324E425FB840AD1DCBD8054B]]></AD_MODEL_OBJECT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -9850,7 +9850,7 @@
 <!--800147 CREATEDBY-->
 <!--800147-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
 <!--800147 UPDATED-->
-<!--800147-->              <UPDATED><![CDATA[2007-11-23 17:39:02.0]]></UPDATED>
+<!--800147-->              <UPDATED><![CDATA[2008-12-09 00:35:04.0]]></UPDATED>
 <!--800147 UPDATEDBY-->
 <!--800147-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
 <!--800147 VALUE-->
@@ -9879,6 +9879,8 @@
 <!--800147-->              <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
 <!--800147 ISJASPER-->
 <!--800147-->              <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--800147 ISEXTERNALSERVICE-->
+<!--800147-->              <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
 <!--800147 AD_MODULE_ID-->
 <!--800147-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800147 UIPATTERN-->
@@ -10208,7 +10210,7 @@
 <!--800158 CREATEDBY-->
 <!--800158-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
 <!--800158 UPDATED-->
-<!--800158-->              <UPDATED><![CDATA[2007-11-23 17:37:54.0]]></UPDATED>
+<!--800158-->              <UPDATED><![CDATA[2008-12-09 00:49:03.0]]></UPDATED>
 <!--800158 UPDATEDBY-->
 <!--800158-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
 <!--800158 VALUE-->
@@ -10233,6 +10235,8 @@
 <!--800158-->              <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
 <!--800158 ISJASPER-->
 <!--800158-->              <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--800158 ISEXTERNALSERVICE-->
+<!--800158-->              <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
 <!--800158 AD_MODULE_ID-->
 <!--800158-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800158 UIPATTERN-->
@@ -13422,13 +13426,17 @@
 <!--970EAD9B846648A7AB1F0CCA5058356C CREATEDBY-->
 <!--970EAD9B846648A7AB1F0CCA5058356C-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
 <!--970EAD9B846648A7AB1F0CCA5058356C UPDATED-->
-<!--970EAD9B846648A7AB1F0CCA5058356C-->              <UPDATED><![CDATA[2008-12-02 17:18:33.0]]></UPDATED>
+<!--970EAD9B846648A7AB1F0CCA5058356C-->              <UPDATED><![CDATA[2008-12-09 00:36:09.0]]></UPDATED>
 <!--970EAD9B846648A7AB1F0CCA5058356C UPDATEDBY-->
 <!--970EAD9B846648A7AB1F0CCA5058356C-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
 <!--970EAD9B846648A7AB1F0CCA5058356C VALUE-->
 <!--970EAD9B846648A7AB1F0CCA5058356C-->              <VALUE><![CDATA[ImportClient]]></VALUE>
 <!--970EAD9B846648A7AB1F0CCA5058356C NAME-->
 <!--970EAD9B846648A7AB1F0CCA5058356C-->              <NAME><![CDATA[Import Client]]></NAME>
+<!--970EAD9B846648A7AB1F0CCA5058356C DESCRIPTION-->
+<!--970EAD9B846648A7AB1F0CCA5058356C-->              <DESCRIPTION><![CDATA[Import a client from xml]]></DESCRIPTION>
+<!--970EAD9B846648A7AB1F0CCA5058356C HELP-->
+<!--970EAD9B846648A7AB1F0CCA5058356C-->              <HELP><![CDATA[Import a client and its data from a xml file]]></HELP>
 <!--970EAD9B846648A7AB1F0CCA5058356C ACCESSLEVEL-->
 <!--970EAD9B846648A7AB1F0CCA5058356C-->              <ACCESSLEVEL><![CDATA[7]]></ACCESSLEVEL>
 <!--970EAD9B846648A7AB1F0CCA5058356C ISUSERSTARTABLE-->
@@ -13582,4 +13590,49 @@
 <!--D56220370A774B7FA51323BE3C6E0F22-->              <UIPATTERN><![CDATA[S]]></UIPATTERN>
 <!--D56220370A774B7FA51323BE3C6E0F22**************--></AD_PROCESS>
 
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9**************--><AD_PROCESS>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 AD_PROCESS_ID-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <AD_PROCESS_ID><![CDATA[D85D5B5E368A49B1A6293BA4AE15F0F9]]></AD_PROCESS_ID>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 AD_CLIENT_ID-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 AD_ORG_ID-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISACTIVE-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 CREATED-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <CREATED><![CDATA[2008-12-09 00:32:58.0]]></CREATED>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 CREATEDBY-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 UPDATED-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <UPDATED><![CDATA[2008-12-09 00:49:33.0]]></UPDATED>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 UPDATEDBY-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 VALUE-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <VALUE><![CDATA[ExportClient]]></VALUE>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 NAME-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <NAME><![CDATA[Export Client]]></NAME>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 DESCRIPTION-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <DESCRIPTION><![CDATA[Export a client to xml]]></DESCRIPTION>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 HELP-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <HELP><![CDATA[Export a client to a xml file]]></HELP>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ACCESSLEVEL-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ACCESSLEVEL><![CDATA[7]]></ACCESSLEVEL>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISUSERSTARTABLE-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISREPORT-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISREPORT><![CDATA[N]]></ISREPORT>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISDIRECTPRINT-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISBACKGROUND-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISJASPER-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 ISEXTERNALSERVICE-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 AD_MODULE_ID-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9 UIPATTERN-->
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9-->              <UIPATTERN><![CDATA[S]]></UIPATTERN>
+<!--D85D5B5E368A49B1A6293BA4AE15F0F9**************--></AD_PROCESS>
+
 </data>
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -10738,7 +10738,7 @@
 <!--800051 CREATEDBY-->
 <!--800051-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
 <!--800051 UPDATED-->
-<!--800051-->              <UPDATED><![CDATA[2007-01-22 16:36:00.0]]></UPDATED>
+<!--800051-->              <UPDATED><![CDATA[2008-12-09 00:49:24.0]]></UPDATED>
 <!--800051 UPDATEDBY-->
 <!--800051-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
 <!--800051 NAME-->
@@ -11576,7 +11576,7 @@
 <!--205EF0C0D4A84C77B295AA69D2B825AF CREATEDBY-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
 <!--205EF0C0D4A84C77B295AA69D2B825AF UPDATED-->
-<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <UPDATED><![CDATA[2008-12-03 15:11:56.0]]></UPDATED>
+<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <UPDATED><![CDATA[2008-12-09 00:33:41.0]]></UPDATED>
 <!--205EF0C0D4A84C77B295AA69D2B825AF UPDATEDBY-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
 <!--205EF0C0D4A84C77B295AA69D2B825AF NAME-->
@@ -11590,13 +11590,13 @@
 <!--205EF0C0D4A84C77B295AA69D2B825AF SEQNO-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <SEQNO><![CDATA[10]]></SEQNO>
 <!--205EF0C0D4A84C77B295AA69D2B825AF AD_REFERENCE_ID-->
-<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <AD_REFERENCE_ID><![CDATA[14]]></AD_REFERENCE_ID>
+<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
 <!--205EF0C0D4A84C77B295AA69D2B825AF COLUMNNAME-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <COLUMNNAME><![CDATA[Name]]></COLUMNNAME>
 <!--205EF0C0D4A84C77B295AA69D2B825AF ISCENTRALLYMAINTAINED-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--205EF0C0D4A84C77B295AA69D2B825AF FIELDLENGTH-->
-<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <FIELDLENGTH><![CDATA[20]]></FIELDLENGTH>
+<!--205EF0C0D4A84C77B295AA69D2B825AF-->              <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
 <!--205EF0C0D4A84C77B295AA69D2B825AF ISMANDATORY-->
 <!--205EF0C0D4A84C77B295AA69D2B825AF-->              <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--205EF0C0D4A84C77B295AA69D2B825AF ISRANGE-->
@@ -11693,6 +11693,49 @@
 <!--3AC22B0F80264CF09D52044F198C75BD-->              <AD_ELEMENT_ID><![CDATA[193]]></AD_ELEMENT_ID>
 <!--3AC22B0F80264CF09D52044F198C75BD**************--></AD_PROCESS_PARA>
 
+<!--73C3F0DC9B624A0BB72D5A5952FD8135**************--><AD_PROCESS_PARA>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_PROCESS_PARA_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_PROCESS_PARA_ID><![CDATA[73C3F0DC9B624A0BB72D5A5952FD8135]]></AD_PROCESS_PARA_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_CLIENT_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_ORG_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 ISACTIVE-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 CREATED-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <CREATED><![CDATA[2008-12-09 00:34:53.0]]></CREATED>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 CREATEDBY-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 UPDATED-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <UPDATED><![CDATA[2008-12-09 00:49:46.0]]></UPDATED>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 UPDATEDBY-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 NAME-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <NAME><![CDATA[Client]]></NAME>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 DESCRIPTION-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <DESCRIPTION><![CDATA[Client for this installation.]]></DESCRIPTION>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 HELP-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <HELP><![CDATA[A Client is a company or a legal entity. You cannot share data between Clients.]]></HELP>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_PROCESS_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_PROCESS_ID><![CDATA[D85D5B5E368A49B1A6293BA4AE15F0F9]]></AD_PROCESS_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 SEQNO-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <SEQNO><![CDATA[10]]></SEQNO>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_REFERENCE_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 COLUMNNAME-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <COLUMNNAME><![CDATA[AD_CLIENT_ID]]></COLUMNNAME>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 ISCENTRALLYMAINTAINED-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 FIELDLENGTH-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 ISMANDATORY-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 ISRANGE-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135 AD_ELEMENT_ID-->
+<!--73C3F0DC9B624A0BB72D5A5952FD8135-->              <AD_ELEMENT_ID><![CDATA[102]]></AD_ELEMENT_ID>
+<!--73C3F0DC9B624A0BB72D5A5952FD8135**************--></AD_PROCESS_PARA>
+
 <!--74099FB272564084889C4ED8F12E91A1**************--><AD_PROCESS_PARA>
 <!--74099FB272564084889C4ED8F12E91A1 AD_PROCESS_PARA_ID-->
 <!--74099FB272564084889C4ED8F12E91A1-->              <AD_PROCESS_PARA_ID><![CDATA[74099FB272564084889C4ED8F12E91A1]]></AD_PROCESS_PARA_ID>
--- a/src-db/database/sourcedata/AD_TREENODE.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src-db/database/sourcedata/AD_TREENODE.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -11876,6 +11876,33 @@
 <!--7AC6A56E80D711DDADB69B718A17D8D7-->              <SEQNO><![CDATA[20]]></SEQNO>
 <!--7AC6A56E80D711DDADB69B718A17D8D7**************--></AD_TREENODE>
 
+<!--8CB53124C58211DDB9A9001D09C4A2FE**************--><AD_TREENODE>
+<!--8CB53124C58211DDB9A9001D09C4A2FE AD_TREENODE_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <AD_TREENODE_ID><![CDATA[8CB53124C58211DDB9A9001D09C4A2FE]]></AD_TREENODE_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE AD_TREE_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE NODE_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <NODE_ID><![CDATA[8BA14A552EA84AB19A33F3F2C3002790]]></NODE_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE AD_CLIENT_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE AD_ORG_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE ISACTIVE-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8CB53124C58211DDB9A9001D09C4A2FE CREATED-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <CREATED><![CDATA[2008-12-09 00:47:18.0]]></CREATED>
+<!--8CB53124C58211DDB9A9001D09C4A2FE CREATEDBY-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <CREATEDBY><![CDATA[100]]></CREATEDBY>
+<!--8CB53124C58211DDB9A9001D09C4A2FE UPDATED-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <UPDATED><![CDATA[2008-12-09 00:47:18.0]]></UPDATED>
+<!--8CB53124C58211DDB9A9001D09C4A2FE UPDATEDBY-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+<!--8CB53124C58211DDB9A9001D09C4A2FE PARENT_ID-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <PARENT_ID><![CDATA[0]]></PARENT_ID>
+<!--8CB53124C58211DDB9A9001D09C4A2FE SEQNO-->
+<!--8CB53124C58211DDB9A9001D09C4A2FE-->              <SEQNO><![CDATA[999]]></SEQNO>
+<!--8CB53124C58211DDB9A9001D09C4A2FE**************--></AD_TREENODE>
+
 <!--F97035E495D911DDB78D001B388C05F0**************--><AD_TREENODE>
 <!--F97035E495D911DDB78D001B388C05F0 AD_TREENODE_ID-->
 <!--F97035E495D911DDB78D001B388C05F0-->              <AD_TREENODE_ID><![CDATA[F97035E495D911DDB78D001B388C05F0]]></AD_TREENODE_ID>
--- a/src/build.xml	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/build.xml	Tue Dec 09 05:54:24 2008 +0000
@@ -147,19 +147,28 @@
 			<fileset dir="${base.src.gen}" />
 		</delete>
 	</target>
-  
-	<!-- <target name="generate.entities" depends="compile.src.gen,clean.src.gen">
-      <taskdef name="workflow" classpathref="project.class.path" classname="org.openarchitectureware.workflow.ant.WorkflowAntTask"/>
-   	<workflow file="${base.src}/org/openbravo/base/gen/gen_entity.oaw">
-          <param name="ob.properties.location" value="${base.config}/Openbravo.properties" />
-          <param name="base.src.gen" value="${base.src.gen}" />
-          <classpath>
-	    <path refid="project.class.path"/>
-	  </classpath>
-        </workflow> 
-</target>-->
 
-
+	<target name="export.reference.data" description="Exports Sample Data">
+		<taskdef name="exportreferencedata" classname="org.openbravo.service.db.ExportReferenceDataTask">
+			<classpath refid="project.class.path"/>
+	    </taskdef>
+	    <echo message="Exporting sample reference data"/>
+	      <exportreferencedata 
+	      		userId="0"
+	      		propertiesFile="${base.config}/Openbravo.properties"
+	      		clients="BigBazaar,Accounting Test"/>
+	  </target>
+	
+	<target name="import.reference.data" description="Import Sample Data">
+		<taskdef name="importreferencedata" classname="org.openbravo.service.db.ImportReferenceDataTask">
+			<classpath refid="project.class.path"/>
+	    </taskdef>
+	    <echo message="Importing sample reference data"/>
+	      <importreferencedata 
+	      		userId="0"
+	      		propertiesFile="${base.config}/Openbravo.properties"
+	      		clients="BigBazaar,Accounting Test"/>
+	  </target>
 
  <target name="generate.entities" depends="compile.src.gen,clean.src.gen">
    <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
@@ -172,7 +181,7 @@
           <path refid="project.class.path" />
        </classpath>
    </workflow>
-    <javac srcdir="${base.src.gen}:${base.src}/org/openbravo/dal:${base.src}/org/openbravo/base/structure" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}"  debug="true" debuglevel="lines,vars,source" deprecation="on">
+    <javac srcdir="${base.src.gen}:${base.src}/org/openbravo/base/model:${base.src}/org/openbravo/dal:${base.src}/org/openbravo/base/structure" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}"  debug="true" debuglevel="lines,vars,source" deprecation="on">
       <classpath refid="project.class.path"/>
     </javac>
  </target>
--- a/src/org/openbravo/base/model/Property.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/base/model/Property.java	Tue Dec 09 05:54:24 2008 +0000
@@ -96,7 +96,7 @@
         setParent(fromColumn.isParent());
         setColumnName(fromColumn.getColumnName());
         setDefaultValue(fromColumn.getDefaultValue());
-        setMandatory(fromColumn.isMandatory());
+        setMandatory(overrideMandatoryCustom(fromColumn));
         setMinValue(fromColumn.getValueMin());
         setMaxValue(fromColumn.getValueMax());
         setUuid(fromColumn.getReference().getName().equals("ID")
@@ -117,6 +117,32 @@
         setInactive(!fromColumn.isActive());
     }
 
+    // TODO: remove this hack when possible
+    // there are four columns in the Application Dictionary which have been set
+    // to mandatory, while on database level the columns are not-mandatory.
+    // This because it is not possible to define in a field if a field should
+    // be mandatory. So these columns are hidden on windows/tabs where they
+    // should not be entered.
+    private boolean overrideMandatoryCustom(Column c) {
+        final boolean columnMandatory = c.isMandatory();
+        if (!c.getTable().getTableName().equalsIgnoreCase("M_Production")) {
+            return columnMandatory;
+        }
+        if (c.getColumnName().equalsIgnoreCase("endtime")) {
+            return false;
+        } else if (c.getColumnName().equalsIgnoreCase("ma_costcenteruser")) {
+            return false;
+        } else if (c.getColumnName().equalsIgnoreCase("MA_Wrphase_ID")) {
+            return false;
+        } else if (c.getColumnName().equalsIgnoreCase("neededquantity")) {
+            return false;
+        } else if (c.getColumnName().equalsIgnoreCase("rejectedquantity")) {
+            return false;
+        } else {
+            return columnMandatory;
+        }
+    }
+
     /**
      * Initializes the name of the property. This is done separately from the
      * {@link #initializeFromColumn(Column) initializeFromColumn} method because
--- a/src/org/openbravo/service/db/ClientImportEntityResolver.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/ClientImportEntityResolver.java	Tue Dec 09 05:54:24 2008 +0000
@@ -110,10 +110,7 @@
     @Override
     public BaseOBObject searchInstance(Entity entity, String id) {
         final AccessLevel al = entity.getAccessLevel();
-        if (al == AccessLevel.SYSTEM || al == AccessLevel.SYSTEM_CLIENT) {
-            return searchSystem(id, entity);
-        }
-        return null;
+        return searchSystem(id, entity);
     }
 
     @Override
--- a/src/org/openbravo/service/db/ClientImportProcessor.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/ClientImportProcessor.java	Tue Dec 09 05:54:24 2008 +0000
@@ -27,10 +27,8 @@
 import org.openbravo.model.ad.access.Role;
 import org.openbravo.model.ad.access.User;
 import org.openbravo.model.ad.system.Client;
-import org.openbravo.model.common.enterprise.DocumentType;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.enterprise.Warehouse;
-import org.openbravo.model.financialmgmt.gl.GLCategory;
 
 /**
  * This ImportProcessor is used during client import. It repairs the names of
@@ -85,6 +83,9 @@
     }
 
     private void replaceName(String originalName, BaseOBObject bob) {
+        if (newName == null || newName.trim().length() == 0) {
+            return;
+        }
         if (bob instanceof Client) {
             final Client client = (Client) bob;
             client.setName(newName);
@@ -101,12 +102,12 @@
         } else if (bob instanceof Warehouse) {
             final Warehouse wh = (Warehouse) bob;
             wh.setName(replace(wh.getName(), originalName));
-        } else if (bob instanceof GLCategory) {
-            final GLCategory glCategory = (GLCategory) bob;
-            glCategory.setName(replace(glCategory.getName(), originalName));
-        } else if (bob instanceof DocumentType) {
-            final DocumentType docType = (DocumentType) bob;
-            docType.setName(replace(docType.getName(), originalName));
+            // } else if (bob instanceof GLCategory) {
+            // final GLCategory glCategory = (GLCategory) bob;
+            // glCategory.setName(replace(glCategory.getName(), originalName));
+            // } else if (bob instanceof DocumentType) {
+            // final DocumentType docType = (DocumentType) bob;
+            // docType.setName(replace(docType.getName(), originalName));
         }
     }
 
--- a/src/org/openbravo/service/db/DataExportService.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/DataExportService.java	Tue Dec 09 05:54:24 2008 +0000
@@ -26,9 +26,13 @@
 import java.util.Set;
 
 import org.apache.log4j.Logger;
+import org.hibernate.criterion.Expression;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.provider.OBSingleton;
 import org.openbravo.base.structure.BaseOBObject;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.xml.EntityXMLConverter;
 import org.openbravo.model.ad.utility.DataSet;
 import org.openbravo.model.ad.utility.DataSetTable;
@@ -45,6 +49,16 @@
 public class DataExportService implements OBSingleton {
     private static final Logger log = Logger.getLogger(DataExportService.class);
 
+    /**
+     * Name of the dataset used for client export.
+     */
+    public static final String CLIENT_DATA_SET_NAME = "Client Definition";
+
+    /**
+     * The name of the client id parameter used in the datasets
+     */
+    public static final String CLIENT_ID_PARAMETER_NAME = "ClientID";
+
     private static DataExportService instance;
 
     /**
@@ -102,17 +116,27 @@
     /**
      * Exports data of a client. The main difference with the standard dataset
      * export is that also references to client and organizations are exported.
+     * The dataset with the name Client Definition is used for the export.
      * 
-     * @param dataSet
-     *            the DataSetTables of this dataSet will be exported
-     * @param moduleId
-     *            the moduleId is used in the where clause of dataset tables
+     * @param parameters
+     *            the parameters used in the queries, the client id should be
+     *            passed in this map with the parameter name ClientID (note is
+     *            case sensitive)
      * @return the xml string, the resulting xml from the export, can be null if
      *         nothing is exported
+     * @see CLIENT_DATA_SET_NAME
+     * @see CLIENT_ID_PARAMETER_NAME
      */
-    public String exportClientToXML(DataSet dataSet, String moduleId,
-            Map<String, Object> parameters) {
-        return exportDataSetToXML(dataSet, moduleId, true, parameters);
+    public String exportClientToXML(Map<String, Object> parameters) {
+        final OBCriteria<DataSet> obc = OBDal.getInstance().createCriteria(
+                DataSet.class);
+        obc.add(Expression.eq("name", CLIENT_DATA_SET_NAME));
+        if (obc.list().size() == 0) {
+            throw new OBException("No dataset found with name "
+                    + CLIENT_DATA_SET_NAME);
+        }
+        final DataSet dataSet = obc.list().get(0);
+        return exportDataSetToXML(dataSet, null, true, parameters);
     }
 
     // note returns null if nothing has been generated
--- a/src/org/openbravo/service/db/DataImportService.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/DataImportService.java	Tue Dec 09 05:54:24 2008 +0000
@@ -141,10 +141,10 @@
      * @see #importDataFromXML(Client, Organization, String)
      */
     public ImportResult importClientData(String xml,
-            EntityXMLProcessor importProcessor, Module module) {
+            EntityXMLProcessor importProcessor) {
         try {
             final Document doc = DocumentHelper.parseText(xml);
-            return importDataFromXML(null, null, doc, true, module,
+            return importDataFromXML(null, null, doc, true, null,
                     importProcessor, true);
         } catch (final Exception e) {
             throw new OBException(e);
--- a/src/org/openbravo/service/db/ExportClientProcess.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/ExportClientProcess.java	Tue Dec 09 05:54:24 2008 +0000
@@ -19,6 +19,12 @@
 
 package org.openbravo.service.db;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.openbravo.base.exception.OBException;
+import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.scheduling.ProcessBundle;
 
 /**
@@ -37,6 +43,22 @@
      * location of the file in which the data for the export should go.
      */
     public void execute(ProcessBundle bundle) throws Exception {
-        // TODO Auto-generated method stub
+
+        try {
+            final URL url = org.openbravo.dal.core.DalContextListener
+                    .getServletContext().getResource("/WEB-INF/referencedata");
+            final File file = new File(new URI(url.toString()));
+        } catch (final Exception e) {
+            throw new OBException(e);
+        }
+        for (final String key : bundle.getParams().keySet()) {
+            System.err.println(key + ": " + bundle.getParams().get(key));
+        }
+        final OBError e = new OBError();
+        e.setType("Success");
+        e.setMessage("ClientID:" + bundle.getParams().get("adClientId"));
+        e.setTitle("Done");
+
+        bundle.setResult(e);
     }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/db/ExportReferenceDataTask.java	Tue Dec 09 05:54:24 2008 +0000
@@ -0,0 +1,84 @@
+package org.openbravo.service.db;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.hibernate.criterion.Expression;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.model.ad.system.Client;
+
+/**
+ * Export reference data of clients defined by the clients parameter.
+ * 
+ */
+public class ExportReferenceDataTask extends ReferenceDataTask {
+    private static final Logger log = Logger
+            .getLogger(ExportReferenceDataTask.class);
+
+    private String clients;
+
+    @Override
+    protected void doExecute() {
+        final File exportDir = getReferenceDataDir();
+        for (final Client client : getClientObjects()) {
+            final Map<String, Object> parameters = new HashMap<String, Object>();
+            parameters.put(DataExportService.CLIENT_ID_PARAMETER_NAME, client
+                    .getId());
+            log.info("Exporting client " + client.getName());
+            final String xml = DataExportService.getInstance()
+                    .exportClientToXML(parameters);
+            final File exportFile = new File(exportDir, client.getValue()
+                    + ".xml");
+            if (exportFile.exists()) {
+                exportFile.delete();
+            }
+            try {
+                final FileWriter fw = new FileWriter(exportFile);
+                fw.write(xml);
+                fw.close();
+            } catch (final IOException e) {
+                throw new OBException(e);
+            }
+        }
+    }
+
+    @Override
+    public String getClients() {
+        return clients;
+    }
+
+    @Override
+    public void setClients(String clients) {
+        this.clients = clients;
+    }
+
+    private List<Client> getClientObjects() {
+        final List<Client> result = new ArrayList<Client>();
+        for (final String clientStr : getClients().split(",")) {
+            result.add(getClient(clientStr.trim()));
+        }
+        return result;
+    }
+
+    private Client getClient(String clientValue) {
+        final org.openbravo.dal.service.OBCriteria<Client> obc = org.openbravo.dal.service.OBDal
+                .getInstance().createCriteria(Client.class);
+        obc.add(Expression.eq(Client.PROPERTY_VALUE, clientValue));
+        final List<Client> result = obc.list();
+        if (result.size() == 0) {
+            throw new OBException("No client found using " + clientValue
+                    + " as the value in the query");
+        }
+        if (result.size() > 1) {
+            throw new OBException("More than one client found using "
+                    + clientValue + " as the value in the query");
+        }
+        return result.get(0);
+    }
+}
--- a/src/org/openbravo/service/db/ImportClientProcess.java	Mon Dec 08 10:21:24 2008 +0000
+++ b/src/org/openbravo/service/db/ImportClientProcess.java	Tue Dec 09 05:54:24 2008 +0000
@@ -38,12 +38,14 @@
      * location of the file with the data to import.
      */
     public void execute(ProcessBundle bundle) throws Exception {
-       final OBError e = new OBError();
-       e.setType("Success");
-       e.setMessage("Name:"+bundle.getParams().get("name"));
-       e.setTitle("Done");
-       
-       bundle.setResult(e);
-       
+        // DataImportService.getInstance().i
+
+        final OBError e = new OBError();
+        e.setType("Success");
+        e.setMessage("Name:" + bundle.getParams().get("name"));
+        e.setTitle("Done");
+
+        bundle.setResult(e);
+
     }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/db/ImportReferenceDataTask.java	Tue Dec 09 05:54:24 2008 +0000
@@ -0,0 +1,59 @@
+package org.openbravo.service.db;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
+
+/**
+ * Imports client data for the clients defined in the clients parameter from the
+ * {@link ReferenceDataTask#REFERENCE_DATA_DIRECTORY} directory.
+ */
+public class ImportReferenceDataTask extends ReferenceDataTask {
+    private static final Logger log = Logger
+            .getLogger(ImportReferenceDataTask.class);
+
+    @Override
+    protected void doExecute() {
+        final File importDir = getReferenceDataDir();
+        for (final String clientStr : getClients().split(",")) {
+            final File importFile = new File(importDir, clientStr.trim()
+                    + ".xml");
+            if (!importFile.exists()) {
+                throw new OBException("No import file present for client "
+                        + clientStr + " complete path: "
+                        + importFile.getAbsolutePath());
+            }
+            log.info("Importing from file " + importFile.getAbsolutePath());
+            final String xml = readFile(importFile);
+            final ClientImportProcessor importProcessor = new ClientImportProcessor();
+            importProcessor.setNewName(null);
+            DataImportService.getInstance().importClientData(xml,
+                    importProcessor);
+        }
+    }
+
+    private String readFile(File file) {
+        final StringBuilder contents = new StringBuilder();
+
+        try {
+            final BufferedReader input = new BufferedReader(
+                    new FileReader(file));
+            try {
+                String line = null;
+                while ((line = input.readLine()) != null) {
+                    contents.append(line);
+                    contents.append(System.getProperty("line.separator"));
+                }
+            } finally {
+                input.close();
+            }
+        } catch (final IOException e) {
+            throw new OBException(e);
+        }
+        return contents.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/db/ReferenceDataTask.java	Tue Dec 09 05:54:24 2008 +0000
@@ -0,0 +1,39 @@
+package org.openbravo.service.db;
+
+import java.io.File;
+
+import org.openbravo.base.exception.OBException;
+import org.openbravo.dal.core.DalInitializingTask;
+
+/**
+ * Ant task which is the basis for the import and export of sample data during
+ * installation of Openbravo. The files are read and exported from and to the
+ * src-db/database/referencedata directory.
+ * 
+ */
+public class ReferenceDataTask extends DalInitializingTask {
+    public static final String REFERENCE_DATA_DIRECTORY = "/referencedata/sampledata";
+    private String clients;
+
+    protected File getReferenceDataDir() {
+        final File mainDir = new File(getProject().getBaseDir().toString())
+                .getParentFile();
+        final File referenceDir = new File(mainDir, REFERENCE_DATA_DIRECTORY);
+        if (!referenceDir.exists()) {
+            referenceDir.mkdirs();
+        }
+        return referenceDir;
+    }
+
+    public String getClients() {
+        if (clients == null) {
+            throw new OBException(
+                    "No clients defined to export, is the clients attribute set in the task definition");
+        }
+        return clients;
+    }
+
+    public void setClients(String clients) {
+        this.clients = clients;
+    }
+}