ConcourseConnect

Open Source Initiative (OSI) PostgreSQL Java

API for Java clients

Concursive Commons is a small java library (.jar) included with ConcourseConnect which encapsulates the HTTP and XML code so that it's easier to write applications that talk with Concursive's products.

Keep in mind the following actions as you review the examples:

  • DataRecord.INSERT
  • DataRecord.SELECT
  • DataRecord.UPDATE
  • DataRecord.DELETE
  • DataRecord.GET_DATETIME

Requirements

The concursive-commons.jar is compiled for Java 5 and Java 6. For some operations you might need the Apache Commons Codec API in your classpath.

A “client” will need to be configured in the ConcourseConnect database which provides remote access to ConcourseConnect's data and is not user specific. In the \ table, an arbitrary client must be inserted with a plain-text password in the \ field. This will be used in the client authentication code.

INSERT INTO sync_client (type, version, enteredby, modifiedby, enabled, code) VALUES ('API', '1.0', 1, 1, true, 'some-arbitrary-password');
-[ sync_client record ]-----------------------------------------------------
client_id  | 1
type       | API
version    | 1.0
entered    | 2010-01-23 22:05:04.425
enteredby  | 1
modified   | 2010-01-23 22:05:04.425
modifiedby | 1
anchor     |
enabled    | t
code       | some-arbitrary-password
----------------------------------------------------------------------------

All objects which the client can access must be added to object_map.xml. The included object_map.xml is a complete set of application objects.

Typical Usage

import com.concursive.commons.api.APIConnection;
import com.concursive.commons.api.DataRecord;

print("Starting transaction...");

APIConnection conn = new APIConnection();
conn.setUrl("http://127.0.0.1:8080/connect");
conn.setClientId(1);
conn.setCode("some-arbitrary-password");

// Example which adds a project and a team member in one transaction

conn.setAutoCommit(false);

DataRecord record = new DataRecord();
record.setName("project");
record.setAction(DataRecord.INSERT);
record.setShareKey(true);
record.addField("title", "API Project Title");
record.addField("shortDescription", "This is the short description");
record.addField("requestDate", "2010-05-01 00:00:00 -0400");
record.addField("enteredBy", 1);
record.addField("modifiedBy", 1);
record.addField("groupId", 1);
conn.save(record);

DataRecord record = new DataRecord();
record.setName("teamMember");
record.setAction(DataRecord.INSERT);
record.addField("projectId", "$C{project.id}");
record.addField("userId", 2);
record.addField("userLevel", 1);
record.addField("enteredBy", 1);
record.addField("modifiedBy", 1);
conn.save(record);

conn.commit();
if (conn.hasError()) {
  System.out.println("Commit error: " + conn.getErrorText());
}

Sign in to add your comment.