Openbiz 2.x Architecture

 

Openbiz 2.x architecture

Openbiz 2.x is a metadata-driven framework. All openbiz objects are declared in their own metadata files. Openbiz 2.x architecture follows the Model-View-Controller (MVC) design pattern, it also implements basic Object/Relational Mapping (ORM) to reduce the time you spend coding CRUD operations.

 

Metadata-driver framework

Openbiz is XML metadata-driven framework, which means openbiz objects are constructed based on metadata files containing pre-defined attributes. Building an Openbiz application means creating metadata files that are read by Openbiz to produce functional web pages. Due to the self-expanatory nature of XML, the application is easy to maintain and extend.

The diagram below shows metadata based objects in Openbiz framework. These objects cover most functional needs of web application development.

The main XML files used in an Openbiz application are BizView, BizForm and BizDataObj.  Let's take a moment to briefly describe each before getting into their role with the MVC model. 

A BizDataObj represents a series of records from one or more tables in your database.  It contains XML attributes that are used to create basic CRUD functions in your application.  Information like the columns that should be included in the Object as well as what tables to join to the object.

A BizForm describes how a BizDataObj is to be displayed.  This includes the actual data columns and rows as well as what CRUD operations are available to the end users.

A BizView groups one or more BizForm onto a single web page.  BizViews also provide rules for how BizForms should be displayed.  Ie. Together on one page or in a Wizard format.

Openbiz's implementation of MVC

One of the key advantages of Openbiz is that it is a framework that follows the Model-View-Controller (MVC) design pattern. This makes Openbiz applications much more manageable because the presentation code (View) is cleanly separated from the application data and logic (Model). All user interactions with the application are handled by a front-end controller.

Comparing Openbiz MVC design with existing MVC frameworks as JSF and Struts shows that Openbiz is more similar to JSF because both share a component based architecture. Openbiz's View layer comprises components of BizView, BizForm and ojects within a BizForm. These components are accessible during request processing. Many developers prefer JSF over struts.  Here are the Top Ten Reasons to Prefer JSF over Struts as well a table showing how Openbiz provides similar advantages.

JSF's advantages 
over Struts
Openbiz implementation
Components BizView and BizForm as persistent UI objects 
Render Kits Associate different templates to UI objects
Renderers Customer class to implement Render() method
Value Binding Support static and dynamic value bindings
Event Model Associate client event to server function
Extensibility Developers can link their own class to openbiz object
other four .... Not applicable

Openbiz's implementation of persistent object and ORM

Similar with the popular Hibernate approach, Openbiz uses sessions to maintain the persistency of objects. Unlike J2EE web containers who have objects pools in memory, PHP objects are be constructed and released for each request (this is called share-nothing architecture). To keep the persistency of objects (BizDataObj, BizForm ...) Openbiz saves a set of states in session, then reconstructs the object with these same states. Also to avoid multiple object instances of same class in the same session, Openbiz uses an ObjectFactory class to protect from duplications.

Openbiz implements the necessary object/relational mapping (ORM) features to allow BizDataObj to represent the data and relationships of database tables. The following table list the features of Openbiz ORM.

Flexible mapping table-per-class, N table to 1 class
Many to one, one to many, many to many, one to one
Query facilities SQL like query language - supports SQL functions and operators, supports SQL aggregate functions, supports group by, having and order by
Metadata facilities XML metadata describes the mapping

Openbiz security model

Openbiz supports web security in three ways - user authentication, view access control and data access control. Openbiz mainly uses plugin services to control security. This implementation allows customers to implement their own logic within these services. This subject will get a full treatment  in the developer guide - Implement authentication, view and data access control.

Basic user authentication flow:

View access control flow:

Security concept Openbiz implementation with plugin services
User authentication Openbiz uses an authentication service (bin/service/authService.php) to authenticate username and password
Role-based view access control  Openbiz uses a profile service (bin/service/profileService.php) to get a user's profile that includes one or more "role" entries. 
These roles are run against the access service (bin/service/accessService.php) to determine the users' accessibility to the view.
Attribute-based data access control Openbiz uses a profile service (bin/service/profileService.php) to get a user's profile that includes their attributes.
These attributes are run again s a BizDataObj's rules to determine if the user has permission to browse/update/delete a data record.

Openbiz 2.0 package organization

OpenBiz simplifies small to medium applications by using the following multi-layer architecture.

Usually a business application can be boiled down to three layers namely a Data layer, Business Logic layer and Presentation layer. In OpenBiz architecture, these 3 layers map to several packages. The Presentation layer is implemented by the BizView package and GUI layers which is implemented by the jbForm javascript package. Business Logic layer is implemented by the BizDataObj package. Openbiz uses the Zend Framework, which is based ond PDO, to make SQL queries.  Finally, a Plugin service provides functional service components that can be invoked by both the presentation and data layer.

Package Class
BizSystem BizSystem
- Provide a global variable accessed anywhere in openbiz application
- Provide the Get method for ObjectFactory, SessionContext, TypeManager, ClientProxy and Configuration
- Provide static methods for accessing XML metadata, logging and error reporting.
ObjectFactory 
- It's a factory class to get metadata-driven objects (BizView, BizForm, BizdataObj and their extended classes) 
SessionContext
- Session management class that has additional methods to save/get session variables of metadata-driven stateful objects through their GetSessionVars|SetSessionVars interfaces
TypeManager
- Type management class that has help methods to format data to UI and unformat UI input to data
ClientProxy
- It's a class that is treated as the bi-direction proxy of client. Through this class, others can get client form inputs, redraw client form or call client javascript functions.
Configuration
- A class that has help methods to get data from config.xml
BizDataObj BizDataObj
- It's the base class of all data object classes. Before Openbiz 1.2, BizDataObj was called BizObj. Since BizObj means Business Object, but it acts as business data unit, in 1.2 it is changed as BizDataObj.
BizRecord
- BizRecord class implements basic function of handling record
BizField
- BizField is the class of a logic field which mapps to a table column
BizDataSql
- BizObjSql is the class to construct SQL statement for BizDataObj
CacheRecordList
- CacheRecordList implements the cache for BizDataObj
ObjRefernces
- ObjReferences contains a list of BizDataObj whose relationship to this object is defined in the ObjReference
TableJoins
- Table Joins contains a list of table joins to the main table of this object
BizView BizView
- BizView is the class that contains list of forms. View is same as html page.
BizForm
- BizForm is the base class that contains UI controls. BizForm is a html form that is included in a BizView which is a html page.
RecordRow
- RecordRow is the class that contains FieldControls
ToolBar
- ToolBar is the class that contains HTMLControls
NavBar
- NavBar is the class that contains navigation buttons
HTMLControl
- HTMLControl is the base class of HTML controls
FieldControl
- FieldControl is the base class of field control who binds with a bizfield
DisplayMode
- contains the BizForm display mode information
jbForm  jbForm (javascript bizForm) 
- the base class that handles RPC function call and callback
PDO Database access is abstracted out through the the Zend Framework and the underlying PDO library. 

Class diagram of multi-layer architecture

Sequence diagram of a typical RPC call

Openbiz client browser communicates with server through AJAX JS-based RPC invocation.