ERP 2.50:Developers Guide/Examples/Data Access Layer and REST
Contents |
Introduction
This page contains links to code and to other resources showing examples of usage of the Data Access Layer and REST Webservices.
Using OBDal and OBCriteria
The OBDalTest class contains examples of using the OBDal and OBCriteria services. Test cases cover simple querying, retrieval of single records and paging.
Using OBQuery
The DAL test cases contain several examples on how to use the OBQuery class. Specifically check out the DalQueryTest test class. It contains examples of querying with multiple joins and paging.
Using the DatasetService class
The DataSetService class offers an api to work with Datasets programmatically.
There are two test classes which test this service, they contain code which can be useful when working with data sets programmatically:
Calling REST Webservices through Java
Openbravo has a number of test cases which are used to test REST webservices on a running Openbravo instance. They are located in the org.openbravo.test.webservice package.
There is a read and a write/update testclass. They both inherit from the BaseWSTest class. This class has good examples of code on how-to build http connections with authentication through Java.
The WSReadTest class inherits from BaseWSTest. It contains examples of doing simple REST requests as well as using a where-clause and paging.
The WSUpdateTest class inherits from BaseWSTest. The tests which are a good basis for your own code:
- reads data through REST, changes it and posts the result back
- create a new entity through REST
- removal of an entity through a REST request
There is a blog on working with Openbravo REST webservices directly from Firefox, this can be useful for test purposes.
Using the runtime model
The Openbravo Data Access Layer implements and makes use of a runtime in-memory representation of the model. This model is also available to application developers and can be used for generic functionality.
The Data Access Layer concepts guide contains an explanation of the runtime model and a code example to convert a business object to xml: see here.
This blog also discusses coding against the runtime model. It contains example code which exports all data in Openbravo with just a few lines of code.
Languages: |
ERP 2.50:Developers Guide/Examples/Window and Tab | ERP 2.50:Developers Guide/Examples/Reference