This makes Initial Data Load a great tool focused to make shorter and cheaper the implementation process of Openbravo ERP but also Initial Data Load is extensible. You can use all the elements and tools provided, like the user interface, default values management, utilities, etc... to modify the existing processes to be adapted to your business requirements and to create new ones to import custom data. This way if you want to create a new process to import data you only need to focus in the logic because all the infrastructure provided by Initial Data Load will be reused.
To help with the task of creating new data import processes for Initial Data Load it is helpful the module Initial Data Load extension for Java. With this new module you will be able to develop a new data import process with a single java class and few lines of code. In this guide I will explain step by step the process of creating and deploying a new data import process using the java class sample included in the Initial Data Load extension for Java. After you read this visual guide you will be able to write, install and execute new processes quickly and reduce a lot the time needed to implement a fully working Openbravo ERP following your business requirements.
Step 1. Installation of the required modules
Log in as System Administrator and activate your instance in General Setup >> Application >> Instance Activation . To activate your instance you need first to adquire an Openbravo ERP Professional Subscription and use the System Key Openbravo will send to you.
After you have your instance activated, go to General Setup >> Application >> Module Management and install the modules Initial Data Load and Initial Data Load Extension for Java.
Step 2. Install the dataset.
The dataset provided by the Initial Data Load module contains the definition of the provided import processes and the default values for each process.
Login as your Client Administrator and go to General Setup >> Enterprise >> Enterprise Module Management, select Initial Data Load and press OK.
Step 3. Configure a new process.
The module Initial Data Load for Java provides a sample java class that implements an import process to import products. Now we are going to configure this class to invoke it from the Initial Data Load process window.
Go to Master Data Management >> Initial Data Load >> Setup >> Entity Default Values. Create a new record and fill in the field values. Pay attention to the field Class Name. The value must be org.openbravo.module.idljava.proc.SampleProductsProcess that is the name of the java class that implements the sample products import process.
The module Initial Data Load for Java provides a sample java class that implements an import process to import products. Now we are going to configure this class to invoke it from the Initial Data Load process window.
Go to Master Data Management >> Initial Data Load >> Setup >> Entity Default Values. Create a new record and fill in the field values. Pay attention to the field Class Name. The value must be org.openbravo.module.idljava.proc.SampleProductsProcess that is the name of the java class that implements the sample products import process.
If you cannot add new records, it is because there is a know issue already fixed in the Initial Data Load that prevents you to create new records. For more information about this, go to the issue report 16787.
Step 4. Execute the new process
Now we have everything we need to execute the new configured process that imports products. Go to Master Data Management >> Initial Data Load >> Process Import. Select the new configured process, in our example Custom Products. You can use this products sample CSV file to test the execution of the process. Press Validate or Process. Validate only checks that the data to import is valid but does not actually import the data. Process checks that the data is valid and import the data.
This is the result after pressing Process.
And one of the products imported:
Quick review the java class that implements this new process
The sample import process used in this post is SampleProductsProcess and is included in the module Initial Data Load for Java and you can use it as a foundation for the new processes you want to create. Here I will explain the main parts of this java class.
All classes that use Initial Data Load for Java to implement a new import process must extend the java class IdlServiceJava.
public class SampleProductsProcess extends IdlServiceJava {
The sample import process used in this post is SampleProductsProcess and is included in the module Initial Data Load for Java and you can use it as a foundation for the new processes you want to create. Here I will explain the main parts of this java class.
All classes that use Initial Data Load for Java to implement a new import process must extend the java class IdlServiceJava.
public class SampleProductsProcess extends IdlServiceJava {
...
Implemeting this class you must override the following methods: getEntityName() that returns the name of the process:
Implemeting this class you must override the following methods: getEntityName() that returns the name of the process:
@Override
public String getEntityName() {
return "Sample Products";
}
getParameters(), that returns an array with the definition of the fields that will be used in this process. Each parameter basically consist in a field name and a data type:
@Override
public Parameter[] getParameters() {
return new Parameter[] {
new Parameter("Organization", Parameter.STRING),
new Parameter("SearchKey", Parameter.STRING),
new Parameter("Name", Parameter.STRING),
...
validateProcess() that validates the integrity of each record in the CSV file. For this task Initial Data Load provides the utility class Validator that has several test methods to check the data integrity:
@Override
protected Object[] validateProcess(Validator validator, String... values) throws Exception {
validator.checkOrganization(values[0]);
validator.checkNotNull(validator.checkString(values[1], 40), "SearchKey");
validator.checkNotNull(validator.checkString(values[2], 60), "Name");
validateProcess() that validates the integrity of each record in the CSV file. For this task Initial Data Load provides the utility class Validator that has several test methods to check the data integrity:
@Override
protected Object[] validateProcess(Validator validator, String... values) throws Exception {
validator.checkOrganization(values[0]);
validator.checkNotNull(validator.checkString(values[1], 40), "SearchKey");
validator.checkNotNull(validator.checkString(values[2], 60), "Name");
...
And internalProcess() that actually imports the data. The recommended way to create Openbravo business objects and store it in the database is the Openbravo Data Access Layer (DAL) that provides an interface to all the Openbravo Business Objects and logic.
@Override
public BaseOBObject internalProcess(Object... values) throws Exception {
And internalProcess() that actually imports the data. The recommended way to create Openbravo business objects and store it in the database is the Openbravo Data Access Layer (DAL) that provides an interface to all the Openbravo Business Objects and logic.
@Override
public BaseOBObject internalProcess(Object... values) throws Exception {
...
If you want an example of a module using Initial Data Load for Java, have a look at the project Initial Data Load extension for invoices. A module that implements a new data import process that allows to import invoices using Initial Data Load.