Tutorial 21 - Binding Reference Table
Tutorial 21 - Binding Reference Table
21 - Binding Reference
Table
Table of contents
OBJECTIVE ................................................................................................................. 4
1. SHARED PART ................................................................................................... 6
1.1. DECLARING THE CONSTANTS........................................................................... 6
1.2. DEFINING THE REFERENCE MODEL .................................................................. 6
1.3. DEFINING THE CLIENT BUSINESS RULE ............................................................ 7
2. CLIENT PART..................................................................................................... 8
2.1. ASSOCIATING THE REFERENCE MODEL TO A VISUAL CONTROL ........................ 8
3. DEFINING A LOOKUP FORMAT................................................................... 9
4. SERVER PART.................................................................................................. 10
4.1. ADDING THE REFERENCE DATA LOADING’S BUSINESS LOGIC ......................... 10
4.2. MODIFICATION OF THE TABLE CONNECTOR ................................................... 10
5. LOOKUP REFERENCE VISUALIZATION ................................................. 11
6. PROPERTIES FILES........................................................................................ 12
6.1. DATABASE DECLARATION ............................................................................. 12
6.2. BUSINESS UNIT .............................................................................................. 15
6.3. BINDER.......................................................................................................... 15
6.4. DOCUMENT LIBRARY ..................................................................................... 16
6.5. MODULE PROPERTIES FILES ........................................................................... 17
6.5.1. un.asytutorialAdv.properties ................................................................... 17
6.5.2. Un.asytutorialAdv.tutorial21.properties ................................................. 17
Figures
FIGURE1 - THIS IS AN EXAMPLE OF FIGURE........................................................................... 3
FIGURE2 - JOB REFERENCE TAB (TUTORIA20 MODULE)........................................................ 5
FIGURE3 - JOB_COD LOOKUP FORMAT ............................................................................ 11
FIGURE4 - JOB_DSC LOOKUP FORMAT ............................................................................. 11
Source code
SOURCE 1 - THIS IS AN EXAMPLE OF SOURCE CODE ................................................................ 3
SOURCE 2 - DECLARING THE CONSTANTS WITHIN THE C_TUTORIAL21 CLASS ....................... 6
SOURCE 3 - DEFINING THE REFERENCE MODEL WITHIN THE D_RADICAL CLASS .................... 6
SOURCE 4 - DEFINING THE CLIENT BUSINESS RULE IN D_ TUTORIAL21 FILE ........................ 7
SOURCE 5 - DEFINING THE CLIENT BUSINESS RULE IN R_REF_JOB FILE ............................... 7
SOURCE 6 - ASSOCIATING THE REFERENCE MODEL TO A VISUAL CONTROL IN
VP_TUTORIAL21 FILE ......................................................................................................... 8
SOURCE 7 - LOOKUP FORMAT DEFINITION PROPERTIES FILE ................................................... 9
SOURCE 8 - ALIASES RESOLUTION .......................................................................................... 9
SOURCE 9 - ADDING A SERVER BUSINESS RULE FOR LOADING REFERENCE DATA IN
S_TUTORIAL21 FILE .......................................................................................................... 10
SOURCE 10 - MODIFICATION OF THE TABLE CONNECTOR ...................................................... 10
SOURCE 11 - INSTALL_SRC.XML DATABASE DECLARATION ................................................... 12
SOURCE 12 - ASYTUTORIALADV_CREATE.XML FILE .............................................................. 13
SOURCE 13 - ASYTUTORIALADV_INSERT.XML FILE ................................................................ 14
SOURCE 14 - PROP.XML MODIFICATIONS ................................................................................ 14
SOURCE 15 - BUSINESS UNIT DECLARATION IN THE INSTALL_SRC.XML FILE .......................... 15
SOURCE 16 - BINDER DECLARATION IN THE INSTALL_SRC.XML FILE ...................................... 16
SOURCE 17 - SHORTCUT DECLARATION IN THE INSTALL_SRC.XML FILE ................................. 16
SOURCE 18 - UN.ASYTUTORIALADV.PROPERTIES ................................................................... 17
SOURCE 19 - UN.ASYTUTORIALADV.TUTORIAL21.PROPERTIES .............................................. 17
Keyword Definition
Source 1 -
This is an example
of source code Source code.
Objective
Presented notions
Reference Model
Client Business Rule
Lookup Format
LookupFormat.properties
Tutorial21.properties
This tutorial explains the way to use a reference table throw a simple example, it is based on
Tutorial 8 and so conserved all its functionalities.
This example consists in indicating the job of a person in the identity form using two combo
boxes (one for the job code, the other for the job full name)
The list of jobs is retrieved from a job reference table (This reference table is issued from the
tutorial Tutorial 20).
1. Shared Part
Source 2 -
Declaring the public interface C_Tutorial21 {
constants within …
the C_Tutorial21 // Visual middle events
class public static final int JOB_LOAD= KernelEvent.INTERNAL_EVENTS_MAX + 16;
…
// Data Model
//Segment JOB
public static final String JOB = "JOB";
// Job Code
public static final String JBC = "JBC";
// Job Description
public static final String JBD = "JBD";
…
// Reference Tables
// Job Reference Table
public static final String JOB_TAB = "JOB_TAB";
…
}
Source 3 -
public class D_Tutorial21 extends KDocument implements C_Tutorial21 {
Defining the ….
reference model public void define_DataModel() {
within the …
D_Radical class // Job
DataSet job = seg(JOB);
job.add(JBC);
job.add(JBD);
}
ds(JOB).de(JBC).setHumanName(lng("Job code"));
ds(JOB).de(JBD).setHumanName(lng("Job description"));
}
…
public void define_ReferenceModel() {
define_Ref(JOB_TAB);
}
…
Source 4 -
Defining the Client public class D_Tutorial21 extends KDocument implements C_Tutorial21 {
Business Rule in ….
D_ Tutorial21 file
public void define_ClientBusinessRule() {
…
ds(JOB).addRule(
new R_Ref_job(ref(JOB_TAB),
ds(JOB).de(JBC),
ds(JOB).de(JBD),
"JOB_COD",
"JOB_DSC",
"Error"),
DATA_VERIFY);
}
}
This class defined the Meta rule used in the D_Tutorial21 Class; it permits to match
together the data fields passed as parameter in the constructor of the class.
Source 5 -
Defining the Client package un.asytutorialAdv.tutorial21;
Business Rule in
R_Ref_job file import so.kernel.core.DataField;
import so.kernel.core.DefaultReferenceModel;
import so.kernel.core.MetaRule;
import so.kernel.core.Rule;
import so.kernel.core.rules.KR_ReferenceConnectorAdvanced;
add(r_NameId);
}
}
2. Client Part
ds(JOB).de(JBC) and ds(JOB).de(JBD) are the data elements associated with the
visual control
RefJob and Job are the alias for the format of the lookup
Source 6 -
Associating the public class VP_Tutorial21IDE extends ElfVisualPage implements C_Tutorial21 {
reference model to ….
a visual control in // Declare Visual controls
VP_Tutorial21 file …
transient private ElfField fcx_JobCod = elfFieldPool.getKComboBox();
transient private ElfField fcx_JobDsc = elfFieldPool.getKComboBox();
// Label
…
add(20, 250, 80, 20, lng("Job"));
…
Source 7 -
Lookup format #TAB_JOB
definition #Job Reference Table
properties file #in the first field we display the code and description when selected
RefJob=JOB_COD 75; JOB_DSC 200;
RefJob.name=Job Reference, Job Label
Source 8 -
aliases resolution un.asycudaAdv.tutorial21.server.S_Tutorial21#JOB_TAB=JOB_TAB
RefJob lookup is applied on the Fcx_JobCod visual control; it will display JOB_COD field,
75 pixels width and JOB_DSC field, 200 pixels width.
RefJob lookup is applied on the Fcx_JobDsc visual control; it will display JOB_DSC field,
200 pixels width.
4. Server Part
The server side is the part that will finally be loading the reference data source from the
database. Therefore, rules and events managing the access to the reference data source are
defined within the S_Tutorial21 class:
Source 9 -
Adding a server public class S_Tutorial21 extends GCFServerBinder implements C_Tutorial21 {
business rule for ……
loading reference
data in public void defineBinder() {
…
S_Tutorial21 file //Job reference table
addServerRule(new ReferenceServerRule(this, new int[] { JOB_LOAD }, JOB_TAB));
…
private void addReferenceModelEvents(AbstractOperation abstractOperation) {
//Add events for reference table
abstractOperation.addEventID(JOB_LOAD,JOB_TAB);
}
…
}
6. Properties files
We have to prepare all configuration files.
Source 11 -
Install_src.xml …..
database </copy>
declaration
<!--
Properties for DB.
-->
<db manager="${gcf.drv_manager}" url="${gcf.url}" user="${gcf.user_name}"
password="${gcf.password}">
<GCF>
<table type="History" name="un_asytutorialAdv_History"/>
<table type="IED" name="un_asytutorialAdv_IED"/>
<table type="Locks" name="un_asytutorialAdv_Locks"/>
<table type="Track" name="un_asytutorialAdv_Track"/>
</GCF>
<appserver dbsource="jdbc/un.asytutorialAdv.gcf"
name="un.asytutorialAdv.gcf">
<pool minPoolSize="1" maxPoolSize="-1" maxIdleTime="5"/>
</appserver>
</db>
…
<!--
Import into Kernel DB
-->
<system>
……
Notice that we declare two files used for database automatic installation.
• asytutorialAdv_create.xml for the automatic creation of the tables in the
database.
• asytutorialAdv_insert.xml for the automatic insertion of records in the
tables.
These files are located in:
un\asytutorialAdv\server\src\un\asytutorialAdv\server\som\db
Source 12 -
asytutorialAdv_cre <create>
ate.xml file <table name="refjob">
<column name="JOB_COD" type="VARCHAR"/>
<column name="JOB_DSC" type="VARCHAR"/>
</table>
<table name="TUTORIAL_PERSON_TAB">
<column name="INSTANCE_ID" type="INTEGER" null="false"/>
<column name="IDE_FNA" type="VARCHAR" size="35"/>
<column name="IDE_LNA" type="VARCHAR" size="35"/>
<column name="IDE_BDA" type="TIMESTAMP"/>
<column name="IDE_PIC" type="LONGVARBINARY"/>
<column name="IDE_SEX" type="INTEGER"/>
<column name="COO_ADR" type="VARCHAR" size="50"/>
<column name="COO_CPO" type="VARCHAR" size="6"/>
<column name="COO_TEL" type="VARCHAR" size="20"/>
<column name="COO_CIT" type="VARCHAR" size="25"/>
<column name="USR_LOG" type="VARCHAR" size="20"/>
<column name="USR_PWD" type="VARCHAR" size="20"/>
<column name="JOB_JBC" type="VARCHAR"/>
<column name="JOB_JBD" type="VARCHAR"/>
<column name="CJT_INSTANCE_ID" type="INTEGER"/>
<primary_key>
<column name= "INSTANCE_ID"/>
</primary_key>
</table>
<table name="TUTORIAL_CHILD_TAB">
<column name="INSTANCE_ID" type="INTEGER" null="false"/>
</create>
Source 13 -
asytutorialAdv_inse <?xml version="1.0" encoding="UTF-8"?>
rt.xml file <!DOCTYPE insert SYSTEM "http://strategyobject.com/dtd/insert.dtd">
<insert>
<table name="refjob">
<row>
<column name="JOB_COD">FIN</column>
<column name="JOB_DSC">Accounting/Finance</column>
</row>
<row>
<column name="JOB_COD">ADV</column>
<column name="JOB_DSC">Advertising/Public Relations</column>
</row>
<row>
<column name="JOB_COD">ART</column>
<column name="JOB_DSC">Arts/Entertainment/Publishing</column>
</row>
<row>
<column name="JOB_COD">BAM</column>
<column name="JOB_DSC">Banking/Mortgage</column>
</row>
<row>
<column name="JOB_COD">ADM</column>
<column name="JOB_DSC">Clerical/Administrative</column>
</row>
…
<row>
<column name="JOB_COD">OTH</column>
<column name="JOB_DSC">Other</column>
</row>
</table>
</insert>
Source 14 -
Prop.xml <properties>
modifications
<group type="connection">
<property name="gcf.drv_manager" from="driver" />
<property name="gcf.url" from="url" default="asytutorialAdvGCF.mod" />
<property name="gcf.user_name" from="user" />
<property name="gcf.password" from="password" />
<description><![CDATA[Connection to database Module asytutorialAdvGCF is
required.This database is available. You can create new or use the same database.
Then enter connection properties in this form.]]></description>
</group>
<group type="connection">
<property name="un.asytutorialAdv.drv_manager" from="driver"/>
<property name="un.asytutorialAdv.url" from="url" default="asytutorialAdv.mod"/>
<property name="un.asytutorialAdv.user_name" from="user"/>
<property name="un.asytutorialAdv.password" from="password"/>
<description><![CDATA[Connection to database Module asytutorialAdv is required.
This database is available. You can create new or use the same database.
Then enter connection properties in this form.]]></description>
</group>
</properties>
Source 15 -
business unit
declaration in the <BU name="BUasytutorialAdv">Advanced tutorial</BU>
install_src.xml file
The Business Units on a document could be defined manually filling this file or using the
ASYCUDA client application. The defined Business Units will be added automatically in
ASYCUDA environment with the appropriated rights if they are defined in the
install_src.xml file.
6.3. Binder
Binder is usually situated after business unit definition within <system> XML tags.
Source 16 -
Binder declaration <BU name="BUasytutorialAdv">Advanced tutorial </BU>
in the
install_src.xml file <binder name="B_TUTORIAL20" status="">
…
<binder name="B_TUTORIAL21" status="">
<field name="server" value="un.asytutorialAdv.tutorial21.server.S_Tutorial21"/>
<field name="dom" value="un.asytutorialAdv.tutorial21.D_Tutorial21"/>
<field name="client" alue="un.asytutorialAdv.tutorial21.client.DC_Tutorial21"/>
<access bu="BUasytutorialAdv">
<full/>
</access>
</binder>
Source 17 -
Shortcut …
declaration in the <DL>
install_src.xml file <folder name="Tutorial ADV" icon="">
…
<item name="Tutorial21 - Binding reference table " icon="">
<field name="binder" value="B_TUTORIAL21"/>
<field name="skin" value="un.asytutorialAdv.tutorial21.client.VD_Tutorial21"/>
<access bu="BUasytutorialAdv">
<full/>
</access>
</item>
</folder>
</DL>
…
6.5.1. un.asytutorialAdv.properties
This file is common to all the reference tables of the module.
We have to include lines for GCF management database and the new properties file
for Tutorial 21.
Source 18 -
un.asytutorialAdv.p …
roperties @include un.asytutorialAdv.tutorial21.properties
module.un.asytutorialAdv.gcf.url=$[un.asytutorialAdv.gcf_URL]
module.un.asytutorialAdv.gcf.user=$[un.asytutorialAdv.gcf_User]
module.un.asytutorialAdv.gcf.password=$[un.asytutorialAdv.gcf_Password]
module.un.asytutorialAdv.gcf.tables.ied=un_asytutorialAdv_IED
module.un.asytutorialAdv.gcf.tables.history=un_asytutorialAdv_History
module.un.asytutorialAdv.gcf.tables.locks=un_asytutorialAdv_Locks
module.un.asytutorialAdv.gcf.tables.track=un_asytutorialAdv_Track
6.5.2. Un.asytutorialAdv.tutorial21.properties
Define the aliases for the database connection of the module in a new file:
un.asytutorialAdv.tutorial21.properties.
These aliases will be used in the database.properties file.
Source 19 -
un.asytutorialAdv.t
utorial21.properties un.asytutorialAdv.tutorial21.server.S_Tutorial21#TUTORIAL_PERSON_DataBaseURL=$[un
.asytutorialAdv_URL]
un.asytutorialAdv.tutorial21.server.S_Tutorial21#TUTORIAL_PERSON_DataBaseUser=$[un
.asytutorialAdv_User]
un.asytutorialAdv.tutorial21.server.S_Tutorial21#TUTORIAL_PERSON_DataBasePassword
=$[un.asytutorialAdv_Password]
un.asytutorialAdv.tutorial21.server.S_Tutorial21#TUTORIAL_PERSON_TAB=TUTORIAL_P
ERSON_TAB
un.asytutorialAdv.tutorial21.server.S_Tutorial21#TUTORIAL_CHILD_TAB=TUTORIAL_CHI
LD_TAB
un.asytutorialAdv.tutorial21.server.S_Tutorial21$attached_finder#CONJOINT=un.asytutorial
Adv B_TUTORIAL21
un.asytutorialAdv.tutorial21.server.S_Tutorial21$attached_finder#LNA=IDE.LNA
un.asytutorialAdv.tutorial21.server.S_Tutorial21#JOB_TAB=JOB_TAB
Now you can compile and deploy your module with Ant tools.