fixes issue 8562: Testcases should be runable from the command line (without Eclipse)
authorMartin Taal <martin.taal@openbravo.com>
Wed, 22 Apr 2009 13:34:41 +0200
changeset 3625 c9bee52a74db
parent 3624 9b57fbd5b521
child 3626 1dafe83a07f7
fixes issue 8562: Testcases should be runable from the command line (without Eclipse)
build.xml
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/DalComplexQueryRequisition.java
src-test/org/openbravo/test/dal/DalComplexQueryRequisitionTest.java
src-test/org/openbravo/test/dal/DalComplexQueryTestOrderLine.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/model/UniqueConstraintTest.java
src-test/org/openbravo/test/modularity/DBPrefixTest.java
src-test/org/openbravo/test/modularity/DatasetServiceTest.java
src-test/org/openbravo/test/security/AccessLevelTest.java
src-test/org/openbravo/test/security/AllowedOrganizationsTest.java
src-test/org/openbravo/test/security/EntityAccessTest.java
src-test/org/openbravo/test/security/WritableReadableOrganizationClientTest.java
src-test/org/openbravo/test/security/WritableReadableOrganizationTest.java
src-test/org/openbravo/test/system/SystemServiceTest.java
src-test/org/openbravo/test/system/SystemValidatorTest.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/ClientDataSetCompleteTest.java
src-test/org/openbravo/test/xml/ClientExportImportTest.java
src-test/org/openbravo/test/xml/ClientExportTest.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/EntityXMLIssues.java
src-test/org/openbravo/test/xml/StaxTest.java
src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java
src-test/org/openbravo/test/xml/testdata/country.xml
src/build.xml
--- a/build.xml	Wed Apr 22 13:20:08 2009 +0200
+++ b/build.xml	Wed Apr 22 13:34:41 2009 +0200
@@ -363,6 +363,14 @@
     <ant dir="${base.src}" target="generate.entities.quick" inheritAll="true" inheritRefs="true" />
   </target>
 
+  <target name="run.tests">
+    <ant dir="${base.src}" target="run.tests" inheritAll="true" inheritRefs="true" />
+  </target>
+
+  <target name="run.quick.tests">
+    <ant dir="${base.src}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
+  </target>
+
   <target name="export.sample.data" depends="code.rev">
     <ant dir="${base.src}" target="export.sample.data" inheritAll="true" inheritRefs="true" />
   </target>
--- a/src-test/org/openbravo/test/AllTests.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/AllTests.java	Wed Apr 22 13:34:41 2009 +0200
@@ -35,12 +35,14 @@
 import org.openbravo.test.security.AccessLevelTest;
 import org.openbravo.test.security.AllowedOrganizationsTest;
 import org.openbravo.test.security.EntityAccessTest;
-import org.openbravo.test.security.WritableReadableOrganizationTest;
-import org.openbravo.test.xml.EntityXMLExportTest;
+import org.openbravo.test.security.WritableReadableOrganizationClientTest;
+import org.openbravo.test.xml.ClientExportImportTest;
 import org.openbravo.test.xml.EntityXMLImportTestBusinessObject;
 import org.openbravo.test.xml.EntityXMLImportTestReference;
 import org.openbravo.test.xml.EntityXMLImportTestSingle;
 import org.openbravo.test.xml.EntityXMLImportTestWarning;
+import org.openbravo.test.xml.EntityXMLIssues;
+import org.openbravo.test.xml.UniqueConstraintImportTest;
 
 public class AllTests {
 
@@ -53,7 +55,7 @@
     suite.addTestSuite(EntityAccessTest.class);
     suite.addTestSuite(AccessLevelTest.class);
     suite.addTestSuite(AllowedOrganizationsTest.class);
-    suite.addTestSuite(WritableReadableOrganizationTest.class);
+    suite.addTestSuite(WritableReadableOrganizationClientTest.class);
 
     // dal
     suite.addTestSuite(HiddenUpdateTest.class);
@@ -72,11 +74,13 @@
     suite.addTestSuite(EvaluationTest.class);
 
     // xml
-    suite.addTestSuite(EntityXMLExportTest.class);
+    suite.addTestSuite(ClientExportImportTest.class);
     suite.addTestSuite(EntityXMLImportTestBusinessObject.class);
+    suite.addTestSuite(EntityXMLImportTestReference.class);
     suite.addTestSuite(EntityXMLImportTestSingle.class);
-    suite.addTestSuite(EntityXMLImportTestReference.class);
     suite.addTestSuite(EntityXMLImportTestWarning.class);
+    suite.addTestSuite(EntityXMLIssues.class);
+    suite.addTestSuite(UniqueConstraintImportTest.class);
 
     // $JUnit-END$
     return suite;
--- a/src-test/org/openbravo/test/authorisations.txt	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/authorisations.txt	Wed Apr 22 13:34:41 2009 +0200
@@ -1,79 +1,61 @@
-
-User 100
+++++++++++++ user 0 ++++++++++++++
 
 >>> Readable entities: 
 
-ADAccountingRptElement
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
-ADAttachment
-ADAuxiliarInput
+ADAuxiliaryInput
 ADCallout
 ADChangeLog
 ADClient
-ADClientInfo
 ADColumn
 ADColumnAccess
-ADDataType
-ADDataset
-ADDatasetColumn
-ADDatasetTable
-ADDimension
 ADElement
 ADElementTrl
 ADField
 ADFieldGroup
 ADFieldGroupTrl
 ADFieldTrl
+ADFileType
 ADForm
 ADFormAccess
 ADFormTrl
 ADHeartbeatLog
 ADImage
-ADImpFormat
-ADImpFormatRow
 ADLanguage
+ADList
+ADListTrl
 ADMenu
 ADMenuTrl
 ADMessage
 ADMessageTrl
-ADModelObject
-ADModelObjectMapping
+ADModelImplementation
+ADModelImplementationMapping
 ADModule
-ADModuleDbprefix
-ADModuleDependency
-ADModuleTrl
-ADModuleVersion
-ADModuleVersionTrl
 ADMonth
+ADMonthTrl
 ADNote
-ADOrg
-ADOrgInfo
-ADPackage
 ADPreference
 ADProcess
 ADProcessAccess
-ADProcessPara
-ADProcessParaTrl
+ADProcessParameter
+ADProcessParameterTrl
 ADProcessScheduling
 ADProcessTrl
 ADRecordAccess
-ADRefList
-ADRefListTrl
-ADRefSearch
-ADRefSearchColumn
-ADRefTable
 ADReference
 ADReferenceTrl
-ADRegistrationInfo
+ADReferencedTable
 ADRole
-ADRoleOrgAccess
+ADRoleOrganization
+ADSelector
+ADSelectorColumn
 ADSequence
 ADSession
 ADSystem
-ADSystemInfo
+ADSystemInformation
 ADTab
 ADTabTrl
 ADTable
@@ -81,13 +63,12 @@
 ADTask
 ADTaskAccess
 ADTaskTrl
-ADTest
-ADTextInterfaces
-ADTextInterfacesTrl
+ADTextInterface
+ADTextInterfaceTrl
 ADTree
 ADUser
 ADUserRoles
-ADValRule
+ADValidation
 ADWFNode
 ADWFNodeNext
 ADWFNodeTrl
@@ -97,238 +78,227 @@
 ADWorkflow
 ADWorkflowAccess
 ADWorkflowTrl
-ATCommand
-ATCommandTrl
-ATLine
-ATRolLogin
+AD_CreateFact_template
 ATTest
-ATTestDocument
-ATTestDocumentLine
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPartner
-CoreCalendar
-CoreCampaign
-CoreCity
-CoreConversionRate
-CoreCountry
-CoreCountryTrl
-CoreCurrency
-CoreCurrencyTrl
-CoreGreeting
-CoreGreetingTrl
-CoreInterOrgAcct
-CoreLocation
-CoreNonBusinessDay
-CorePeriod
-CorePeriodControl
-CoreProject
-CoreRegion
-CoreSalesRegion
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxTrl
-CoreTaxZone
-CoreUOM
-CoreUOMConversion
-CoreUOMTrl
-CoreValidCombination
-CoreYear
-CustomRContactInterest
-CustomRInterestArea
-CustomRMailText
-CustomRRequest
-CustomRRequestAction
-CustomRRequestProcessor
-CustomRRequestProcessorRoute
-CustomRRequestType
-GLCategory
-ImportBPartner
-ImportBankStatement
-ImportBudgetline
-ImportElementValue
-ImportGLJournal
-ImportInventory
-ImportInvoice
-ImportOrder
-ImportProduct
-ImportTax
-MaterialProduct
+Attachment
+BusinessPartner
+City
+ClientInformation
+Command
+CommandTrl
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DataPackage
+DataSet
+DataSetColumn
+DataSetTable
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+FinancialMgmtAccountingCombination
+FinancialMgmtDimension
+FinancialMgmtGLCategory
+FinancialMgmtInterOrgAccounts
+Greeting
+GreetingTrl
+InterestArea
+Line
+Location
+MarketingCampaign
+MarketingMailText
+MaterialMgmtABCActivity
+ModelImplementationParameter
+ModuleDBPrefix
+ModuleDependency
+ModuleTrl
+NamingException
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+ProcessRequest
+Product
+Project
+Region
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+RolLogin
+SalesRegion
+Test
+TestDocument
+TestDocumentLine
+UOM
+UOMConversion
+UOMTrl
 
->>> Derived Readabled entities: 
+>>> Derived Readable entities: 
 
-ADModuleLog
-ADRefDataLoaded
+ADClientModule
+ADOrgModule
 ADTreeNode
-Asset
-AssetAcct
-AssetGroupAcct
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPTaxCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBank
-CoreBankAccount
-CoreBankAccountAcct
-CoreBankStatement
-CoreBankStatementLine
-CoreBudget
-CoreBudgetLine
-CoreCashBook
-CoreCashBookAcct
-CoreChannel
-CoreCharge
-CoreChargeAcct
-CoreDebtPayment
-CoreDiscount
-CoreDocType
-CoreDocTypeTrl
-CoreElement
-CoreElementValue
-CoreElementValueTrl
-CoreGlitem
-CoreGlitemAcct
-CoreInvoice
-CoreInvoiceLine
-CoreInvoiceSchedule
-CoreOrder
-CoreOrderLine
-CorePaymentTerm
-CorePaymentTermTrl
-CorePhase
-CoreProjectAcct
-CoreProjectDetailsV
-CoreProjectIssue
-CoreProjectLine
-CoreProjectPhase
-CoreProjectProposal
-CoreProjectType
-CoreProjectVendor
-CoreSalaryCategory
-CoreWithholding
-CoreWithholdingAcct
-GLJournal
-GLJournalBatch
-GLJournalLine
+ApprovedVendor
+AttributeSet
+AttributeSetInstance
+Bank
+BankAccount
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+CustomerAccounts
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+FinancialMgmtAcctSchema
+FinancialMgmtAsset
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtDebtPayment
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCharge
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxRate
+FinancialMgmtTaxTrl
+FinancialMgmtWithholding
+Invoice
+InvoiceLine
+InvoiceSchedule
+Locator
 MRPPlanner
 MRPPlanningMethod
 ManufacturingProcessPlan
-MaterialAttributeSet
-MaterialAttributeSetInstance
-MaterialCosting
-MaterialFreightCategory
-MaterialInventory
-MaterialInventoryLine
-MaterialLocator
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductTrl
-MaterialProductUOM
-MaterialRappel
-MaterialRappelBpartner
-MaterialReplenish
-MaterialShipper
-MaterialSubstitute
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-ServiceExpenseType
-ServiceResource
-ServiceTimeExpenseLine
+MarketingChannel
+MaterialMgmtCosting
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+ModuleLog
+Order
+OrderLine
+PricingDiscount
+PricingPriceList
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProposal
+ProjectStandardPhase
+ProjectType
+ProjectVendor
+ReferenceDataStore
+Replenish
+Resource
+SalaryCategory
+ShippingFreightCategory
+ShippingShippingCompany
+TimeAndExpenseSheetLine
+VendorAccounts
+Warehouse
+WarehouseShipper
 
->>> Writable Readabled entities: 
+>>> Writable entities: 
 
-ADAccountingRptElement
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
-ADAttachment
-ADAuxiliarInput
+ADAuxiliaryInput
 ADCallout
 ADChangeLog
 ADClient
-ADClientInfo
 ADColumn
 ADColumnAccess
-ADDataType
-ADDataset
-ADDatasetColumn
-ADDatasetTable
-ADDimension
 ADElement
 ADElementTrl
 ADField
 ADFieldGroup
 ADFieldGroupTrl
 ADFieldTrl
+ADFileType
 ADForm
 ADFormAccess
 ADFormTrl
 ADHeartbeatLog
 ADImage
-ADImpFormat
-ADImpFormatRow
 ADLanguage
+ADList
+ADListTrl
 ADMenu
 ADMenuTrl
 ADMessage
 ADMessageTrl
-ADModelObject
-ADModelObjectMapping
+ADModelImplementation
+ADModelImplementationMapping
 ADModule
-ADModuleDbprefix
-ADModuleDependency
-ADModuleTrl
-ADModuleVersion
-ADModuleVersionTrl
 ADMonth
+ADMonthTrl
 ADNote
-ADOrg
-ADOrgInfo
-ADPackage
 ADPreference
 ADProcess
 ADProcessAccess
-ADProcessPara
-ADProcessParaTrl
+ADProcessParameter
+ADProcessParameterTrl
 ADProcessScheduling
 ADProcessTrl
 ADRecordAccess
-ADRefList
-ADRefListTrl
-ADRefSearch
-ADRefSearchColumn
-ADRefTable
 ADReference
 ADReferenceTrl
-ADRegistrationInfo
+ADReferencedTable
 ADRole
-ADRoleOrgAccess
+ADRoleOrganization
+
+ADSelector
+ADSelectorColumn
 ADSequence
 ADSession
 ADSystem
-ADSystemInfo
+ADSystemInformation
 ADTab
 ADTabTrl
 ADTable
@@ -336,13 +306,175 @@
 ADTask
 ADTaskAccess
 ADTaskTrl
-ADTest
-ADTextInterfaces
-ADTextInterfacesTrl
+ADTextInterface
+ADTextInterfaceTrl
 ADTree
 ADUser
 ADUserRoles
-ADValRule
+ADValidation
+ADWFNode
+ADWFNodeNext
+ADWFNodeTrl
+ADWindow
+ADWindowAccess
+ADWindowTrl
+ADWorkflow
+
+ADWorkflowAccess
+ADWorkflowTrl
+AD_CreateFact_template
+ATTest
+Attachment
+BusinessPartner
+City
+ClientInformation
+Command
+CommandTrl
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DataPackage
+DataSet
+DataSetColumn
+DataSetTable
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+FinancialMgmtAccountingCombination
+FinancialMgmtDimension
+FinancialMgmtGLCategory
+FinancialMgmtInterOrgAccounts
+Greeting
+GreetingTrl
+InterestArea
+Line
+Location
+MarketingCampaign
+MarketingMailText
+MaterialMgmtABCActivity
+ModelImplementationParameter
+ModuleDBPrefix
+ModuleDependency
+ModuleTrl
+NamingException
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+ProcessRequest
+Product
+Project
+Region
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+RolLogin
+SalesRegion
+Test
+TestDocument
+TestDocumentLine
+UOM
+UOMConversion
+UOMTrl
+
+
+
+>>> Readable Not-Writable entities: 
+
+
+
+540  [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_PeriodControl_V not found in runtime model
+594  [main] WARN  org.openbravo.base.model.ModelProvider - Table name: AD_Process_Execution_V not found in runtime model
+++++++++++++ user 100 ++++++++++++++
+
+>>> Readable entities: 
+
+ADAlert
+ADAlertRecipient
+ADAlertRule
+ADAlertRuleTrl
+ADAuxiliaryInput
+ADCallout
+ADChangeLog
+ADClient
+ADColumn
+ADColumnAccess
+ADElement
+ADElementTrl
+ADField
+ADFieldGroup
+ADFieldGroupTrl
+ADFieldTrl
+ADFileType
+ADForm
+ADFormAccess
+ADFormTrl
+ADHeartbeatLog
+ADImage
+ADLanguage
+ADList
+ADListTrl
+ADMenu
+ADMenuTrl
+ADMessage
+ADMessageTrl
+ADModelImplementation
+ADModelImplementationMapping
+ADModule
+ADMonth
+ADMonthTrl
+ADNote
+ADPreference
+ADProcess
+ADProcessAccess
+ADProcessParameter
+ADProcessParameterTrl
+ADProcessScheduling
+ADProcessTrl
+ADRecordAccess
+ADReference
+ADReferenceTrl
+ADReferencedTable
+ADRole
+ADRoleOrganization
+ADSelector
+ADSelectorColumn
+ADSequence
+ADSession
+ADSystem
+ADSystemInformation
+ADTab
+ADTabTrl
+ADTable
+ADTableAccess
+ADTask
+ADTaskAccess
+ADTaskTrl
+ADTextInterface
+ADTextInterfaceTrl
+ADTree
+ADUser
+ADUserRoles
+ADValidation
 ADWFNode
 ADWFNodeNext
 ADWFNodeTrl
@@ -352,599 +484,485 @@
 ADWorkflow
 ADWorkflowAccess
 ADWorkflowTrl
-ATCommand
-ATCommandTrl
-ATLine
-ATRolLogin
+AD_CreateFact_template
 ATTest
-ATTestDocument
-ATTestDocumentLine
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPartner
-CoreCalendar
-CoreCampaign
-CoreCity
-CoreConversionRate
-CoreCountry
-CoreCountryTrl
-CoreCurrency
-CoreCurrencyTrl
-CoreGreeting
-CoreGreetingTrl
-CoreInterOrgAcct
-CoreLocation
-CoreNonBusinessDay
-CorePeriod
-CorePeriodControl
-CoreProject
-CoreRegion
-CoreSalesRegion
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxTrl
-CoreTaxZone
-CoreUOM
-CoreUOMConversion
-CoreUOMTrl
-CoreValidCombination
-CoreYear
-CustomRContactInterest
-CustomRInterestArea
-CustomRMailText
-CustomRRequest
-CustomRRequestAction
-CustomRRequestProcessor
-CustomRRequestProcessorRoute
-CustomRRequestType
-GLCategory
-ImportBPartner
-ImportBankStatement
-ImportBudgetline
-ImportElementValue
-ImportGLJournal
-ImportInventory
-ImportInvoice
-ImportOrder
-ImportProduct
-ImportTax
-MaterialProduct
+Attachment
+BusinessPartner
+City
+ClientInformation
+Command
+CommandTrl
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DataPackage
+DataSet
+DataSetColumn
+DataSetTable
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+FinancialMgmtAccountingCombination
+FinancialMgmtDimension
+FinancialMgmtGLCategory
+FinancialMgmtInterOrgAccounts
+Greeting
+GreetingTrl
+InterestArea
+Line
+Location
+MarketingCampaign
+MarketingMailText
+MaterialMgmtABCActivity
+ModelImplementationParameter
+ModuleDBPrefix
+ModuleDependency
+ModuleTrl
+NamingException
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+ProcessRequest
+Product
+Project
+Region
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+RolLogin
+SalesRegion
+Test
+TestDocument
+TestDocumentLine
+UOM
+UOMConversion
+UOMTrl
 
+>>> Derived Readable entities: 
 
-User 1000000
+ADClientModule
+ADOrgModule
+ADTreeNode
+ApprovedVendor
+AttributeSet
+AttributeSetInstance
+Bank
+BankAccount
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+CustomerAccounts
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+FinancialMgmtAcctSchema
+FinancialMgmtAsset
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtDebtPayment
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCharge
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxRate
+FinancialMgmtTaxTrl
+FinancialMgmtWithholding
+Invoice
+InvoiceLine
+InvoiceSchedule
+Locator
+MRPPlanner
+MRPPlanningMethod
+ManufacturingProcessPlan
+MarketingChannel
+MaterialMgmtCosting
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+ModuleLog
+Order
+OrderLine
+PricingDiscount
+PricingPriceList
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProposal
+ProjectStandardPhase
+ProjectType
+ProjectVendor
+ReferenceDataStore
+Replenish
+Resource
+SalaryCategory
+ShippingFreightCategory
+ShippingShippingCompany
+TimeAndExpenseSheetLine
+VendorAccounts
+Warehouse
+WarehouseShipper
 
->>> Readabled entities: 
+>>> Writable entities: 
 
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
-ADOrg
-ADSequence
-AccountingAcct
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPartner
-CoreBankStatement
-CoreBankStatementLine
-CoreCalendar
-CoreCampaign
-CoreCash
-CoreCashLine
-CoreCharge
-CoreChargeAcct
-CoreDPManagement
-CoreDPManagementLine
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDocType
-CoreDocTypeTrl
-CoreElement
-CoreElementValue
-CoreElementValueOperand
-CoreElementValueTrl
-CoreGlitem
-CoreGlitemAcct
-CoreNonBusinessDay
-CorePeriod
-CorePeriodControl
-CoreProject
-CoreRemittance
-CoreRemittanceLine
-CoreRemittanceParameter
-CoreRemittanceType
-CoreSalesRegion
-CoreSettlement
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxTrl
-CoreTaxZone
-CoreValidCombination
-CoreYear
-GLCategory
-GLJournal
-GLJournalBatch
-GLJournalLine
-MaterialProduct
-
->>> Derived Readabled entities: 
-
+ADAuxiliaryInput
+ADCallout
+ADChangeLog
 ADClient
+ADColumn
+ADColumnAccess
+ADElement
+ADElementTrl
+ADField
+ADFieldGroup
+ADFieldGroupTrl
+ADFieldTrl
+ADFileType
+ADForm
+ADFormAccess
+ADFormTrl
+ADHeartbeatLog
 ADImage
 ADLanguage
-ADOrgInfo
+ADList
+ADListTrl
+ADMenu
+ADMenuTrl
+ADMessage
+ADMessageTrl
+ADModelImplementation
+ADModelImplementationMapping
+ADModule
+ADMonth
+ADMonthTrl
+ADNote
+ADPreference
+ADProcess
+ADProcessAccess
+ADProcessParameter
+ADProcessParameterTrl
+ADProcessScheduling
+ADProcessTrl
+ADRecordAccess
+ADReference
+ADReferenceTrl
+ADReferencedTable
 ADRole
-ADRoleOrgAccess
+ADRoleOrganization
+ADSelector
+ADSelectorColumn
+ADSequence
+ADSession
+ADSystem
+ADSystemInformation
 ADTab
+ADTabTrl
 ADTable
+ADTableAccess
+ADTask
+ADTaskAccess
+ADTaskTrl
+ADTextInterface
+ADTextInterfaceTrl
 ADTree
 ADUser
+ADUserRoles
+ADValidation
+ADWFNode
+ADWFNodeNext
+ADWFNodeTrl
 ADWindow
-Asset
-AssetAcct
-AssetGroupAcct
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPTaxCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBank
-CoreBankAccount
-CoreBankAccountAcct
-CoreCashBook
-CoreCashBookAcct
-CoreChannel
-CoreCountry
-CoreCurrency
-CoreDebtPayment
-CoreDiscount
-CoreGreeting
-CoreInterOrgAcct
-CoreInvoice
-CoreInvoiceSchedule
-CoreLocation
-CoreOrder
-CorePaymentTerm
-CorePhase
-CoreProjectAcct
-CoreProjectDetailsV
-CoreProjectIssue
-CoreProjectLine
-CoreProjectPhase
-CoreProjectProposal
-CoreProjectType
-CoreProjectVendor
-CoreRegion
-CoreSalaryCategory
-CoreUOM
-CoreWithholding
-CoreWithholdingAcct
-MRPPlanner
-MRPPlanningMethod
-ManufacturingProcessPlan
-MaterialAttributeSet
-MaterialAttributeSetInstance
-MaterialCosting
-MaterialFreightCategory
-MaterialLocator
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductTrl
-MaterialProductUOM
-MaterialRappel
-MaterialRappelBpartner
-MaterialReplenish
-MaterialSubstitute
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-ServiceExpenseType
-ServiceResource
-ServiceTimeExpenseLine
+ADWindowAccess
+ADWindowTrl
+ADWorkflow
+ADWorkflowAccess
+ADWorkflowTrl
+AD_CreateFact_template
+ATTest
+Attachment
+BusinessPartner
+City
+ClientInformation
+Command
+CommandTrl
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DataPackage
+DataSet
+DataSetColumn
+DataSetTable
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+FinancialMgmtAccountingCombination
+FinancialMgmtDimension
+FinancialMgmtGLCategory
+FinancialMgmtInterOrgAccounts
+Greeting
+GreetingTrl
+InterestArea
+Line
+Location
+MarketingCampaign
+MarketingMailText
+MaterialMgmtABCActivity
+ModelImplementationParameter
+ModuleDBPrefix
+ModuleDependency
+ModuleTrl
+NamingException
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+ProcessRequest
+Product
+Project
+Region
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+RolLogin
+SalesRegion
+Test
+TestDocument
+TestDocumentLine
+UOM
+UOMConversion
+UOMTrl
 
->>> Writable Readabled entities: 
+
+
+>>> Readable Not-Writable entities: 
+
+
+++++++++++++ user 1000020 ++++++++++++++
+
+>>> Readable entities: 
 
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
-ADOrg
+ADChangeLog
+ADNote
+ADPreference
+ADProcessScheduling
 ADSequence
-AccountingAcct
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPartner
-CoreBankStatement
-CoreBankStatementLine
-CoreCalendar
-CoreCampaign
-CoreCash
-CoreCashLine
-CoreCharge
-CoreChargeAcct
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDocType
-CoreDocTypeTrl
-CoreElement
-CoreElementValue
-CoreElementValueOperand
-CoreElementValueTrl
-CoreGlitem
-CoreGlitemAcct
-CoreNonBusinessDay
-CorePeriod
-CorePeriodControl
-CoreProject
-CoreRemittanceParameter
-CoreRemittanceType
-CoreSalesRegion
-CoreSettlement
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxTrl
-CoreTaxZone
-CoreValidCombination
-CoreYear
-GLCategory
-GLJournal
-GLJournalBatch
-GLJournalLine
-MaterialProduct
-
-
-User 1000001
-
->>> Readabled entities: 
-
+ADSession
 ADUser
-Asset
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartner
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBankStatement
-CoreBankStatementLine
-CoreCash
-CoreCashLine
-CoreDebtPayment
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDiscount
-CoreExternalPOS
-CoreExternalPOSCategory
-CoreExternalPOSProduct
-CoreGreeting
-CoreGreetingTrl
-CoreInvoice
-CoreInvoiceDiscount
-CoreInvoiceLine
-CoreInvoiceLineAcctDimension
-CoreInvoiceLineOffer
-CoreInvoiceSchedule
-CoreInvoiceTax
-CoreOrder
-CoreOrderLine
-CoreOrderLineOffer
-CoreOrderTax
-CorePaymentTerm
-CorePaymentTermLine
-CorePaymentTermTrl
-CoreProject
-CoreProjectLine
-CoreProjectProposal
-CoreProjectProposalLine
-CoreProjectProposalTask
-CoreProjectVendor
-CoreRemittanceParameter
-CoreRemittanceType
-CoreRevenueRecognition
-CoreRevenueRecognitionPlan
-CoreRevenueRecognitionRun
-CoreSettlement
-CustomRContactInterest
-CustomRRequest
-MaterialAttribute
-MaterialAttributeSet
-MaterialAttributeUse
-MaterialAttributeValue
-MaterialCosting
-MaterialDiscountSchema
-MaterialDiscountSchemaLine
-MaterialInOut
-MaterialInOutLine
-MaterialInventory
-MaterialInventoryLine
-MaterialLocator
-MaterialLocatorType
-MaterialLot
-MaterialLotCtl
-MaterialMatchInv
-MaterialMatchPO
-MaterialMovement
-MaterialMovementLine
-MaterialOffer
-MaterialOfferBPGroup
-MaterialOfferBPartner
-MaterialOfferPriceList
-MaterialOfferProduct
-MaterialOfferProductCat
-MaterialPerpetualInv
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProduct
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductPrice
-MaterialProductTemplate
-MaterialProductTrl
-MaterialProductUOM
-MaterialRappel
-MaterialRappelBpartner
-MaterialRappelInvoice
-MaterialRappelProduct
-MaterialRappelProductcategory
-MaterialRappelScale
-MaterialReplenish
-MaterialSerNoCtl
-MaterialStorageDetail
-MaterialSubstitute
-MaterialTransaction
-MaterialWHPeriod
-MaterialWHPeriodInvoiced
-MaterialWHSchedule
-MaterialWHScheduleProduct
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-
->>> Derived Readabled entities: 
-
-ADClient
-ADImage
-ADLanguage
-ADOrg
-ADRole
 ADUserRoles
-Amortization
-Amortizationline
-AssetAcct
-AssetAmortization
-AssetGroup
-CoreAcctSchema
-CoreActivity
-CoreBPTaxCategory
-CoreBank
-CoreBankAccount
-CoreCampaign
-CoreCashBook
-CoreCharge
-CoreCommissionDetail
-CoreCountry
-CoreCurrency
-CoreDPManagement
-CoreDocType
-CoreGlitem
-CoreIncoterms
-CoreLocation
-CorePhase
-CoreProjectAcct
-CoreProjectDetailsV
-CoreProjectIssue
-CoreProjectPhase
-CoreProjectType
-CoreRegion
-CoreSalaryCategory
-CoreSalesRegion
-CoreTax
-CoreTaxCategory
-CoreUOM
-CoreValidCombination
-CoreWithholding
-CustomRInterestArea
-CustomRMailText
-CustomRRequestType
-GLJournal
-MRPPlanner
-MRPPlanningMethod
-ManufacturingProcessPlan
-MaterialAttributeInstance
-MaterialAttributeSetInstance
-MaterialFreightCategory
-MaterialInOutLineV
-MaterialInternalConsumptionLine
-MaterialProduction
-MaterialProductionLine
-MaterialProductionPlan
-MaterialShipper
-ServiceExpenseType
-ServiceResource
-ServiceResourceAssignment
-ServiceTimeExpenseLine
-
->>> Writable Readabled entities: 
-
-ADUser
-Asset
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartner
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBankStatement
-CoreBankStatementLine
-CoreCash
-CoreCashLine
-CoreDebtPayment
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDiscount
-CoreExternalPOS
-CoreExternalPOSCategory
-CoreExternalPOSProduct
-CoreGreeting
-CoreGreetingTrl
-CoreInvoice
-CoreInvoiceDiscount
-CoreInvoiceLine
-CoreInvoiceLineAcctDimension
-CoreInvoiceLineOffer
-CoreInvoiceSchedule
-CoreInvoiceTax
-CoreOrder
-CoreOrderLine
-CoreOrderLineOffer
-CoreOrderTax
-CorePaymentTerm
-CorePaymentTermLine
-CorePaymentTermTrl
-CoreProject
-CoreProjectLine
-CoreProjectProposal
-CoreProjectProposalLine
-CoreProjectProposalTask
-CoreProjectVendor
-CoreRemittanceParameter
-CoreRemittanceType
-CoreRevenueRecognition
-CoreRevenueRecognitionPlan
-CoreRevenueRecognitionRun
-CoreSettlement
-CustomRContactInterest
-CustomRRequest
-MaterialAttribute
-MaterialAttributeSet
-MaterialAttributeUse
-MaterialAttributeValue
-MaterialCosting
-MaterialDiscountSchema
-MaterialDiscountSchemaLine
-MaterialInOut
-MaterialInOutLine
-MaterialInventory
-MaterialInventoryLine
-MaterialLocator
-MaterialLocatorType
-MaterialLot
-MaterialLotCtl
-MaterialMatchInv
-MaterialMatchPO
-MaterialMovement
-MaterialMovementLine
-MaterialOffer
-MaterialOfferBPGroup
-MaterialOfferBPartner
-MaterialOfferPriceList
-MaterialOfferProduct
-MaterialOfferProductCat
-MaterialPerpetualInv
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProduct
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductPrice
-MaterialProductTemplate
-MaterialProductTrl
-MaterialProductUOM
-MaterialRappel
-MaterialRappelBpartner
-MaterialRappelInvoice
-MaterialRappelProduct
-MaterialRappelProductcategory
-MaterialRappelScale
-MaterialReplenish
-MaterialSerNoCtl
-MaterialStorageDetail
-MaterialSubstitute
-MaterialTransaction
-MaterialWHPeriod
-MaterialWHPeriodInvoiced
-MaterialWHSchedule
-MaterialWHScheduleProduct
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-
-
-User 1000002
-
->>> Readabled entities: 
-
+AcctSchemaTableDocType
+ApprovedVendor
+Attribute
+AttributeSet
+AttributeUse
+AttributeValue
+Bank
+BankAccount
+BankAccountAccounts
+BusinessPartner
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerCategoryAccount
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerProductTemplate
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+ContactInterest
+CustomerAccounts
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailTemplate
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+ExternalPOS
+ExternalPOSCategory
+ExternalPOSProduct
+FinancialMgmtAccountingCombination
+FinancialMgmtAccountingFact
+FinancialMgmtAccountingReport
+FinancialMgmtAccountingRptElement
+FinancialMgmtAcctRptGroup
+FinancialMgmtAcctRptNode
+FinancialMgmtAcctSchema
+FinancialMgmtAcctSchemaDefault
+FinancialMgmtAcctSchemaElement
+FinancialMgmtAcctSchemaGL
+FinancialMgmtAcctSchemaTable
+FinancialMgmtAmortization
+FinancialMgmtAmortizationLine
+FinancialMgmtAsset
+FinancialMgmtAssetAccounts
+FinancialMgmtAssetGroup
+FinancialMgmtAssetGroupAcct
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtCashBook
+FinancialMgmtCashBookAccounts
+FinancialMgmtCashJournal
+FinancialMgmtDPManagement
+FinancialMgmtDPManagementLine
+FinancialMgmtDebtPayment
+FinancialMgmtDebtPaymentBalReplace
+FinancialMgmtDebtPaymentBalancing
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueOperand
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCategory
+FinancialMgmtGLCharge
+FinancialMgmtGLChargeAccounts
+FinancialMgmtGLItem
+FinancialMgmtGLItemAccounts
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtIncoterms
+FinancialMgmtInterOrgAccounts
+FinancialMgmtJournalLine
+FinancialMgmtNonBusinessDay
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermLine
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtPeriodControl
+FinancialMgmtPromissoryFormat
+FinancialMgmtRemittance
+FinancialMgmtRemittanceLine
+FinancialMgmtRemittanceParameter
+FinancialMgmtRemittanceType
+FinancialMgmtSettlement
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxPayment
+FinancialMgmtTaxRate
+FinancialMgmtTaxRateAccounts
+FinancialMgmtTaxRegister
+FinancialMgmtTaxRegisterType
+FinancialMgmtTaxRegisterTypeLines
+FinancialMgmtTaxRegisterline
+FinancialMgmtTaxReport
+FinancialMgmtTaxTrl
+FinancialMgmtTaxZone
+FinancialMgmtWithholding
+FinancialMgmtWithholdingAccounts
+FinancialMgmtYear
+Greeting
+GreetingTrl
+InterestArea
+Invoice
+InvoiceDiscount
+InvoiceLine
+InvoiceLineAccountingDimension
+InvoiceLineOffer
+InvoiceSchedule
+InvoiceTax
+Location
+Locator
+LocatorType
+Lot
+LotControl
 MRPPlanner
 MRPPlanningMethod
 MRPPlanningMethodLine
-MRPRunProduction
-MRPRunProductionLine
-MRPRunPurchase
-MRPRunPurchaseLine
+MRPProductionRun
+MRPProductionRunLine
+MRPPurchasingRun
+MRPPurchasingRunLine
 MRPSalesForecast
 MRPSalesForecastLine
-ManufacturingCCP
-ManufacturingCCPGroup
-ManufacturingCCPShift
+ManufacturingActivity
+ManufacturingActivityToolset
+ManufacturingCase
+ManufacturingCheckPoint
+ManufacturingCheckPointSet
+ManufacturingCheckPointShift
 ManufacturingCostCenter
 ManufacturingCostCenterMachine
 ManufacturingCostcenterEmployee
@@ -957,86 +975,335 @@
 ManufacturingMachine
 ManufacturingMachineCost
 ManufacturingMachineStation
-ManufacturingMaintPeriodicity
+ManufacturingMachineType
+ManufacturingMainteanceOrder
 ManufacturingMaintenance
+ManufacturingMaintenancePeriodicity
+ManufacturingMaintenanceSchedule
+ManufacturingMaintenanceTask
+ManufacturingMaintenanceWorker
 ManufacturingMeasureGroup
 ManufacturingMeasureShift
 ManufacturingMeasureTime
 ManufacturingMeasureValues
-ManufacturingPCCase
-ManufacturingPCTest
-ManufacturingPCValue
-ManufacturingPLEmployee
-ManufacturingPLIC
-ManufacturingPLInvoiceLine
-ManufacturingPLMachine
+ManufacturingOperation
+ManufacturingOperationEmployee
+ManufacturingOperationIndirectCost
+ManufacturingOperationMachine
+ManufacturingOperationProduct
 ManufacturingPeriodicControl
-ManufacturingProcess
 ManufacturingProcessPlan
-ManufacturingProcessPlanVersion
+ManufacturingProductionLine
+ManufacturingProductionRunEmployee
+ManufacturingProductionRunIndirectCosts
+ManufacturingProductionRunInvoiceLine
+ManufacturingProductionRunMachine
+ManufacturingProductionRunToolset
 ManufacturingSection
-ManufacturingSequence
-ManufacturingSequenceEmployee
-ManufacturingSequenceIC
-ManufacturingSequenceMachine
-ManufacturingSequenceProduct
+ManufacturingTest
 ManufacturingToolset
-ManufacturingToolsetProcess
 ManufacturingToolsetType
-ManufacturingToolsetUsed
-ManufacturingWEEmployee
-ManufacturingWEIncidence
-ManufacturingWRPhase
-ManufacturingWRPhaseProduct
+ManufacturingValue
+ManufacturingVersion
+ManufacturingWorkCenter
+ManufacturingWorkEffortEmployee
+ManufacturingWorkEffortIncidence
 ManufacturingWorkRequirement
-ManufacturingWorkStation
-MaterialProduction
-MaterialProductionLine
-MaterialProductionPlan
-MaterialRequisition
-MaterialRequisitionLine
-MaterialRequisitionOrder
+ManufacturingWorkRequirementOperation
+ManufacturingWorkRequirementProduct
+MarketingCampaign
+MarketingChannel
+MarketingMailText
+MaterialMgmtABCActivity
+MaterialMgmtCosting
+MaterialMgmtInternalConsumption
+MaterialMgmtInternalConsumptionLine
+MaterialMgmtInternalMovement
+MaterialMgmtInternalMovementLine
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+MaterialMgmtMaterialTransaction
+MaterialMgmtProductionPlan
+MaterialMgmtProductionTransaction
+MaterialMgmtShipmentInOut
+MaterialMgmtShipmentInOutLine
+MaterialMgmtStorageDetail
+Order
+OrderDiscount
+OrderLine
+OrderLineOffer
+OrderTax
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+PeriodControlLog
+PerpetualInv
+PricingAdjustment
+PricingAdjustmentBusinessPartner
+PricingAdjustmentBusinessPartnerGroup
+PricingAdjustmentPriceList
+PricingAdjustmentProduct
+PricingAdjustmentProductCategory
+PricingDiscount
+PricingPriceList
+PricingPriceListSchema
+PricingPriceListSchemeLine
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+PricingVolumeDiscountInvoice
+PricingVolumeDiscountProduct
+PricingVolumeDiscountProductCategory
+PricingVolumeDiscountScale
+ProcessRequest
+ProcurementPOInvoiceMatch
+ProcurementReceiptInvoiceMatch
+ProcurementRequisition
+ProcurementRequisitionLine
+ProcurementRequisitionPOMatch
+Product
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCategoryAccounts
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+Project
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProjectProposalTask
+ProjectProposal
+ProjectProposalLine
+ProjectStandardPhase
+ProjectStandardTask
+ProjectTask
+ProjectType
+ProjectVendor
+Replenish
+Request
+RequestType
+RequestionAction
+Resource
+ResourceAssignment
+ResourcePlanCost
+ResourceType
+ResourceUnAvailable
+RevenueRecognition
+RevenueRecognitionPlan
+RevenueRecognitionRun
+SalaryCategory
+SalaryCategoryCost
+SalesCommission
+SalesCommissionAmount
+SalesCommissionDetail
+SalesCommissionLine
+SalesCommissionRun
+SalesRegion
+SerialNumberControl
+ServiceLevel
+ServiceLevelLine
+ShippingFreightCategory
+ShippingShippingCompany
+ShippingShippingCompanyFreight
+TimeAndExpenseSheet
+TimeAndExpenseSheetLine
+TimeType
+VendorAccounts
+Warehouse
+WarehouseAccounts
+WarehousePeriod
+WarehousePeriodInvoiced
+WarehouseSchedule
+WarehouseScheduleProduct
+WarehouseShipper
 
->>> Derived Readabled entities: 
+>>> Derived Readable entities: 
 
 ADClient
-ADOrg
-ADUser
-CoreActivity
-CoreBPGroup
-CoreBPartner
-CoreCampaign
-CoreCurrency
-CoreInvoice
-CoreInvoiceLine
-CoreOrder
-CoreOrderLine
-CoreProject
-CoreSalaryCategory
-CoreUOM
-ManufacturingMachineType
-ManufacturingMaintOperation
-MaterialAttributeSetInstance
-MaterialLocator
-MaterialPriceList
-MaterialProduct
-MaterialProductCategory
-MaterialProductUOM
+ADColumn
+ADImage
+ADLanguage
+ADMessage
+ADProcess
+ADRole
+ADRoleOrganization
+ADTab
+ADTable
+ADTree
+ADWindow
+AD_CreateFact_template
+AttributeInstance
+AttributeSetInstance
+City
+Country
+Currency
+OrganizationClosing
+Region
+UOM
 
 >>> Writable entities: 
 
+ADAlert
+ADAlertRecipient
+ADAlertRule
+ADAlertRuleTrl
+ADChangeLog
+ADNote
+ADPreference
+ADProcessScheduling
+ADSequence
+ADSession
+ADUser
+ADUserRoles
+AcctSchemaTableDocType
+ApprovedVendor
+Attribute
+AttributeSet
+AttributeUse
+AttributeValue
+Bank
+BankAccount
+BankAccountAccounts
+BusinessPartner
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerCategoryAccount
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerProductTemplate
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+ContactInterest
+CustomerAccounts
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailTemplate
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+ExternalPOS
+ExternalPOSCategory
+ExternalPOSProduct
+FinancialMgmtAccountingCombination
+FinancialMgmtAccountingFact
+FinancialMgmtAccountingReport
+FinancialMgmtAccountingRptElement
+FinancialMgmtAcctRptGroup
+FinancialMgmtAcctRptNode
+FinancialMgmtAcctSchema
+FinancialMgmtAcctSchemaDefault
+FinancialMgmtAcctSchemaElement
+FinancialMgmtAcctSchemaGL
+FinancialMgmtAcctSchemaTable
+FinancialMgmtAmortization
+FinancialMgmtAmortizationLine
+FinancialMgmtAsset
+FinancialMgmtAssetAccounts
+FinancialMgmtAssetGroup
+FinancialMgmtAssetGroupAcct
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtCashBook
+FinancialMgmtCashBookAccounts
+FinancialMgmtCashJournal
+FinancialMgmtDPManagement
+FinancialMgmtDPManagementLine
+FinancialMgmtDebtPayment
+FinancialMgmtDebtPaymentBalReplace
+FinancialMgmtDebtPaymentBalancing
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueOperand
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCategory
+FinancialMgmtGLCharge
+FinancialMgmtGLChargeAccounts
+FinancialMgmtGLItem
+FinancialMgmtGLItemAccounts
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtIncoterms
+FinancialMgmtInterOrgAccounts
+FinancialMgmtJournalLine
+FinancialMgmtNonBusinessDay
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermLine
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtPeriodControl
+FinancialMgmtPromissoryFormat
+FinancialMgmtRemittance
+FinancialMgmtRemittanceLine
+FinancialMgmtRemittanceParameter
+FinancialMgmtRemittanceType
+FinancialMgmtSettlement
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxPayment
+FinancialMgmtTaxRate
+FinancialMgmtTaxRateAccounts
+FinancialMgmtTaxRegister
+FinancialMgmtTaxRegisterType
+FinancialMgmtTaxRegisterTypeLines
+FinancialMgmtTaxRegisterline
+FinancialMgmtTaxReport
+FinancialMgmtTaxTrl
+FinancialMgmtTaxZone
+FinancialMgmtWithholding
+FinancialMgmtWithholdingAccounts
+FinancialMgmtYear
+Greeting
+GreetingTrl
+InterestArea
+Invoice
+InvoiceDiscount
+InvoiceLine
+InvoiceLineAccountingDimension
+InvoiceLineOffer
+InvoiceSchedule
+InvoiceTax
+Location
+Locator
+LocatorType
+Lot
+LotControl
 MRPPlanner
 MRPPlanningMethod
 MRPPlanningMethodLine
-MRPRunProduction
-MRPRunProductionLine
-MRPRunPurchase
-MRPRunPurchaseLine
+MRPProductionRun
+MRPProductionRunLine
+MRPPurchasingRun
+MRPPurchasingRunLine
 MRPSalesForecast
 MRPSalesForecastLine
-ManufacturingCCP
-ManufacturingCCPGroup
-ManufacturingCCPShift
+ManufacturingActivity
+ManufacturingActivityToolset
+ManufacturingCase
+ManufacturingCheckPoint
+ManufacturingCheckPointSet
+ManufacturingCheckPointShift
 ManufacturingCostCenter
 ManufacturingCostCenterMachine
 ManufacturingCostcenterEmployee
@@ -1049,76 +1316,189 @@
 ManufacturingMachine
 ManufacturingMachineCost
 ManufacturingMachineStation
-ManufacturingMaintPeriodicity
+ManufacturingMachineType
+ManufacturingMainteanceOrder
 ManufacturingMaintenance
+ManufacturingMaintenancePeriodicity
+ManufacturingMaintenanceSchedule
+ManufacturingMaintenanceTask
+ManufacturingMaintenanceWorker
 ManufacturingMeasureGroup
 ManufacturingMeasureShift
 ManufacturingMeasureTime
 ManufacturingMeasureValues
-ManufacturingPCCase
-ManufacturingPCTest
-ManufacturingPCValue
-ManufacturingPLEmployee
-ManufacturingPLIC
-ManufacturingPLInvoiceLine
-ManufacturingPLMachine
+ManufacturingOperation
+ManufacturingOperationEmployee
+ManufacturingOperationIndirectCost
+ManufacturingOperationMachine
+ManufacturingOperationProduct
 ManufacturingPeriodicControl
-ManufacturingProcess
 ManufacturingProcessPlan
-ManufacturingProcessPlanVersion
+ManufacturingProductionLine
+ManufacturingProductionRunEmployee
+ManufacturingProductionRunIndirectCosts
+ManufacturingProductionRunInvoiceLine
+ManufacturingProductionRunMachine
+ManufacturingProductionRunToolset
 ManufacturingSection
-ManufacturingSequence
-ManufacturingSequenceEmployee
-ManufacturingSequenceIC
-ManufacturingSequenceMachine
-ManufacturingSequenceProduct
+ManufacturingTest
 ManufacturingToolset
-ManufacturingToolsetProcess
 ManufacturingToolsetType
-ManufacturingToolsetUsed
-ManufacturingWEEmployee
-ManufacturingWEIncidence
-ManufacturingWRPhase
-ManufacturingWRPhaseProduct
+ManufacturingValue
+ManufacturingVersion
+ManufacturingWorkCenter
+ManufacturingWorkEffortEmployee
+ManufacturingWorkEffortIncidence
 ManufacturingWorkRequirement
-ManufacturingWorkStation
-MaterialProduction
-MaterialProductionLine
-MaterialProductionPlan
-MaterialRequisition
-MaterialRequisitionLine
-MaterialRequisitionOrder
+ManufacturingWorkRequirementOperation
+ManufacturingWorkRequirementProduct
+MarketingCampaign
+MarketingChannel
+MarketingMailText
+MaterialMgmtABCActivity
+MaterialMgmtCosting
+MaterialMgmtInternalConsumption
+MaterialMgmtInternalConsumptionLine
+MaterialMgmtInternalMovement
+MaterialMgmtInternalMovementLine
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+MaterialMgmtMaterialTransaction
+MaterialMgmtProductionPlan
+MaterialMgmtProductionTransaction
+MaterialMgmtShipmentInOut
+MaterialMgmtShipmentInOutLine
+MaterialMgmtStorageDetail
+Order
+OrderDiscount
+OrderLine
+OrderLineOffer
+OrderTax
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+PeriodControlLog
+PerpetualInv
+PricingAdjustment
+PricingAdjustmentBusinessPartner
+PricingAdjustmentBusinessPartnerGroup
+PricingAdjustmentPriceList
+PricingAdjustmentProduct
+PricingAdjustmentProductCategory
+PricingDiscount
+PricingPriceList
+PricingPriceListSchema
+PricingPriceListSchemeLine
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+PricingVolumeDiscountInvoice
+PricingVolumeDiscountProduct
+PricingVolumeDiscountProductCategory
+PricingVolumeDiscountScale
+ProcessRequest
+ProcurementPOInvoiceMatch
+ProcurementReceiptInvoiceMatch
+ProcurementRequisition
+ProcurementRequisitionLine
+ProcurementRequisitionPOMatch
+Product
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCategoryAccounts
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+Project
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProjectProposalTask
+ProjectProposal
+ProjectProposalLine
+ProjectStandardPhase
+ProjectStandardTask
+ProjectTask
+ProjectType
+ProjectVendor
+Replenish
+Request
+RequestType
+RequestionAction
+Resource
+ResourceAssignment
+ResourcePlanCost
+ResourceType
+ResourceUnAvailable
+RevenueRecognition
+RevenueRecognitionPlan
+RevenueRecognitionRun
+SalaryCategory
+SalaryCategoryCost
+SalesCommission
+SalesCommissionAmount
+SalesCommissionDetail
+SalesCommissionLine
+SalesCommissionRun
+SalesRegion
+SerialNumberControl
+ServiceLevel
+ServiceLevelLine
+ShippingFreightCategory
+ShippingShippingCompany
+ShippingShippingCompanyFreight
+TimeAndExpenseSheet
+TimeAndExpenseSheetLine
+TimeType
+VendorAccounts
+Warehouse
+WarehouseAccounts
+WarehousePeriod
+WarehousePeriodInvoiced
+WarehouseSchedule
+WarehouseScheduleProduct
+WarehouseShipper
 
-User 1000019
 
->>> Readabled entities: 
 
-ADAccountingRptElement
+>>> Readable Not-Writable entities: 
+
+
+
+2147 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: AD_Process_Execution_V not found in runtime model
+2171 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_Projectproposal_V not found in runtime model
+2172 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_Debt_Payment_Generate not found in runtime model
+2173 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_Debt_Payment_Cancel not found in runtime model
+2173 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_Debt_Payment_Generate not found in runtime model
+2207 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: S_TimeExpenseLine_V not found in runtime model
+2529 [main] WARN  org.openbravo.base.model.ModelProvider - Table name: C_PeriodControl_V not found in runtime model
+++++++++++++ user 1000019 ++++++++++++++
+
+>>> Readable entities: 
+
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
 ADChangeLog
 ADClient
-ADClientInfo
 ADColumnAccess
-ADDataset
-ADDatasetColumn
-ADDatasetTable
 ADFormAccess
-ADImpFormat
-ADImpFormatRow
 ADMenu
 ADMenuTrl
 ADNote
-ADOrg
-ADOrgInfo
 ADPreference
 ADProcessAccess
 ADProcessScheduling
 ADRecordAccess
 ADRole
-ADRoleOrgAccess
+ADRoleOrganization
 ADSequence
 ADSession
 ADTableAccess
@@ -1135,185 +1515,159 @@
 ADWorkflow
 ADWorkflowAccess
 ADWorkflowTrl
-AccountingAcct
-Amortization
-Amortizationline
-Asset
-AssetAcct
-AssetGroup
-AssetGroupAcct
-CoreAcctRpt
-CoreAcctRptGroup
-CoreAcctRptNode
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPTaxCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartner
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBank
-CoreBankAccount
-CoreBankAccountAcct
-CoreBankStatement
-CoreBankStatementLine
-CoreBudget
-CoreBudgetLine
-CoreCalendar
-CoreCampaign
-CoreCash
-CoreCashBook
-CoreCashBookAcct
-CoreCashLine
-CoreChannel
-CoreCharge
-CoreChargeAcct
-CoreCity
-CoreCommission
-CoreCommissionAmt
-CoreCommissionDetail
-CoreCommissionLine
-CoreCommissionRun
-CoreConversionRate
-CoreCountry
-CoreCountryTrl
-CoreCurrency
-CoreCurrencyTrl
-CoreDPManagement
-CoreDPManagementLine
-CoreDebtPayment
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDiscount
-CoreDocType
-CoreDocTypeTrl
-CoreElement
-CoreElementValue
-CoreElementValueOperand
-CoreElementValueTrl
-CoreExternalPOS
-CoreExternalPOSCategory
-CoreExternalPOSProduct
-CoreGlitem
-CoreGlitemAcct
-CoreGreeting
-CoreGreetingTrl
-CoreIncoterms
-CoreInterOrgAcct
-CoreInvoice
-CoreInvoiceDiscount
-CoreInvoiceLine
-CoreInvoiceLineAcctDimension
-CoreInvoiceLineOffer
-CoreInvoiceSchedule
-CoreInvoiceTax
-CoreLocation
-CoreNonBusinessDay
-CoreOrder
-CoreOrderLine
-CoreOrderLineOffer
-CoreOrderTax
-CorePaymentTerm
-CorePaymentTermLine
-CorePaymentTermTrl
-CorePeriod
-CorePeriodControl
-CorePhase
-CoreProject
-CoreProjectAcct
-CoreProjectIssue
-CoreProjectLine
-CoreProjectPhase
-CoreProjectProposal
-CoreProjectProposalLine
-CoreProjectProposalTask
-CoreProjectTask
-CoreProjectType
-CoreProjectVendor
-CoreProjectproposalV
-CorePromissoryFormat
-CoreRegion
-CoreRemittance
-CoreRemittanceLine
-CoreRemittanceParameter
-CoreRemittanceType
-CoreRevenueRecognition
-CoreRevenueRecognitionPlan
-CoreRevenueRecognitionRun
-CoreSalaryCategory
-CoreSalaryCategoryCost
-CoreSalesRegion
-CoreServiceLevel
-CoreServiceLevelLine
-CoreSettlement
-CoreTAXREPORT
-CoreTask
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxPayment
-CoreTaxRegister
-CoreTaxRegisterType
-CoreTaxRegisterTypeLines
-CoreTaxRegisterline
-CoreTaxTrl
-CoreTaxZone
-CoreUOM
-CoreUOMConversion
-CoreUOMTrl
-CoreValidCombination
-CoreWithholding
-CoreWithholdingAcct
-CoreYear
-CustomRContactInterest
-CustomRInterestArea
-CustomRMailText
-CustomRRequest
-CustomRRequestAction
-CustomRRequestProcessor
-CustomRRequestProcessorRoute
-CustomRRequestType
-CustomRResourcePlanCost
-GLCategory
-GLJournal
-GLJournalBatch
-GLJournalLine
-ImportBPartner
-ImportBankStatement
-ImportBudgetline
-ImportElementValue
-ImportGLJournal
-ImportInventory
-ImportInvoice
-ImportOrder
-ImportProduct
-ImportTax
+AD_CreateFact_template
+AcctSchemaTableDocType
+ApprovedVendor
+Attribute
+AttributeSet
+AttributeUse
+AttributeValue
+Bank
+BankAccount
+BankAccountAccounts
+BusinessPartner
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerCategoryAccount
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerProductTemplate
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+City
+ClientInformation
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+CustomerAccounts
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+ExternalPOS
+ExternalPOSCategory
+ExternalPOSProduct
+FinancialMgmtAccountingCombination
+FinancialMgmtAccountingFact
+FinancialMgmtAccountingReport
+FinancialMgmtAccountingRptElement
+FinancialMgmtAcctRptGroup
+FinancialMgmtAcctRptNode
+FinancialMgmtAcctSchema
+FinancialMgmtAcctSchemaDefault
+FinancialMgmtAcctSchemaElement
+FinancialMgmtAcctSchemaGL
+FinancialMgmtAcctSchemaTable
+FinancialMgmtAmortization
+FinancialMgmtAmortizationLine
+FinancialMgmtAsset
+FinancialMgmtAssetAccounts
+FinancialMgmtAssetGroup
+FinancialMgmtAssetGroupAcct
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtCashBook
+FinancialMgmtCashBookAccounts
+FinancialMgmtCashJournal
+FinancialMgmtDPManagement
+FinancialMgmtDPManagementLine
+FinancialMgmtDebtPayment
+FinancialMgmtDebtPaymentBalReplace
+FinancialMgmtDebtPaymentBalancing
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueOperand
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCategory
+FinancialMgmtGLCharge
+FinancialMgmtGLChargeAccounts
+FinancialMgmtGLItem
+FinancialMgmtGLItemAccounts
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtIncoterms
+FinancialMgmtInterOrgAccounts
+FinancialMgmtJournalLine
+FinancialMgmtNonBusinessDay
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermLine
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtPeriodControl
+FinancialMgmtPromissoryFormat
+FinancialMgmtRemittance
+FinancialMgmtRemittanceLine
+FinancialMgmtRemittanceParameter
+FinancialMgmtRemittanceType
+FinancialMgmtSettlement
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxPayment
+FinancialMgmtTaxRate
+FinancialMgmtTaxRateAccounts
+FinancialMgmtTaxRegister
+FinancialMgmtTaxRegisterType
+FinancialMgmtTaxRegisterTypeLines
+FinancialMgmtTaxRegisterline
+FinancialMgmtTaxReport
+FinancialMgmtTaxTrl
+FinancialMgmtTaxZone
+FinancialMgmtWithholding
+FinancialMgmtWithholdingAccounts
+FinancialMgmtYear
+Greeting
+GreetingTrl
+InterestArea
+Invoice
+InvoiceDiscount
+InvoiceLine
+InvoiceLineAccountingDimension
+InvoiceLineOffer
+InvoiceSchedule
+InvoiceTax
+Location
+Locator
+LocatorType
+Lot
+LotControl
 MRPPlanner
 MRPPlanningMethod
 MRPPlanningMethodLine
-MRPRunProduction
-MRPRunProductionLine
-MRPRunPurchase
-MRPRunPurchaseLine
+MRPProductionRun
+MRPProductionRunLine
+MRPPurchasingRun
+MRPPurchasingRunLine
 MRPSalesForecast
 MRPSalesForecastLine
-ManufacturingCCP
-ManufacturingCCPGroup
-ManufacturingCCPShift
+ManufacturingActivity
+ManufacturingActivityToolset
+ManufacturingCase
+ManufacturingCheckPoint
+ManufacturingCheckPointSet
+ManufacturingCheckPointShift
 ManufacturingCostCenter
 ManufacturingCostCenterMachine
 ManufacturingCostcenterEmployee
@@ -1327,170 +1681,197 @@
 ManufacturingMachineCost
 ManufacturingMachineStation
 ManufacturingMachineType
-ManufacturingMaintOperation
-ManufacturingMaintPart
-ManufacturingMaintPeriodicity
-ManufacturingMaintScheduled
-ManufacturingMaintWorker
+ManufacturingMainteanceOrder
 ManufacturingMaintenance
+ManufacturingMaintenancePeriodicity
+ManufacturingMaintenanceSchedule
+ManufacturingMaintenanceTask
+ManufacturingMaintenanceWorker
 ManufacturingMeasureGroup
 ManufacturingMeasureShift
 ManufacturingMeasureTime
 ManufacturingMeasureValues
-ManufacturingPCCase
-ManufacturingPCTest
-ManufacturingPCValue
-ManufacturingPLEmployee
-ManufacturingPLIC
-ManufacturingPLInvoiceLine
-ManufacturingPLMachine
+ManufacturingOperation
+ManufacturingOperationEmployee
+ManufacturingOperationIndirectCost
+ManufacturingOperationMachine
+ManufacturingOperationProduct
 ManufacturingPeriodicControl
-ManufacturingProcess
 ManufacturingProcessPlan
-ManufacturingProcessPlanVersion
+ManufacturingProductionLine
+ManufacturingProductionRunEmployee
+ManufacturingProductionRunIndirectCosts
+ManufacturingProductionRunInvoiceLine
+ManufacturingProductionRunMachine
+ManufacturingProductionRunToolset
 ManufacturingSection
-ManufacturingSequence
-ManufacturingSequenceEmployee
-ManufacturingSequenceIC
-ManufacturingSequenceMachine
-ManufacturingSequenceProduct
+ManufacturingTest
 ManufacturingToolset
-ManufacturingToolsetProcess
 ManufacturingToolsetType
-ManufacturingToolsetUsed
-ManufacturingWEEmployee
-ManufacturingWEIncidence
-ManufacturingWRPhase
-ManufacturingWRPhaseProduct
+ManufacturingValue
+ManufacturingVersion
+ManufacturingWorkCenter
+ManufacturingWorkEffortEmployee
+ManufacturingWorkEffortIncidence
 ManufacturingWorkRequirement
-ManufacturingWorkStation
-MaterialAttribute
-MaterialAttributeSet
-MaterialAttributeUse
-MaterialAttributeValue
-MaterialCosting
-MaterialDiscountSchema
-MaterialDiscountSchemaLine
-MaterialFreight
-MaterialFreightCategory
-MaterialInOut
-MaterialInOutLine
-MaterialInternalConsumption
-MaterialInternalConsumptionLine
-MaterialInventory
-MaterialInventoryLine
-MaterialLocator
-MaterialLocatorType
-MaterialLot
-MaterialLotCtl
-MaterialMatchInv
-MaterialMatchPO
-MaterialMovement
-MaterialMovementLine
-MaterialOffer
-MaterialOfferBPGroup
-MaterialOfferBPartner
-MaterialOfferPriceList
-MaterialOfferProduct
-MaterialOfferProductCat
-MaterialPerpetualInv
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProduct
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductPrice
-MaterialProductTemplate
-MaterialProductTrl
-MaterialProductUOM
-MaterialProduction
-MaterialProductionLine
-MaterialProductionPlan
-MaterialRappel
-MaterialRappelBpartner
-MaterialRappelInvoice
-MaterialRappelProduct
-MaterialRappelProductcategory
-MaterialRappelScale
-MaterialReplenish
-MaterialRequisition
-MaterialRequisitionLine
-MaterialRequisitionOrder
-MaterialSerNoCtl
-MaterialShipper
-MaterialStorageDetail
-MaterialSubstitute
-MaterialTransaction
-MaterialWHPeriod
-MaterialWHPeriodInvoiced
-MaterialWHSchedule
-MaterialWHScheduleProduct
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-ServiceExpenseType
-ServiceResource
-ServiceResourceAssignment
-ServiceResourceType
-ServiceResourceUnAvailable
-ServiceTimeExpense
-ServiceTimeExpenseLine
-ServiceTimeExpenseLineV
-ServiceTimeType
+ManufacturingWorkRequirementOperation
+ManufacturingWorkRequirementProduct
+MarketingCampaign
+MarketingChannel
+MarketingMailText
+MaterialMgmtABCActivity
+MaterialMgmtCosting
+MaterialMgmtInternalConsumption
+MaterialMgmtInternalConsumptionLine
+MaterialMgmtInternalMovement
+MaterialMgmtInternalMovementLine
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+MaterialMgmtMaterialTransaction
+MaterialMgmtProductionPlan
+MaterialMgmtProductionTransaction
+MaterialMgmtShipmentInOut
+MaterialMgmtShipmentInOutLine
+MaterialMgmtStorageDetail
+Order
+OrderDiscount
+OrderLine
+OrderLineOffer
+OrderTax
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+PeriodControlLog
+PerpetualInv
+PricingAdjustment
+PricingAdjustmentBusinessPartner
+PricingAdjustmentBusinessPartnerGroup
+PricingAdjustmentPriceList
+PricingAdjustmentProduct
+PricingAdjustmentProductCategory
+PricingDiscount
+PricingPriceList
+PricingPriceListSchema
+PricingPriceListSchemeLine
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+PricingVolumeDiscountInvoice
+PricingVolumeDiscountProduct
+PricingVolumeDiscountProductCategory
+PricingVolumeDiscountScale
+ProcessRequest
+ProcurementPOInvoiceMatch
+ProcurementReceiptInvoiceMatch
+ProcurementRequisition
+ProcurementRequisitionLine
+ProcurementRequisitionPOMatch
+Product
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCategoryAccounts
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+Project
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProjectProposalTask
+ProjectProposal
+ProjectProposalLine
+ProjectStandardPhase
+ProjectStandardTask
+ProjectTask
+ProjectType
+ProjectVendor
+Region
+Replenish
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+Resource
+ResourceAssignment
+ResourcePlanCost
+ResourceType
+ResourceUnAvailable
+RevenueRecognition
+RevenueRecognitionPlan
+RevenueRecognitionRun
+SalaryCategory
+SalaryCategoryCost
+SalesCommission
+SalesCommissionAmount
+SalesCommissionDetail
+SalesCommissionLine
+SalesCommissionRun
+SalesRegion
+SerialNumberControl
+ServiceLevel
+ServiceLevelLine
+ShippingFreightCategory
+ShippingShippingCompany
+ShippingShippingCompanyFreight
+TimeAndExpenseSheet
+TimeAndExpenseSheetLine
+TimeType
+UOM
+UOMConversion
+UOMTrl
+VendorAccounts
+Warehouse
+WarehouseAccounts
+WarehousePeriod
+WarehousePeriodInvoiced
+WarehouseSchedule
+WarehouseScheduleProduct
+WarehouseShipper
 
->>> Derived Readabled entities: 
+>>> Derived Readable entities: 
 
 ADColumn
 ADForm
 ADImage
 ADLanguage
 ADMessage
-ADModelObject
+ADModelImplementation
 ADModule
 ADProcess
 ADTab
 ADTable
 ADTreeNode
 ADWindow
-AssetAmortization
-CoreProjectDetailsV
-MaterialAttributeInstance
-MaterialAttributeSetInstance
-MaterialInOutLineV
+AttributeInstance
+AttributeSetInstance
+OrganizationClosing
 
 >>> Writable entities: 
 
-ADAccountingRptElement
 ADAlert
 ADAlertRecipient
 ADAlertRule
 ADAlertRuleTrl
 ADChangeLog
 ADClient
-ADClientInfo
 ADColumnAccess
-ADDataset
-ADDatasetColumn
-ADDatasetTable
 ADFormAccess
-ADImpFormat
-ADImpFormatRow
 ADMenu
 ADMenuTrl
 ADNote
-ADOrg
-ADOrgInfo
 ADPreference
 ADProcessAccess
 ADProcessScheduling
 ADRecordAccess
 ADRole
-ADRoleOrgAccess
+ADRoleOrganization
 ADSequence
 ADSession
 ADTableAccess
@@ -1507,185 +1888,159 @@
 ADWorkflow
 ADWorkflowAccess
 ADWorkflowTrl
-AccountingAcct
-Amortization
-Amortizationline
-Asset
-AssetAcct
-AssetGroup
-AssetGroupAcct
-CoreAcctRpt
-CoreAcctRptGroup
-CoreAcctRptNode
-CoreAcctSchema
-CoreAcctSchemaDefault
-CoreAcctSchemaElement
-CoreAcctSchemaGL
-CoreAcctSchemaTable
-CoreActivity
-CoreBPBankAccount
-CoreBPCustomerAcct
-CoreBPEmployeeAcct
-CoreBPGroup
-CoreBPGroupAcct
-CoreBPSalCategory
-CoreBPTaxCategory
-CoreBPVendorAcct
-CoreBPWithholding
-CoreBPartner
-CoreBPartnerDiscount
-CoreBPartnerLocation
-CoreBank
-CoreBankAccount
-CoreBankAccountAcct
-CoreBankStatement
-CoreBankStatementLine
-CoreBudget
-CoreBudgetLine
-CoreCalendar
-CoreCampaign
-CoreCash
-CoreCashBook
-CoreCashBookAcct
-CoreCashLine
-CoreChannel
-CoreCharge
-CoreChargeAcct
-CoreCity
-CoreCommission
-CoreCommissionAmt
-CoreCommissionDetail
-CoreCommissionLine
-CoreCommissionRun
-CoreConversionRate
-CoreCountry
-CoreCountryTrl
-CoreCurrency
-CoreCurrencyTrl
-CoreDPManagement
-CoreDPManagementLine
-CoreDebtPayment
-CoreDebtPaymentBalReplace
-CoreDebtPaymentBalancing
-CoreDebtPaymentCancelV
-CoreDebtPaymentGenerateV
-CoreDiscount
-CoreDocType
-CoreDocTypeTrl
-CoreElement
-CoreElementValue
-CoreElementValueOperand
-CoreElementValueTrl
-CoreExternalPOS
-CoreExternalPOSCategory
-CoreExternalPOSProduct
-CoreGlitem
-CoreGlitemAcct
-CoreGreeting
-CoreGreetingTrl
-CoreIncoterms
-CoreInterOrgAcct
-CoreInvoice
-CoreInvoiceDiscount
-CoreInvoiceLine
-CoreInvoiceLineAcctDimension
-CoreInvoiceLineOffer
-CoreInvoiceSchedule
-CoreInvoiceTax
-CoreLocation
-CoreNonBusinessDay
-CoreOrder
-CoreOrderLine
-CoreOrderLineOffer
-CoreOrderTax
-CorePaymentTerm
-CorePaymentTermLine
-CorePaymentTermTrl
-CorePeriod
-CorePeriodControl
-CorePhase
-CoreProject
-CoreProjectAcct
-CoreProjectIssue
-CoreProjectLine
-CoreProjectPhase
-CoreProjectProposal
-CoreProjectProposalLine
-CoreProjectProposalTask
-CoreProjectTask
-CoreProjectType
-CoreProjectVendor
-CoreProjectproposalV
-CorePromissoryFormat
-CoreRegion
-CoreRemittance
-CoreRemittanceLine
-CoreRemittanceParameter
-CoreRemittanceType
-CoreRevenueRecognition
-CoreRevenueRecognitionPlan
-CoreRevenueRecognitionRun
-CoreSalaryCategory
-CoreSalaryCategoryCost
-CoreSalesRegion
-CoreServiceLevel
-CoreServiceLevelLine
-CoreSettlement
-CoreTAXREPORT
-CoreTask
-CoreTax
-CoreTaxAcct
-CoreTaxCategory
-CoreTaxCategoryTrl
-CoreTaxPayment
-CoreTaxRegister
-CoreTaxRegisterType
-CoreTaxRegisterTypeLines
-CoreTaxRegisterline
-CoreTaxTrl
-CoreTaxZone
-CoreUOM
-CoreUOMConversion
-CoreUOMTrl
-CoreValidCombination
-CoreWithholding
-CoreWithholdingAcct
-CoreYear
-CustomRContactInterest
-CustomRInterestArea
-CustomRMailText
-CustomRRequest
-CustomRRequestAction
-CustomRRequestProcessor
-CustomRRequestProcessorRoute
-CustomRRequestType
-CustomRResourcePlanCost
-GLCategory
-GLJournal
-GLJournalBatch
-GLJournalLine
-ImportBPartner
-ImportBankStatement
-ImportBudgetline
-ImportElementValue
-ImportGLJournal
-ImportInventory
-ImportInvoice
-ImportOrder
-ImportProduct
-ImportTax
+AD_CreateFact_template
+AcctSchemaTableDocType
+ApprovedVendor
+Attribute
+AttributeSet
+AttributeUse
+AttributeValue
+Bank
+BankAccount
+BankAccountAccounts
+BusinessPartner
+BusinessPartnerBankAccount
+BusinessPartnerCategory
+BusinessPartnerCategoryAccount
+BusinessPartnerDiscount
+BusinessPartnerLocation
+BusinessPartnerProductTemplate
+BusinessPartnerTaxCategory
+BusinessPartnerWithholding
+City
+ClientInformation
+ContactInterest
+Country
+CountryTrl
+Currency
+CurrencyConversionRate
+CurrencyTrl
+CustomerAccounts
+DataImportBankStatement
+DataImportBudgetLine
+DataImportBusinessPartner
+DataImportElementValue
+DataImportFormat
+DataImportFormatRow
+DataImportGLJournal
+DataImportInventory
+DataImportInvoice
+DataImportOrder
+DataImportProduct
+DataImportTax
+DocumentTemplate
+DocumentType
+DocumentTypeTrl
+EmailServerConfiguration
+EmailTemplate
+EmployeeAccounts
+EmployeeSalaryCategory
+ExpenseType
+ExternalPOS
+ExternalPOSCategory
+ExternalPOSProduct
+FinancialMgmtAccountingCombination
+FinancialMgmtAccountingFact
+FinancialMgmtAccountingReport
+FinancialMgmtAccountingRptElement
+FinancialMgmtAcctRptGroup
+FinancialMgmtAcctRptNode
+FinancialMgmtAcctSchema
+FinancialMgmtAcctSchemaDefault
+FinancialMgmtAcctSchemaElement
+FinancialMgmtAcctSchemaGL
+FinancialMgmtAcctSchemaTable
+FinancialMgmtAmortization
+FinancialMgmtAmortizationLine
+FinancialMgmtAsset
+FinancialMgmtAssetAccounts
+FinancialMgmtAssetGroup
+FinancialMgmtAssetGroupAcct
+FinancialMgmtBankStatement
+FinancialMgmtBankStatementLine
+FinancialMgmtBudget
+FinancialMgmtBudgetLine
+FinancialMgmtCalendar
+FinancialMgmtCashBook
+FinancialMgmtCashBookAccounts
+FinancialMgmtCashJournal
+FinancialMgmtDPManagement
+FinancialMgmtDPManagementLine
+FinancialMgmtDebtPayment
+FinancialMgmtDebtPaymentBalReplace
+FinancialMgmtDebtPaymentBalancing
+FinancialMgmtElement
+FinancialMgmtElementValue
+FinancialMgmtElementValueOperand
+FinancialMgmtElementValueTrl
+FinancialMgmtGLBatch
+FinancialMgmtGLCategory
+FinancialMgmtGLCharge
+FinancialMgmtGLChargeAccounts
+FinancialMgmtGLItem
+FinancialMgmtGLItemAccounts
+FinancialMgmtGLJournal
+FinancialMgmtGLJournalLine
+FinancialMgmtIncoterms
+FinancialMgmtInterOrgAccounts
+FinancialMgmtJournalLine
+FinancialMgmtNonBusinessDay
+FinancialMgmtPaymentTerm
+FinancialMgmtPaymentTermLine
+FinancialMgmtPaymentTermTrl
+FinancialMgmtPeriod
+FinancialMgmtPeriodControl
+FinancialMgmtPromissoryFormat
+FinancialMgmtRemittance
+FinancialMgmtRemittanceLine
+FinancialMgmtRemittanceParameter
+FinancialMgmtRemittanceType
+FinancialMgmtSettlement
+FinancialMgmtTaxCategory
+FinancialMgmtTaxCategoryTrl
+FinancialMgmtTaxPayment
+FinancialMgmtTaxRate
+FinancialMgmtTaxRateAccounts
+FinancialMgmtTaxRegister
+FinancialMgmtTaxRegisterType
+FinancialMgmtTaxRegisterTypeLines
+FinancialMgmtTaxRegisterline
+FinancialMgmtTaxReport
+FinancialMgmtTaxTrl
+FinancialMgmtTaxZone
+FinancialMgmtWithholding
+FinancialMgmtWithholdingAccounts
+FinancialMgmtYear
+Greeting
+GreetingTrl
+InterestArea
+Invoice
+InvoiceDiscount
+InvoiceLine
+InvoiceLineAccountingDimension
+InvoiceLineOffer
+InvoiceSchedule
+InvoiceTax
+Location
+Locator
+LocatorType
+Lot
+LotControl
 MRPPlanner
 MRPPlanningMethod
 MRPPlanningMethodLine
-MRPRunProduction
-MRPRunProductionLine
-MRPRunPurchase
-MRPRunPurchaseLine
+MRPProductionRun
+MRPProductionRunLine
+MRPPurchasingRun
+MRPPurchasingRunLine
 MRPSalesForecast
 MRPSalesForecastLine
-ManufacturingCCP
-ManufacturingCCPGroup
-ManufacturingCCPShift
+ManufacturingActivity
+ManufacturingActivityToolset
+ManufacturingCase
+ManufacturingCheckPoint
+ManufacturingCheckPointSet
+ManufacturingCheckPointShift
 ManufacturingCostCenter
 ManufacturingCostCenterMachine
 ManufacturingCostcenterEmployee
@@ -1699,119 +2054,163 @@
 ManufacturingMachineCost
 ManufacturingMachineStation
 ManufacturingMachineType
-ManufacturingMaintOperation
-ManufacturingMaintPart
-ManufacturingMaintPeriodicity
-ManufacturingMaintScheduled
-ManufacturingMaintWorker
+ManufacturingMainteanceOrder
 ManufacturingMaintenance
+ManufacturingMaintenancePeriodicity
+ManufacturingMaintenanceSchedule
+ManufacturingMaintenanceTask
+ManufacturingMaintenanceWorker
 ManufacturingMeasureGroup
 ManufacturingMeasureShift
 ManufacturingMeasureTime
 ManufacturingMeasureValues
-ManufacturingPCCase
-ManufacturingPCTest
-ManufacturingPCValue
-ManufacturingPLEmployee
-ManufacturingPLIC
-ManufacturingPLInvoiceLine
-ManufacturingPLMachine
+ManufacturingOperation
+ManufacturingOperationEmployee
+ManufacturingOperationIndirectCost
+ManufacturingOperationMachine
+ManufacturingOperationProduct
 ManufacturingPeriodicControl
-ManufacturingProcess
 ManufacturingProcessPlan
-ManufacturingProcessPlanVersion
+ManufacturingProductionLine
+ManufacturingProductionRunEmployee
+ManufacturingProductionRunIndirectCosts
+ManufacturingProductionRunInvoiceLine
+ManufacturingProductionRunMachine
+ManufacturingProductionRunToolset
 ManufacturingSection
-ManufacturingSequence
-ManufacturingSequenceEmployee
-ManufacturingSequenceIC
-ManufacturingSequenceMachine
-ManufacturingSequenceProduct
+ManufacturingTest
 ManufacturingToolset
-ManufacturingToolsetProcess
 ManufacturingToolsetType
-ManufacturingToolsetUsed
-ManufacturingWEEmployee
-ManufacturingWEIncidence
-ManufacturingWRPhase
-ManufacturingWRPhaseProduct
+ManufacturingValue
+ManufacturingVersion
+ManufacturingWorkCenter
+ManufacturingWorkEffortEmployee
+ManufacturingWorkEffortIncidence
 ManufacturingWorkRequirement
-ManufacturingWorkStation
-MaterialAttribute
-MaterialAttributeSet
-MaterialAttributeUse
-MaterialAttributeValue
-MaterialCosting
-MaterialDiscountSchema
-MaterialDiscountSchemaLine
-MaterialFreight
-MaterialFreightCategory
-MaterialInOut
-MaterialInOutLine
-MaterialInternalConsumption
-MaterialInternalConsumptionLine
-MaterialInventory
-MaterialInventoryLine
-MaterialLocator
-MaterialLocatorType
-MaterialLot
-MaterialLotCtl
-MaterialMatchInv
-MaterialMatchPO
-MaterialMovement
-MaterialMovementLine
-MaterialOffer
-MaterialOfferBPGroup
-MaterialOfferBPartner
-MaterialOfferPriceList
-MaterialOfferProduct
-MaterialOfferProductCat
-MaterialPerpetualInv
-MaterialPriceList
-MaterialPriceListVersion
-MaterialProduct
-MaterialProductAcct
-MaterialProductBOM
-MaterialProductCategory
-MaterialProductCategoryAcct
-MaterialProductCustomer
-MaterialProductOrg
-MaterialProductPO
-MaterialProductPrice
-MaterialProductTemplate
-MaterialProductTrl
-MaterialProductUOM
-MaterialProduction
-MaterialProductionLine
-MaterialProductionPlan
-MaterialRappel
-MaterialRappelBpartner
-MaterialRappelInvoice
-MaterialRappelProduct
-MaterialRappelProductcategory
-MaterialRappelScale
-MaterialReplenish
-MaterialRequisition
-MaterialRequisitionLine
-MaterialRequisitionOrder
-MaterialSerNoCtl
-MaterialShipper
-MaterialStorageDetail
-MaterialSubstitute
-MaterialTransaction
-MaterialWHPeriod
-MaterialWHPeriodInvoiced
-MaterialWHSchedule
-MaterialWHScheduleProduct
-MaterialWarehouse
-MaterialWarehouseAcct
-MaterialWarehouseShipper
-ServiceExpenseType
-ServiceResource
-ServiceResourceAssignment
-ServiceResourceType
-ServiceResourceUnAvailable
-ServiceTimeExpense
-ServiceTimeExpenseLine
-ServiceTimeExpenseLineV
-ServiceTimeType
+ManufacturingWorkRequirementOperation
+ManufacturingWorkRequirementProduct
+MarketingCampaign
+MarketingChannel
+MarketingMailText
+MaterialMgmtABCActivity
+MaterialMgmtCosting
+MaterialMgmtInternalConsumption
+MaterialMgmtInternalConsumptionLine
+MaterialMgmtInternalMovement
+MaterialMgmtInternalMovementLine
+MaterialMgmtInventoryCount
+MaterialMgmtInventoryCountLine
+MaterialMgmtMaterialTransaction
+MaterialMgmtProductionPlan
+MaterialMgmtProductionTransaction
+MaterialMgmtShipmentInOut
+MaterialMgmtShipmentInOutLine
+MaterialMgmtStorageDetail
+Order
+OrderDiscount
+OrderLine
+OrderLineOffer
+OrderTax
+Organization
+OrganizationAcctSchema
+OrganizationInformation
+OrganizationType
+PeriodControlLog
+PerpetualInv
+PricingAdjustment
+PricingAdjustmentBusinessPartner
+PricingAdjustmentBusinessPartnerGroup
+PricingAdjustmentPriceList
+PricingAdjustmentProduct
+PricingAdjustmentProductCategory
+PricingDiscount
+PricingPriceList
+PricingPriceListSchema
+PricingPriceListSchemeLine
+PricingPriceListVersion
+PricingProductPrice
+PricingVolumeDiscount
+PricingVolumeDiscountBusinessPartner
+PricingVolumeDiscountInvoice
+PricingVolumeDiscountProduct
+PricingVolumeDiscountProductCategory
+PricingVolumeDiscountScale
+ProcessRequest
+ProcurementPOInvoiceMatch
+ProcurementReceiptInvoiceMatch
+ProcurementRequisition
+ProcurementRequisitionLine
+ProcurementRequisitionPOMatch
+Product
+ProductAccounts
+ProductBOM
+ProductCategory
+ProductCategoryAccounts
+ProductCustomer
+ProductOrg
+ProductSubstitute
+ProductTrl
+ProductUOM
+Project
+ProjectAccounts
+ProjectIssue
+ProjectLine
+ProjectPhase
+ProjectProjectProposalTask
+ProjectProposal
+ProjectProposalLine
+ProjectStandardPhase
+ProjectStandardTask
+ProjectTask
+ProjectType
+ProjectVendor
+Region
+Replenish
+Request
+RequestProcessor
+RequestProcessorRoute
+RequestType
+RequestionAction
+Resource
+ResourceAssignment
+ResourcePlanCost
+ResourceType
+ResourceUnAvailable
+RevenueRecognition
+RevenueRecognitionPlan
+RevenueRecognitionRun
+SalaryCategory
+SalaryCategoryCost
+SalesCommission
+SalesCommissionAmount
+SalesCommissionDetail
+SalesCommissionLine
+SalesCommissionRun
+SalesRegion
+SerialNumberControl
+ServiceLevel
+ServiceLevelLine
+ShippingFreightCategory
+ShippingShippingCompany
+ShippingShippingCompanyFreight
+TimeAndExpenseSheet
+TimeAndExpenseSheetLine
+TimeType
+UOM
+UOMConversion
+UOMTrl
+VendorAccounts
+Warehouse
+WarehouseAccounts
+WarehousePeriod
+WarehousePeriodInvoiced
+WarehouseSchedule
+WarehouseScheduleProduct
+WarehouseShipper
 
+
+
+>>> Readable Not-Writable entities: 
+
+
+
--- a/src-test/org/openbravo/test/base/BaseTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/base/BaseTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -24,8 +24,11 @@
 import java.sql.SQLException;
 
 import junit.framework.TestCase;
+import junit.framework.TestResult;
 
 import org.openbravo.base.exception.OBException;
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.provider.OBConfigFileProvider;
 import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.base.structure.BaseOBObject;
@@ -36,7 +39,8 @@
 import org.openbravo.dal.service.OBDal;
 
 /**
- * Testcase.
+ * Base test class which can/should be extended by most other test classes which want to make use of
+ * the Openbravo test infrastructure.
  * 
  * @author mtaal
  */
@@ -45,15 +49,25 @@
 
   private boolean errorOccured = false;
 
+  /**
+   * Overridden to initialize the Dal layer, sets the current user to the the BigBazaar 1000000
+   * user.
+   */
   @Override
   protected void setUp() throws Exception {
     initializeDalLayer();
     // clear the session otherwise it keeps the old model
     setBigBazaarUserContext();
     super.setUp();
-    setErrorOccured(true);
+    // be negative is set back to false at the end of a successfull test.
+    errorOccured = true;
   }
 
+  /**
+   * Initializes the DALLayer, can be overridden to add specific initialization behavior.
+   * 
+   * @throws Exception
+   */
   protected void initializeDalLayer() throws Exception {
     if (!DalLayerInitializer.getInstance().isInitialized()) {
       setConfigPropertyFiles();
@@ -61,8 +75,10 @@
     }
   }
 
+  /**
+   * Reads the configuration properties from the property files.
+   */
   protected void setConfigPropertyFiles() {
-
     // get the location of the current class file
     final URL url = this.getClass().getResource(getClass().getSimpleName() + ".class");
     File f = new File(url.getPath());
@@ -81,22 +97,57 @@
     OBConfigFileProvider.getInstance().setFileLocation(configDirectory.getAbsolutePath());
   }
 
+  /**
+   * Set the current user to the 0 user.
+   */
   protected void setSystemAdministratorContext() {
     setUserContext("0");
   }
 
+  /**
+   * Sets the current user to the 1000000 user.
+   */
   protected void setBigBazaarUserContext() {
     setUserContext("1000000");
   }
 
+  @Override
+  public TestResult run() {
+    // TODO Auto-generated method stub
+    return super.run();
+  }
+
+  /**
+   * Overridden to keep track if an exception was thrown, if not then errorOccurred is set to false,
+   * signaling to tearDown to commit the transaction.
+   */
+  @Override
+  public void runTest() throws Throwable {
+    super.runTest();
+    errorOccured = false;
+  }
+
+  /**
+   * Sets the current user,
+   * 
+   * @param userId
+   *          the id of the user to use.
+   */
   protected void setUserContext(String userId) {
     OBContext.setOBContext(userId);
   }
 
+  /**
+   * Sets the current user to the 100 user.
+   */
   protected void setBigBazaarAdminContext() {
     setUserContext("100");
   }
 
+  /**
+   * Performs rolling back of a transaction (in case setTestCompleted was not called by the
+   * subclass), or commits the transaction if the testcase passed without exception.
+   */
   @Override
   protected void tearDown() throws Exception {
     try {
@@ -120,6 +171,14 @@
     super.tearDown();
   }
 
+  /**
+   * Prints the stacktrace of the exception to System.err. Handles the case that the exception is a
+   * SQLException which has the real causing exception in the
+   * {@link SQLException#getNextException()} method.
+   * 
+   * @param e
+   *          the exception to report.
+   */
   protected void reportException(Exception e) {
     if (e == null)
       return;
@@ -133,14 +192,42 @@
     return errorOccured;
   }
 
-  public void commitTransaction() {
-    setErrorOccured(false);
+  /**
+   * Does a rollback of the transaction;
+   */
+  public void rollback() {
+    OBDal.getInstance().rollbackAndClose();
   }
 
+  /**
+   * Commits the transaction to the database.
+   */
+  public void commitTransaction() {
+    OBDal.getInstance().commitAndClose();
+  }
+
+  /**
+   * Deprecated, no need to call this method explicitly anymore. The BaseTest class overrides the
+   * runTest method which sets the internal flag, overriding any value passed in this method.
+   * 
+   * @param errorOccured
+   * @deprecated
+   */
   public void setErrorOccured(boolean errorOccured) {
     this.errorOccured = errorOccured;
   }
 
+  /**
+   * Convenience method, gets an instance for the passed Class from the database. If there are no
+   * records for that class then an exception is thrown. If there is more than one result then an
+   * arbitrary instance is returned (the first one in the un-ordered resultset).
+   * 
+   * @param <T>
+   *          the specific class to query for.
+   * @param clz
+   *          instances
+   * @return an instance of clz.
+   */
   protected <T extends BaseOBObject> T getOneInstance(Class<T> clz) {
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     if (obc.list().size() == 0) {
@@ -148,4 +235,37 @@
     }
     return obc.list().get(0);
   }
+
+  /**
+   * Extends the read and write access of the current user to also include the passed class. This
+   * can be used to circumvent restrictive access which is not usefull for the test itself.
+   * 
+   * @param clz
+   *          after this call the current user (in the {@link OBContext}) will have read/write
+   *          access to this class.
+   */
+  protected void addReadWriteAccess(Class<?> clz) {
+    final Entity entity = ModelProvider.getInstance().getEntity(clz);
+    if (!OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().contains(entity)) {
+      OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().add(entity);
+    }
+    if (!OBContext.getOBContext().getEntityAccessChecker().getReadableEntities().contains(entity)) {
+      OBContext.getOBContext().getEntityAccessChecker().getReadableEntities().add(entity);
+    }
+  }
+
+  /**
+   * Counts the total occurences in the database for the passed class. Note that active, client and
+   * organization filtering applies.
+   * 
+   * @param <T>
+   *          a class type parameter
+   * @param clz
+   *          the class to count occurences for
+   * @return the number of occurences which are active and belong to the current client/organization
+   */
+  protected <T extends BaseOBObject> int count(Class<T> clz) {
+    final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
+    return obc.count();
+  }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/AllTests.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/AllTests.java	Wed Apr 22 13:34:41 2009 +0200
@@ -26,16 +26,17 @@
 
   public static Test suite() {
     final TestSuite suite = new TestSuite("Test for org.openbravo.test.dal");
-    // $JUnit-BEGIN$
-    // suite.addTestSuite(CompositeIdTest.class);
+    suite.addTestSuite(DalComplexQueryRequisitionTest.class);
+    suite.addTestSuite(DalComplexQueryTestOrderLine.class);
+    suite.addTestSuite(DalPerformanceInventoryLineTest.class);
+    suite.addTestSuite(DalPerformanceProductTest.class);
+    suite.addTestSuite(DalQueryTest.class);
+    suite.addTestSuite(DalTest.class);
+    suite.addTestSuite(DynamicEntityTest.class);
     suite.addTestSuite(HiddenUpdateTest.class);
+    suite.addTestSuite(HqlTest.class);
     suite.addTestSuite(MappingGenerationTest.class);
     suite.addTestSuite(ValidationTest.class);
-    suite.addTestSuite(DynamicEntityTest.class);
-    suite.addTestSuite(DalTest.class);
-    suite.addTestSuite(DalQueryTest.class);
-    suite.addTestSuite(HqlTest.class);
-    // $JUnit-END$
     return suite;
   }
 
--- a/src-test/org/openbravo/test/dal/DalComplexQueryRequisition.java	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,334 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (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.html 
- * 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) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.test.dal;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.dal.service.OBQuery;
-import org.openbravo.model.procurement.RequisitionLine;
-import org.openbravo.test.base.BaseTest;
-
-/**
- * Tests a complex query using the DAL
- * 
- * @author mtaal
- */
-
-public class DalComplexQueryRequisition extends BaseTest {
-  // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
-  // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
-  // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
-  // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
-  // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS VENDOR,
-  // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'), to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
-  // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
-  // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
-  // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
-  // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
-  // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
-  // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
-  // FROM M_REQUISITIONLINE, M_REQUISITION, C_BPARTNER
-  // WHERE M_REQUISITIONLINE.M_REQUISITION_ID = M_REQUISITION.M_REQUISITION_ID
-  // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
-  // C_BPARTNER.C_BPARTNER_ID
-  // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
-  // AND M_REQUISITION.ISACTIVE = 'Y'
-  // AND M_REQUISITIONLINE.ISACTIVE = 'Y'
-  // AND M_REQUISITION.DOCSTATUS = 'CO'
-  // AND M_REQUISITIONLINE.REQSTATUS = 'O'
-  // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
-  // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
-  // AND M_REQUISITION.AD_CLIENT_ID IN ?
-  // AND M_REQUISITIONLINE.AD_ORG_ID IN ?
-  // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
-  // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
-  // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
-  // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
-  // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
-  // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
-  // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
-  // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
-
-  public void testComplexQueryOne() {
-    setErrorOccured(true);
-    setUserContext("100");
-
-    // the query parameters are added to this list
-    final List<Object> parameters = new ArrayList<Object>();
-    final StringBuilder whereClause = new StringBuilder();
-    whereClause.append(" as rl");
-
-    // do a left outer join on business partner
-    whereClause.append(" left join fetch rl.product");
-    whereClause.append(" left join fetch rl.businessPartner");
-    whereClause.append(" left join fetch rl.businessPartner.language");
-    whereClause.append(" left join fetch rl.requisition");
-    whereClause.append(" left join fetch rl.priceList");
-    whereClause.append(" left join fetch rl.requisition.businessPartner");
-    whereClause.append(" left join fetch rl.requisition.businessPartner.language");
-
-    // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
-    // C_BPARTNER.C_BPARTNER_ID
-    // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
-    whereClause
-        .append(" where (rl.businessPartner.pOPaymentTerms != null or rl.requisition.businessPartner.pOPaymentTerms != null)");
-
-    // AND M_REQUISITION.ISACTIVE = 'Y'
-    whereClause.append(" and rl.requisition.active=true");
-
-    // AND M_REQUISITIONLINE.ISACTIVE = 'Y' <-- is done by the DAL Layer
-
-    // AND M_REQUISITION.DOCSTATUS = 'CO'
-    whereClause.append(" and rl.requisition.documentStatus='CO'");
-
-    // AND M_REQUISITIONLINE.REQSTATUS = 'O'
-    whereClause.append(" and rl.requisitionLineStatus='O'");
-
-    // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
-    // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
-    whereClause.append(" and (rl.lockedBy = null or rl.lockDate<? or rl.lockDate = null)");
-    final long threeDays = 1000 * 3600 * 24 * 3;
-    parameters.add(new Date(System.currentTimeMillis() - threeDays));
-
-    // AND M_REQUISITION.AD_CLIENT_ID IN ? <-- Done by the DAL
-    // AND M_REQUISITIONLINE.AD_ORG_ID IN ? <-- Done by the DAL
-
-    // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
-    whereClause.append(" and rl.needByDate>=?");
-    // needByDate from, set at 30 days back
-    final long thirtyDays = threeDays * 10;
-    parameters.add(new Date(System.currentTimeMillis() - thirtyDays));
-
-    // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
-    whereClause.append(" and rl.needByDate<?");
-    // needByDate to, set at 30 days in the future
-    parameters.add(new Date(System.currentTimeMillis() + thirtyDays));
-
-    // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
-    whereClause.append(" and rl.product.id=?");
-    parameters.add("1000010");
-
-    // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
-    whereClause.append(" and rl.requisition.userContact.id=?");
-    parameters.add("100");
-
-    // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
-    // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
-    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
-    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
-    whereClause
-        .append(" and ((rl.businessPartner.id = ? or rl.requisition.businessPartner.id = ?) or "
-            + "(rl.businessPartner = null and rl.requisition.businessPartner = null))");
-    parameters.add("1000011");
-    parameters.add("1000011");
-
-    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
-    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
-    whereClause.append(" order by rl.needByDate, rl.product.id, rl.attributeSetValue.id");
-
-    final OBQuery<RequisitionLine> obQuery = OBDal.getInstance().createQuery(RequisitionLine.class,
-        whereClause.toString());
-
-    obQuery.setParameters(parameters);
-
-    // now print the select clause parts
-    for (RequisitionLine requisitionLine : obQuery.list()) {
-      // now print the information from the select clause
-      // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
-      System.err.println(requisitionLine.getId());
-      System.err.println(requisitionLine.getNeedByDate());
-      // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
-      if (requisitionLine.getOrderQuantity() != null) {
-        System.err.println(requisitionLine.getQuantity().min(requisitionLine.getOrderQuantity()));
-      }
-      // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
-      System.err.println(requisitionLine.getUnitPrice());
-
-      // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
-      // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS
-      // VENDOR,
-      if (requisitionLine.getBusinessPartner() != null) {
-        System.err.println(requisitionLine.getBusinessPartner().getIdentifier());
-      } else if (requisitionLine.getRequisition().getBusinessPartner() != null) {
-        System.err.println(requisitionLine.getRequisition().getBusinessPartner().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'),
-      // to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
-      // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
-      if (requisitionLine.getPriceList() != null) {
-        System.err.println(requisitionLine.getPriceList().getIdentifier());
-      } else if (requisitionLine.getRequisition().getPriceList() != null) {
-        System.err.println(requisitionLine.getRequisition().getPriceList().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
-      // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
-      System.err.println(requisitionLine.getProduct().getIdentifier());
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
-      // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
-      if (requisitionLine.getAttributeSetValue() != null) {
-        System.err.println(requisitionLine.getAttributeSetValue().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
-      System.err.println(requisitionLine.getRequisition().getUserContact().getIdentifier());
-
-      System.err.println(requisitionLine.getIdentifier());
-    }
-    setErrorOccured(false);
-  }
-
-  public void _testComplexQueryOne() {
-    setErrorOccured(true);
-    setUserContext("100");
-
-    final StringBuilder whereClause = new StringBuilder();
-
-    whereClause.append(" left outer join businessPartner as bp where ");
-
-    // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
-    // C_BPARTNER.C_BPARTNER_ID
-    // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
-    whereClause
-        .append(" (bp.pOPaymentTerms != null or requisition.businessPartner.pOPaymentTerms != null)");
-
-    // AND M_REQUISITION.ISACTIVE = 'Y'
-    whereClause.append(" and requisition.active=true");
-
-    // AND M_REQUISITIONLINE.ISACTIVE = 'Y' <-- is done by the DAL Layer
-
-    // AND M_REQUISITION.DOCSTATUS = 'CO'
-    whereClause.append(" and requisition.documentStatus='CO'");
-
-    // AND M_REQUISITIONLINE.REQSTATUS = 'O'
-    whereClause.append(" and requisitionLineStatus='O'");
-
-    // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
-    // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
-    whereClause.append(" and (lockedBy = null or lockDate<? or lockDate = null)");
-
-    // AND M_REQUISITION.AD_CLIENT_ID IN ? <-- Done by the DAL
-    // AND M_REQUISITIONLINE.AD_ORG_ID IN ? <-- Done by the DAL
-
-    // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
-    whereClause.append(" and needByDate>=?");
-
-    // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
-    whereClause.append(" and needByDate<?");
-
-    // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
-    whereClause.append(" and product.id=?");
-
-    // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
-    whereClause.append(" and requisition.userContact.id=?");
-
-    // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
-    // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
-    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
-    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
-    whereClause.append(" and ((businessPartner.id = ? or requisition.businessPartner.id = ?) or "
-        + "(businessPartner = null and requisition.businessPartner = null))");
-
-    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
-    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
-    whereClause.append(" order by needByDate, product.id, attributeSetValue.id");
-
-    final OBQuery<RequisitionLine> obQuery = OBDal.getInstance().createQuery(RequisitionLine.class,
-        whereClause.toString());
-
-    // now set the parameters
-    final List<Object> parameters = new ArrayList<Object>();
-
-    // lockDate
-    final long threeDays = 1000 * 3600 * 24 * 3;
-    parameters.add(new Date(System.currentTimeMillis() - threeDays));
-
-    // needByDate from, set at 30 days back
-    final long thirtyDays = threeDays * 10;
-    parameters.add(new Date(System.currentTimeMillis() - thirtyDays));
-
-    // needByDate to, set at 30 days in the future
-    parameters.add(new Date(System.currentTimeMillis() + thirtyDays));
-
-    // product.id
-    parameters.add("1000010");
-
-    // userContact.id
-    parameters.add("100");
-
-    // businessPartner.id
-    parameters.add("1000011");
-    parameters.add("1000011");
-
-    obQuery.setParameters(parameters);
-
-    // now print the select clause parts
-    for (RequisitionLine requisitionLine : obQuery.list()) {
-      // now print the information from the select clause
-      // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
-      System.err.println(requisitionLine.getId());
-      System.err.println(requisitionLine.getNeedByDate());
-      // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
-      System.err.println(requisitionLine.getQuantity().min(requisitionLine.getOrderQuantity()));
-      // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
-      System.err.println(requisitionLine.getUnitPrice());
-
-      // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
-      // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS
-      // VENDOR,
-      if (requisitionLine.getBusinessPartner() != null) {
-        System.err.println(requisitionLine.getBusinessPartner().getIdentifier());
-      } else if (requisitionLine.getRequisition().getBusinessPartner() != null) {
-        System.err.println(requisitionLine.getRequisition().getBusinessPartner().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'),
-      // to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
-      // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
-      if (requisitionLine.getPriceList() != null) {
-        System.err.println(requisitionLine.getPriceList().getIdentifier());
-      } else if (requisitionLine.getRequisition().getPriceList() != null) {
-        System.err.println(requisitionLine.getRequisition().getPriceList().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
-      // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
-      System.err.println(requisitionLine.getProduct().getIdentifier());
-
-      // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
-      // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
-      if (requisitionLine.getAttributeSetValue() != null) {
-        System.err.println(requisitionLine.getAttributeSetValue().getIdentifier());
-      }
-
-      // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
-      System.err.println(requisitionLine.getRequisition().getUserContact().getIdentifier());
-
-      System.err.println(requisitionLine.getIdentifier());
-    }
-    System.err.println("done");
-    setErrorOccured(false);
-  }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/dal/DalComplexQueryRequisitionTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -0,0 +1,337 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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.html 
+ * 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) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.dal;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBQuery;
+import org.openbravo.model.procurement.RequisitionLine;
+import org.openbravo.test.base.BaseTest;
+
+/**
+ * Tests a complex query using the DAL. Is used in the Developers Guide HowTo.
+ * 
+ * @author mtaal
+ */
+
+public class DalComplexQueryRequisitionTest extends BaseTest {
+
+  private static final Logger log = Logger.getLogger(DalComplexQueryRequisitionTest.class);
+
+  // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
+  // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
+  // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
+  // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
+  // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS VENDOR,
+  // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'), to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
+  // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
+  // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
+  // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
+  // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
+  // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
+  // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
+  // FROM M_REQUISITIONLINE, M_REQUISITION, C_BPARTNER
+  // WHERE M_REQUISITIONLINE.M_REQUISITION_ID = M_REQUISITION.M_REQUISITION_ID
+  // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
+  // C_BPARTNER.C_BPARTNER_ID
+  // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
+  // AND M_REQUISITION.ISACTIVE = 'Y'
+  // AND M_REQUISITIONLINE.ISACTIVE = 'Y'
+  // AND M_REQUISITION.DOCSTATUS = 'CO'
+  // AND M_REQUISITIONLINE.REQSTATUS = 'O'
+  // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
+  // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
+  // AND M_REQUISITION.AD_CLIENT_ID IN ?
+  // AND M_REQUISITIONLINE.AD_ORG_ID IN ?
+  // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
+  // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
+  // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
+  // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
+  // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
+  // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
+  // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
+  // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
+
+  /**
+   * Tests a complex query related to requisition lines.
+   */
+  public void testComplexQueryOne() {
+    setUserContext("100");
+
+    // the query parameters are added to this list
+    final List<Object> parameters = new ArrayList<Object>();
+    final StringBuilder whereClause = new StringBuilder();
+    whereClause.append(" as rl");
+
+    // do a left outer join on business partner
+    whereClause.append(" left join fetch rl.product");
+    whereClause.append(" left join fetch rl.businessPartner");
+    whereClause.append(" left join fetch rl.businessPartner.language");
+    whereClause.append(" left join fetch rl.requisition");
+    whereClause.append(" left join fetch rl.priceList");
+    whereClause.append(" left join fetch rl.requisition.businessPartner");
+    whereClause.append(" left join fetch rl.requisition.businessPartner.language");
+
+    // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
+    // C_BPARTNER.C_BPARTNER_ID
+    // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
+    whereClause
+        .append(" where (rl.businessPartner.pOPaymentTerms != null or rl.requisition.businessPartner.pOPaymentTerms != null)");
+
+    // AND M_REQUISITION.ISACTIVE = 'Y'
+    whereClause.append(" and rl.requisition.active=true");
+
+    // AND M_REQUISITIONLINE.ISACTIVE = 'Y' <-- is done by the DAL Layer
+
+    // AND M_REQUISITION.DOCSTATUS = 'CO'
+    whereClause.append(" and rl.requisition.documentStatus='CO'");
+
+    // AND M_REQUISITIONLINE.REQSTATUS = 'O'
+    whereClause.append(" and rl.requisitionLineStatus='O'");
+
+    // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
+    // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
+    whereClause.append(" and (rl.lockedBy = null or rl.lockDate<? or rl.lockDate = null)");
+    final long threeDays = 1000 * 3600 * 24 * 3;
+    parameters.add(new Date(System.currentTimeMillis() - threeDays));
+
+    // AND M_REQUISITION.AD_CLIENT_ID IN ? <-- Done by the DAL
+    // AND M_REQUISITIONLINE.AD_ORG_ID IN ? <-- Done by the DAL
+
+    // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
+    whereClause.append(" and rl.needByDate>=?");
+    // needByDate from, set at 30 days back
+    final long thirtyDays = threeDays * 10;
+    parameters.add(new Date(System.currentTimeMillis() - thirtyDays));
+
+    // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
+    whereClause.append(" and rl.needByDate<?");
+    // needByDate to, set at 30 days in the future
+    parameters.add(new Date(System.currentTimeMillis() + thirtyDays));
+
+    // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
+    whereClause.append(" and rl.product.id=?");
+    parameters.add("1000010");
+
+    // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
+    whereClause.append(" and rl.requisition.userContact.id=?");
+    parameters.add("100");
+
+    // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
+    // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
+    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
+    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
+    whereClause
+        .append(" and ((rl.businessPartner.id = ? or rl.requisition.businessPartner.id = ?) or "
+            + "(rl.businessPartner = null and rl.requisition.businessPartner = null))");
+    parameters.add("1000011");
+    parameters.add("1000011");
+
+    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
+    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
+    whereClause.append(" order by rl.needByDate, rl.product.id, rl.attributeSetValue.id");
+
+    final OBQuery<RequisitionLine> obQuery = OBDal.getInstance().createQuery(RequisitionLine.class,
+        whereClause.toString());
+
+    obQuery.setParameters(parameters);
+
+    // now print the select clause parts
+    for (RequisitionLine requisitionLine : obQuery.list()) {
+      // now print the information from the select clause
+      // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
+      log.debug(requisitionLine.getId());
+      log.debug(requisitionLine.getNeedByDate());
+      // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
+      if (requisitionLine.getOrderQuantity() != null) {
+        log.debug(requisitionLine.getQuantity().min(requisitionLine.getOrderQuantity()));
+      }
+      // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
+      log.debug(requisitionLine.getUnitPrice());
+
+      // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
+      // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS
+      // VENDOR,
+      if (requisitionLine.getBusinessPartner() != null) {
+        log.debug(requisitionLine.getBusinessPartner().getIdentifier());
+      } else if (requisitionLine.getRequisition().getBusinessPartner() != null) {
+        log.debug(requisitionLine.getRequisition().getBusinessPartner().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'),
+      // to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
+      // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
+      if (requisitionLine.getPriceList() != null) {
+        log.debug(requisitionLine.getPriceList().getIdentifier());
+      } else if (requisitionLine.getRequisition().getPriceList() != null) {
+        log.debug(requisitionLine.getRequisition().getPriceList().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
+      // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
+      log.debug(requisitionLine.getProduct().getIdentifier());
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
+      // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
+      if (requisitionLine.getAttributeSetValue() != null) {
+        log.debug(requisitionLine.getAttributeSetValue().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
+      log.debug(requisitionLine.getRequisition().getUserContact().getIdentifier());
+
+      log.debug(requisitionLine.getIdentifier());
+    }
+  }
+
+  public void _testComplexQueryOne() {
+    setUserContext("100");
+
+    final StringBuilder whereClause = new StringBuilder();
+
+    whereClause.append(" left outer join businessPartner as bp where ");
+
+    // AND COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID,M_REQUISITION.C_BPARTNER_ID) =
+    // C_BPARTNER.C_BPARTNER_ID
+    // AND C_BPARTNER.PO_PAYMENTTERM_ID IS NOT NULL
+    whereClause
+        .append(" (bp.pOPaymentTerms != null or requisition.businessPartner.pOPaymentTerms != null)");
+
+    // AND M_REQUISITION.ISACTIVE = 'Y'
+    whereClause.append(" and requisition.active=true");
+
+    // AND M_REQUISITIONLINE.ISACTIVE = 'Y' <-- is done by the DAL Layer
+
+    // AND M_REQUISITION.DOCSTATUS = 'CO'
+    whereClause.append(" and requisition.documentStatus='CO'");
+
+    // AND M_REQUISITIONLINE.REQSTATUS = 'O'
+    whereClause.append(" and requisitionLineStatus='O'");
+
+    // AND (M_REQUISITIONLINE.LOCKEDBY IS NULL OR
+    // COALESCE (M_REQUISITIONLINE.LOCKDATE, TO_DATE('01-01-1900', 'DD-MM-YYYY')) < (now()-3))
+    whereClause.append(" and (lockedBy = null or lockDate<? or lockDate = null)");
+
+    // AND M_REQUISITION.AD_CLIENT_ID IN ? <-- Done by the DAL
+    // AND M_REQUISITIONLINE.AD_ORG_ID IN ? <-- Done by the DAL
+
+    // AND M_REQUISITIONLINE.NEEDBYDATE >= ?
+    whereClause.append(" and needByDate>=?");
+
+    // AND AND M_REQUISITIONLINE.NEEDBYDATE < ?
+    whereClause.append(" and needByDate<?");
+
+    // AND M_REQUISITIONLINE.M_PRODUCT_ID = ?
+    whereClause.append(" and product.id=?");
+
+    // AND M_REQUISITION.AD_USER_ID = TO_CHAR(?)
+    whereClause.append(" and requisition.userContact.id=?");
+
+    // AND ((M_REQUISITIONLINE.C_BPARTNER_ID = ? OR M_REQUISITION.C_BPARTNER_ID = ?) OR
+    // (M_REQUISITIONLINE.C_BPARTNER_ID IS NULL AND M_REQUISITION.C_BPARTNER_ID IS NULL))
+    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
+    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
+    whereClause.append(" and ((businessPartner.id = ? or requisition.businessPartner.id = ?) or "
+        + "(businessPartner = null and requisition.businessPartner = null))");
+
+    // ORDER BY M_REQUISITIONLINE.NEEDBYDATE, M_REQUISITIONLINE.M_PRODUCT_ID,
+    // M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID
+    whereClause.append(" order by needByDate, product.id, attributeSetValue.id");
+
+    final OBQuery<RequisitionLine> obQuery = OBDal.getInstance().createQuery(RequisitionLine.class,
+        whereClause.toString());
+
+    // now set the parameters
+    final List<Object> parameters = new ArrayList<Object>();
+
+    // lockDate
+    final long threeDays = 1000 * 3600 * 24 * 3;
+    parameters.add(new Date(System.currentTimeMillis() - threeDays));
+
+    // needByDate from, set at 30 days back
+    final long thirtyDays = threeDays * 10;
+    parameters.add(new Date(System.currentTimeMillis() - thirtyDays));
+
+    // needByDate to, set at 30 days in the future
+    parameters.add(new Date(System.currentTimeMillis() + thirtyDays));
+
+    // product.id
+    parameters.add("1000010");
+
+    // userContact.id
+    parameters.add("100");
+
+    // businessPartner.id
+    parameters.add("1000011");
+    parameters.add("1000011");
+
+    obQuery.setParameters(parameters);
+
+    // now print the select clause parts
+    for (RequisitionLine requisitionLine : obQuery.list()) {
+      // now print the information from the select clause
+      // SELECT M_REQUISITIONLINE_ID, M_REQUISITIONLINE.NEEDBYDATE,
+      log.debug(requisitionLine.getId());
+      log.debug(requisitionLine.getNeedByDate());
+      // M_REQUISITIONLINE.QTY - M_REQUISITIONLINE.ORDEREDQTY AS QTYTOORDER,
+      log.debug(requisitionLine.getQuantity().min(requisitionLine.getOrderQuantity()));
+      // M_REQUISITIONLINE.PRICEACTUAL AS PRICE,
+      log.debug(requisitionLine.getUnitPrice());
+
+      // AD_COLUMN_IDENTIFIER(to_char('C_BPartner'),
+      // to_char(COALESCE(M_REQUISITIONLINE.C_BPARTNER_ID, M_REQUISITION.C_BPARTNER_ID)), ?) AS
+      // VENDOR,
+      if (requisitionLine.getBusinessPartner() != null) {
+        log.debug(requisitionLine.getBusinessPartner().getIdentifier());
+      } else if (requisitionLine.getRequisition().getBusinessPartner() != null) {
+        log.debug(requisitionLine.getRequisition().getBusinessPartner().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_PriceList'),
+      // to_char(COALESCE(M_REQUISITIONLINE.M_PRICELIST_ID,
+      // M_REQUISITION.M_PRICELIST_ID)), ?) AS PRICELISTID,
+      if (requisitionLine.getPriceList() != null) {
+        log.debug(requisitionLine.getPriceList().getIdentifier());
+      } else if (requisitionLine.getRequisition().getPriceList() != null) {
+        log.debug(requisitionLine.getRequisition().getPriceList().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_Product'),
+      // to_char(M_REQUISITIONLINE.M_PRODUCT_ID), ?) AS PRODUCT,
+      log.debug(requisitionLine.getProduct().getIdentifier());
+
+      // AD_COLUMN_IDENTIFIER(to_char('M_AttributeSetInstance'),
+      // to_char(M_REQUISITIONLINE.M_ATTRIBUTESETINSTANCE_ID), ?) AS ATTRIBUTE,
+      if (requisitionLine.getAttributeSetValue() != null) {
+        log.debug(requisitionLine.getAttributeSetValue().getIdentifier());
+      }
+
+      // AD_COLUMN_IDENTIFIER(to_char('AD_User'), to_char(M_REQUISITION.AD_USER_ID), ?) AS REQUESTER
+      log.debug(requisitionLine.getRequisition().getUserContact().getIdentifier());
+
+      log.debug(requisitionLine.getIdentifier());
+    }
+    log.debug("done");
+  }
+}
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DalComplexQueryTestOrderLine.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DalComplexQueryTestOrderLine.java	Wed Apr 22 13:34:41 2009 +0200
@@ -23,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.openbravo.dal.service.OBDal;
@@ -38,6 +39,8 @@
 
 public class DalComplexQueryTestOrderLine extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(DalComplexQueryTestOrderLine.class);
+
   // SELECT C_ORDERLINE.C_ORDERLINE_ID AS ID, C_ORDER.C_ORDER_ID AS C_ORDER_ID, C_ORDER.DOCUMENTNO
   // AS DOCUMENTNO, C_ORDER.DATEORDERED AS DATEORDERED,
   // C_BPARTNER.C_BPARTNER_ID AS C_BPARTNER_ID, C_BPARTNER.NAME AS PARTNER_NAME,
@@ -62,8 +65,10 @@
   // C_ORDERLINE.QTYORDERED
   // ORDER BY PARTNER_NAME, DOCUMENTNO, DATEORDERED
 
+  /**
+   * Tests a complexer query related to order lines.
+   */
   public void testComplexOBQuery() {
-    setErrorOccured(true);
     setUserContext("100");
 
     // create the where clause
@@ -112,30 +117,30 @@
     for (OrderLine ol : qry.list()) {
 
       // C_ORDERLINE.C_ORDERLINE_ID AS ID, C_ORDER.C_ORDER_ID AS C_ORDER_ID
-      System.err.println(ol.getId());
-      System.err.println(ol.getSalesOrder().getId());
+      log.debug(ol.getId());
+      log.debug(ol.getSalesOrder().getId());
 
       // C_ORDER.DOCUMENTNO AS DOCUMENTNO, C_ORDER.DATEORDERED AS DATEORDERED,
-      System.err.println(ol.getSalesOrder().getDocumentNo());
-      System.err.println(ol.getSalesOrder().getOrderDate());
+      log.debug(ol.getSalesOrder().getDocumentNo());
+      log.debug(ol.getSalesOrder().getOrderDate());
 
       // C_BPARTNER.C_BPARTNER_ID AS C_BPARTNER_ID, C_BPARTNER.NAME AS PARTNER_NAME,
-      System.err.println(ol.getSalesOrder().getBusinessPartner().getId());
-      System.err.println(ol.getSalesOrder().getBusinessPartner().getName());
+      log.debug(ol.getSalesOrder().getBusinessPartner().getId());
+      log.debug(ol.getSalesOrder().getBusinessPartner().getName());
 
       // AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(C_ORDERLINE.M_PRODUCT_ID),
       // TO_CHAR(?)) AS PRODUCT_NAME,
-      System.err.println(ol.getProduct().getIdentifier());
-      System.err.println(ol.getProduct().getId());
-      System.err.println(ol.getProduct().getName());
+      log.debug(ol.getProduct().getIdentifier());
+      log.debug(ol.getProduct().getId());
+      log.debug(ol.getProduct().getName());
 
       // M_ATTRIBUTESETINSTANCE.DESCRIPTION AS DESCRIPTION,
       if (ol.getAttributeSetValue() != null) {
-        System.err.println(ol.getAttributeSetValue().getDescription());
+        log.debug(ol.getAttributeSetValue().getDescription());
       }
 
       // C_ORDERLINE.QTYORDERED AS TOTAL_QTY,
-      System.err.println(ol.getOrderedQuantity());
+      log.debug(ol.getOrderedQuantity());
 
       // C_ORDERLINE.QTYORDERED-SUM(COALESCE(M_MATCHPO.QTY,0)) AS QTYORDERED, '-1' AS ISACTIVE
       // todo this we have to repeat the sum query, we use direct hql for this
@@ -145,13 +150,11 @@
       final Query query = session.createQuery(hql);
       query.setParameter(0, ol);
       final BigDecimal sum = (BigDecimal) query.uniqueResult();
-      System.err.println(sum);
+      log.debug(sum);
     }
-    setErrorOccured(false);
   }
 
   public void testComplexQueryTwoHQL() {
-    setErrorOccured(true);
     setUserContext("100");
 
     final StringBuilder selectClause = new StringBuilder();
@@ -211,7 +214,7 @@
     final String hql = selectClause.toString() + fromClause.toString() + whereClause.toString()
         + groupClause.toString() + orderByClause.toString();
 
-    System.err.println(hql);
+    log.debug(hql);
 
     // final Session session = OBDal.getInstance().getSession();
     // session.createQuery(hql.toString());
@@ -221,9 +224,8 @@
     for (Object o : query.list()) {
       final Object[] os = (Object[]) o;
       for (Object result : os) {
-        System.err.println(result);
+        log.debug(result);
       }
     }
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DalPerformanceInventoryLineTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DalPerformanceInventoryLineTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,6 +21,7 @@
 
 import java.math.BigDecimal;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.service.OBCriteria;
@@ -30,20 +31,33 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Does some simple performance tests.
+ * Does some simple performance tests by creating sets of {@link InventoryCount} and
+ * {@link InventoryCountLine} objects and then reading and updating them.
  * 
  * @author mtaal
  */
 
 public class DalPerformanceInventoryLineTest extends BaseTest {
 
-  private static final int NO_HEADER = 5000;
+  private static final Logger log = Logger.getLogger(DalPerformanceInventoryLineTest.class);
+
+  // increase this number to make it a real performance test
+  private static final int NO_HEADER = 50;
   private static final int NO_LINE = 10;
   private static String NAME_PREFIX = "" + System.currentTimeMillis();
 
+  /**
+   * Creates {@link #NO_HEADER} {@link InventoryCount} objects and for each of them {@link #NO_LINE}
+   * {@link InventoryCountLine} objects. These objects are stored in the database and the timing is
+   * reported.
+   */
   public void testACreateInventoryLine() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+
+    // make sure our user can do this
+    addReadWriteAccess(InventoryCount.class);
+    addReadWriteAccess(InventoryCountLine.class);
+
     final OBCriteria<InventoryCount> icObc = OBDal.getInstance().createCriteria(
         InventoryCount.class);
     icObc.setFirstResult(1);
@@ -73,14 +87,19 @@
       OBDal.getInstance().save(ic);
     }
     OBDal.getInstance().commitAndClose();
-    System.err.println("Created " + NO_HEADER + " inventorycounts and " + (NO_HEADER * NO_LINE)
+    log.debug("Created " + NO_HEADER + " inventorycounts and " + (NO_HEADER * NO_LINE)
         + " inventory lines" + " in " + (System.currentTimeMillis() - time) + " milliseconds");
-    setErrorOccured(false);
   }
 
+  /**
+   * Reads the {@link InventoryCountLine} objects created in the above tests and adds one new line
+   * and updates one line. The timings are reported in the log.
+   */
   public void testBReadAndAddLine() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    // make sure our user can do this
+    addReadWriteAccess(InventoryCount.class);
+    addReadWriteAccess(InventoryCountLine.class);
 
     final OBCriteria<InventoryCountLine> iclObc = OBDal.getInstance().createCriteria(
         InventoryCountLine.class);
@@ -112,9 +131,8 @@
       OBDal.getInstance().save(ic);
     }
     OBDal.getInstance().commitAndClose();
-    System.err.println("Read " + cnt + " inventorycounts with each " + cntLine
+    log.debug("Read " + cnt + " inventorycounts with each " + cntLine
         + " inventory lines and added one new line and updated one line in "
         + (System.currentTimeMillis() - time) + " milliseconds");
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DalPerformanceProductTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DalPerformanceProductTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -19,26 +19,30 @@
 
 package org.openbravo.test.dal;
 
-import org.openbravo.dal.core.OBContext;
+import org.apache.log4j.Logger;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Does some simple performance tests.
+ * Does some simple performance tests by reading and updating of all {@link Product} objects, either
+ * directly or in paged mode.
  * 
  * @author mtaal
  */
 
 public class DalPerformanceProductTest extends BaseTest {
-  // tests a paged read of products and print of the identifier.
+  private static final Logger log = Logger.getLogger(DalPerformanceProductTest.class);
+
+  /**
+   * Tests a paged read of products and print of the identifier. The timing is reported in the log.
+   */
   public void testProduct25PageRead() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final OBCriteria<Product> countObc = OBDal.getInstance().createCriteria(Product.class);
     final int count = countObc.count();
-    System.err.println("Number of products " + count);
+    log.debug("Number of products " + count);
     final int pageSize = 25;
     final int pageCount = 1 + (count / pageSize);
     long time = System.currentTimeMillis();
@@ -50,9 +54,9 @@
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
 
-      System.err.println("PAGE>>> " + (1 + i));
+      log.debug("PAGE>>> " + (1 + i));
       for (final Product t : obc.list()) {
-        System.err.println(t.getIdentifier());
+        log.debug(t.getIdentifier());
       }
       if (avg == 0) {
         avg = System.currentTimeMillis() - time;
@@ -63,18 +67,19 @@
       OBDal.getInstance().commitAndClose();
     }
 
-    System.err.println("Read " + pageCount + " pages with average " + avg
-        + " milliSeconds per page");
-    setErrorOccured(false);
+    log.debug("Read " + pageCount + " pages with average " + avg + " milliSeconds per page");
   }
 
-  // tests a paged read of products and print of the identifier.
+  /**
+   * Tests a paged read of products and print of the identifier. In addition extra information is
+   * read for the {@link Product}, nl. the {@link Product#getProductCategory()} and the
+   * {@link Product#getTaxCategory()}. The timing is reported in the log.
+   */
   public void testProduct25PageReadGetExtra() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final OBCriteria<Product> countObc = OBDal.getInstance().createCriteria(Product.class);
     final int count = countObc.count();
-    System.err.println("Number of products " + count);
+    log.debug("Number of products " + count);
     final int pageSize = 25;
     final int pageCount = 1 + (count / pageSize);
     long time = System.currentTimeMillis();
@@ -86,13 +91,13 @@
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
 
-      System.err.println("PAGE>>> " + (1 + i));
+      log.debug("PAGE>>> " + (1 + i));
       for (final Product t : obc.list()) {
-        System.err.println(t.toString() + " Product Category "
+        log.debug(t.toString() + " Product Category "
             + (t.getProductCategory() != null ? t.getProductCategory().getIdentifier() : "NULL")
             + " Tax Category "
             + (t.getTaxCategory() != null ? t.getTaxCategory().getIdentifier() : "NULL"));
-        System.err.println(t.toString());
+        log.debug(t.toString());
       }
       if (avg == 0) {
         avg = System.currentTimeMillis() - time;
@@ -103,14 +108,15 @@
       OBDal.getInstance().commitAndClose();
     }
 
-    System.err.println("Read " + pageCount + " pages with average " + avg
+    log.debug("Read " + pageCount + " pages with average " + avg
         + " milliSeconds per page (read extra info)");
-    setErrorOccured(false);
   }
 
-  // tests reading all products
+  /**
+   * Reads all {@link Product} objects sorted by name and also prints related information:
+   * {@link Product#getProductCategory()} and {@link Product#getTaxCategory()}.
+   */
   public void testReadProducts() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final OBCriteria<Product> obc = OBDal.getInstance().createCriteria(Product.class);
     obc.setFilterOnReadableOrganization(false);
@@ -122,45 +128,47 @@
           + (t.getProductCategory() != null ? t.getProductCategory().getIdentifier() : "NULL")
           + " Tax Category "
           + (t.getTaxCategory() != null ? t.getTaxCategory().getIdentifier() : "NULL");
-      System.err.println(rs);
+      log.debug(rs);
     }
 
-    System.err.println("Read 75000 products in " + (System.currentTimeMillis() - time)
+    log.debug("Read 75000 products in " + (System.currentTimeMillis() - time)
         + " milliSeconds (reading extra info)");
-    setErrorOccured(false);
   }
 
-  // tests a paged read of products and print of the identifier.
+  /**
+   * Reads all {@link Product} objects and updates the name.
+   */
   public void testUpdateAllProducts() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final OBCriteria<Product> countObc = OBDal.getInstance().createCriteria(Product.class);
     final int count = countObc.count();
-    System.err.println("Number of products " + count);
+    log.debug("Number of products " + count);
     final long time = System.currentTimeMillis();
     final OBCriteria<Product> obc = OBDal.getInstance().createCriteria(Product.class);
     obc.setFilterOnReadableOrganization(false);
     obc.addOrderBy(Product.PROPERTY_NAME, true);
 
-    OBContext.getOBContext().setInAdministratorMode(true);
+    // don't be bothered by security exceptions
+    addReadWriteAccess(Product.class);
     for (final Product t : obc.list()) {
       t.setName(t.getName() + "t");
       OBDal.getInstance().save(t);
     }
     OBDal.getInstance().flush();
     OBDal.getInstance().commitAndClose();
-    System.err.println("Updated " + count + " products in " + (System.currentTimeMillis() - time)
+    log.debug("Updated " + count + " products in " + (System.currentTimeMillis() - time)
         + " milliseconds ");
-    setErrorOccured(false);
   }
 
+  /**
+   * Reads all products in a paged manner and updates the name.
+   */
   public void testUpdateAllProductsByPage() {
-    setErrorOccured(true);
     setUserContext("1000019");
-    OBContext.getOBContext().setInAdministratorMode(true);
+    addReadWriteAccess(Product.class);
     final OBCriteria<Product> countObc = OBDal.getInstance().createCriteria(Product.class);
     final int count = countObc.count();
-    System.err.println("Number of products " + count);
+    log.debug("Number of products " + count);
     final int pageSize = 25;
     final int pageCount = 1 + (count / pageSize);
     long time = System.currentTimeMillis();
@@ -172,7 +180,7 @@
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
 
-      // System.err.println("PAGE>>> " + (1 + i));
+      // log.debug("PAGE>>> " + (1 + i));
       for (final Product t : obc.list()) {
         t.setName(t.getName() + "t");
         OBDal.getInstance().save(t);
@@ -186,8 +194,7 @@
       OBDal.getInstance().commitAndClose();
     }
 
-    System.err.println("Updated " + pageCount + " pages of products with average " + avg
+    log.debug("Updated " + pageCount + " pages of products with average " + avg
         + " milliSeconds per page and 25 products per page");
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DalQueryTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DalQueryTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,6 +22,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.exception.OBSecurityException;
@@ -40,7 +41,7 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test different parts of the dal api.
+ * Test different parts of the dal api, specifically querying.
  * 
  * Note the testcases assume that they are run in the order defined in this class.
  * 
@@ -48,19 +49,23 @@
  */
 
 public class DalQueryTest extends BaseTest {
+  private static final Logger log = Logger.getLogger(DalQueryTest.class);
 
+  /**
+   * Tests a left join with {@link ModelImplementation} as the main class.
+   */
   public void testDalFirstWhereLeftJoinClause() {
-    setErrorOccured(true);
     setUserContext("100");
-    final String where = "as mo left join mo.callout left join mo.reference left join mo.form left join mo.process left join mo.workflow left join mo.tab where mo.callout.module.id='0' or mo.reference.module.id='0' or mo.form.module.id='0' or mo.process.module.id='0' or mo.workflow.module.id='0' or mo.tab.module.id='0'";
+    final String where = "as mo left join mo.callout left join mo.reference left join mo.specialForm left join mo.process left join mo.workflow left join mo.tab where mo.callout.module.id='0' or mo.reference.module.id='0' or mo.specialForm.module.id='0' or mo.process.module.id='0' or mo.workflow.module.id='0' or mo.tab.module.id='0'";
     final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(
         ModelImplementation.class, where);
     assertTrue(obq.list().size() > 0);
-    setErrorOccured(false);
   }
 
+  /**
+   * Tests a left join with {@link ModelImplementation} as the main class.
+   */
   public void testDalExtraJoinWhereLeftJoinClause() {
-    setErrorOccured(true);
     setUserContext("100");
     final String where = "as mom left join mom."
         + ModelImplementationMapping.PROPERTY_MODELOBJECT
@@ -76,60 +81,56 @@
         + ModelImplementation.PROPERTY_WORKFLOW
         + " left join mo."
         + ModelImplementation.PROPERTY_TAB
-        + " where mo.callout.module.id='0' or mo.reference.module.id='0' or mo.form.module.id='0' or mo.process.module.id='0' or mo.workflow.module.id='0' or mo.tab.module.id='0'";
+        + " where mo.callout.module.id='0' or mo.reference.module.id='0' or mo.specialForm.module.id='0' or mo.process.module.id='0' or mo.workflow.module.id='0' or mo.tab.module.id='0'";
     final OBQuery<ModelImplementationMapping> obq = OBDal.getInstance().createQuery(
         ModelImplementationMapping.class, where);
     assertTrue(obq.list().size() > 0);
-    setErrorOccured(false);
   }
 
   public void testDalWhereLeftJoinClause() {
-    setErrorOccured(true);
     setUserContext("100");
     final String where = "as mo left join mo.callout left join mo.reference where mo.callout.module.id='0' or mo.reference.module.id='0'";
     final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(
         ModelImplementation.class, where);
     assertTrue(obq.list().size() > 0);
-    setErrorOccured(false);
   }
 
   public void testDalOtherWhereLeftJoinClause() {
-    setErrorOccured(true);
     setUserContext("100");
     final String where = "as mo left join mo.callout left join mo.reference where (mo.callout.module.id='0' or mo.reference.module.id='0') and exists(from ADUser where id<>'0')";
     final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(
         ModelImplementation.class, where);
     assertTrue(obq.list().size() > 0);
-    setErrorOccured(false);
   }
 
   public void testDalAnOtherWhereLeftJoinClause() {
-    setErrorOccured(true);
     setUserContext("100");
     final String where = "exists(from ADUser where id<>'0')";
     final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(
         ModelImplementation.class, where);
     assertTrue(obq.list().size() > 0);
-    setErrorOccured(false);
   }
 
-  // creates a new BPGroup, test simple save, BPGroup is removed in next test
+  /**
+   * Test creates a new {@link Category} and saves it. The new object is removed in next test
+   */
   public void testCreateBPGroup() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Category.class);
     final Category bpg = OBProvider.getInstance().get(Category.class);
     bpg.setDefault(true);
     bpg.setDescription("testdescription");
     bpg.setName("testname");
     bpg.setSearchKey("testvalue");
+    bpg.setActive(true);
     OBDal.getInstance().save(bpg);
-    setErrorOccured(false);
   }
 
-  // query for the BPGroup again and remove it
+  /**
+   * Test queries for the created {@link Category} and removes it.
+   */
   public void testRemoveBPGroup() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBQuery<Category> obQuery = OBDal.getInstance().createQuery(Category.class,
         Category.PROPERTY_NAME + "='testname' or " + Category.PROPERTY_SEARCHKEY + "='testvalue'");
     final List<Category> bpgs = obQuery.list();
@@ -159,24 +160,24 @@
       OBDal.getInstance().remove(bga);
     }
     OBDal.getInstance().remove(bpgs.get(0));
-    setErrorOccured(false);
   }
 
-  // check if the BPGroup was removed
+  /**
+   * Check that the {@link Category} was indeed removed.
+   */
   public void testCheckBPGroupRemoved() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBQuery<Category> obQuery = OBDal.getInstance().createQuery(Category.class,
         Category.PROPERTY_NAME + "='testname' or " + Category.PROPERTY_SEARCHKEY + "='testvalue'");
     final List<Category> bpgs = obQuery.list();
     assertEquals(0, bpgs.size());
-    setErrorOccured(false);
   }
 
-  // test querying for a specific currency and then updating it
-  // should fail for a user
+  /**
+   * Tests queries for a currency and then updates it. The test should fail as the user does not
+   * have update authorisation.
+   */
   public void testUpdateCurrencyByUser() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
     obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
@@ -190,17 +191,16 @@
     } catch (final OBSecurityException e) {
       // successfull check
     }
-    setErrorOccured(false);
   }
 
-  // tests a paged read of transactions and print of the identifier.
-  // the identifier of a transaction has been implemented such that
-  // it reads all the references (which are non-null) and uses their
-  // identifier to create the identifier of the transaction.
-  // test sorting on product.name
+  /**
+   * Tests a paged read of transactions and print of the identifier. The identifier of a transaction
+   * has been implemented such that it reads all the references (which are non-null) and uses their
+   * identifier to create the identifier of the transaction. The test sorts on product.name.
+   */
   public void testTransaction25PageRead() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(MaterialTransaction.class);
     final OBQuery<MaterialTransaction> cq = OBDal.getInstance().createQuery(
         MaterialTransaction.class, " order by product.name");
     final int count = cq.count();
@@ -217,11 +217,10 @@
       qry.setMaxResults(pageSize);
       qry.setFirstResult(i * pageSize);
 
-      System.err.println("PAGE>>> " + (1 + i));
+      log.debug("PAGE>>> " + (1 + i));
       for (final Object o : qry.list()) {
-        System.err.println(((MaterialTransaction) o).getIdentifier());
+        log.debug(((MaterialTransaction) o).getIdentifier());
       }
     }
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DalTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DalTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -61,9 +61,7 @@
   public void testADataAccessLevel() {
     setUserContext("0");
     final List<Entity> entities = ModelProvider.getInstance().getModel();
-    System.err.println("Checking started");
     for (Entity e : entities) {
-      System.err.println("Checking entity " + e.getName());
       final OBCriteria<BaseOBObject> obc = OBDal.getInstance().createCriteria(e.getName());
       for (BaseOBObject bob : obc.list()) {
         String clientId = null;
@@ -78,18 +76,11 @@
           try {
             e.checkAccessLevel(clientId, orgId);
           } catch (OBSecurityException ex) {
-            System.err.println(e.getTableName() + " " + ex.getMessage());
             break;
           }
         }
       }
     }
-
-  }
-
-  public void testShowInPreciseDouble() {
-    final double a = 0.58;
-    System.err.println(a * 100);
   }
 
   // set correct default role
@@ -110,8 +101,8 @@
     bpg.setDescription("testdescription");
     bpg.setName("testname");
     bpg.setSearchKey("testvalue");
+    bpg.setActive(true);
     OBDal.getInstance().save(bpg);
-    commitTransaction();
   }
 
   // query for the BPGroup again and remove it
@@ -131,9 +122,9 @@
     // longer in the past, You need to manually delete the currency record
     if (true) {
       assertTrue("Created time not updated", (System.currentTimeMillis() - bpg.getCreationDate()
-          .getTime()) < 2000);
+          .getTime()) < 3000);
       assertTrue("Updated time not updated", (System.currentTimeMillis() - bpg.getUpdated()
-          .getTime()) < 2000);
+          .getTime()) < 3000);
     }
 
     // first delete the related accounts
@@ -145,7 +136,6 @@
       OBDal.getInstance().remove(bga);
     }
     OBDal.getInstance().remove(bpgs.get(0));
-    commitTransaction();
   }
 
   // check if the BPGroup was removed
@@ -155,7 +145,6 @@
     obc.add(Expression.eq(Category.PROPERTY_NAME, "testname"));
     final List<Category> bpgs = obc.list();
     assertEquals(0, bpgs.size());
-    commitTransaction();
   }
 
   // test querying for a specific currency and then updating it
@@ -174,7 +163,6 @@
     } catch (final OBSecurityException e) {
       // successfull check
     }
-    commitTransaction();
   }
 
   public void testUpdateCurrencyByAdmin() {
@@ -186,17 +174,16 @@
     final Currency c = cs.get(0);
     c.setDescription(c.getDescription() + " a test");
     OBDal.getInstance().save(c);
-    commitTransaction();
   }
 
   // Test toString and using class for querying
   public void testToString() {
     setBigBazaarAdminContext();
     final List<Product> products = OBDal.getInstance().createCriteria(Product.class).list();
+    final StringBuilder sb = new StringBuilder();
     for (final Product p : products) {
-      System.err.println(p.toString());
+      sb.append(p.toString());
     }
-    commitTransaction();
   }
 
   // tests a paged read of transactions and print of the identifier.
@@ -214,6 +201,7 @@
     if (pageCount > 25) {
       pageCount = 25;
     }
+    final StringBuilder sb = new StringBuilder();
     for (int i = 0; i < pageCount; i++) {
       final OBCriteria<MaterialTransaction> obc = OBDal.getInstance().createCriteria(
           MaterialTransaction.class);
@@ -221,12 +209,11 @@
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
 
-      System.err.println("PAGE>>> " + (1 + i));
+      sb.append("\nPAGE>>> " + (1 + i));
       for (final MaterialTransaction t : obc.list()) {
-        System.err.println(t.getIdentifier());
+        sb.append("\n" + t.getIdentifier());
       }
     }
-    commitTransaction();
   }
 
   // test reads 500 pages of the transaction table and then prints how many
@@ -247,10 +234,6 @@
       obc.addOrderBy(MaterialTransaction.PROPERTY_PRODUCT + "." + Product.PROPERTY_NAME, false);
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
-
-      if ((i % 25) == 0) {
-        System.err.println("PAGE>>> " + (1 + i) + "/" + pageCount);
-      }
       for (final MaterialTransaction t : obc.list()) {
         log.debug(t.getIdentifier());
         // System.err.println(t.getIdentifier() +
@@ -267,8 +250,7 @@
       SessionHandler.getInstance().commitAndClose();
     }
 
-    System.err.println("Read " + pageCount + " pages with average " + avg
-        + " milliSeconds per page");
+    log.debug("Read " + pageCount + " pages with average " + avg + " milliSeconds per page");
   }
 
   // test paged read of currencys
@@ -284,12 +266,11 @@
       obc.setMaxResults(pageSize);
       obc.setFirstResult(i * pageSize);
 
-      System.err.println("PAGE>>> " + (1 + i));
+      log.debug("PAGE>>> " + (1 + i));
       for (final Currency c : obc.list()) {
-        System.err.println(c.getISOCode() + " " + c.getSymbol());
+        log.debug(c.getISOCode() + " " + c.getSymbol());
       }
     }
-    commitTransaction();
   }
 
   // test the read of a dynamically mapped entity
@@ -303,12 +284,12 @@
       obc.setFirstResult(i * pageSize);
       obc.setMaxResults(pageSize);
 
-      System.err.println("CashBook PAGE>>> " + (1 + i));
+      log.debug("CashBook PAGE>>> " + (1 + i));
       for (final CashBook c : obc.list()) {
-        System.err.println(c.getName() + " " + c.getDescription());
+        log.debug(c.getName() + " " + c.getDescription());
       }
     }
-    commitTransaction();
+
   }
 
   // Test trigger on creation of cashbook. Note that this test uses a type
@@ -318,7 +299,7 @@
   // possible
   public void testCashBookTrigger() {
     setUserContext("1000000");
-    OBContext.getOBContext().setInAdministratorMode(true);
+    addReadWriteAccess(Currency.class);
     String cashBookId = "";
     {
       final OBCriteria<Currency> cc = OBDal.getInstance().createCriteria(Currency.class);
@@ -347,8 +328,7 @@
     assertTrue(cbas.size() > 0);
     for (final Object co : cbas) {
       final CashBookAccounts cba = (CashBookAccounts) co;
-      System.err.println(cba.getUpdated() + " " + cba.getCashbook().getName());
+      log.debug(cba.getUpdated() + " " + cba.getCashbook().getName());
     }
-    commitTransaction();
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/DynamicEntityTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/DynamicEntityTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
@@ -41,24 +42,24 @@
  */
 
 public class DynamicEntityTest extends BaseTest {
+  private static final Logger log = Logger.getLogger(DynamicEntityTest.class);
+
   public void testCreateBPGroup() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final DynamicOBObject bpGroup = new DynamicOBObject();
     bpGroup.setEntityName(Category.ENTITY_NAME);
     bpGroup.set(Category.PROPERTY_DEFAULT, true);
     bpGroup.set(Category.PROPERTY_DESCRIPTION, "hello world");
     bpGroup.set(Category.PROPERTY_NAME, "hello world");
     bpGroup.set(Category.PROPERTY_SEARCHKEY, "hello world");
+    bpGroup.setActive(true);
     OBDal.getInstance().save(bpGroup);
     printXML(bpGroup);
-    setErrorOccured(false);
   }
 
   // query for the BPGroup again and remove it
   public void testRemoveBPGroup() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBCriteria<Category> obc = OBDal.getInstance().createCriteria(Category.class);
     obc.add(Expression.eq(Category.PROPERTY_NAME, "hello world"));
     final List<Category> bpgs = obc.list();
@@ -87,18 +88,15 @@
       OBDal.getInstance().remove(bga);
     }
     OBDal.getInstance().remove(bpgs.get(0));
-    setErrorOccured(false);
   }
 
   // check if the BPGroup was removed
   public void testCheckBPGroupRemoved() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBCriteria<Category> obc = OBDal.getInstance().createCriteria(Category.class);
     obc.add(Expression.eq(Category.PROPERTY_NAME, "hello world"));
     final List<Category> bpgs = obc.list();
     assertEquals(0, bpgs.size());
-    setErrorOccured(false);
   }
 
   private void printXML(BaseOBObject bob) {
@@ -112,7 +110,7 @@
     // Note: bob.getEntity() also gives the entity of the object
 
     // print the opening tag
-    System.err.println("<" + e.getName() + ">");
+    log.debug("<" + e.getName() + ">");
 
     // iterate through the properties of the entity
     for (final Property p : e.getProperties()) {
@@ -123,7 +121,7 @@
 
       // handle null, just create an empty tag for that
       if (value == null) {
-        System.err.println(indent + "<" + p.getName() + "/>");
+        log.debug(indent + "<" + p.getName() + "/>");
         continue;
       }
 
@@ -131,17 +129,17 @@
       if (p.isPrimitive()) {
         // in reality some form of xml conversion/encoding should take
         // place...
-        System.err.println(indent + "<" + p.getName() + ">" + value + "</" + p.getName() + ">");
+        log.debug(indent + "<" + p.getName() + ">" + value + "</" + p.getName() + ">");
       } else {
         // cast to the parent of all openbravo objects
         final BaseOBObject referencedObject = (BaseOBObject) value;
         // assumes that the id is always a primitive type
-        System.err.println(indent + "<" + p.getName() + ">" + referencedObject.getId() + "</"
-            + p.getName() + ">");
+        log.debug(indent + "<" + p.getName() + ">" + referencedObject.getId() + "</" + p.getName()
+            + ">");
       }
     }
 
     // and the closing tag
-    System.err.println("</" + e.getName() + ">");
+    log.debug("</" + e.getName() + ">");
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/HiddenUpdateTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/HiddenUpdateTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -27,12 +27,9 @@
 import org.hibernate.cfg.Configuration;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.type.Type;
-import org.openbravo.base.model.Entity;
-import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.session.SessionFactoryController;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.dal.core.DalSessionFactoryController;
-import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.xml.EntityXMLConverter;
@@ -42,8 +39,6 @@
  * Test for updates which can happen behind the scenes (but should not happen) if properties are
  * accidentally changed.
  * 
- * Note the testcases assume that they are run in the order defined in this class.
- * 
  * @author mtaal
  */
 
@@ -53,11 +48,9 @@
   // Hidden updates can occur when a load/read of an entity also
   // changes the state, or that hibernate detects dirty in another way
   public void testHiddenUpdates() {
-    setErrorOccured(true);
     setUserContext("0");
 
     final SessionFactoryController currentSFC = SessionFactoryController.getInstance();
-    OBContext.getOBContext().setInAdministratorMode(true);
     try {
       final SessionFactoryController newSFC = new LocalSessionFactoryController();
       SessionFactoryController.setInstance(newSFC);
@@ -73,12 +66,6 @@
         final PersistentClass pc = (PersistentClass) it.next();
         final String entityName = pc.getEntityName();
 
-        final Entity e = ModelProvider.getInstance().getEntity(entityName);
-
-        if (entityName.startsWith("C_Selection")) {
-          continue;
-        }
-        System.err.println("++++++++ Reading entity " + entityName + " +++++++++++");
         for (final Object o : OBDal.getInstance().createCriteria(entityName).list()) {
           if (o == null) {
             // can occur when reading views which have nullable
@@ -92,9 +79,7 @@
       }
     } finally {
       SessionFactoryController.setInstance(currentSFC);
-      OBContext.getOBContext().setInAdministratorMode(false);
     }
-    setErrorOccured(false);
   }
 
   class LocalSessionFactoryController extends DalSessionFactoryController {
--- a/src-test/org/openbravo/test/dal/HqlTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/HqlTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -19,6 +19,7 @@
 
 package org.openbravo.test.dal;
 
+import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.openbravo.base.structure.BaseOBObject;
@@ -29,15 +30,18 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Allows testing of hql
+ * Tests hql and the DAL.
+ * 
+ * NOTE: simple test class only used for testing queries manually, should not be part of a test
+ * suite.
  * 
  * @author mtaal
  */
 
 public class HqlTest extends BaseTest {
-  // creates a new BPGroup, test simple save, BPGroup is removed in next test
+  private static final Logger log = Logger.getLogger(HqlTest.class);
+
   public void testDalWhereClause() {
-    setErrorOccured(true);
     setUserContext("100");
     // final String where =
     // " tree.id='10' and exists( from ADMenu as menu where menu.id = node_id and menu.module.id='0')"
@@ -53,23 +57,22 @@
     final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(
         ModelImplementation.class, where);
     for (final BaseOBObject o : obq.list()) {
-      System.err.println(o.getIdentifier());
+      log.debug(o.getIdentifier());
     }
-    setErrorOccured(false);
   }
 
   // query for the BPGroup again and remove it
   public void testHql() {
-    setErrorOccured(true);
     setUserContext("100");
 
     final Session s = SessionHandler.getInstance().getSession();
     final Query q = s
-        .createQuery("select mo from ADModelObject as mo left join mo.callout left join mo.reference where mo.callout.module.id='0' or mo.reference.module.id='0'");
+        .createQuery("select mo from "
+            + ModelImplementation.ENTITY_NAME
+            + " as mo left join mo.callout left join mo.reference where mo.callout.module.id='0' or mo.reference.module.id='0'");
     for (final Object o : q.list()) {
-      System.err.println(((BaseOBObject) o).getIdentifier());
+      log.debug(((BaseOBObject) o).getIdentifier());
     }
 
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/MappingGenerationTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/MappingGenerationTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -19,86 +19,18 @@
 
 package org.openbravo.test.dal;
 
-import java.util.Iterator;
-
-import org.hibernate.MappingException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.PersistentClass;
-import org.openbravo.base.session.SessionFactoryController;
-import org.openbravo.base.structure.BaseOBObject;
-import org.openbravo.base.structure.Identifiable;
 import org.openbravo.dal.core.DalMappingGenerator;
-import org.openbravo.dal.core.SessionHandler;
-import org.openbravo.dal.service.OBCriteria;
-import org.openbravo.dal.service.OBDal;
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test generation of mappings
+ * Test generation of hbm, very basic just generates it.
  * 
  * @author mtaal
  */
 
 public class MappingGenerationTest extends BaseTest {
 
-  public void _testMappingGeneration() {
+  public void testMappingGeneration() {
     DalMappingGenerator.getInstance().generateMapping();
   }
-
-  public void testAllPageReadAll() {
-    setErrorOccured(true);
-    setBigBazaarAdminContext();
-    final Configuration cfg = SessionFactoryController.getInstance().getConfiguration();
-    for (final Iterator<?> it = cfg.getClassMappings(); it.hasNext();) {
-      final PersistentClass pc = (PersistentClass) it.next();
-      final String entityName = pc.getEntityName();
-
-      // System.err.println("++++++++ Reading entity " + entityName +
-      // " +++++++++++");
-
-      // do ordering for some of the classes
-      boolean orderOnName = false;
-      try {
-        if (pc.getProperty("name") != null) {
-          orderOnName = true;
-        }
-      } catch (final MappingException m) {
-        // ignore on purpose
-      }
-      try {
-        final int count = OBDal.getInstance().createCriteria(entityName).count();
-        final int pageSize = 5;
-        int pageCount = 1 + (count / pageSize);
-        if (pageCount > 25) {
-          // System.err.println("Pagecount " + pageCount +
-          // " setting to max 25 because of performance reasons");
-          pageCount = 25;
-        }
-        for (int i = 0; i < pageCount; i++) {
-          final OBCriteria<BaseOBObject> obc = OBDal.getInstance().createCriteria(entityName);
-          obc.setFirstResult(i * pageSize);
-          obc.setMaxResults(pageSize);
-          if (orderOnName) {
-            obc.addOrderBy("name", true);
-          }
-
-          // System.err.println("PAGE>>> " + (1 + i));
-          for (final Object o : obc.list()) {
-            if (o instanceof Identifiable) {
-              // final Identifiable n = (Identifiable) o;
-              // System.err.println(entityName + ": " +
-              // n.getIdentifier());
-            } else {
-              // System.err.println(entityName + ": " + o);
-            }
-          }
-        }
-      } catch (final Exception e) {
-        System.err.println("Exception for entity: " + entityName);
-        e.printStackTrace(System.err);
-      }
-      SessionHandler.getInstance().commitAndClose();
-    }
-    setErrorOccured(false);
-  }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/dal/ValidationTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/dal/ValidationTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,12 +22,12 @@
 import java.math.BigDecimal;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.structure.DynamicOBObject;
 import org.openbravo.base.util.CheckException;
 import org.openbravo.base.validation.ValidationException;
-import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
@@ -39,15 +39,15 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Validation test
+ * Test property validations.
  * 
  * @author mtaal
  */
 
 public class ValidationTest extends BaseTest {
+  private static final Logger log = Logger.getLogger(ValidationTest.class);
 
   public void testTypeChecking() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
     obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
@@ -65,17 +65,14 @@
     } catch (final CheckException e) {
       // correct!
     }
-    setErrorOccured(false);
   }
 
   public void testTypeCheckDynamicObject() {
-    setErrorOccured(true);
     final DynamicOBObject bpGroup = new DynamicOBObject();
     bpGroup.setEntityName(Category.ENTITY_NAME);
     setValue(bpGroup, Category.PROPERTY_CLIENT, "test", "only allows reference instances of type");
     setValue(bpGroup, Category.PROPERTY_DESCRIPTION, new Double(400.0), "only allows instances of");
     setValue(bpGroup, Category.PROPERTY_DEFAULT, new BigDecimal(100.0), "only allows instances of");
-    setErrorOccured(false);
   }
 
   private void setValue(BaseOBObject bob, String propName, Object value, String expectedMessage) {
@@ -95,7 +92,6 @@
   }
 
   public void testListValue() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final OBCriteria<AlertRule> obc = OBDal.getInstance().createCriteria(AlertRule.class);
     for (final AlertRule ar : obc.list()) {
@@ -109,11 +105,9 @@
         // success
       }
     }
-    setErrorOccured(false);
   }
 
   public void testFieldLength() {
-    setErrorOccured(true);
     setUserContext("0");
 
     final StringBuffer sb = new StringBuffer();
@@ -133,52 +127,37 @@
         // success
       }
     }
-    setErrorOccured(false);
   }
 
   public void testMaxValue() {
-    setErrorOccured(true);
-    // otherwise it fails on other things
-    OBContext.getOBContext().setInAdministratorMode(true);
-    try {
-      setUserContext("1000001");
-      final OBCriteria<InvoiceSchedule> obc = OBDal.getInstance().createCriteria(
-          InvoiceSchedule.class);
-      for (final InvoiceSchedule is : obc.list()) {
-        try {
-          is.setInvoiceCutOffDay((long) 40);
-          fail("Maxvalue constraint not enforced");
-        } catch (final ValidationException ve) {
-          // success
-          break;
-        }
+    addReadWriteAccess(InvoiceSchedule.class);
+    setUserContext("1000000");
+    final OBCriteria<InvoiceSchedule> obc = OBDal.getInstance().createCriteria(
+        InvoiceSchedule.class);
+    for (final InvoiceSchedule is : obc.list()) {
+      try {
+        is.setInvoiceCutOffDay((long) 40);
+        fail("Maxvalue constraint not enforced");
+      } catch (final ValidationException ve) {
+        // success
+        break;
       }
-      setErrorOccured(false);
-    } finally {
-      OBContext.getOBContext().setInAdministratorMode(false);
     }
   }
 
   public void testMinValue() {
-    setErrorOccured(true);
-    // otherwise it fails on other things
-    OBContext.getOBContext().setInAdministratorMode(true);
-    try {
-      setUserContext("1000001");
-      final OBCriteria<InvoiceSchedule> obc = OBDal.getInstance().createCriteria(
-          InvoiceSchedule.class);
-      for (final InvoiceSchedule is : obc.list()) {
-        try {
-          is.setInvoiceCutOffDay((long) 0);
-          fail();
-        } catch (final ValidationException ve) {
-          // success
-          break;
-        }
+    addReadWriteAccess(InvoiceSchedule.class);
+    setUserContext("1000000");
+    final OBCriteria<InvoiceSchedule> obc = OBDal.getInstance().createCriteria(
+        InvoiceSchedule.class);
+    for (final InvoiceSchedule is : obc.list()) {
+      try {
+        is.setInvoiceCutOffDay((long) 0);
+        fail();
+      } catch (final ValidationException ve) {
+        // success
+        break;
       }
-      setErrorOccured(false);
-    } finally {
-      OBContext.getOBContext().setInAdministratorMode(false);
     }
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/expression/EvaluationTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/expression/EvaluationTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -24,6 +24,7 @@
 import javax.script.ScriptEngineFactory;
 import javax.script.ScriptEngineManager;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.expression.Evaluator;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.datamodel.Table;
@@ -31,23 +32,21 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test different parts of the dal api.
- * 
- * Note the testcases assume that they are run in the order defined in this class.
+ * Test the expression processor used in datasets.
  * 
  * @author mtaal
  */
 
 public class EvaluationTest extends BaseTest {
+  private static final Logger log = Logger.getLogger(EvaluationTest.class);
 
   public void testEvaluation() {
-    setErrorOccured(true);
     setUserContext("0");
 
     // as a test print scripting language names
     final ScriptEngineManager manager = new ScriptEngineManager();
     for (final ScriptEngineFactory sef : manager.getEngineFactories()) {
-      System.err.println(sef.getEngineName());
+      log.debug(sef.getEngineName());
     }
 
     final List<Table> tables = OBDal.getInstance().createCriteria(Table.class).list();
@@ -57,10 +56,9 @@
           + Table.PROPERTY_DBTABLENAME + "== 'AD_Client' && " + Table.PROPERTY_DATAACCESSLEVEL
           + " > 5";
       final Boolean result = Evaluator.getInstance().evaluateBoolean(t, script);
-      System.err.println(t.getName() + " : " + result);
+      log.debug(t.getName() + " : " + result);
       found = found || result;
     }
     assertTrue(found);
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/model/OneToManyTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/model/OneToManyTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -19,6 +19,7 @@
 
 package org.openbravo.test.model;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.dal.service.OBCriteria;
@@ -30,69 +31,64 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test cases for one-to-many support
+ * Test cases for one-to-many support.
  * 
  * @author iperdomo
  */
 public class OneToManyTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(OneToManyTest.class);
+
   private String lineId;
 
   public void testAccessChildCollection() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBCriteria<Order> order = OBDal.getInstance().createCriteria(Order.class);
     // order.add(Expression.eq("id", "1000019"));
     for (final Order o : order.list()) {
-      System.out.println("Order: " + o.toString());
+      log.debug("Order: " + o.toString());
       for (final OrderLine l : o.getOrderLineList()) {
-        System.out.println("Line: " + l.toString());
+        log.debug("Line: " + l.toString());
       }
-      System.out.println("-----");
+      log.debug("-----");
     }
-    setErrorOccured(false);
   }
 
   public void testDeleteChild() {
 
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBCriteria<Order> orders = OBDal.getInstance().createCriteria(Order.class);
     orders.add(Expression.eq(Order.PROPERTY_DOCUMENTSTATUS, "DR")); // Draft
     // document
 
     for (final Order o : orders.list()) {
-      System.out.println("Order: " + o.get(Order.PROPERTY_DOCUMENTNO) + " - no. lines: "
+      log.debug("Order: " + o.get(Order.PROPERTY_DOCUMENTNO) + " - no. lines: "
           + o.getOrderLineList().size());
 
       if (o.getOrderLineList().size() > 0) {
         final OrderLine l = o.getOrderLineList().get(0);
         lineId = l.getId();
-        System.out.println("OrderLine to remove: " + l.toString());
+        log.debug("OrderLine to remove: " + l.toString());
         o.getOrderLineList().remove(l); // or
         // OBDal.getInstance().remove(
         // l);
       }
     }
 
-    setErrorOccured(false);
   }
 
   public void testConfirmDeleted() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
 
     final OBCriteria<OrderLine> lines = OBDal.getInstance().createCriteria(OrderLine.class);
     lines.add(Expression.eq(OrderLine.PROPERTY_ID, lineId));
 
     assertEquals(0, lines.list().size());
 
-    setErrorOccured(false);
   }
 
   public void testAddChild() throws Exception {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final OBCriteria<BusinessPartner> bpartners = OBDal.getInstance().createCriteria(
         BusinessPartner.class);
     bpartners.add(Expression.eq(BusinessPartner.PROPERTY_SEARCHKEY, "mafalda"));
@@ -114,6 +110,5 @@
       assertEquals(count + 1, partner.getADUserList().size());
     } else
       throw new Exception("malfalda not found in business partners list");
-    setErrorOccured(false);
   }
 }
--- a/src-test/org/openbravo/test/model/RuntimeModelTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/model/RuntimeModelTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,6 +22,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.model.Column;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
@@ -31,12 +32,15 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
+ * Tests the in-memory runtime model.
  * 
  * @author iperdomo
  */
 
 public class RuntimeModelTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(RuntimeModelTest.class);
+
   // don't initialize dal layer for model tests
   @Override
   protected void setUp() throws Exception {
@@ -46,10 +50,9 @@
 
   public void testDumpModel() {
     for (Entity e : ModelProvider.getInstance().getModel()) {
-      System.err.println(">>>>>>>>>>>>>> " + e.getName() + " (" + e.getTableName()
-          + ") <<<<<<<<<<<<<<<<<");
+      log.debug(">>>>>>>>>>>>>> " + e.getName() + " (" + e.getTableName() + ") <<<<<<<<<<<<<<<<<");
       for (Property p : e.getProperties()) {
-        System.err.println(p.getName() + " (" + p.getColumnName() + ")");
+        log.debug(p.getName() + " (" + p.getColumnName() + ")");
       }
     }
   }
@@ -57,14 +60,14 @@
   public void testPK() {
     final ArrayList<Table> tablesWithoutPK = new ArrayList<Table>();
     for (final Table t : ModelProvider.getInstance().getTables()) {
-      if (t.getPrimaryKeyColumns().size() == 0) {
+      if (!t.isView() && t.getPrimaryKeyColumns().size() == 0) {
         tablesWithoutPK.add(t);
       }
     }
     if (tablesWithoutPK.size() != 0) {
-      System.err.println("Tables without primary keys defined:");
+      log.debug("Tables without primary keys defined:");
       for (final Table t2 : tablesWithoutPK) {
-        System.err.println(t2);
+        log.debug(t2);
       }
     }
     assertEquals(0, tablesWithoutPK.size());
@@ -72,10 +75,10 @@
 
   public void testModelProvider() {
     for (final Entity e : ModelProvider.getInstance().getModel()) {
-      System.out.println("tablename: " + e.getTableName() + " -- classname: " + e.getClassName()
+      log.debug("tablename: " + e.getTableName() + " -- classname: " + e.getClassName()
           + " -- mappingname: " + e.getName());
       for (final Property p : e.getProperties())
-        System.out.println("property: " + p.getColumnName() + " -- mapping: " + p.getName());
+        log.debug("property: " + p.getColumnName() + " -- mapping: " + p.getName());
     }
     assertNotNull(ModelProvider.getInstance().getModel());
   }
@@ -85,7 +88,7 @@
     boolean duplicated = false;
     for (final Entity e : ModelProvider.getInstance().getModel()) {
       if (mappings.contains(e.getName())) {
-        System.err.println("Duplicated table mapping name: " + e.getName());
+        log.debug("Duplicated table mapping name: " + e.getName());
         duplicated = true;
         break;
       }
@@ -100,7 +103,7 @@
       final List<String> propMappings = new ArrayList<String>();
       for (final Property p : e.getProperties()) {
         if (!p.isOneToMany() && propMappings.contains(p.getName())) {
-          System.err.println("Duplicated column mapping name: " + p.getName() + " -- column: "
+          log.debug("Duplicated column mapping name: " + p.getName() + " -- column: "
               + p.getColumnName() + " -- table: " + e.getTableName());
           duplicated = true;
         }
@@ -114,24 +117,24 @@
     int total = 0;
     for (final Table t : ModelProvider.getInstance().getTables()) {
       if (!t.isView() && t.getPrimaryKeyColumns().size() > 1) {
-        System.out.println("Table: " + t.getId() + " - " + t.getTableName());
-        System.out.print("  Columns : ");
+        log.debug("Table: " + t.getId() + " - " + t.getTableName());
+        log.debug("  Columns : ");
         for (final Column c : t.getColumns())
-          System.out.print(c.getColumnName() + ", ");
-        System.out.print("\n");
-        System.out.print("    Keys: ");
+          log.debug(c.getColumnName() + ", ");
+        log.debug("\n");
+        log.debug("    Keys: ");
         for (final Column c : t.getPrimaryKeyColumns())
-          System.out.print(c.getColumnName() + ", ");
-        System.out.print("\n");
-        System.out.print("    Identifiers: ");
+          log.debug(c.getColumnName() + ", ");
+        log.debug("\n");
+        log.debug("    Identifiers: ");
         for (final Column c : t.getIdentifierColumns())
-          System.out.print(c.getColumnName() + ", ");
-        System.out.print("\n");
+          log.debug(c.getColumnName() + ", ");
+        log.debug("\n");
         total++;
       }
     }
     if (total != 0)
-      System.err.println(total + " tables with more than one primary key");
+      log.debug(total + " tables with more than one primary key");
     assertEquals(0, total);
   }
 
@@ -142,9 +145,9 @@
         tables.add(t.getTableName());
     }
     if (tables.size() != 0) {
-      System.err.println(tables.size() + " tables without Identifier columns");
+      log.debug(tables.size() + " tables without Identifier columns");
       for (final String tableName : tables)
-        System.err.println(tableName);
+        log.debug(tableName);
     }
     // assertEquals(0, tables.size());
   }
@@ -164,7 +167,7 @@
     }
 
     if (columns.size() != 0) {
-      System.err.println(columns.size() + " columns set as *isParent* errors (wrong reference): "
+      log.debug(columns.size() + " columns set as *isParent* errors (wrong reference): "
           + columns.toString());
     }
     assertEquals(0, columns.size());
@@ -182,7 +185,7 @@
     }
 
     if (columns.size() != 0)
-      System.err.println(columns.size() + " columns set as *isParent* and are *primitive type*: "
+      log.debug(columns.size() + " columns set as *isParent* and are *primitive type*: "
           + columns.toString());
     assertEquals(0, columns.size());
   }
@@ -199,7 +202,7 @@
     }
 
     if (columns.size() != 0)
-      System.err.println(columns.size()
+      log.debug(columns.size()
           + " columns set as *isParent* with reference *TABLE* and don't have table defined : "
           + columns.toString());
     assertEquals(0, columns.size());
--- a/src-test/org/openbravo/test/model/UniqueConstraintTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/model/UniqueConstraintTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,13 +21,13 @@
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
 import org.openbravo.base.model.UniqueConstraint;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.dal.core.DalUtil;
-import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.geography.Country;
 import org.openbravo.test.base.BaseTest;
@@ -40,6 +40,8 @@
 
 public class UniqueConstraintTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(UniqueConstraintTest.class);
+
   public void testUniqueConstraintLoad() {
     final Entity entity = ModelProvider.getInstance().getEntityByTableName("C_Country_Trl");
     assertEquals(1, entity.getUniqueConstraints().size());
@@ -48,7 +50,7 @@
 
   public void testUniqueConstraintQuerying() {
     setUserContext("1000001");
-    OBContext.getOBContext().setInAdministratorMode(true);
+    addReadWriteAccess(Country.class);
     final List<Country> countries = OBDal.getInstance().createCriteria(Country.class).list();
     assertTrue(countries.size() > 0);
     for (final Country c : countries) {
@@ -66,13 +68,13 @@
     for (final Entity e : ModelProvider.getInstance().getModel()) {
       if (e.getUniqueConstraints().size() > 0) {
         for (final UniqueConstraint uc : e.getUniqueConstraints()) {
-          System.err.println(">>> Entity " + e);
-          System.err.println("UniqueConstraint " + uc.getName());
+          log.debug(">>> Entity " + e);
+          log.debug("UniqueConstraint " + uc.getName());
           for (final Property p : uc.getProperties()) {
-            System.err.print(p.getName() + " ");
+            log.debug(p.getName() + " ");
           }
         }
-        System.err.println("");
+        log.debug("");
       }
     }
   }
--- a/src-test/org/openbravo/test/modularity/DBPrefixTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/modularity/DBPrefixTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -48,7 +48,6 @@
     module.setDescription("Testing dbprefixes");
     module.setInDevelopment(true);
     OBDal.getInstance().save(module);
-    commitTransaction();
   }
 
   /**
@@ -105,7 +104,6 @@
       System.out.println("Removing module: " + mod.getName());
       OBDal.getInstance().remove(mod);
     }
-    commitTransaction();
   }
 
   // Obtains the module iserted for testing purposes
@@ -136,13 +134,12 @@
       OBDal.getInstance().commitAndClose();
     } catch (org.hibernate.exception.GenericJDBCException e) {
       exception = true;
+      OBDal.getInstance().rollbackAndClose();
     }
 
     if (isValid)
       assertFalse("Not inserted a valid prefix:" + name, exception);
     else
       assertTrue("Inserted a non-valid prefix:" + name, exception);
-
-    commitTransaction();
   }
 }
--- a/src-test/org/openbravo/test/modularity/DatasetServiceTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/modularity/DatasetServiceTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.model.Property;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
@@ -38,15 +39,16 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Tests the Dataset Service Object
+ * Tests the Dataset Service Object, queries, expressions etc.
  * 
  * @author mtaal
  */
 
 public class DatasetServiceTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(DatasetServiceTest.class);
+
   public void testCheckQueries() {
-    setErrorOccured(true);
     setUserContext("100");
 
     Map<String, Object> parameters = new HashMap<String, Object>();
@@ -61,15 +63,13 @@
           // just test but do nothing with return value
           DataSetService.getInstance().getExportableObjects(dt, "0", parameters);
         } catch (final Exception e) {
-          System.err.println(ds.getName() + ": " + dt.getEntityName() + ": " + e.getMessage());
+          log.debug(ds.getName() + ": " + dt.getEntityName() + ": " + e.getMessage());
         }
       }
     }
-    setErrorOccured(false);
   }
 
   public void testExportAllDataSets() {
-    setErrorOccured(true);
     setUserContext("100");
     final OBCriteria<DataSet> obc = OBDal.getInstance().createCriteria(DataSet.class);
     final List<DataSet> dss = obc.list();
@@ -80,14 +80,12 @@
 
     for (final DataSet ds : dss) {
       final String xml = DataExportService.getInstance().exportDataSetToXML(ds, "0", parameters);
-      System.err.println(xml);
+      log.debug(xml);
     }
-    setErrorOccured(false);
   }
 
   // test whereclause
   public void testDataSetTable() {
-    setErrorOccured(true);
     setUserContext("100");
     final DataSetTable dst = OBProvider.getInstance().get(DataSetTable.class);
     final Table t = OBProvider.getInstance().get(Table.class);
@@ -97,13 +95,11 @@
         + "='N') and client.id='0'");
     final List<BaseOBObject> l = DataSetService.getInstance().getExportableObjects(dst, "0");
     for (final BaseOBObject bob : l) {
-      System.err.println(bob.getIdentifier());
+      log.debug(bob.getIdentifier());
     }
-    setErrorOccured(false);
   }
 
   public void testReadAll() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
 
     Map<String, Object> parameters = new HashMap<String, Object>();
@@ -113,11 +109,11 @@
     final OBCriteria<DataSet> obc = OBDal.getInstance().createCriteria(DataSet.class);
     final List<DataSet> ds = obc.list();
     for (final DataSet d : ds) {
-      System.err.println("Exporting DataSet: " + d.getName());
-      System.err.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+      log.debug("Exporting DataSet: " + d.getName());
+      log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
       final List<DataSetTable> dts = d.getDataSetTableList();
       for (final DataSetTable dt : dts) {
-        System.err.println("Exporting DataSetTable: " + dt.getTable().getName());
+        log.debug("Exporting DataSetTable: " + dt.getTable().getName());
         final List<DataSetColumn> dcs = dt.getDataSetColumnList();
 
         final List<BaseOBObject> bobs = dss.getExportableObjects(dt, "0", parameters);
@@ -134,12 +130,11 @@
           // } else {
           // sb.append(value);
           // }
-          // System.err.println(sb.toString());
+          // log.debug(sb.toString());
           // }
         }
       }
     }
-    setErrorOccured(false);
   }
 
   public void psuedoCode() {
@@ -170,6 +165,6 @@
   }
 
   public void exportProperty(Property p, Object value) {
-    System.err.println(p + ": " + value);
+    log.debug(p + ": " + value);
   }
 }
--- a/src-test/org/openbravo/test/security/AccessLevelTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/security/AccessLevelTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -20,18 +20,19 @@
 package org.openbravo.test.security;
 
 import org.openbravo.base.exception.OBSecurityException;
+import org.openbravo.base.validation.AccessLevelChecker;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.geography.Country;
 import org.openbravo.model.financialmgmt.cashmgmt.CashJournal;
-import org.openbravo.model.financialmgmt.tax.TaxRate;
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Tests check of the accesslevel of an entity
+ * Tests/checks the accesslevel of an entity. See the {@link AccessLevelChecker}.
  * 
  * @author mtaal
  */
@@ -39,7 +40,6 @@
 public class AccessLevelTest extends BaseTest {
 
   public void testAccessLevelCO() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final Client c = OBDal.getInstance().get(Client.class, "0");
 
@@ -53,11 +53,9 @@
       assertTrue(e.getMessage().indexOf("may not have instances with client 0") != -1);
       SessionHandler.getInstance().rollback();
     }
-    setErrorOccured(false);
   }
 
   public void testAccessLevelSystem() {
-    setErrorOccured(true);
     setUserContext("0");
     final Organization o = OBDal.getInstance().get(Organization.class, "1000002");
     final Table t = OBDal.getInstance().get(Table.class, "100");
@@ -72,11 +70,9 @@
           " may only have instances with organization *") != -1);
       SessionHandler.getInstance().rollback();
     }
-    setErrorOccured(false);
   }
 
   public void testAccessLevelOrganization() {
-    setErrorOccured(true);
     setUserContext("0");
     final Organization o = OBDal.getInstance().get(Organization.class, "0");
     final CashJournal c = OBDal.getInstance().get(CashJournal.class, "1000000");
@@ -91,26 +87,23 @@
           " may not have instances with organization *") != -1);
       SessionHandler.getInstance().rollback();
     }
-    setErrorOccured(false);
   }
 
   public void testAccessLevelSC() {
-    setErrorOccured(true);
     setUserContext("0");
     final Organization o = OBDal.getInstance().get(Organization.class, "1000001");
-    final TaxRate t = OBDal.getInstance().get(TaxRate.class, "1000000");
-    t.setOrganization(o);
+    final Country c = OBDal.getInstance().get(Country.class, "100");
+    c.setOrganization(o);
 
     try {
       SessionHandler.getInstance().commitAndClose();
-      fail();
+      fail("The organization of a system client may not be set to a non-zero org.");
     } catch (final OBSecurityException e) {
       // no fail!
       assertTrue("Invalid exception " + e.getMessage(), e.getMessage().indexOf(
           "may only have instances with organization *") != -1);
       SessionHandler.getInstance().rollback();
     }
-    setErrorOccured(false);
   }
 
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/security/AllowedOrganizationsTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/security/AllowedOrganizationsTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -39,7 +39,6 @@
 public class AllowedOrganizationsTest extends BaseTest {
 
   public void testOrganizationTree() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final OrganizationStructureProvider osp = new OrganizationStructureProvider();
     osp.setClientId("1000000");
@@ -55,7 +54,6 @@
     checkResult("1000007", osp, new String[] { "1000000", "0", "1000005", "1000007" });
     checkResult("1000008", osp, new String[] { "1000000", "1000006", "0", "1000008", "1000005" });
     checkResult("1000009", osp, new String[] { "1000009", "1000006", "0", "1000000", "1000005" });
-    setErrorOccured(false);
   }
 
   private void checkResult(String id, OrganizationStructureProvider osp, String[] values) {
@@ -66,16 +64,7 @@
     }
   }
 
-  public void testProjectUpdate() {
-    setErrorOccured(true);
-    setUserContext("1000001");
-    final Project p = OBDal.getInstance().get(Project.class, "1000001");
-    p.setName(p.getName() + "A");
-    setErrorOccured(false);
-  }
-
   public void testOrganizationCheck() {
-    setErrorOccured(true);
     setUserContext("0");
     OBContext.getOBContext().getOrganizationStructureProvider().reInitialize();
 
@@ -94,6 +83,5 @@
       // no fail!
       SessionHandler.getInstance().rollback();
     }
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/security/EntityAccessTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/security/EntityAccessTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.exception.OBSecurityException;
 import org.openbravo.base.provider.OBProvider;
@@ -38,8 +39,9 @@
 
 public class EntityAccessTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(EntityAccessTest.class);
+
   public void testCreateCurrency() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
     obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "TE2"));
@@ -54,14 +56,11 @@
       c.setCostingPrecision((long) 4);
       OBDal.getInstance().save(c);
     }
-    setErrorOccured(false);
   }
 
   // query for the currency again and remove it
   public void testNonDeletable() {
-    setErrorOccured(true);
-    setBigBazaarAdminContext();
-    setUserContext("1000002");
+    setUserContext("1000000");
     final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
     obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "TE2"));
     final List<Currency> cs = obc.list();
@@ -69,43 +68,34 @@
     final Currency c = cs.get(0);
     try {
       OBDal.getInstance().remove(c);
+      OBDal.getInstance().flush();
       fail("Currency should be non-deletable");
     } catch (final OBSecurityException e) {
       assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
           "is not deletable") != -1);
     }
-    setErrorOccured(false);
   }
 
-  // check if the currency was removed
   public void testCheckDerivedReadableCurrency() {
-    setErrorOccured(true);
-    final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
-    obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "TE2"));
-    final List<Currency> cs = obc.list();
-    final Currency c = cs.get(0);
-    System.err.println(c.getIdentifier());
-    System.err.println(c.getId());
+    setUserContext("1000020");
+    final Currency c = OBDal.getInstance().get(Currency.class, "100");
+    log.debug(c.getIdentifier());
+    log.debug(c.getId());
     try {
-      System.err.println(c.getSymbol());
+      log.debug(c.getCostingPrecision());
       fail("Derived readable not applied");
     } catch (final OBSecurityException e) {
       assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
           "is not directly readable") != -1);
     }
-    setErrorOccured(false);
   }
 
   // test derived readable on a set method and test save action
   public void testUpdateCurrencyDerivedRead() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
-    obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
-    final List<Currency> cs = obc.list();
-    final Currency c = cs.get(0);
+    setUserContext("1000020");
+    final Currency c = OBDal.getInstance().get(Currency.class, "100");
     try {
-      System.err.println(c.getDescription());
+      c.setCostingPrecision((long) 5);
       fail("Derived readable not checked on set");
     } catch (final OBSecurityException e) {
       assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
@@ -119,12 +109,10 @@
       assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
           "is not writable by this user") != -1);
     }
-    setErrorOccured(false);
   }
 
   // test non readable
   public void testNonReadable() {
-    setErrorOccured(true);
     setUserContext("1000002");
     try {
       final OBCriteria<Costing> obc = OBDal.getInstance().createCriteria(Costing.class);
@@ -139,7 +127,6 @@
   }
 
   public void testUpdateCurrencySucces() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
     obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
@@ -147,6 +134,5 @@
     final Currency c = cs.get(0);
     c.setDescription(" a test");
     OBDal.getInstance().save(c);
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/security/WritableReadableOrganizationClientTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -0,0 +1,126 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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.html 
+ * 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) 2008 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.security;
+
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.criterion.Expression;
+import org.openbravo.base.exception.OBSecurityException;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.core.SessionHandler;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.Category;
+import org.openbravo.model.materialmgmt.cost.Costing;
+import org.openbravo.test.base.BaseTest;
+
+/**
+ * Tests check of writable organization and allowed client.
+ * 
+ * @author mtaal
+ */
+
+public class WritableReadableOrganizationClientTest extends BaseTest {
+
+  public void testAccessLevelCO() {
+    setUserContext("0");
+    doCheckUser();
+    setBigBazaarUserContext();
+    doCheckUser();
+  }
+
+  private void doCheckUser() {
+    final OBContext obContext = OBContext.getOBContext();
+    final Set<String> writOrgs = obContext.getWritableOrganizations();
+    final String[] readOrgs = obContext.getReadableOrganizations();
+    final StringBuilder sb = new StringBuilder();
+    for (final String s : readOrgs) {
+      sb.append("," + s);
+    }
+
+    for (final String wo : writOrgs) {
+      boolean found = false;
+      for (final String s : readOrgs) {
+        found = s.equals(wo);
+        if (found) {
+          break;
+        }
+      }
+      assertTrue("Org " + wo + " not present in readableOrglist " + sb.toString(), found);
+    }
+  }
+
+  public void testClient() {
+    final OBContext obContext = OBContext.getOBContext();
+    final String[] cs = obContext.getReadableClients();
+    final String cid = obContext.getCurrentClient().getId();
+    boolean found = false;
+    final StringBuilder sb = new StringBuilder();
+    for (final String s : cs) {
+      sb.append("," + s);
+    }
+    for (final String s : cs) {
+      found = s.equals(cid);
+      if (found) {
+        break;
+      }
+    }
+    assertTrue("Current client " + cid + " not found in clienttlist " + sb.toString(), found);
+  }
+
+  public void testUpdateNotAllowed() {
+    setUserContext("1000000");
+    final OBCriteria<Costing> obc = OBDal.getInstance().createCriteria(Costing.class);
+    obc.add(Expression.eq("id", "1000078"));
+    final List<Costing> cs = obc.list();
+    assertEquals(1, cs.size());
+    final Costing c = cs.get(0);
+    c.setCost(c.getCost() + 1);
+
+    // switch usercontext to force exception
+    setUserContext("1000002");
+    try {
+      SessionHandler.getInstance().commitAndClose();
+      fail("Writable organizations not checked");
+    } catch (final OBSecurityException e) {
+      assertTrue("Invalid exception " + e.getMessage(), e.getMessage().indexOf(
+          " is not writable by this user") != -1);
+    }
+  }
+
+  public void testCheckInvalidClient() {
+    setUserContext("1000000");
+    final OBCriteria<Category> obc = OBDal.getInstance().createCriteria(Category.class);
+    obc.add(Expression.eq("name", "Standard"));
+    final List<Category> bogs = obc.list();
+    assertEquals(1, bogs.size());
+    final Category bp = bogs.get(0);
+    bp.setDescription(bp.getDescription() + "A");
+    // switch usercontext to force exception
+    setUserContext("1000019");
+    try {
+      SessionHandler.getInstance().commitAndClose();
+    } catch (final OBSecurityException e) {
+      assertTrue("Invalid exception " + e.getMessage(), e.getMessage().indexOf(
+          "is not present in ClientList") != -1);
+    }
+  }
+}
\ No newline at end of file
--- a/src-test/org/openbravo/test/security/WritableReadableOrganizationTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (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.html 
- * 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) 2008 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.test.security;
-
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.criterion.Expression;
-import org.openbravo.base.exception.OBSecurityException;
-import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.core.SessionHandler;
-import org.openbravo.dal.service.OBCriteria;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.model.common.businesspartner.Category;
-import org.openbravo.model.materialmgmt.cost.Costing;
-import org.openbravo.test.base.BaseTest;
-
-/**
- * Tests check of the accesslevel of an entity
- * 
- * @author mtaal
- */
-
-public class WritableReadableOrganizationTest extends BaseTest {
-
-  public void testAccessLevelCO() {
-    setErrorOccured(true);
-    setUserContext("0");
-    doCheckUser();
-    setBigBazaarUserContext();
-    doCheckUser();
-    setErrorOccured(false);
-  }
-
-  private void doCheckUser() {
-    final OBContext obContext = OBContext.getOBContext();
-    final Set<String> writOrgs = obContext.getWritableOrganizations();
-    final String[] readOrgs = obContext.getReadableOrganizations();
-    final StringBuilder sb = new StringBuilder();
-    for (final String s : readOrgs) {
-      sb.append("," + s);
-    }
-
-    for (final String wo : writOrgs) {
-      boolean found = false;
-      for (final String s : readOrgs) {
-        found = s.equals(wo);
-        if (found) {
-          break;
-        }
-      }
-      assertTrue("Org " + wo + " not present in readableOrglist " + sb.toString(), found);
-    }
-  }
-
-  public void testClient() {
-    setErrorOccured(true);
-    final OBContext obContext = OBContext.getOBContext();
-    final String[] cs = obContext.getReadableClients();
-    final String cid = obContext.getCurrentClient().getId();
-    boolean found = false;
-    final StringBuilder sb = new StringBuilder();
-    for (final String s : cs) {
-      sb.append("," + s);
-    }
-    for (final String s : cs) {
-      found = s.equals(cid);
-      if (found) {
-        break;
-      }
-    }
-    assertTrue("Current client " + cid + " not found in clienttlist " + sb.toString(), found);
-    setErrorOccured(false);
-  }
-
-  public void testUpdateCosting() {
-    setErrorOccured(true);
-    setUserContext("1000001");
-    final OBCriteria<Costing> obc = OBDal.getInstance().createCriteria(Costing.class);
-    obc.add(Expression.eq("id", "1000078"));
-    final List<Costing> cs = obc.list();
-    assertEquals(1, cs.size());
-    final Costing c = cs.get(0);
-    c.setCost(c.getCost() + 1);
-
-    // switch usercontext to force eexception
-    setUserContext("1000002");
-    try {
-      SessionHandler.getInstance().commitAndClose();
-      fail("Writable organizations not checked");
-    } catch (final OBSecurityException e) {
-      e.printStackTrace(System.err);
-      assertTrue("Invalid exception " + e.getMessage(), e.getMessage().indexOf(
-          " is not writable by this user") != -1);
-    }
-    setErrorOccured(false);
-  }
-
-  public void testUpdateBPGroup() {
-    setErrorOccured(true);
-    setUserContext("1000001");
-    final OBCriteria<Category> obc = OBDal.getInstance().createCriteria(Category.class);
-    obc.add(Expression.eq("name", "Standard"));
-    final List<Category> bogs = obc.list();
-    assertEquals(1, bogs.size());
-    final Category bp = bogs.get(0);
-    bp.setDescription(bp.getDescription() + "A");
-    try {
-      SessionHandler.getInstance().commitAndClose();
-    } catch (final OBSecurityException e) {
-      assertTrue("Invalid exception " + e.getMessage(), e.getMessage().indexOf(
-          "is not present  in OrganizationList") != -1);
-    }
-
-    setErrorOccured(false);
-  }
-}
\ No newline at end of file
--- a/src-test/org/openbravo/test/system/SystemServiceTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/system/SystemServiceTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -32,7 +32,7 @@
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test the System Service class.
+ * Test the {@link SystemService} class.
  * 
  * @author mtaal
  */
@@ -40,7 +40,6 @@
 public class SystemServiceTest extends BaseTest {
 
   public void testChangedDataSet() {
-    setErrorOccured(true);
     setUserContext("0");
     final List<DataSet> dss = OBDal.getInstance().createCriteria(DataSet.class).list();
     final Date now = new Date(System.currentTimeMillis());
@@ -53,11 +52,9 @@
     for (DataSet ds : dss) {
       assertTrue(DataSetService.getInstance().hasChanged(ds, past));
     }
-    setErrorOccured(false);
   }
 
   public void testChangedClasses() {
-    setErrorOccured(true);
     setUserContext("0");
     final Class<?>[] clzs = new Class<?>[] { Table.class, Column.class, Reference.class };
 
@@ -67,6 +64,5 @@
     // 600 days in the past
     final Date past = new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 600));
     assertTrue(SystemService.getInstance().hasChanged(clzs, past));
-    setErrorOccured(false);
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/system/SystemValidatorTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/system/SystemValidatorTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,53 +22,56 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
 import org.openbravo.service.system.ApplicationDictionaryValidator;
+import org.openbravo.service.system.DatabaseValidator;
 import org.openbravo.service.system.ModuleValidator;
 import org.openbravo.service.system.SystemValidationResult;
 import org.openbravo.service.system.SystemValidationResult.SystemValidationType;
 import org.openbravo.test.base.BaseTest;
 
 /**
- * Test the System Validation.
+ * Tests System Validation.
+ * 
+ * @see DatabaseValidator
+ * @see ModuleValidator
  * 
  * @author mtaal
  */
 
 public class SystemValidatorTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(SystemValidatorTest.class);
+
   public void _testSystemValidation() {
-    setErrorOccured(true);
     setUserContext("0");
     final ApplicationDictionaryValidator adValidator = new ApplicationDictionaryValidator();
     final Map<String, SystemValidationResult> results = adValidator.validate();
 
     for (String key : results.keySet()) {
-      System.err.println("++++++++++++++++++++++++++++++++++++++++++++++++++");
-      System.err.println(key);
-      System.err.println("++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.debug("++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.debug(key);
+      log.debug("++++++++++++++++++++++++++++++++++++++++++++++++++");
       final SystemValidationResult result = results.get(key);
       printResult(result);
     }
-    setErrorOccured(false);
   }
 
   public void testModulesValidation() {
-    setErrorOccured(true);
     setUserContext("0");
     final ModuleValidator moduleValidator = new ModuleValidator();
     final SystemValidationResult result = moduleValidator.validate();
     printResult(result);
-    setErrorOccured(false);
   }
 
   private void printResult(SystemValidationResult result) {
     for (SystemValidationType validationType : result.getWarnings().keySet()) {
-      System.err.println("\n+++++++++++++++++++++++++++++++++++++++++++++++++++");
-      System.err.println("Warnings for Validation type: " + validationType);
-      System.err.println("\n+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.debug("\n+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.debug("Warnings for Validation type: " + validationType);
+      log.debug("\n+++++++++++++++++++++++++++++++++++++++++++++++++++");
       final List<String> warnings = result.getWarnings().get(validationType);
       for (String warning : warnings) {
-        System.err.println(warning);
+        log.debug(warning);
       }
     }
 
@@ -84,8 +87,11 @@
           sb.append("\n");
         }
       }
+      if (errors.size() > 0) {
+        fail(sb.toString());
+      }
     }
-    System.err.println(sb.toString());
+    log.debug(sb.toString());
   }
 
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/webservice/BaseWSTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/webservice/BaseWSTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -26,6 +26,7 @@
 import java.net.PasswordAuthentication;
 import java.net.URL;
 
+import org.apache.log4j.Logger;
 import org.dom4j.Document;
 import org.dom4j.io.SAXReader;
 import org.openbravo.base.exception.OBException;
@@ -40,17 +41,17 @@
 
 public class BaseWSTest extends BaseTest {
 
+  private static final Logger log = Logger.getLogger(BaseWSTest.class);
+
   private static final String OB_URL = "http://localhost:8080/openbravo";
   private static final String LOGIN = "Openbravo";
   private static final String PWD = "openbravo";
 
   protected void doDirectDeleteRequest(String wsPart, int expectedResponse) {
     try {
-      setErrorOccured(true);
       final HttpURLConnection hc = createConnection(wsPart, "DELETE");
       hc.connect();
       assertEquals(expectedResponse, hc.getResponseCode());
-      setErrorOccured(false);
     } catch (final Exception e) {
       throw new OBException(e);
     }
@@ -59,7 +60,6 @@
   protected String doContentRequest(String wsPart, String content, int expectedResponse,
       String expectedContent, String method) {
     try {
-      setErrorOccured(true);
       final HttpURLConnection hc = createConnection(wsPart, method);
       final OutputStream os = hc.getOutputStream();
       os.write(content.getBytes("UTF-8"));
@@ -78,10 +78,9 @@
       final Document doc = sr.read(is);
       final String retContent = XMLUtil.getInstance().toString(doc);
       if (retContent.indexOf(expectedContent) == -1) {
-        System.err.println(retContent);
+        log.debug(retContent);
         fail();
       }
-      setErrorOccured(false);
       return retContent;
     } catch (final Exception e) {
       throw new OBException(e);
@@ -102,7 +101,6 @@
 
   protected String doTestGetRequest(String wsPart, String testContent, int responseCode) {
     try {
-      setErrorOccured(true);
       final HttpURLConnection hc = createConnection(wsPart, "GET");
       hc.connect();
       final SAXReader sr = new SAXReader();
@@ -110,12 +108,11 @@
       final Document doc = sr.read(is);
       final String content = XMLUtil.getInstance().toString(doc);
       if (testContent != null && content.indexOf(testContent) == -1) {
-        System.err.println(content);
+        log.debug(content);
         fail();
       }
       assertEquals(responseCode, hc.getResponseCode());
       is.close();
-      setErrorOccured(false);
       return content;
     } catch (final Exception e) {
       throw new OBException(e);
@@ -129,7 +126,7 @@
         return new PasswordAuthentication(LOGIN, PWD.toCharArray());
       }
     });
-    System.err.println(method + ": " + OB_URL + wsPart);
+    log.debug(method + ": " + OB_URL + wsPart);
     final URL url = new URL(OB_URL + wsPart);
     final HttpURLConnection hc = (HttpURLConnection) url.openConnection();
     hc.setRequestMethod(method);
--- a/src-test/org/openbravo/test/webservice/WSReadTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/webservice/WSReadTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -82,7 +82,6 @@
   }
 
   public void testAllToXML() {
-    setErrorOccured(true);
     setBigBazaarAdminContext();
     final Configuration cfg = SessionFactoryController.getInstance().getConfiguration();
 
@@ -91,7 +90,6 @@
       final String entityName = pc.getEntityName();
       doTestGetRequest("/ws/dal/" + entityName, "<ob:Openbravo", 200);
     }
-    setErrorOccured(false);
   }
 
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/webservice/WSUpdateTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/webservice/WSUpdateTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,6 +21,7 @@
 
 import java.io.FileNotFoundException;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
@@ -37,6 +38,8 @@
 
 public class WSUpdateTest extends BaseWSTest {
 
+  private static final Logger log = Logger.getLogger(WSUpdateTest.class);
+
   private static String cityId = null;
 
   // this test must be run before the others because it sets the cityId
@@ -64,7 +67,7 @@
 
   public void testReadUpdateCity() throws Exception {
     final String city = doTestGetRequest("/ws/dal/City/" + cityId, null, 200);
-    System.err.println(System.currentTimeMillis());
+    log.debug(System.currentTimeMillis());
     String newCity;
     if (city.indexOf("<coordinates>") != -1) { // test already run
       final int index1 = city.indexOf("<coordinates>");
@@ -82,8 +85,8 @@
 
   public void testIncorrectRootTag() throws Exception {
     final String city = doTestGetRequest("/ws/dal/City/" + cityId, null, 200);
-    System.err.println(city);
-    System.err.println("---");
+    log.debug(city);
+    log.debug("---");
     String newCity = city.replaceAll("ob:Openbravo", "ob:WrongOpenbravo");
     final String content = doContentRequest("/ws/dal/City/" + cityId, newCity, 500, "<updated>",
         "POST");
@@ -104,7 +107,7 @@
     newCity = newCity.substring(0, index) + "City id=\"test"
         + newCity.substring(index + "City id=\"test".length());
     final String content = doContentRequest("/ws/dal/City", newCity, 200, "<inserted>", "POST");
-    // System.err.println(content);
+    // log.debug(content);
     // get the id and check if it is there
     final int index1 = content.indexOf("City id=\"") + "City id=\"".length();
     final int index2 = content.indexOf("\"", index1);
--- a/src-test/org/openbravo/test/xml/ClientDataSetCompleteTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/ClientDataSetCompleteTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -25,6 +25,7 @@
 
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.exception.OBException;
+import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.utility.DataSet;
@@ -34,7 +35,10 @@
 /**
  * Tests if the client definition data set is complete.
  * 
+ * Class is based on an old structure of the Openbravo project, keeping it for reference.
+ * 
  * @author mtaal
+ * @deprecated
  */
 
 public class ClientDataSetCompleteTest extends XMLBaseTest {
@@ -47,8 +51,9 @@
       throw new OBException("No dataset found with name " + DataExportService.CLIENT_DATA_SET_NAME);
     }
     final DataSet dataSet = obc.list().get(0);
-    final File dir = new File(
-        "/home/mtaal/mydata/dev/workspaces/obtrunk/openbravo/src-db/database/sampledata");
+    final String sourcePath = (String) OBPropertiesProvider.getInstance().getOpenbravoProperties()
+        .get("source.path");
+    final File dir = new File(sourcePath + "/src-db/database/sampledata");
     final Set<String> names = new HashSet<String>();
     for (final File child : dir.listFiles()) {
       if (!child.isDirectory()) {
@@ -58,8 +63,12 @@
     for (final DataSetTable dst : dataSet.getDataSetTableList()) {
       names.remove(dst.getTable().getDBTableName().toUpperCase() + ".xml");
     }
+    final StringBuilder sb = new StringBuilder();
     for (final String name : names) {
-      System.err.println(name);
+      sb.append(" " + name);
+    }
+    if (names.size() > 0) {
+      fail("Not all sample data files are present in the client data set: " + sb.toString());
     }
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/ClientExportImportTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/ClientExportImportTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -45,7 +45,6 @@
 public class ClientExportImportTest extends XMLBaseTest {
 
   public void _testImportReferenceData() throws Exception {
-    setErrorOccured(true);
     setUserContext("0");
 
     final String sourcePath = OBPropertiesProvider.getInstance().getOpenbravoProperties()
@@ -69,19 +68,17 @@
         }
       }
     }
-    setErrorOccured(true);
   }
 
-  public void _testExportImportClient1000000() {
+  public void testExportImportClient1000000() {
     exportImport("1000000");
   }
 
-  public void _testExportImportClient1000001() {
+  public void testExportImportClient1000001() {
     exportImport("1000001");
   }
 
   private void exportImport(String clientId) {
-    setErrorOccured(true);
     setUserContext("0");
     final Map<String, Object> parameters = new HashMap<String, Object>();
     parameters.put(DataExportService.CLIENT_ID_PARAMETER_NAME, clientId);
@@ -90,7 +87,13 @@
     DataExportService.getInstance().exportClientToXML(parameters, false, sw);
     String xml = sw.toString();
     try {
-      final File f = new File("/tmp/export.xml");
+      final String sourcePath = (String) OBPropertiesProvider.getInstance()
+          .getOpenbravoProperties().get("source.path");
+      final File dir = new File(sourcePath + File.separator + "temp");
+      if (!dir.exists()) {
+        dir.mkdir();
+      }
+      final File f = new File(dir, "export.xml");
       if (f.exists()) {
         f.delete();
       }
@@ -108,7 +111,6 @@
           false, new StringReader(xml));
       xml = null;
       if (ir.getException() != null) {
-        ir.getException().printStackTrace(System.err);
         throw new OBException(ir.getException());
       }
       if (ir.getErrorMessages() != null) {
@@ -125,17 +127,9 @@
           assertTrue(!ce.getClient().getId().equals("0"));
         }
       }
-
-      System.err.println(ir.getWarningMessages());
     } catch (final Exception e) {
-      e.printStackTrace(System.err);
       throw new OBException(e);
     }
-    setErrorOccured(false);
-  }
-
-  public void testImportBB() {
-    doImport("bb.xml");
   }
 
   public void _testImportAccountingTest() {
@@ -143,7 +137,6 @@
   }
 
   private void doImport(String fileName) {
-    setErrorOccured(true);
     setUserContext("0");
 
     final ClientImportProcessor importProcessor = new ClientImportProcessor();
@@ -156,20 +149,14 @@
       final ImportResult ir = DataImportService.getInstance().importClientData(importProcessor,
           false, new FileReader(f));
       if (ir.getException() != null) {
-        ir.getException().printStackTrace(System.err);
         throw new OBException(ir.getException());
       }
       if (ir.getErrorMessages() != null && ir.getErrorMessages().trim().length() > 0) {
-        System.err.println(ir.getErrorMessages());
         fail(ir.getErrorMessages());
       }
-
-      System.err.println(ir.getWarningMessages());
     } catch (final Exception e) {
-      e.printStackTrace(System.err);
       throw new OBException(e);
     }
-    setErrorOccured(false);
   }
 
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/ClientExportTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (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.html 
- * 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) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.test.xml;
-
-import java.io.FileWriter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.model.ad.system.Client;
-import org.openbravo.service.db.DataExportService;
-
-/**
- * Tests export and import of client dataset.
- * 
- * @author mtaal
- */
-
-public class ClientExportTest extends XMLBaseTest {
-  public void _testListClients() {
-    setErrorOccured(true);
-    setUserContext("0");
-    final List<Client> cls = OBDal.getInstance().createCriteria(Client.class).list();
-    for (Client c : cls) {
-      System.err.println(c.getId() + " " + c.getName());
-    }
-    setErrorOccured(false);
-  }
-
-  public void testExportClient() throws Exception {
-    setErrorOccured(true);
-    setUserContext("0");
-    DataExportService des = DataExportService.getInstance();
-    final Map<String, Object> params = new HashMap<String, Object>();
-    params.put(DataExportService.CLIENT_ID_PARAMETER_NAME, "1000000");
-    final FileWriter fw = new FileWriter("/tmp/bb.xml");
-    DataExportService.getInstance().exportClientToXML(params, false, fw);
-    fw.close();
-    setErrorOccured(false);
-  }
-
-}
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/EntityXMLExportTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (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.html 
- * 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) 2008 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.test.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.criterion.Expression;
-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.common.businesspartner.BusinessPartner;
-import org.openbravo.model.financialmgmt.tax.TaxCategory;
-import org.openbravo.model.financialmgmt.tax.TaxRate;
-
-/**
- * Tests export of entities to xml
- * 
- * TEST NEEDS TO BE REWORKED AS TEST DATA HAS CHANGED
- * 
- * @author mtaal
- */
-
-public class EntityXMLExportTest extends XMLBaseTest {
-  public void testExportTax() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<?> obc = OBDal.getInstance().createCriteria(TaxRate.class);
-
-    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
-    exc.setOptionIncludeChildren(true);
-    exc.setOptionIncludeReferenced(true);
-    exc.setAddSystemAttributes(false);
-
-    @SuppressWarnings("unchecked")
-    final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
-    final String xml = exc.toXML(list);
-    System.err.println(xml);
-  }
-
-  public void testExportTaxCategory() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<?> obc = OBDal.getInstance().createCriteria(TaxCategory.class);
-
-    obc.setFilterOnActive(false);
-    obc.setFilterOnReadableClients(false);
-    obc.setFilterOnReadableOrganization(false);
-
-    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
-    exc.setOptionIncludeChildren(true);
-    exc.setOptionIncludeReferenced(true);
-    exc.setAddSystemAttributes(false);
-
-    @SuppressWarnings("unchecked")
-    final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
-    final String xml = exc.toXML(list);
-    System.err.println(xml);
-  }
-
-  public void testXMLExport() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<BusinessPartner> obc = OBDal.getInstance().createCriteria(
-        BusinessPartner.class);
-    // a bit complexer expression, just to test that
-    obc.add(Expression.and(Expression.in("id", new String[] { "1000006", "1000007", "1000008",
-        "1000009" }), Expression
-        .and(Expression.ge("id", "1000006"), Expression.le("id", "1000009"))));
-    obc.addOrderBy("name", true);
-    final List<BusinessPartner> bps = obc.list();
-    assertEquals(4, bps.size());
-    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
-    exc.setOptionIncludeChildren(true);
-    exc.setOptionIncludeReferenced(true);
-    exc.setOptionEmbedChildren(true);
-    exc.setAddSystemAttributes(false);
-    final String xml = exc.toXML(new ArrayList<BaseOBObject>(bps));
-    compare(xml, "bp_list_1.xml");
-  }
-
-  public void testXMLExportIncludeReference() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<BusinessPartner> obc = OBDal.getInstance().createCriteria(
-        BusinessPartner.class);
-    obc.addOrderBy("name", true);
-    final List<BusinessPartner> bps = obc.list();
-    // only export the first three, otherwise it is to big..
-    bps.removeAll(new ArrayList<BusinessPartner>(bps.subList(3, bps.size())));
-    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
-    exc.setOptionIncludeReferenced(true);
-    exc.setAddSystemAttributes(false);
-    final String xml = exc.toXML(new ArrayList<BaseOBObject>(bps));
-    compare(xml, "bp_list_2.xml");
-  }
-
-  public void testXMLExportIncludeChildren() {
-    setErrorOccured(true);
-    setUserContext("1000000");
-    final OBCriteria<BusinessPartner> obc = OBDal.getInstance().createCriteria(
-        BusinessPartner.class);
-    obc.addOrderBy("name", true);
-    final List<BusinessPartner> bps = obc.list();
-    // only export the first three, otherwise it is to big..
-    bps.removeAll(new ArrayList<BusinessPartner>(bps.subList(3, bps.size())));
-    final EntityXMLConverter exc = EntityXMLConverter.newInstance();
-    exc.setOptionIncludeChildren(true);
-    exc.setAddSystemAttributes(false);
-    final String xml = exc.toXML(new ArrayList<BaseOBObject>(bps));
-    // System.err.println(xml);
-    compare(xml, "bp_list_3.xml");
-  }
-}
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/EntityXMLImportTestBusinessObject.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLImportTestBusinessObject.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,6 +22,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
@@ -34,6 +35,7 @@
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.PaymentTerm;
 import org.openbravo.model.financialmgmt.payment.PaymentTermLine;
+import org.openbravo.model.financialmgmt.payment.PaymentTermTrl;
 import org.openbravo.service.db.DataImportService;
 import org.openbravo.service.db.ImportResult;
 
@@ -45,6 +47,8 @@
 
 public class EntityXMLImportTestBusinessObject extends XMLBaseTest {
 
+  private static final Logger log = Logger.getLogger(EntityXMLImportTestBusinessObject.class);
+
   private static int NO_OF_PT = 1;
   private static int NO_OF_PT_LINE = 1 + NO_OF_PT * NO_OF_PT;
   // add NO_OF_PT twice because it was translated to one language
@@ -55,48 +59,49 @@
 
   public void testAPaymentTerm() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     createSavePaymentTerm();
-    setErrorOccured(false);
   }
 
   // export and create in client 100001
   public void testBPaymentTerm() {
-    setErrorOccured(true);
 
     // read from 1000000
-    setUserContext("1000001");
+    setUserContext("1000000");
+    setAccess();
+
     final List<PaymentTerm> pts = getPaymentTerms();
     String xml = getXML(pts);
 
-    System.err.println(xml);
+    log.debug(xml);
 
     // there is a unique constraint on name
     xml = xml.replaceAll("</name>", "t</name>");
 
     // export to client 1000001
     setUserContext("1000019");
+    // don't be bothered by access checks...
+    setAccess();
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     }
 
     assertEquals(TOTAL_PT_PTL, ir.getInsertedObjects().size());
     assertEquals(0, ir.getUpdatedObjects().size());
-
-    setErrorOccured(false);
   }
 
   // do the same thing again, no updates!
   public void testCPaymentTerm() {
-    setErrorOccured(true);
 
     // read from 1000000
-    setUserContext("1000001");
+    setUserContext("1000000");
+    setAccess();
     final List<PaymentTerm> pts = getPaymentTerms();
     String xml = getXML(pts);
 
@@ -105,6 +110,7 @@
 
     // export to client 1000001
     setUserContext("1000019");
+    setAccess();
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
@@ -115,16 +121,15 @@
 
     assertEquals(0, ir.getInsertedObjects().size());
     assertEquals(0, ir.getUpdatedObjects().size());
-
-    setErrorOccured(false);
   }
 
   // change a child so that it is updated and change a parent
   public void testDPaymentTerm() {
-    setErrorOccured(true);
 
     // read from 1000000
-    setUserContext("1000001");
+    setUserContext("1000000");
+    setAccess();
+
     // make a copy of the paymentterms and their children so that the
     // original db is not updated
     final List<BaseOBObject> pts = DalUtil.copyAll(new ArrayList<BaseOBObject>(getPaymentTerms()),
@@ -133,12 +138,13 @@
     // change some data and export
     final PaymentTerm pt = (PaymentTerm) pts.get(0);
     pt.setName("testtest");
-    pt.getFinancialMgmtPaymentTermLineList().get(0).setOverduePaymentDayRule("R");
+    pt.getFinancialMgmtPaymentTermLineList().get(0).setOverduePaymentDayRule("2");
 
     String xml = getXML(pts);
     xml = xml.replaceAll("</name>", "t</name>");
 
     setUserContext("1000019");
+    setAccess();
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
@@ -156,16 +162,14 @@
         assertTrue(ir.getUpdatedObjects().contains(ptl.getPaymentTerms()));
       }
     }
-
-    setErrorOccured(false);
   }
 
   // remove the first payment line of each payment term
   public void testEPaymentTerm() {
-    setErrorOccured(true);
 
     // read from 1000000
-    setUserContext("1000001");
+    setUserContext("1000000");
+    setAccess();
     // make a copy of the paymentterms and their children so that the
     // original db is not updated
     final List<BaseOBObject> pts = DalUtil.copyAll(new ArrayList<BaseOBObject>(getPaymentTerms()),
@@ -182,6 +186,8 @@
     xml = xml.replaceAll("</name>", "t</name>");
 
     setUserContext("1000019");
+    // a payment term line is not deletable, but for this test it should be done anyway
+    // force this by being admin
     OBContext.getOBContext().setInAdministratorMode(true);
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
@@ -192,17 +198,16 @@
     }
 
     assertEquals(0, ir.getInsertedObjects().size());
-    assertEquals(NO_OF_PT, ir.getUpdatedObjects().size());
+    // name of paymentterm has changed
+    // overduepaymentrule of paymenttermline is set back to 1
+    assertEquals(2, ir.getUpdatedObjects().size());
     for (final Object o : ir.getUpdatedObjects()) {
-      assertTrue(o instanceof PaymentTerm);
+      assertTrue(o instanceof PaymentTerm || o instanceof PaymentTermLine);
     }
-
-    setErrorOccured(false);
   }
 
   // test that the removal was successfull
   public void testFPaymentTerm() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final List<PaymentTerm> pts = getPaymentTerms();
     for (final PaymentTerm pt : pts) {
@@ -211,38 +216,41 @@
         assertTrue(!ptl.getLineNo().equals(new Integer(1)));
       }
     }
-    setErrorOccured(false);
   }
 
   // and now add a line!
   public void testGPaymentTerm() {
-    setErrorOccured(true);
 
     // read from 1000000
-    setUserContext("1000001");
+    setUserContext("1000019");
+    setAccess();
     // make a copy of the paymentterms and their children so that the
     // original db is not updated
     final List<BaseOBObject> pts = DalUtil.copyAll(new ArrayList<BaseOBObject>(getPaymentTerms()),
-        false);
+        true);
 
     // add one at the back
     for (final BaseOBObject bob : pts) {
       final PaymentTerm pt = (PaymentTerm) bob;
-      final PaymentTermLine ptl = (PaymentTermLine) DalUtil.copy(pt
-          .getFinancialMgmtPaymentTermLineList().get(0));
+      pt.setId("abc");
+      final PaymentTermLine ptl0 = pt.getFinancialMgmtPaymentTermLineList().get(0);
+      ptl0.setPaymentTerms(pt);
+      final PaymentTermLine ptl = (PaymentTermLine) DalUtil.copy(ptl0);
+      ptl.setId(null);
       ptl.setClient(null);
       ptl.setOrganization(null);
       ptl.setLineNo((long) NO_OF_PT_LINE);
       pt.getFinancialMgmtPaymentTermLineList().add(ptl);
+      ptl.setPaymentTerms(pt);
     }
 
     String xml = getXML(pts);
-    // System.err.println(xml);
+    // log.debug(xml);
     // there is a unique constraint on name
     xml = xml.replaceAll("</name>", "t</name>");
 
     setUserContext("1000019");
-    OBContext.getOBContext().setInAdministratorMode(true);
+    setAccess();
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
@@ -251,42 +259,34 @@
       fail(ir.getException().getMessage());
     }
 
-    // Note that the check is on 2 * NO_OF_PT, because the paymentterm
-    // contains 4 paymenttermlines of which 2 new ones
-    // per paymentterm, 3 read from the current client, 1 new. In the target
-    // database there are only 2 lines per paymentterm
-    assertEquals(2 * NO_OF_PT, ir.getInsertedObjects().size());
+    assertEquals(NO_OF_PT + NO_OF_PT_LINE, ir.getInsertedObjects().size());
     assertEquals(NO_OF_PT, ir.getUpdatedObjects().size());
     for (final Object o : ir.getUpdatedObjects()) {
-      assertTrue(o instanceof PaymentTerm);
+      assertTrue(o instanceof PaymentTermTrl);
     }
     for (final Object o : ir.getInsertedObjects()) {
-      assertTrue(o instanceof PaymentTermLine);
+      assertTrue(o instanceof PaymentTerm || o instanceof PaymentTermLine);
     }
-
-    setErrorOccured(false);
   }
 
   // test that the Addition was successfull
   public void testHPaymentTerm() {
-    setErrorOccured(true);
     setUserContext("1000019");
+    setAccess();
     final List<PaymentTerm> pts = getPaymentTerms();
     for (final PaymentTerm pt : pts) {
-      assertEquals(NO_OF_PT_LINE + 1, pt.getFinancialMgmtPaymentTermLineList().size());
-      int i = 0;
-      for (final PaymentTermLine ptl : pt.getFinancialMgmtPaymentTermLineList()) {
-        assertEquals(new Integer(i++), ptl.getLineNo());
-      }
+      // one pt has 2 lines, one has 1 line
+      final int size = pt.getFinancialMgmtPaymentTermLineList().size();
+      assertTrue(size == 1 || size == 2);
     }
-    setErrorOccured(false);
   }
 
   // cleans up everything
   public void testZPaymentTerm() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
     final List<PaymentTerm> pts = getPaymentTerms();
+    // financialmanagementpaymenttermline is not deletable, but as we are cleaning up
+    // force delete by being the admin
     OBContext.getOBContext().setInAdministratorMode(true);
     for (final PaymentTerm pt : pts) {
       OBDal.getInstance().remove(pt);
@@ -295,19 +295,22 @@
 
     setUserContext("1000019");
     final List<PaymentTerm> pts2 = getPaymentTerms();
+    // financialmanagementpaymenttermline is not deletable, but as we are cleaning up
+    // force delete by being the admin
     OBContext.getOBContext().setInAdministratorMode(true);
     for (final PaymentTerm pt : pts2) {
       OBDal.getInstance().remove(pt);
     }
-    setErrorOccured(false);
+    OBDal.getInstance().commitAndClose();
   }
 
   private void createSavePaymentTerm() {
+    setAccess();
     final List<PaymentTerm> result = new ArrayList<PaymentTerm>();
     for (int i = 0; i < NO_OF_PT; i++) {
       final PaymentTerm source = OBDal.getInstance().get(PaymentTerm.class, "1000000");
       final PaymentTerm pt = (PaymentTerm) DalUtil.copy(source);
-      pt.setName(pt.getName() + i);
+      pt.setName("test " + i);
       pt.setOrganization(OBContext.getOBContext().getCurrentOrganization());
 
       // force new
@@ -351,4 +354,11 @@
     exc.setAddSystemAttributes(false);
     return exc.toXML((List<BaseOBObject>) pts);
   }
+
+  // set the access so that the test are not bothered by security checks
+  // these are not tested here
+  private void setAccess() {
+    addReadWriteAccess(PaymentTerm.class);
+    addReadWriteAccess(PaymentTermLine.class);
+  }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/EntityXMLImportTestReference.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLImportTestReference.java	Wed Apr 22 13:34:41 2009 +0200
@@ -20,7 +20,6 @@
 package org.openbravo.test.xml;
 
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 import org.hibernate.Criteria;
@@ -35,58 +34,65 @@
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.enterprise.Warehouse;
-import org.openbravo.model.common.geography.Location;
 import org.openbravo.service.db.DataImportService;
 import org.openbravo.service.db.ImportResult;
 
 /**
- * Test import of data with a business object, adding and removing childs
+ * Test import of data with a business object, adding and removing childs.
  * 
  * @author mtaal
  */
 
 public class EntityXMLImportTestReference extends XMLBaseTest {
 
+  // keeps track of created warehouses.
+  private List<String> warehouseIds = new ArrayList<String>();
+
   public void _testPrintReadable() {
     setUserContext("1000019");
-    System.err.println("User 1000019");
     OBContext.getOBContext().getEntityAccessChecker().dump();
   }
 
   // import greetings in 1000002
   public void test1Warehouse() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
-
+    setUserContext("1000000");
+    addReadWriteAccess(Warehouse.class);
     final String xml = getXML(Warehouse.class);
-    // insert in org 1000002
+    // insert in org 1000001
     setUserContext("1000019");
-    // System.err.println(xml);
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     } else {
       assertEquals(4, ir.getInsertedObjects().size());
       assertEquals(0, ir.getUpdatedObjects().size());
+      for (BaseOBObject bob : ir.getInsertedObjects()) {
+        warehouseIds.add((String) bob.getId());
+      }
     }
-    setErrorOccured(ir.hasErrorOccured());
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
+    }
   }
 
+  // clean up
   public void test2Warehouse() {
-    setErrorOccured(true);
     setUserContext("1000019");
+    // a warehouse is not deletable, but as we are cleaning up, they should be
+    // deleted, force this by being admin
+    OBContext.getOBContext().setInAdministratorMode(true);
     removeAll(Warehouse.class, 2, Expression.ne("id", "1000002"));
-    setErrorOccured(false);
   }
 
   public void test3Warehouse() {
-    setErrorOccured(true);
-    setUserContext("1000001");
-
+    setUserContext("1000000");
+    addReadWriteAccess(Warehouse.class);
     final String xml = getXML(Warehouse.class);
     setUserContext("1000019");
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
@@ -95,52 +101,46 @@
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     }
     assertEquals(2, ir.getInsertedObjects().size());
     for (final BaseOBObject bob : ir.getInsertedObjects()) {
       assertTrue(bob instanceof Warehouse);
     }
     assertEquals(0, ir.getUpdatedObjects().size());
-    setErrorOccured(ir.hasErrorOccured());
-  }
-
-  public void test4Warehouse() {
-    setErrorOccured(true);
-    setUserContext("1000019");
-    removeAll(Warehouse.class, 2, Expression.gt("created", new Date(
-        System.currentTimeMillis() - 1000 * 3600 * 24)));
-    removeAll(Location.class, 2, Expression.gt("created", new Date(
-        System.currentTimeMillis() - 1000 * 3600 * 24)));
-    setErrorOccured(false);
-  }
-
-  public <T extends BaseOBObject> void removeAll(Class<T> clz, int expectCount, Criterion c) {
-    boolean prevMode = false;
-    try {
-      setErrorOccured(true);
-      setUserContext("1000019");
-      prevMode = OBContext.getOBContext().setInAdministratorMode(true);
-
-      final Criteria criteria = SessionHandler.getInstance().getSession().createCriteria(clz);
-      if (c != null) {
-        criteria.add(c);
-      }
-      criteria.add(Expression.eq("client.id", "1000001"));
-
-      @SuppressWarnings("unchecked")
-      final List<T> list = criteria.list();
-      assertEquals(expectCount, list.size());
-      for (final T t : list) {
-        SessionHandler.getInstance().getSession().delete(t);
-      }
-      setErrorOccured(false);
-    } finally {
-      OBContext.getOBContext().setInAdministratorMode(prevMode);
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
     }
   }
 
-  public <T extends BaseOBObject> String getXML(Class<T> clz) {
-    setErrorOccured(true);
+  // clean up
+  public void test4Warehouse() {
+    setUserContext("1000019");
+    // a warehouse is not deletable, but as we are cleaning up, they should be
+    // deleted, force this by being admin
+    OBContext.getOBContext().setInAdministratorMode(true);
+    removeAll(Warehouse.class, 2, Expression.ne("id", "1000002"));
+  }
+
+  private <T extends BaseOBObject> void removeAll(Class<T> clz, int expectCount, Criterion c) {
+    final Criteria criteria = SessionHandler.getInstance().getSession().createCriteria(clz);
+    if (c != null) {
+      criteria.add(c);
+    }
+    criteria.add(Expression.eq("client.id", "1000001"));
+
+    @SuppressWarnings("unchecked")
+    final List<T> list = criteria.list();
+    if (expectCount != -1) {
+      assertEquals(expectCount, list.size());
+    }
+    for (final T t : list) {
+      SessionHandler.getInstance().getSession().delete(t);
+    }
+  }
+
+  private <T extends BaseOBObject> String getXML(Class<T> clz) {
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
--- a/src-test/org/openbravo/test/xml/EntityXMLImportTestSingle.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLImportTestSingle.java	Wed Apr 22 13:34:41 2009 +0200
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.dal.core.OBContext;
@@ -38,31 +39,29 @@
 import org.openbravo.service.db.ImportResult;
 
 /**
- * Test import of data
+ * Test import of data, different scenarios in which data is re-imported (no update should occur),
+ * or small changes are made and an update should occur.
  * 
  * @author mtaal
  */
 
 public class EntityXMLImportTestSingle extends XMLBaseTest {
 
+  private static final Logger log = Logger.getLogger(EntityXMLImportTestSingle.class);
+
   public void testImportWarning() {
-    setErrorOccured(true);
-    setUserContext("1000000");
+    setUserContext("100");
 
     final String xml = exportTax();
-    setUserContext("1000001");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000000"),
-        OBDal.getInstance().get(Organization.class, "1000000"), xml);
+    final Client c = OBDal.getInstance().get(Client.class, "1000000");
+    final Organization o = OBDal.getInstance().get(Organization.class, "1000000");
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
 
-    System.err.println("WARNING>>>>");
-    System.err.println(ir.getWarningMessages());
-    assertTrue(ir.getWarningMessages() != null && ir.getWarningMessages().trim().length() != 0);
-    System.err.println("ERROR>>>>");
-    System.err.println(ir.getErrorMessages());
-    assertTrue(ir.getErrorMessages() != null && ir.getErrorMessages().trim().length() != 0);
-
-    setErrorOccured(false);
+    log.debug("WARNING>>>>");
+    assertTrue(ir.getWarningMessages(), ir.getWarningMessages() == null);
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
+    }
   }
 
   public String exportTax() {
@@ -76,30 +75,33 @@
     @SuppressWarnings("unchecked")
     final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
     final String xml = exc.toXML(list);
-    System.err.println(xml);
+    log.debug(xml);
     return xml;
   }
 
-  // import greetings in 1000002
+  // import greetings in 1000001
   public void test1Greeting() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    final int cnt = count(Greeting.class);
+    addReadWriteAccess(Greeting.class);
     final String xml = getXML(Greeting.class);
-    // insert in org 1000002
+    // insert in org 1000001
     setUserContext("1000019");
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
-    assertEquals(7, ir.getInsertedObjects().size());
+    assertEquals(cnt, ir.getInsertedObjects().size());
     assertEquals(0, ir.getUpdatedObjects().size());
-    setErrorOccured(ir.hasErrorOccured());
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
+    }
   }
 
   // test that a re-import does not update or insert
   public void test2Greeting() {
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Greeting.class);
     final String xml = getXML(Greeting.class);
     setUserContext("1000019");
     // insert in org 1000002
@@ -108,64 +110,62 @@
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
     assertEquals(0, ir.getInsertedObjects().size());
     assertEquals(0, ir.getUpdatedObjects().size());
-    setErrorOccured(ir.hasErrorOccured());
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
+    }
   }
 
   // change something in the xml and re-import
   // 2 updates should happen
   public void test3Greeting() {
-    setErrorOccured(true);
     setUserContext("1000019");
     String xml = getXML(Greeting.class);
     xml = xml.replaceAll("Mrs", "Mrsses");
     xml = xml.replaceAll("Herr", "Heer");
     xml = xml.replaceAll("Heer", "Her");
-    setUserContext("100");
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
         OBDal.getInstance().get(Client.class, "1000001"),
         OBDal.getInstance().get(Organization.class, "1000001"), xml);
     assertEquals(0, ir.getInsertedObjects().size());
     assertEquals(2, ir.getUpdatedObjects().size());
-    setErrorOccured(ir.hasErrorOccured());
+    if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
+    }
   }
 
   // remove the data
   public void test4Greeting() {
-    setErrorOccured(true);
     setUserContext("1000019");
     final Organization org = OBDal.getInstance().get(Organization.class, "1000001");
     final OBCriteria<Greeting> obc = OBDal.getInstance().createCriteria(Greeting.class);
     obc.setFilterOnReadableClients(false);
     obc.setFilterOnReadableOrganization(false);
     obc.add(Expression.eq(PROPERTY_ORGANIZATION, org));
-    assertEquals(7, obc.list().size());
+    // assertEquals(7, obc.list().size());
     for (final Greeting g : obc.list()) {
       OBDal.getInstance().remove(g);
     }
-    setErrorOccured(false);
   }
 
   // check remove was done
   public void test5Greeting() {
-    setErrorOccured(true);
     setUserContext("1000019");
-    final Organization org = OBDal.getInstance().get(Organization.class, "1000001");
+    final Organization org = OBDal.getInstance().get(Organization.class, "1000000");
     final OBCriteria<Greeting> obc = OBDal.getInstance().createCriteria(Greeting.class);
     obc.setFilterOnReadableClients(false);
     obc.setFilterOnReadableClients(false);
     obc.add(Expression.eq(PROPERTY_ORGANIZATION, org));
     assertEquals(0, obc.list().size());
-    setErrorOccured(false);
   }
 
   // test exporting and then importing in same organization
   public void test6Greeting() {
+    addReadWriteAccess(Greeting.class);
     doTestNoChange(Greeting.class);
   }
 
   // do it again, no change!
-  public <T extends BaseOBObject> void doTestNoChange(Class<T> clz) {
-    setErrorOccured(true);
+  private <T extends BaseOBObject> void doTestNoChange(Class<T> clz) {
     setUserContext("1000000");
     final String xml = getXML(clz);
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
@@ -173,11 +173,9 @@
         OBContext.getOBContext().getCurrentOrganization(), xml);
     assertTrue(ir.getInsertedObjects().size() == 0);
     assertTrue(ir.getUpdatedObjects().size() == 0);
-    setErrorOccured(false);
   }
 
   public <T extends BaseOBObject> String getXML(Class<T> clz) {
-    setErrorOccured(true);
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
--- a/src-test/org/openbravo/test/xml/EntityXMLImportTestWarning.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLImportTestWarning.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,8 +22,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.structure.BaseOBObject;
-import org.openbravo.dal.core.SessionHandler;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.xml.EntityXMLConverter;
@@ -43,62 +45,49 @@
 
 public class EntityXMLImportTestWarning extends XMLBaseTest {
 
-  public void testNotWritableWarningUpdate() {
+  public void testNotWritableUpdate() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Greeting.class);
 
     final List<Greeting> gs = getList(Greeting.class);
     String xml = getXML(gs);
 
     // change the xml to force an update
     xml = xml.replaceAll("</name>", "t</name>");
+
+    final Client c = OBDal.getInstance().get(Client.class, "1000000");
+    final Organization o = OBDal.getInstance().get(Organization.class, "1000000");
     setUserContext("1000000");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000000"),
-        OBDal.getInstance().get(Organization.class, "1000000"), xml);
+    OBContext.getOBContext().setCurrentOrganization(o);
+    OBContext.getOBContext().setCurrentClient(c);
+
+    // remove the entity to force a not-write situation
+    final Entity entity = ModelProvider.getInstance().getEntity(Greeting.class);
+    OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().remove(entity);
+    OBContext.getOBContext().getEntityAccessChecker().getReadableEntities().add(entity);
+
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     } else {
+      // assertEquals(0, ir.getUpdatedObjects().size());
+      // assertEquals(0, ir.getUpdatedObjects().size());
       assertTrue(ir.getWarningMessages() != null);
       assertTrue(ir.getWarningMessages().indexOf("updating") != -1);
       assertTrue(ir.getWarningMessages().indexOf(" because it is not writable") != -1);
     }
     // force a rollback, so that the db is not changed
-    setErrorOccured(true);
-  }
-
-  public void testNotWritableReferencedDataWarning() {
-    cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
-
-    final List<Warehouse> ws = getList(Warehouse.class);
-    String xml = getXML(ws);
-
-    // change the xml to force an update
-    xml = xml.replaceAll("</name>", "t</name>");
-    setUserContext("1000020");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000001"),
-        OBDal.getInstance().get(Organization.class, "1000001"), xml);
-    if (ir.getException() != null) {
-      ir.getException().printStackTrace(System.err);
-      fail(ir.getException().getMessage());
-    } else {
-      assertTrue(ir.getWarningMessages() != null);
-      assertTrue(ir.getWarningMessages().indexOf("updating") != -1);
-      assertTrue(ir.getWarningMessages().indexOf(" because it is not writable") != -1);
-    }
-    // force a rollback, so that the db is not changed
-    setErrorOccured(true);
+    rollback();
   }
 
   public void testNotWritableInsertWarning() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Warehouse.class);
 
     final List<Warehouse> ws = getList(Warehouse.class);
     String xml = getXML(ws);
@@ -106,52 +95,27 @@
     // change the xml to force an update
     xml = xml.replaceAll("</name>", "t</name>");
     xml = xml.replaceAll("</id>", "new</id>");
-    setUserContext("1000001");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000001"),
-        OBDal.getInstance().get(Organization.class, "1000001"), xml);
-    if (ir.getException() != null) {
-      ir.getException().printStackTrace(System.err);
-      fail(ir.getException().getMessage());
-    } else {
-      assertTrue(ir.getWarningMessages() != null);
-      assertTrue(ir.getWarningMessages().indexOf("Not allowed to create entity") != -1);
-      assertTrue(ir.getWarningMessages().indexOf(" because it is not writable") != -1);
-    }
+    final Client c = OBDal.getInstance().get(Client.class, "1000001");
+    final Organization o = OBDal.getInstance().get(Organization.class, "1000001");
+    setUserContext("1000019");
+
+    // remove the entity from the writable entities to force an access error
+    final Entity entity = ModelProvider.getInstance().getEntity(Warehouse.class);
+    OBContext.getOBContext().getEntityAccessChecker().getWritableEntities().remove(entity);
+
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
+    assertTrue("No error messages, error messages expected", ir.getErrorMessages() != null);
+    assertTrue("Incorrect error", ir.getErrorMessages().indexOf("Object Warehouse") != -1);
+    assertTrue("Incorrect error", ir.getErrorMessages().indexOf("is new but not writable") != -1);
+    assertTrue("There should not be warnings", ir.getWarningMessages() == null);
     // force a rollback, so that the db is not changed
-    setErrorOccured(true);
-  }
-
-  public void testNotUpdatingReferencedDataWarning() {
-    cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
-
-    final List<Warehouse> ws = getList(Warehouse.class);
-    String xml = getXML(ws);
-
-    // change the xml to force an update
-    xml = xml.replaceAll("</name>", "t</name>");
-    xml = xml.replaceAll("</id>", "new</id>");
-    setUserContext("0");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000001"),
-        OBDal.getInstance().get(Organization.class, "1000001"), xml);
-    if (ir.getException() != null) {
-      ir.getException().printStackTrace(System.err);
-      fail(ir.getException().getMessage());
-    } else {
-      assertTrue(ir.getWarningMessages() != null);
-      assertTrue(ir.getWarningMessages().indexOf("has not been updated because it already exists") != -1);
-    }
-    // force a rollback, so that the db is not changed
-    setErrorOccured(true);
+    rollback();
   }
 
   public void testUpdatingOtherOrganizationWarning() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Warehouse.class);
 
     final List<Warehouse> ws = getList(Warehouse.class);
     String xml = getXML(ws);
@@ -166,6 +130,8 @@
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     } else {
       assertTrue(ir.getWarningMessages() != null);
       assertTrue(ir.getWarningMessages().indexOf("Updating entity") != -1);
@@ -173,13 +139,14 @@
           "eventhough it does not belong to the target organization ") != -1);
     }
     // force a rollback, so that the db is not changed
-    setErrorOccured(true);
+    rollback();
   }
 
-  public void testUpdateOtherClientWarning() {
+  // works also but disabled for now
+  public void _testUpdateOtherOrganizationWarning() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    setUserContext("1000000");
+    addReadWriteAccess(Location.class);
 
     final List<Location> cs = getList(Location.class);
     String xml = getXML(cs);
@@ -197,57 +164,55 @@
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     } else {
       assertTrue(ir.getWarningMessages() != null);
       assertTrue(ir.getWarningMessages().indexOf("Updating entity") != -1);
       assertTrue(ir.getWarningMessages().indexOf(
-          "eventhough it does not belong to the target client") != -1);
-    }
-    // force a rollback, so that the db is not changed
-    setErrorOccured(true);
-  }
-
-  public void testInsertOtherOrganizationWarning() {
-    cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("100");
-
-    final List<Location> cs = getList(Location.class);
-    String xml = getXML(cs);
-
-    // clears the session and ensures that it starts with a new one
-    SessionHandler.getInstance().rollback();
-
-    // the following should result in creation of location
-    xml = xml.replaceAll("<name>", "<name>new");
-    xml = xml.replaceAll("region id=\"", "region id=\"new");
-    xml = xml.replaceAll("Region id=\"", "Region id=\"new");
-    System.err.println(xml);
-    setUserContext("0");
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000000"),
-        OBDal.getInstance().get(Organization.class, "1000001"), xml);
-    if (ir.getException() != null) {
-      ir.getException().printStackTrace(System.err);
-      fail(ir.getException().getMessage());
-    } else {
-      assertTrue(ir.getWarningMessages() != null);
-      assertTrue(ir.getWarningMessages().indexOf("Creating entity ") != -1);
-      assertTrue(ir.getWarningMessages().indexOf(
           "eventhough it does not belong to the target organization") != -1);
     }
     // force a rollback, so that the db is not changed
-    setErrorOccured(true);
+    rollback();
   }
 
+  // public void testInsertOtherClientWarning() {
+  // cleanRefDataLoaded();
+  // setUserContext("0");
+  //
+  // final List<Region> cs = getList(Region.class);
+  // String xml = getXML(cs);
+  //
+  // // clears the session and ensures that it starts with a new one
+  // SessionHandler.getInstance().rollback();
+  //
+  // // the following should result in creation of location
+  // xml = xml.replaceAll("<name>", "<name>new");
+  // xml = xml.replaceAll("region id=\"", "region id=\"new");
+  // xml = xml.replaceAll("Region id=\"", "Region id=\"new");
+  // setUserContext("0");
+  // final ImportResult ir = DataImportService.getInstance().importDataFromXML(
+  // OBDal.getInstance().get(Client.class, "1000000"),
+  // OBDal.getInstance().get(Organization.class, "1000001"), xml);
+  // if (ir.getException() != null) {
+  // ir.getException().printStackTrace(System.err);
+  // fail(ir.getException().getMessage());
+  // } else {
+  // assertTrue(ir.getWarningMessages() != null);
+  // assertTrue(ir.getWarningMessages().indexOf("Creating entity ") != -1);
+  // assertTrue(ir.getWarningMessages().indexOf(
+  // "eventhough it does not belong to the target organization") != -1);
+  // }
+  // // force a rollback, so that the db is not changed
+  // rollback();
+  // }
+
   public <T extends BaseOBObject> List<T> getList(Class<T> clz) {
-    setErrorOccured(true);
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     return obc.list();
   }
 
   public <T extends BaseOBObject> String getXML(List<T> objs) {
-    setErrorOccured(true);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
     // exc.setOptionEmbedChildren(true);
@@ -257,7 +222,6 @@
   }
 
   public <T extends BaseOBObject> String getXML(Class<T> clz) {
-    setErrorOccured(true);
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
--- a/src-test/org/openbravo/test/xml/EntityXMLIssues.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/EntityXMLIssues.java	Wed Apr 22 13:34:41 2009 +0200
@@ -22,6 +22,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.service.OBCriteria;
@@ -30,6 +31,7 @@
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.businesspartner.Greeting;
 import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.uom.UOM;
 import org.openbravo.service.db.DataImportService;
 import org.openbravo.service.db.ImportResult;
 
@@ -45,36 +47,37 @@
    * Checks mantis issue 6212, issue text: When inserting reference data using DAL into ad_client 0
    * it should not generate new uuids but maintain the current ids but it is doing so.
    */
-  public void _testMantis6212() {
+  public void testMantis6212() {
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    final Client c = OBDal.getInstance().get(Client.class, "1000000");
+    final Organization o = OBDal.getInstance().get(Organization.class, "1000000");
+    setUserContext("1000000");
 
-    final List<Greeting> gs = getList(Greeting.class);
+    addReadWriteAccess(Greeting.class);
 
     // only do one greeting
-    final Greeting greeting = (Greeting) DalUtil.copy(gs.get(0));
+    final Greeting greeting = (Greeting) OBProvider.getInstance().get(Greeting.class);
     final String id = "" + System.currentTimeMillis();
+    greeting.setName("test" + id);
     greeting.setId(id);
+    greeting.setTitle("test");
     final List<Greeting> newGs = new ArrayList<Greeting>();
     newGs.add(greeting);
     final String xml = getXML(newGs);
 
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000000"),
-        OBDal.getInstance().get(Organization.class, "1000000"), xml);
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
 
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.getErrorMessages() != null) {
+      fail(ir.getErrorMessages());
     }
 
     assertEquals(1, ir.getInsertedObjects().size());
     assertTrue(ir.getWarningMessages() == null);
     final BaseOBObject bob = ir.getInsertedObjects().get(0);
     assertEquals(id, bob.getId());
-    System.err.println(id);
-    setErrorOccured(false);
   }
 
   /**
@@ -85,62 +88,62 @@
   public void testMantis6213() {
     final String spaces = "   ";
     cleanRefDataLoaded();
-    setErrorOccured(true);
-    setUserContext("1000001");
+    final Client c = OBDal.getInstance().get(Client.class, "1000000");
+    final Organization o = OBDal.getInstance().get(Organization.class, "1000000");
+    setUserContext("1000000");
+    addReadWriteAccess(UOM.class);
 
-    // update all greetings to have a name with spaces
-    {
-      final List<Greeting> gs = getList(Greeting.class);
-      for (final Greeting g : gs) {
-        g.setTitle(spaces);
-      }
-      OBDal.getInstance().commitAndClose();
-    }
+    final List<UOM> uoms = getList(UOM.class);
 
-    final List<Greeting> gs = getList(Greeting.class);
-    for (final Greeting g : gs) {
-      assertEquals(spaces, g.getTitle());
-    }
+    // only copy one uom
+    final UOM prevUom = uoms.get(0);
+    // a prerequisite, if this fails then the length has changed
+    assertEquals(3, prevUom.getSymbol().length());
+    final UOM uom = (UOM) DalUtil.copy(prevUom);
+    final List<UOM> newUoms = new ArrayList<UOM>();
+    final String id = "" + System.currentTimeMillis();
+    uom.setId(id);
+    uom.setName(id);
+    uom.setSymbol("   ");
+    newUoms.add(uom);
+    final String xml = getXML(newUoms);
+    assertTrue(xml.indexOf("<symbol>" + uom.getSymbol() + "</symbol>") != -1);
 
-    // only do one greeting
-    final Greeting greeting = (Greeting) DalUtil.copy(gs.get(0));
-    final List<Greeting> newGs = new ArrayList<Greeting>();
-    final String id = "" + System.currentTimeMillis();
-    greeting.setId(id);
-    newGs.add(greeting);
-    final String xml = getXML(newGs);
-    assertTrue(xml.indexOf("<greetingName>   </greetingName>") != -1);
-
-    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
-        OBDal.getInstance().get(Client.class, "1000000"),
-        OBDal.getInstance().get(Organization.class, "1000000"), xml);
+    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
     if (ir.getException() != null) {
       ir.getException().printStackTrace(System.err);
       fail(ir.getException().getMessage());
+    } else if (ir.hasErrorOccured()) {
+      fail(ir.getErrorMessages());
     }
 
     assertEquals(1, ir.getInsertedObjects().size());
-    assertTrue(ir.getWarningMessages() == null);
+    // there is a warning that the uom is created in org *, that's fine
+    assertTrue(ir.getWarningMessages() != null);
+    assertTrue(ir.getWarningMessages().indexOf(
+        "eventhough it does not belong to the target organization") != -1);
     final BaseOBObject bob = ir.getInsertedObjects().get(0);
     assertEquals(id, bob.getId());
 
     OBDal.getInstance().commitAndClose();
 
     // now reread the greeting and check that the space is still there
-    final Greeting newGreeting = OBDal.getInstance().get(Greeting.class, id);
-    assertTrue(greeting != newGreeting);
-    assertEquals(spaces, newGreeting.getTitle());
-    setErrorOccured(false);
+    final UOM newUom = OBDal.getInstance().get(UOM.class, id);
+    // before testing if it is okay remove it!
+    OBDal.getInstance().remove(newUom);
+    OBDal.getInstance().commitAndClose();
+
+    // ensure that hibernate did not give us the same object twice
+    assertTrue(uom != newUom);
+    assertEquals(uom.getSymbol(), newUom.getSymbol());
   }
 
   public <T extends BaseOBObject> List<T> getList(Class<T> clz) {
-    setErrorOccured(true);
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     return obc.list();
   }
 
   public <T extends BaseOBObject> String getXML(List<T> objs) {
-    setErrorOccured(true);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
     // exc.setOptionEmbedChildren(true);
@@ -150,7 +153,6 @@
   }
 
   public <T extends BaseOBObject> String getXML(Class<T> clz) {
-    setErrorOccured(true);
     final OBCriteria<T> obc = OBDal.getInstance().createCriteria(clz);
     final EntityXMLConverter exc = EntityXMLConverter.newInstance();
     exc.setOptionIncludeReferenced(true);
--- a/src-test/org/openbravo/test/xml/StaxTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (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.html 
- * 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) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.test.xml;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * Tests various aspects of stax.
- * 
- * @author mtaal
- */
-
-public class StaxTest extends XMLBaseTest {
-
-  public void testStaxRead() throws Exception {
-    final String countryXML = getFileContent("country.xml");
-
-    XMLInputFactory factory = XMLInputFactory.newInstance();
-    XMLStreamReader r = factory.createXMLStreamReader(new StringReader(countryXML));
-    try {
-      int event = r.getEventType();
-      while (true) {
-        switch (event) {
-        case XMLStreamConstants.START_DOCUMENT:
-          System.err.println("Start Document.");
-          break;
-        case XMLStreamConstants.START_ELEMENT:
-          System.err.println("Start Element: " + r.getLocalName());
-          for (int i = 0, n = r.getAttributeCount(); i < n; ++i)
-            System.err
-                .println("Attribute: " + r.getAttributeName(i) + "=" + r.getAttributeValue(i));
-          if (r.getLocalName().compareTo("Country") != 0
-              && r.getLocalName().compareTo("Openbravo") != 0) {
-            // System.err.println("ElementText: " + r.getElementText());
-          }
-
-          break;
-        case XMLStreamConstants.CHARACTERS:
-          if (r.isWhiteSpace())
-            break;
-
-          System.err.println("Text: " + r.getText());
-          break;
-        case XMLStreamConstants.CDATA:
-          if (r.isWhiteSpace())
-            break;
-
-          System.err.println("CDATA: " + r.getText());
-          break;
-        case XMLStreamConstants.END_ELEMENT:
-          System.err.println("End Element:" + r.getName());
-          break;
-        case XMLStreamConstants.END_DOCUMENT:
-          System.err.println("End Document.");
-          break;
-        }
-
-        if (!r.hasNext())
-          break;
-
-        event = r.next();
-      }
-    } finally {
-      r.close();
-    }
-
-  }
-
-  public void testWriteSax() throws Exception {
-    StringWriter sw = new StringWriter();
-    // XMLOutputFactory factory = XMLOutputFactory.newInstance();
-    // XMLStreamWriter writer = factory.createXMLStreamWriter(sw);
-    // writer.writeStartDocument("ISO-8859-1", "1.0");
-    // writer.writeStartElement("greeting");
-    // writer.writeAttribute("id", "g1 &\"");
-    // writer.writeCharacters("Hello StAX &");
-    // writer.writeEndDocument();
-    // writer.flush();
-    // writer.close();
-    // System.err.println(sw.toString());
-
-    StreamResult streamResult = new StreamResult(sw);
-    SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-    // SAX2.0 ContentHandler.
-    TransformerHandler hd = tf.newTransformerHandler();
-    Transformer serializer = hd.getTransformer();
-    serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-    serializer.setOutputProperty(OutputKeys.VERSION, "1.0");
-    serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-    serializer.setOutputProperty(OutputKeys.INDENT, "yes");
-    hd.setResult(streamResult);
-    hd.startDocument();
-
-    AttributesImpl atts = new AttributesImpl();
-    // USERS tag.
-    hd.startElement("", "", "USERS", atts);
-    // USER tags.
-    String[] id = { "PWD122", "MX787", "A4Q457&" };
-    String[] type = { "customer", "manager", "employee" };
-    String[] desc = { "Tim@Home", "Jack&Moud", "John D'oé" };
-    for (int i = 0; i < id.length; i++) {
-      atts.clear();
-      atts.addAttribute("", "", "ID", "CDATA", id[i]);
-      atts.addAttribute("", "", "TYPE", "CDATA", type[i]);
-      hd.startElement("", "", "USER", atts);
-      hd.startElement("", "", "USER2", null);
-      hd.characters(desc[i].toCharArray(), 0, desc[i].length());
-      hd.endElement("", "", "USER2");
-      hd.startElement("", "", "USER3", null);
-      hd.endElement("", "", "USER3");
-      hd.endElement("", "", "USER");
-    }
-    hd.endElement("", "", "USERS");
-    hd.endDocument();
-    System.err.println(sw.toString());
-  }
-}
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java	Wed Apr 22 13:20:08 2009 +0200
+++ b/src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java	Wed Apr 22 13:34:41 2009 +0200
@@ -21,6 +21,7 @@
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.structure.BaseOBObject;
@@ -37,16 +38,17 @@
 import org.openbravo.service.db.ImportResult;
 
 /**
- * Test import of data
+ * Test the influence of unique constraints when importing data.
  * 
  * @author mtaal
  */
 
 public class UniqueConstraintImportTest extends XMLBaseTest {
 
+  private static final Logger log = Logger.getLogger(UniqueConstraintImportTest.class);
+
   // country trl table can be empty, create some test values
   public void testACreateCountryTrl() {
-    setErrorOccured(true);
     setUserContext("0");
     final Country country = getCountry("Norway");
     final OBCriteria<CountryTrl> obc = OBDal.getInstance().createCriteria(CountryTrl.class);
@@ -67,12 +69,13 @@
       countryTrl.setDescription(country.getDescription());
       countryTrl.setName(country.getName());
       countryTrl.setRegionName(country.getRegionName());
+      countryTrl.setAddressPrintFormat("test");
+      countryTrl.setActive(true);
       // countryTrl.setDescription(getName())isplaySequence(country.getDisplaySequence());
       OBDal.getInstance().save(countryTrl);
       created++;
     }
-    System.err.println("Created " + created + " countrytrl objects");
-    setErrorOccured(false);
+    log.debug("Created " + created + " countrytrl objects");
   }
 
   // this test, reads countrytrl from the db and imports them again
@@ -80,13 +83,12 @@
   // countrytrl because they are found using the unique constraint of country
   // and language
   public void testCountryTrlImport() {
-    setErrorOccured(true);
     setUserContext("100");
 
     // read countrytrl
     String xml = exportClass(CountryTrl.class, "country", getCountry("Norway"));
 
-    // 
+    // change the id
     xml = xml.replaceAll("<CountryTrl id=\"..", "<CountryTrl id=\"1k");
 
     final ImportResult ir = DataImportService.getInstance().importDataFromXML(
@@ -94,15 +96,18 @@
         OBDal.getInstance().get(Organization.class, "1000001"), xml,
         OBDal.getInstance().get(Module.class, "0"));
 
-    System.err.println("WARNING>>>>");
-    System.err.println(ir.getWarningMessages());
-    assertTrue(ir.getWarningMessages() != null && ir.getWarningMessages().trim().length() != 0);
+    log.debug("WARNING>>>>");
+    log.debug(ir.getWarningMessages());
+    assertTrue(ir.getWarningMessages() != null
+        && ir.getWarningMessages().trim().length() != 0
+        && ir.getWarningMessages().indexOf(
+            "eventhough it does not belong to the target organization") != -1);
 
     for (final BaseOBObject bob : ir.getUpdatedObjects()) {
       assertEquals(CountryTrl.class.getName(), bob.getClass().getName());
+      // and clean up
+      OBDal.getInstance().remove(bob);
     }
-
-    setErrorOccured(false);
   }
 
   private Country getCountry(String name) {
@@ -125,7 +130,7 @@
     @SuppressWarnings("unchecked")
     final List<BaseOBObject> list = (List<BaseOBObject>) obc.list();
     final String xml = exc.toXML(list);
-    System.err.println(xml);
+    log.debug(xml);
     return xml;
   }
 }
\ No newline at end of file
--- a/src-test/org/openbravo/test/xml/testdata/country.xml	Wed Apr 22 13:20:08 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<ob:Openbravo xmlns:ob="http://www.openbravo.com" created="Thu Feb 12 08:33:58 CET 2009" ob-version="2.50" ob-revision="12839">
-  <Country id="125" identifier="Bahamas">
-    <id>125</id>
-    <client id="0" entity-name="ADClient &quot;" identifier="System"/>
-    <organization id="0" entity-name="Organization" identifier="*"/>
-    <active>true</active>
-    <creationDate transient="true">2003-03-09T00:00:00.0Z</creationDate>
-    <createdBy transient="true" id="0" entity-name="ADUser" identifier="System"/>
-    <updated transient="true">2003-03-09T00:00:00.0Z</updated>
-    <updatedBy transient="true" id="0" entity-name="ADUser" identifier="System"/>
-    <name>Bahamas &amp; Test</name>
-    <description>Bahamas</description>
-    <iSOCountryCode>BS</iSOCountryCode>
-    <hasRegions>false</hasRegions>
-    <regionName><![CDATA[The region name < > isds]]></regionName>
-    <phoneNoFormat/>
-    <addressPrintFormat>@C@,  @P@</addressPrintFormat>
-    <postalCodeFormat/>
-    <additionalPostalCode>false</additionalPostalCode>
-    <additionalPostalFormat/>
-    <default>false</default>
-    <language/>
-    <currency id="199" entity-name="Currency" identifier="BSD"/>
-    <iBANLength/>
-    <iBANCode/>
-    <regionList/>
-  </Country>
-</ob:Openbravo>
--- a/src/build.xml	Wed Apr 22 13:20:08 2009 +0200
+++ b/src/build.xml	Wed Apr 22 13:34:41 2009 +0200
@@ -228,6 +228,22 @@
     </javac>
   </target>
 
+  <target name="run.tests" depends="compileSqlc,generate.entities.quick">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AllAntTaskTests" haltonfailure="no"/>
+    </junit>
+  </target>
+
+  <target name="run.quick.tests" depends="compileSqlc,generate.entities.quick">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AllQuickAntTaskTests" haltonfailure="no"/>
+    </junit>
+  </target>
+  
   <target name="compileSqlc" depends="sqlc">
     <javac  srcdir="${basedir}:${build.sqlc}/src:${build.sqlc}/srcAD:${base.src.test}:${base.modules}" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
       <classpath refid="project.class.path" />