02.05.2013 Views

MKS Integrity 2007 Integrations Builder Guide

MKS Integrity 2007 Integrations Builder Guide

MKS Integrity 2007 Integrations Builder Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: Using the <strong>MKS</strong> API<br />

22<br />

C Example: Retrieving Work Items<br />

response = mksCmdRunnerExecCmd(cr, cmd, NO_INTERIM);<br />

workItem = mksResponseGetFirstWorkItem(response);<br />

/* Do something with the first work item. */<br />

while ((workItem = mksResponseGetNextWorkItem(response)) != NULL) {<br />

/* Do something with the work item. */<br />

}<br />

Each retrieved work item contains an ID, a context (if needed), a display string, a model type<br />

(for example, state, issue), and, optionally, a result.<br />

Retrieving Work Item Results<br />

Each work item optionally contains information about the action taken. For example, if you<br />

run si resync and there is nothing to resynchronize for a particular member, there is no<br />

result for that work item, indicating that no action was taken. If an action was taken, there is a<br />

result. In the case of si resync, the result is the revision that was checked out. The following<br />

examples show how to retrieve result information for a work item.<br />

Java Example: Retrieving Work Item Results<br />

String newRevisionId =<br />

workItem.getResult().getPrimaryValue().getId();<br />

C Example: Retrieving Work Item Results<br />

result = mksWorkItemGetResult(workItem);<br />

item = mksResultGetPrimaryValue(result);<br />

newId = (wchar_t *) malloc(256*sizeof(wchar_t));<br />

rtn = mksItemGetId(item, newId, 256 * sizeof(wchar_t));<br />

View Commands<br />

View commands provide access to the current state of information within an application.<br />

Typically, the command names are either the name of the item type to be viewed (for<br />

example, issues, sandboxes), or they start with the word “view”. The response for a view<br />

command communicates the content of the item being viewed, no matter how complex.<br />

Like action commands, view commands always return work items, command exceptions,<br />

and work item exceptions. Unlike action commands, a view command does not need to<br />

report the results of an action.<br />

Retrieving View Information<br />

Work items can be retrieved from the response for view commands in the same way as they<br />

are for action commands.<br />

Once you have identified the work items, you can access their content. All work item content<br />

is contained in fields. You can access the information in the fields without parsing. The fields<br />

are either the basic data types (for example, string, Boolean) or contain a list of basic data

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!