Openbiz Configuration Guide

Eclipse Editor

Developers can use any XML editor to edit metadata files or they can use Openbiz's Eclipse Plug-in.  The latter is recommended to be used by new OB users or by anyone when rapidly design and configuring a new application. Please refer to Openbiz Eclipse plug-in designer manual.

Organize metadata by package

In a big application, user may need to build lots of objects, therefore they might have a big metadata file list. Meta files under a single directory can be difficult to manage.  From openbiz 1.1, metadata files can be organized by package name. Bear in mind, metadata package is different with the (BizObj, BizView ...) packages which are the code units. Metadata package is a naming system, different package maps to different directory. It is like the package concept used in Java. 

PackageX.PackageY.metaA.xml refers to the metaA.xml under META_PATH/PackageA/PackageB directory. Where META_PATH is the root metadata directory. This setting is defined in sysheader.inc and app.inc. 

How to configure  package in metadata files?

Let's explain it with the demo example. After you unzip the source, find the demo directory under metadata directory. Open FMRegist.xml file with a text editor. You'll see a Package="demo" attribute in the BizForm element. This attribute is to say the default package of any type of openbiz object is under "demo" package. Here the openbiz objects refer to the following object types.

Object Type Referred as attributes in metadata files
BizObj BizForm[BizObj]
BizObj->BizFieldList->BizField[SelectBizObj]
BizForm BizView->ControlList->Control[Form]
BizView->ControlList->Control[SubCtrl]
BizForm->BizCtrlList->BizCtrl[SelectFrom]
BizView  
BizPopup BizForm->BizCtrlList->BizCtrl[SelectBizForm]
BizFormTree Same as BizForm

If an object name doesn't contain dot symbol ("."), the system uses the package attribute defined in the object root element as its package. Otherwise, if an object name has format as aaa.objectname, the system thinks such object under package "aaa" and will locate such object under aaa directory.

Go back to the example, you can find

<BizForm Name="FMRegist" Package="demo" ... BizObj="BORegist"...>
...
<BizCtrl Name="reg_attdln" ...  SelectBizForm="AttendeePopup"...>
<BizCtrl Name="reg_fee" ... SelectFrom="Selection(Fee)"...>

They all use default package, so the system will try to locate the metadata files as demo/BORegist.xml, demo/AttendeePopup.xml and demo/Selection.xml.

If you want to refer to an object under another package, just add the package name as the prefix of the object name. Notice, there're a Selection.xml under /demo directory and another Selection.xml under /design directory, they belong to different packages. In FMRegist, whose package is "demo", you can use <BizCtrl ...  SelectFrom="design.Selection(Mode)" ...> to configure a comboBox whose values are from the "Mode" element of "design/Selection.xml".

You cannot refer to an object in different a application. But you can refer to any object in openbiz core application. For example, the core application has references to objects under metadata/shared/ directory. Openbiz tries to locate objects in same application and then in core application. If no object is found, it reports an error.

Use object metadata inheritance

If you have a complex application, you want to reuse the existing object to different places, but you want the object behave a little differently in different scenarios. Object inheritance will help with this frequent problem. Since objects map to metadata files in OB, object inheritance becomes metadata file inheritance.

How to specify inheritance between metadata files?

Specify an object attribute, InheritFrom = "parent object name". For example, in demo application, BOEventX has
<BizObj Name="BOEventX" Description="Event BizObj Extended from BOEvent" Package="demo" Class="BizObj" InheritFrom="demo.BOEvent"...>
This indicates that is BOEventX is inherited from BOEvent. 

Metadata file inheritance is similar with class inheritance in programming languages, child objects can inherit parent object settings.  OB will use the child object attributes where they conflict with parent object attributes.

Object Type which can has inheritance What CAN be inherited or overridden What CANNOT be inherited - must be specified in child metadata file
BizObj Object Attributes: Description, DBName, Table, SearchRule, SortRule, OtherSQLRule, CacheMode

Object BizFieldList: BizField

Object Attributes: Name, Package, Class, InheritFrom
BizForm Object Attributes: Description, jsClass, Title, BizObj, PageSize, Width, Height, SearchRule

Object BizCtrlList: BizCtrl
Object DisplayModes: Mode
Object Toolbar: Control
Object Navbar: Control

Object Attributes: Name, Package, Class, InheritFrom

Simple Expression Language

In order to add flexibility to metadata configuration, Openbiz accepts simple expressions in metadata files. If a statement has {expr} pattern, the expression is evaluated and used by the metadata config file.   Expression can be used in a number of ways including:

  • A single PHP statement which returns a value. ie {Date()}
  • Reference registered services such as the Validate service.  ie. {@validate:email('[Email]')}
  • Reference OB object variables ie. {@:Control[attd_fname].Value}
  • Simple expression language also allow developers to use any global variables supported by PHP. Please read http://us2.php.net/manual/en/reserved.variables.php for details

Because it's a simple expression language, users should put more complicated logic in an associated object.  Developers can also extend property support by modifying/overriding GetProperty() method. The input of GetProperty() can be either "property_name" or "*[child_name]" or something new supported by customer code.

Where To Use Expressions

  • BizDataObj
    SearchRule, SortRule, OtherSQLRule, AccessRule, UpdateCondition, DeleteCondition. These attributes are query related attributes of BizDataObj element, [field_name] is not evaluated to field value. [field_name] is the syntax of query lanaguage, it will be replaced by table column name. Please see Query Language in BizDataObj for details.
  • BizDataObj.BizFied
    Required, Validator, Value, DefaultValue 
  • BizForm
    Link, Style, Hidden, Enabled, SelectFrom
  • BizForm.EventHandler
    Function, PostAction

Literal Support

The simple expression language defines the following literals:

  • Boolean: true and false
  • Integer: as in PHP
  • Floating point: as in PHP
  • String: with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \\.
  • Null: null

Operator Support

The simple expression language provides the following operators:

  • Arithmetic: +, - (binary), *, / and div, % and mod, - (unary)
  • Logical: and, &&, or, ||, not, !
  • Relational: ==, !=, <, >, <=, >=.  Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
  • Conditional: A ? B : C. Evaluate B or C, depending on the result of the evaluation of A. 

Variable Support

Simple expression allows developers to use variables of openbiz metadata objects:

  • <BizDataObj SearchRule="[Start]>'date(\"Y-m-d\")'">
  • <BizDataObj AccessRule="[OwnerId]='{@profile:USERID}'">
  • <BizDataObj UpdateCondition="[OrgId]=={@profile:ORGID}">
  • <BizDataObj DeleteCondition="'admin'=={@profile:ROLEID}">
  • <BizField Name="NeedApprove" Required="{[Amount]>1500}"/>
  • <BizField Name="Fee" Validator="{[Fee]>=15}"/>
  • <BizField Name="FullName" Value="{[LastName]}, {@:Field[FirstName].Value}"/>

The following table describes variable support in more detail.

Syntax to get metadata object variables Meaning Implementation Sample usage
@object_name:property_name get the given property of the given object. Call object->GetProperty ($propname) @BOEvent:Name
@FMEvent:Title
@object_name:*[child_name].property_name get the given property of the given object's child element Call object->GetProperty ($propname), where $propname="*[child_name]", to get the child object. 
Then call child_object->GetProperty($propname)
@BOEvent:Field[Id].Value
@FMEvent:Control[evt_id].Value
@:property_name or 
@this:property_name
get the given property of this object ("this" object is the object defined in the metadata file) Call this->GetProperty ($propname) In BOEvent, @:Name or @this:Name means getting the "Name" property of BOEvent.
@:*[child_name].property_name or
@this:*[child_name].property_name
get the given property of this object's child element Call this->GetProperty ($propname), where $propname="*[child_name]", to get the child object. 
Then call child_object->GetProperty($propname)
In BOEvent, @:Field[Id].Value or @this:Field[Id].Value means getting the "Id" field value of BOEvent.
[field_name] get the value of a given BizField of this BizDataObj. 
It is evaluated to field value only if it is used in BizField element
Call object->GetProperty ($field_name) to get the child BizField object. 
Then call field_object->GetProperty("Value")
In BOEvent, [Id] means getting the "Id" field value of BOEvent.
@object_name:param[param_name] or
@:param[param_name]
get the given parameter's value of this object Call object->GetProperty ($propname), where $propname="param[param_name]" @:param[Evt_Id]
@profile:property_name get the user profile property.  User profile is provided with ProfileService. @profile:ROLEID

 

Functions

Developers can invoke any PHP functions in simple expression. A user defined functions can be invoked if the file that contains such function is included. For example, if the metadata object A is based on a customer class, the class file is A.php that includes another A_help.inc. In this case, you can invoke functions defined in A_help.inc in simple expression.

 NEED EXAMPLE