Difference between revisions of "Creating New Data Import Window"

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
(Create User Interface)
m (Overview)
Line 4: Line 4:
 
In ADempeire, there is a great way of importing data into the system using the existing Data Import module. You can read about how the Data Import works from [[Data Import]]. The great thing is that, we can always do validation to our data before the data transfer really take place.
 
In ADempeire, there is a great way of importing data into the system using the existing Data Import module. You can read about how the Data Import works from [[Data Import]]. The great thing is that, we can always do validation to our data before the data transfer really take place.
  
'''''The data import process has two main steps. Data is read into the system and placed in a temporary table. From there it is processed and entered into the main database. The two step process helps prevent errors in the data from affecting the main database. The first step of importing the data requires a: definition of the data file that will be imported and information about where to put it in the temporary tables. This is performed by an Import File Loader and an Import Loader Format.'''''
+
''The data import process has two main steps. Data is read into the system and placed in a temporary table. From there it is processed and entered into the main database. The two step process helps prevent errors in the data from affecting the main database. The first step of importing the data requires a: definition of the data file that will be imported and information about where to put it in the temporary tables. This is performed by an Import File Loader and an Import Loader Format.''
  
 
The only shortcoming is that, the Data Import Window available for standard version only cover some of the main data, i.e., Product, BPartner, etc. and not all data we want to import can be imported. In many case, we will want to customize our own data validation. This page will give the steps by steps on how to create a new Data Import Window.
 
The only shortcoming is that, the Data Import Window available for standard version only cover some of the main data, i.e., Product, BPartner, etc. and not all data we want to import can be imported. In many case, we will want to customize our own data validation. This page will give the steps by steps on how to create a new Data Import Window.

Revision as of 00:17, 15 October 2010

This page is under construction --Kittiu 04:42, 12 October 2010 (UTC)

Overview

In ADempeire, there is a great way of importing data into the system using the existing Data Import module. You can read about how the Data Import works from Data Import. The great thing is that, we can always do validation to our data before the data transfer really take place.

The data import process has two main steps. Data is read into the system and placed in a temporary table. From there it is processed and entered into the main database. The two step process helps prevent errors in the data from affecting the main database. The first step of importing the data requires a: definition of the data file that will be imported and information about where to put it in the temporary tables. This is performed by an Import File Loader and an Import Loader Format.

The only shortcoming is that, the Data Import Window available for standard version only cover some of the main data, i.e., Product, BPartner, etc. and not all data we want to import can be imported. In many case, we will want to customize our own data validation. This page will give the steps by steps on how to create a new Data Import Window.

Example Scenario

As an easy example, let's say we have a huge list of Product's attribute values to import into the system. We will be creating a new Import Attribute Value window to do the task. Each window and its field will be pretty much matching with the window we want to import data to.

Import Attribute Value window, to import data to Tab Attribute Values under Attribute window

Note: In real life case, we might design a complex import window that validate data and import into different tables in one go.

Create New Data Import Window

With ADempiere's Application Dictionary framework, creating new Data Import Window is easy.

  1. Create User Interface (Table & Columns, Windows & Fields, Model Calss)
  2. Create Business Logic (Process & Parameters)

Create User Interface

You can look at how to create new window at NewWindow. In our case we are going to do the same thing, except we will use it to create Importing Window.

1) Login as System, go to window "Table and Column"
  • Create new DB Table = "I_AttributeValue"
Create i attribute table.jpg
  • Click on Copy Column from Table and select "M_AttributeValue"
  • New columns will be created as of M_AttributeValue, except that it will has Key Column I_AttributeValue_ID in stead of M_AttributeValue_ID
2) Create more columns for this importing table
  • 5 Mandatory columns: I_ErrorMsg, I_IsImported,Processing, Processed, ID column of target table - in this case, M_AttributeValue_ID -- (1)
  • Optional lookup columns: AttributeName -- (2)
I attrvalue columns.jpg
Note.gif Note:
  1. Additional ID field (i.e., M_AttributeValue_ID) is used to save back the ID of record inserted in target table, use for reference.
  2. The preferred function of using this Import Window is that, user will only supply the Name/Vlaue field, and let the system validate for matching ID field. this is where the optional lookup field come in.
3) Create Import Table in Database
  • On any record in Column Tab, Click on Synchronize Column button.
Note.gif Note:
  • On the first time, as table is not yet crated, it will create new table and all the columns.
  • After this, if we modify it and click this button, it will only modify the current record.
4) Create Interface and Model Classes for new table
  • In your Eclipse project, run GenerateModel class to create Interface and Model for this table. These models will be useful when we refer to data in this table in Business Logic.
  • In our case, we are creating I_I_AttributeValue.java and X_I_AttributeValue.java. Note that our Entity Type is 'RJC', so the arguments are,
C:\<target folder>\
org.compiere.model
'RJC'
'I_AttributeValue'
  • Copy and paste these 2 files under org.compiere.model package.
5) Login as System, go to window "Window, Tab & Field"
  • Create new Window = "Import Attribute Value"
Import attributevalue window.jpg
  • Create new Tab = "Attribute Value". Note that, for ease of use, Data Import window will always have only 1 tab.
  • Refer this tab to table "I_AttributeValue", created previously.
Import attributevalue tab.jpg