API Examples
Project Examples
Lookup List Examples
Project Permissions Examples
Team Members Examples
Users Examples
Wiki Examples
These examples assume the following...
A SyncClient exists in the database with an arbitrary CLIENT_CODE string:
// Insert a new sync client for the API to test against
SyncClient syncClient = new SyncClient();
syncClient.setType("API Test Client");
syncClient.setVersion((String) null);
syncClient.setEnteredBy(USER_ID);
syncClient.setModifiedBy(USER_ID);
syncClient.setEnabled(true);
syncClient.setCode(CLIENT_CODE);
syncClient.insert(db);
The APIConnection class is used for brokering the request and response using the defined SyncClient; and that multiple transaction items are batched by setting autoCommit(false); this has the same effect as putting multiple actions inside a single XML transaction:
APIConnection api = new APIConnection();
api.setUrl("http://127.0.0.1:8080/team");
api.setClientId(syncClient.getId());
api.setSystemId(SYSTEM_ID);
api.setCode(CLIENT_CODE);
api.setAutoCommit(false);
DataRecord(s) and Metadata are added to the APIConnection:
api.save(record1);
api.save(record2);
The transaction is executed:
api.commit();
The response can be queried:
boolean hasError = api.hasError();
String errorText = api.getErrorText();
int recordCount = api.getRecordCount();
String responseValue = api.getResponseValue("id");
int responseId = api.getResponseValueAsInt("id");
ArrayList<DataRecord> records = getRecords();
Before executing a transaction, the XML can be reviewed:
String xml = api.generateXMLPacket();
The previously used sync_table is no longer required; ALL records in this table must be deleted in order for the object_map.xml to be used
The object mappings are now stored in a file called object_map.xml on the server. It is included in the .war file.
See API XML Object Mappings for released values.