Compiere has a quite a few options to integrate with other applications. Here, I want to concentrate on the Plain Old Java Object (POJO) interface options. Other options to interface are via sql and various file formats. In a future article, I will discus how to interface via JMS (e.g. to an Enterprise Service Bus (ESB)), SOAP and XML services. The Compiere Business Objects start with "M" based on the naming convention of the used Model-View-Controller Architecture. The base persistence class PO.java has a bunch of methods which allow to build integrations to other sytems quickly. The PO class is abstract and the typed access is provided by a generated class layer starting with X_{fileName}. An example for illustration:
- Table: C_BPartner
- Generated Access Layer: X_C_BPartner.java (extends PO.java)
- The Business functionality class : MBPartner.java (extends X_C_BPartner.java)
There are vatious options how to create a business object. The most common contructor use the context, primary key ID and the transaction:
- Ctx ctx = Env.getCtx();
- int C_BPartner_ID = 100;
- String trx = null;
- MBPartner bp = new MBPartner(ctx, C_BPartner_ID, trx);
- boolean noComment = false;
- boolean dataOnly = false;
- org.w3c.dom.Document doc = bp.get_xmlDocument(noComment, dataOnly);
- StringBuffer existingString = null;
- StringBuffer bpXml = bp.get_xmlString(existingString, dataOnly);
- <AD_Client_ID>11</AD_Client_ID>
- <AD_Client_ID>
<Value>11</Value>
<Label><Info>GardenWorld</Info>
</AD_Client_ID>
- VO vo = bp.getVO();
- public MMyClass (Ctx ctx, VO vo)
{
this(ctx, 0, null);
load(vo);
}