31.01.2015 Views

SOA Magazine IV 01.2015

SOA Magazine IV 01.2015

SOA Magazine IV 01.2015

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.

processes. So, as we implement more and more processes, the number of new types for each new<br />

process rapidly decreases allowing us to reduce implementation complexity and times.<br />

Then on the BpmLib we created our own java class representing a payload item, containing the name of<br />

the item (a key to a resource file), its value, type, if it is editable or read only, and if it is visible. Lastly we<br />

expose two methods:<br />

<br />

<br />

getTaskPayload: for a given tasknumber returns a list of payload items;<br />

updateTaskPayload: for a tasknumber and a Map updates the task<br />

payload of the task.<br />

GetTaskPayload Method<br />

The getTaskPayload method starts by calling the following code:<br />

ITaskMetadataService.getTaskDefinition(context,task).getWorkflowConfiguration().getPayload().getMessageAttribute();<br />

It returns a list of MessageAttributeType. Each MessageAttributeType represents one entry of the task<br />

payload that we see on the .task file. While this gives us some information (name, type, and if it is<br />

updatable) it is not enough, so we need to also get the actual schema of the payload. This schema is<br />

available on the MDS, and there are several ways to access it. We chose to use the URL<br />

http://[host]:[port]/soa-infra/services/[partition]/[composite]/[path_to_file]/[name_of_task]Payload.xsd<br />

We can feed this url to the XSDBuilder like<br />

XMLSchema schema = new XSDBuilder().build(url);<br />

and get an object representing the payload. From here is just a matter of iterating<br />

MessageAttributeType list and for each item get the corresponding XMLElement of the payload and<br />

build our own PayloadItem object to return.<br />

UpdateTaskPayload<br />

The updateTaskPayload method receives the values to update in a Map where the String<br />

(key) is the name of the payload item, and the Object (value) is its value. The actual class of the Object is<br />

dependent on the type of the payload item. For simple types it's the closest equivalent in java to the<br />

type, for example a String, an Integer, or a Date. For complex types it's a String with the XML value that<br />

needs to be stored. It starts by calling the Task.getPayloadAsElement() method to get an XMLElement<br />

with the current payload. Then it also gets the XMLSchema in the same way as the getTaskPayload. This<br />

is needed to know the type of each payload item. It then updates the XMLElement with the values<br />

passed in the parameter and calls the ITaskService().updateTask(context, task) method to save the<br />

changes.<br />

Copyright © 2015 | All Rights Reserved <strong>SOA</strong> <strong>Magazine</strong> <strong>IV</strong> 25

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

Saved successfully!

Ooh no, something went wrong!