The REST API for Task Management

A set of functions in the REST API allows developers to manage tasks. For full details of the REST API, see the online REST documentation at the URL http://yourhost:7378/madappsvcs.

The task functions in the REST API are:
  • getTask
  • searchForTaskListByRecordId
  • searchForTaskListByUserId
  • updateTask
  • linkRecord
  • unlinkRecord
  • markRecordLink
  • createCustomTask
A parallel set of functions are available with ESOA:
  • getRecordTask
  • getEntityTask
  • searchTaskByRecordId
  • searchTaskByUserId
  • updateTask
  • linkRecord
  • unlinkRecord
  • markRecordLink
  • createCustomTask

See the following sample Java™ code for implementation details for some of the REST functions. For the web client, the sample code uses the Apache CXF services framework.

getTask

The following snippet submits a task ID and returns a JSON object that specifies the legal name and home address of the member (also called a record) associated with the task. You can supply a subset of attributes for the member to prevent the service from returning all attributes.
	protected string execute_getTask(long taskId) throws Exception {
		string result = null;

		WebClient client = getWebClient();

		client.path("/task/{taskId}",taskId);
		client.query("attributes", "LGLNAME,HOMEADDR");
		client.accept("application/json");
		client.type("application/json");
		Response response = client.get();

		result = getResultString(
				(InputStream)response.getEntity());
.
.
.
		return result;
	}

searchForTaskListByRecordId

In the following snippet, srcCode indicates data repository that contains the member and memIdnum is the identifier for the specific member. Together they are a unique pointer to the member. The code returns (as XML) any tasks associated with the member.
		WebClient client = getWebClient();

		client.path("/task/record/{srcCode}/{memIdnum}",
				srcCode,memIdnum);
		client.accept("txt/xml");
		client.type("txt/xml");
		Response response = client.get();

updateTask

Given a task ID, the following code sets the status of the task to Resolved. In this case, the user ID is system, but you can specify rwuser or any authorized ID.

Because the function writes a change, the code uses client.put rather than client.get.
		WebClient client = getWebClient();

		client.path("/task/{taskId}",taskId);
		client.query("status", "Resolved");
		client.query("user", "system");
		client.accept("txt/xml");
		client.type("txt/xml");

		Response response = client.put("");

linkRecord

The following snippet demonstrates how to link a record (also sometimes called a member) to an entity. In this case, the entity type is "id". To make the link, the code must supply the full entity and record information.

If your system uses only one entity type, you can omit the line:
client.query("entType", "id");
The system defaults to the one entity type.
Here again, because the function writes a change, the code uses client.put rather than client.get.
		WebClient client = getWebClient();

		client.path("/record/link/{entRecno}/{srcCode}/{memIdnum}/",
				entRecno,srcCode,memIdnum);
		client.query("entType", "id");
		client.accept("txt/xml");
		client.type("txt/xml");
		Response response = client.put("");

unlinkRecord

The following snippet demonstrates how to sever a record from an entity. In this case, the entity type is hh. To sever the link, the code requires only a unique identifier for the record (consisting of the srcCode and the memIdnum).
		WebClient client = getWebClient();

		client.path("/record/unlink/{srcCode}/{memIdnum}/",
				srcCode,memIdnum);
		client.query("entType", "hh");
		client.accept("txt/xml");
		client.type("txt/xml");
		Response response = client.put("");