Tutorial - 1 - Basic Example
Tutorial - 1 - Basic Example
1 - Basic example
Subject BasicTutorial
Version ADK 244
Issue date 16/07/2005
Beneficiaries Developers
File Tutorial - 1 - Basic example.doc
Status Final
Checked by Asycuda World - Lyon Competence center
Copyrights United Nations Conference on Trade and Development
Developer Guide
Version ADK 244
1 - Basic example
Table of contents
1. MODULE CREATION ....................................................................................... 5
1.1. GLOBAL ARCHITECTURE GENERATION, USING SOMWIZARD............................. 5
2. DOCUMENT CREATION................................................................................ 10
2.1. DEFAULT FILES NEEDED ................................................................................ 10
2.1.1. Shared parts ............................................................................................ 10
2.1.2. Client side................................................................................................ 12
2.1.3. Server side ............................................................................................... 16
3. MODULE CONFIGURATION ........................................................................ 18
3.1. DATABASE CONFIGURATION.......................................................................... 19
3.2. BUSINESS UNIT .............................................................................................. 20
3.3. BINDER.......................................................................................................... 20
3.4. DOCUMENT LIBRARY ..................................................................................... 21
3.5. PROPERTIES FILE ........................................................................................... 22
Figures
FIGURE1 - THIS IS AN EXAMPLE OF FIGURE........................................................................... 3
FIGURE2 - GUI TO OBTAIN ................................................................................................... 4
FIGURE3 - SOM WIZARD FIRST SCREEN ............................................................................... 5
FIGURE4 - LIST OF INSTALLED MODULES.............................................................................. 6
FIGURE5 - CREATION OF A NEW MODULE ............................................................................. 6
FIGURE6 - GENERAL INFORMATION ABOUT THE MODULE..................................................... 7
FIGURE7 - SPECIFIC INFORMATION ABOUT THE MODULE ...................................................... 8
FIGURE8 - DEPENDENCIES BETWEEN MODULES .................................................................... 9
Source code
SOURCE 1 - THIS IS AN EXAMPLE OF SOURCE CODE ................................................................ 3
SOURCE 2 - GLOBAL.PROPERTIES NEW LINES .......................................................................... 9
SOURCE 3 - ADDING GLOBAL CONSTANTS IN THE C_TUTORIAL1 CLASS .............................. 11
SOURCE 4 - DATA MODEL BASIC METHODS IN THE D_TUTORIAL1 CLASS ........................... 11
SOURCE 5 - BUSINESS RULES IN THE DC_TUTORIAL1 CLASS ............................................... 12
SOURCE 6 - VISUAL DOCUMENT DECLARATION IN THE VD_TUTORIAL1 CLASS ................... 12
SOURCE 7 - VISUAL FORM DECLARATION IN THE VF_TUTORIAL1 CLASS............................. 13
SOURCE 8 - VISUAL PAGE DECLARATION IN THE VP_TUTORIAL1 CLASS ............................. 15
SOURCE 9 - S_TUTORIAL1 CLASS ......................................................................................... 16
SOURCE 10 - PROP.XML DATABASE CONNECTION .................................................................. 19
SOURCE 11 - INSTALL_SRC.XML DATABASE DEFINITION ........................................................ 20
SOURCE 12 - BUSINESS UNIT DECLARATION IN THE INSTALL_SRC.XML FILE .......................... 20
SOURCE 13 - BINDER DECLARATION IN THE INSTALL_SRC.XML FILE ...................................... 21
SOURCE 14 - SHORTCUT DECLARATION IN THE INSTALL_SRC.XML FILE ................................. 21
SOURCE 15 - UN.ASYTUTORIAL.PROPERTIES MODIFICATIONS ................................................ 22
Keyword Definition
Source 1 -
This is an example
of source code Source code.
Objective
In this document you will learn
a. How to create the global architecture of a module
b. How to create the default classes of a document
This tutorial will only present basic structure of a module, and all required files. A module
wizard is used to create this architecture.
1. Module creation
On the next screen, the list of installed modules is shown. Don’t select any and press the
next button. The utility will ask for the creation of a new module.
The global information about the module has to be entered on the next screen.
In the next screens, fill the module description and license screen, then the select specific
information screen is displayed.
A module can have dependencies with others. It will be used during the installation. Select
modules if necessary.
Source 2 -
global.properties #Module asytutorial
new lines #Wed May 26 11:30:03 CEST 2004
mod.un.asytutorial.client.jar=${mod.un.asytutorial}/lib/asytutorialc.jar
mod.un.asytutorial.shared.jar=${mod.un.asytutorial}/lib/asytutorial.jar
mod.un.asytutorial.server.jar=${mod.un.asytutorial}/lib/asytutorials.jar
mod.un.asytutorial=${un_dir}/asytutorial
mod.un.asytutorial.dsc=test tutorial
2. Document creation
Presented notions
• Declaration of the minimal variables
• Creation of the Data Model file
• Definition of the Graphical User Interface (GUI)
• Definition of the server side
The starting point is to define all the constants in the C_radical classes. However, in
this example, no Data Model will be implemented. This means that the only necessary
constants to be declared are the ones related to the creation of a new instance of an e-
document. Consequently, only a nil operation called “Null” is going to be created.
Source 3 -
Adding global package un.asytutorial.tutorial1;
constants in the
C_Tutorial1 class import so.kernel.core.*;
// Operation name
public static final String OP_NULL = "Null";
// Operation identificator
public static final int OI_NULL = Operation.INTERNAL_OPERATIONS_MAX+1;
Next step is to define the Data Model class, D_radical. If there is no Data Model,
there is no definition within this class. However, this is the right time to define the
basic methods that will be implemented later for more complex documents.
Source 4 -
Data Model basic package un.asytutorial.tutorial1;
methods in the
D_Tutorial1 class import so.kernel.core.*;
/**
* Document constructor - Sets the document name
*/
public D_Tutorial1() {
super("Document name");
}
/**
* Definition of the Data Model
*/
public void define_DataModel() { }
/**
* Definition of the Finder Model
*/
/**
* Definition of the Reference Model
*/
public void define_ReferenceModel() { }
/**
* Definition of the Client Business Rules
*/
public void define_ClientBusinessRule() { }
}
Source 5 -
Business rules in package un.asytutorial.tutorial1.client;
the DC_Tutorial1
class import un.asytutorial.tutorial1.*;
import so.kernel.client.*;
import so.kernel.core.*;
VD_radical (VD stands for Visual Document) is the single class that contains the
global definition for the visual document. This is where the visual form(s) has / have
to be declared. In our example, there is only one visual form, VF_Tutorial1.
Source 6 -
Visual document package un.asytutorial.tutorial1.client;
declaration in the
VD_Tutorial1 class import so.kernel.client.*;
import un.asytutorial.tutorial1.C_Tutorial1;
/**
* Retrieves a property string in the current working language.
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}
The main form of the document corresponds to the class VF_radical (VF stands for
Visual Form). Every other form of the visual document is defined in a separate class.
The visual page(s) is/are also defined in the main visual form class
(VF_radical.java).
Source 7 -
Visual form package un.asytutorial.tutorial1.client;
declaration in the
VF_Tutorial1 class import so.kernel.client.VisualForm;
/**
* Retrieves a property string in the current working language.
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}
The main page of the main form corresponds to the class VP_radical, (where VP
stands for Visual Page).
Every other page of the visual document is defined in a separate class. This is the class
where all the visual controls are going to be defined.
In our example, there is no visual control, only a title stripe and a label. Furthermore,
as there is not even a connection to the database, there is no facet definition within it.
Source 8 -
Visual page package un.asytutorial.tutorial1.client;
declaration in the
VP_Tutorial1 class import java.awt.Color;
import java.awt.Font;
import so.kernel.client.KVisualPage ;
import so.kernel.client.elf.ElfVisualPage;
import un.asytutorial.tutorial1.C_Tutorial1;
// Label
// syntax: add( X, Y, Width, Height, lng("label caption"));
add(20, 50, 200, 20,lng("This is your first e-Document."));
}
/**
* Retrieves a property string in the current working language.
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}
Source 9 -
S_Tutorial1 class package un.asytutorial.tutorial1.server;
import so.kernel.core.Operation;
import so.kernel.core.Operations;
import so.kernel.server.OperationFactory;
import so.kernel.server.DPP;
import so.kernel.server.GCFServerBinder;
import un.asytutorial.tutorial1.C_Tutorial1;
/**
* Server side class that manages the binding document/database
*/
public class S_Tutorial1 extends GCFServerBinder implements C_Tutorial1 {
The DPP (Document processing path) is very simple : only one operation, and one
state. But it is mandatory to create one, otherwise the operation is not visible.
3. Module configuration
We have to prepare all configuration files.
Source 10 -
Prop.xml database <properties>
connection <group type="connection">
<property name="gcf.drv_manager" from="driver" />
<property name="gcf.url" from="url" default="asytutorialGCF" />
<property name="gcf.user_name" from="user" />
<property name="gcf.password" from="password" />
<description><![CDATA[Connection to database Module asytutorialGCF 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 11 -
install_src.xml <db manager="${gcf.drv_manager}" url="${gcf.url}" user="${gcf.user_name}"
database definition password="${gcf.password}">
<GCF>
<table type="History" name="un_asytutorial_History"/>
<table type="IED" name="un_asytutorial_IED"/>
<table type="Locks" name="un_asytutorial_Locks"/>
<table type="Track" name="un_asytutorial_Track"/>
</GCF>
<appserver dbsource="jdbc/un.asytutorial.gcf" name="un.asytutorial.gcf">
<pool minPoolSize="1" maxPoolSize="-1" maxIdleTime="5"/>
</appserver>
</db>
Business Unit represents a general name for all authorized persons who
have the same claims.
Source 12 -
business unit
declaration in the <BU name="BUasytutorial">tutorial BU</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.
3.3. Binder
Binder is usually situated after business unit definition within <system> XML tags.
Source 13 -
Binder declaration ...
in the <binder name="B_TUTORIAL_1" status="">
install_src.xml file <field name="server" value="un.asytutorial.tutorial1.server.S_Tutorial1"/>
<field name="dom" value="un.asytutorial.tutorial1.D_Tutorial1"/>
<field name="client" value="un.asytutorial.tutorial1.client.DC_Tutorial1"/>
<access bu="BUasytutorial">
<full/>
</access>
</binder>
…
Source 14 -
Shortcut
declaration in the …
install_src.xml file <DL>
<folder name="Basic Tutorials" icon="">
<access bu="BUasytutorial">
<full/>
</access>
<item name="Tutorial 1 : Basic Example" icon="">
<field name="binder" value="B_TUTORIAL_1"/>
<field name="skin" value="un.asytutorial.tutorial1.client.VD_Tutorial1"/>
<access bu="BUasytutorial">
<full/>
</access>
</item>
</folder>
</DL>
…
Source 15 -
Un.asytutorial.prop module.un.asytutorial.gcf.url=$[un.asytutorial.gcf_URL]
erties modifications module.un.asytutorial.gcf.user=$[un.asytutorial.gcf_User]
module.un.asytutorial.gcf.password=$[un.asytutorial.gcf_Password]
module.un.asytutorial.gcf.tables.ied=un_asytutorial_IED
module.un.asytutorial.gcf.tables.history=un_asytutorial_History
module.un.asytutorial.gcf.tables.locks=un_asytutorial_Locks
module.un.asytutorial.gcf.tables.track=un_asytutorial_Track
Now you can compile and deploy your module with Ant tools.