03 June, 2005

My OFBiz Journey

The following my advice, do it first!

  • Read existing documents and wiki
  • OFBiz is a "big" software, the best way to learn it, is to set it up, and try to use it
  • After setting it up, try to use the webtools, it will let you access most of the administrative functions
  • Inside the "applications" directory, the ecommerce application is a web store, which use a lots of OFBiz functionality, by studying this application you can have a more solid understanding about OFBiz, for example, how a HTTP request is processed, and how a view composed, also you can have a taste on how to use the entity engine.

This document record what I have learned when I try to use 'ecommerce' module as a webstore for a chocolate company

Datasource
Use the latest version from subversion repository directly $ svn co http://svn.ofbiz.org/svn/ofbiz/trunk ofbiz-trunk

By default, ofbiz use 'derby' a Java based standalone database, you can change to use other data source. All you have to do is:

  1. Create a database 'ofbiz' (or whatever you want)
  2. Create user 'ofbizUserName' and 'ofbizPassword' and grant the permission appropriately.
  3. Then you can chagne the setting so that ofbiz will use your database.
    The file should be changed is: [ofbiz-trunk/framework/entity/config/entityengine.xml]

For all the delegator element, change the attr. 'datasource-name'. For example, I use MySQL, I will change this attr to 'localmysql'

Why localmysql, because, more detail data source parameter is defined at the lower half that XML config file. The name (or ID) for the MySQL config is 'localmysql'.

Then you should also change the setting for the datasource. So found the 'datasource' element and change the following entry:

  • jdbc-uri
  • jdbc-username
  • jdbc-password

NOTE: The "table-type" attr will make ofbiz generate wrong SQL to create table. So comment it out.
Seed Data

After setting the datasource, it is ready to install the seed data Seed data is a set of basic data will is required for ofbiz to run normally, for example, some UOM, and Geograpical data. To install, you can run $ ant run-install-seed

OFBiz will startup in 'install mode'. In this mode, it will found out all 'seed data' and install (insert) it into the datasource

This seed data is defined in XML file with root element named 'entity-engine-xml'. Each element in the XML correspsond to a ROW in the datasource.

The list of all seed data file is defined in ofbiz-component.xml. Each component in OFBiz will have one such file. It is read by the component loader when OFBiz starting up (as install mode).

For example, under framework/common, ofbiz-component.xml contains these lines: <entity-resource type="data" reader-name="seed" loader="main" location="data/CommonTypeData.xml"/>

Demo data

Demo data is similar to seed data, they are defined in the same way. The differnce are the data is not 'required' by OFBiz operation, rather, they are used as demo. For example, "applications/ecommerce" has provided a set of demo data, if the data is installed, you can see a 'fake' product catalog when you asscess the ecommerce website

Another difference between seed and demo data is, how it is defined inside ofbiz-component.xml; For demo data, the element is look like this: <entity-resource type="data" reader-name="demo" loader="main" location="data/DemoProduct.xml"/> Please note that reader-name is now "demo", but no "seed"

To install all demo data, you can $ java -jar ofbiz.jar install readers=demo

However, if you are now going to 'customize', there is no reason to install the "stock" demo data. You have at least two choice.

Simply remove all those demo data xml or comment out the relevant lines in various ofbiz-component.xml

Other configuration

Under base/config directory, you can found some base configuration. Among the list, the most important files:

  • ofbiz-containers.xml
  • cache.properties
  • debug.properties

The meaning of cache.properties and debug.properties is obvious. For the ofbiz-containers.xml, it is the core config file for OFBiz OFBiz will parse this during normal startup. Inside this file you can found some some definition for various container which is started up by OFBiz at the very first moment.

The most import should be cataline-container (tomcat). You can adjust various tomcat properties at there. For example, changing the listening ports, and comment out ajp stuff, if not really used, etc

No comments: