View source | Discuss this page | Page history | Printable version   

ERP 2.50:Developers Guide/How to create a dataset

ERP 2.50:Developers Guide

Index

Contents

Objective

This how-to will focus on creating a dataset in Openbravo ERP and also to explain with some examples in detail under Examples section. Dataset will export both reference data as well as default data.

Introduction to Dataset Concept

Bulbgraph.png   For detailed theoretical concepts on datasets please have a look at:
  1. Modularity Project
  2. Developer's guide

First of all we need to understand the dataset concept, which allows to export the sets of data from different tables in one step. This is especially useful to manage and distribute the module along with reference data, for instance tax rates, regions or default data in a new table(s) added by a module.

A dataset is defined by its Dataset Tables and Dataset Columns. This detailed configuration leads to which tables to be exported, and which columns of each table are executed and exported.


Bulbgraph.png   There are some important things to note:
  • A Dataset belongs to a module, so modules can add Datasets and define their own Datasets.
  • Data Access Level: filters the tables which can be selected for this dataset, only tables with the set data access level can be included in the data set (see Data Access Level section for more information).

Reference Data

The reference data is packaged, distributed and installed together with the program code implementation of the module.

In Openbravo ERP 2.50, the concept of reference data is generalized and any data in the instance can be exported in a module and imported when installing / applying the module.

You can find the Has reference data field / option at the time of module creation.

Data structure to define Dataset

There are mainly 3 tables referred as data structure to define datasets. They are:

1. DataSet with the following columns: Value, Name, Description, Module and DataAccessLevel

Dataset.png

If the export allowed column is flagged then an Export Reference Data button is displayed. 

2. DataSet_Table with the following columns: DataSet, Table, fullBusinessObjec, includeAllColumns, excludeAuditInfo and whereClause (HQL expression)

Dataset table.png

Note: If IsBusinessObject field is flagged then the 'child-records' of the table are exported.
For example if the Dataset Table is defined for the C_Order table and this field is flagged then also the 
related C_OrderLines are exported. 


Bulbgraph.png   A full business object is a record including all its one-to-many relationships as defined in the AD through the isParent attribute of a column. An example of a full business object is a product with its vendors, prices, etc. A complete description of business objects is provided in the DAL project.


3. Dataset_column with the following columns with the following columns: DataSet_Table, Column, isExcluded and conditionClause(Java expression).

Dataset column.png


Data Access Level

The Data Access Level is used to define how to import / install the module at various level like System level, Client level, Organization level, etc. These access level value is available at Dataset table. Following is the detailed explanatory at each access level.


Exporting Module

Before packaging we need to export the module which creates a directory in the module under Openbravo ERP root directory and the appropriate XML files for inclusion in the finished module. Modules that are not flagged as being in development are not exported so remember that you must select the In Development checkbox when you define a new module.

When the development of the module is finished, open a command window/shell and navigate to the Openbravo ERP development project execute the export.database command.

ant export.database

Packaging a Module

The last step in the process is to package the module and distribute across to the end user.

To package a module, execute the command ant package.module -Dmodule=modulename, where modulename is the Java package name of the module. So in the case of the howto module, the command would be:

ant package.module -Dmodule=org.openbravo.howto


Examples

Please find below the examples to know how to create a dataset and to export it along with the reference data.

Dataset of roles and accesses

In this section you can find the example of a dataset of roles and access. It basically covers the definition of the role in the organization and the privileges they require.

Create a Role and Assign Privileges

Create a User and assign the user to the Role

Create a new module

Create a Dataset of roles and access

  1. From the Application menu, select Application Dictionary > Dataset
  2. Click New.
  3. From the Module list, select the module above created.
  4. Specify a search key, name and description.
  5. From the Data Access Level list, select the Data access level as Organization.
  6. Select the Export allowed option.
  7. Select the Table Tab
  8. From the Table list, select the table whose content you want to include in the module. For example, ad_role_org_access, ad_role, ad_user_roles
  9. In the SQL where clause field, specify the SQL "WHERE" statement that will identify the set of rows to be exported, in DAL notation. For example, adrole.id='2EA831D59184490E9BA858E9745EF89F'
  10. Select the Include All Columns option.
  11. Select isBusinessObject option
  12. Click Save
  13. Click the Export Reference Data button to export the reference data to an .xml file that you can include in the module

Exporting and Packaging Module

After completing all the steps successfully. Run the below ant task to

export the module:
ant export.database -Dmodule="org.openbravo.rolesandaccess"
packaging the module:
ant package.module -Dmodule="org.openbravo.rolesandaccess"

On successful execution of the above task an .obx file has been generated.


How to Install - Organization Access Level Reference Data

To install the new module into the running Openbravo ERP then need handle the steps carefully. In this example we have selected the access level as Organization then the installation would be done using Enterprise Module Management find below the steps.

Dataset of taxes or alerts

In this section you can find the example on dataset of taxes or alerts. The process for creating a standard reference data module for taxes and alerts, you have set up Openbravo ERP in a particular way to meet local requirements, you can export this data and convert it to a module, so that you can share it with other users.

Registering a data module for taxes and alerts:

Defining and exporting the dataset

  1. From the Application menu, select Application Dictionary > Dataset
  2. Click New.
  3. From the Module list, select the module above created.
  4. Specify a search key, name and description.
  5. From the Data Access Level list, select the Data access level as System only
  6. Select the Export allowed option.
  7. Select the Table Tab
  8. From the Table list, select the table whose content you want to include in the module.
  9. In the SQL where clause field, specify the SQL "WHERE" statement that will identify the set of rows to be exported, in DAL notation. For example, client.id='1000001'
  10. To export all columns, select the Include All Columns option. To include only the columns you specify, select the Columns tab and create a new record for each column you want to export.
  11. To include the security audit columns (created, createdby, updated and updatedby) in the export, clear the Exclude Audit Info checkbox.
  12. Clear the Is Business Object option.
  13. Click Save
  14. Click the Export Reference Data button to export the reference data to an .xml file that you can include in the module


Exporting and Packaging Module

After completing all the steps successfully. Run the below ant task to

export the module:
ant export.database -Dmodule="org.openbravo.taxesandalerts"
packaging the module:
ant package.module -Dmodule="org.openbravo.taxesandalerts"

On successful execution of the above task an .obx file has been generated.


How to Install - System/Client Access Level Reference Data

To install the new module into the running Openbravo ERP then need handle the steps carefully. In this example we have selected the access level as Organization then the installation would be done using Enterprise Module Management find below the steps.


Dataset of regions

In this section you can export the reference data with the examples on regions. Find below the steps to create the Dataset for this module:

select * from c_country where countrycode like 'IN%';


Exporting and Packaging Module

After completing all the steps successfully. Run the below ant task to

export the module:
ant export.database -Dmodule="org.openbravo.indianstates"
packaging the module:
ant package.module -Dmodule="org.openbravo.indianstates"

On successful execution of the above task an .obx file has been generated.


How to Install - System Only Access Level Reference Data

To install the new module into the running Openbravo ERP then need handle the steps carefully. In this example we have selected the access level as Organization then the installation would be done using Enterprise Module Management find below the steps.




ERP 2.50:Developers Guide/How to define users roles privileges menus | ERP 2.50:Developers Guide/How to work with the Data Access Layer 

Retrieved from "http://wiki.openbravo.com/wiki/ERP_2.50:Developers_Guide/How_to_create_a_dataset"

This page has been accessed 16,993 times. This page was last modified on 14 June 2011, at 11:04. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.