1,234
edits
Changes
no edit summary
{{Admon/obsolete}} [[category: NexJ Current Past Projects]]
[[category: NexJ Express JSON Message Adapter]]
== Project Goal==
To create an adapter for the NexJ Core similar in methodology and design of existing message adapters (XML, Fixed, CSV etc.) but using the JSON format
* [[User:Gbatumbya|Grace Batumbya]]
* [[User:Brianlim | Brian Lim]]
== Current Status==
* '''Completed''' (February 02, 2012)
==Project PhasesDefinitions == {| class="wikitable" border="1"|-! Term! Description|-| Formatter| Turns data into JSON|-| Parser| Turns JSON into data|-| Message| The metadata to be used when formatting and parsing a message. The grammar. It is a tree-like structure.|-| MessageInstance| The information to be parsed or formatted|} Because the Integration layer allows a Model to interact with external applications asynchronously, a description / grammar of the data to be exchanged between the two systems is defined using a Message in the Model. * Formatting is turning internal NexJ representation of a MessageInstance into JSON. The formatter is given a Message (the grammar), MessageInstance (the data), and a pipe. This accomplished by walking the Message tree-like structure while validating the data in the MessageInstance and streaming JSON format to the pipe. If the data in the MessageInstance does not conform to the Message, the formatter throws an exception. * Parsing is turning JSON representation of a MessageInstance into an internal NexJ representation of a MessageInstance. The parser is given a Message (the grammar) and an input stream. First the input stream is parsed for JSON using a JSONParser which returns either an Object or an Array. The formatter walks the Message building the structure of the MessageInstance and adding validated values in the object returned by the JSONParser to the MessageInstance. If the data from the input stream does not match the expected input at any time, the parser throws an exception. ==== Message Fundamentals ====Message - Messages can contain values or other messages. The red nodes are messages, the green nodes are values. [[File:NexJExpressMessages.gif|NexJ Express Messages]] Internally, messages are Transfer Objects. To determine if a node is a message, use instanceof on CompositeMessagePartInstance after retrieving the MessagePart. For example, <pre>public void format(TransferObject tobj, Message message, Output out) throws IntegrationException{...CompositeMessagePart root = message.getRoot(); // Gets the root of the message.Iterator it = root.getPartIterator();while (it.hasNext()){ part = (MessagePart)it.next()); if (part instanceof CompositeMessagePartInstance) { // This part is a message } else if (part instanceof PrimitiveMessagePart) { // This part is a value }...}...</pre>
===Phase VII2. OptimizationDesign Proposal (DONE)===# Receive general approval for project# Receive approval for JSON encoding options# Receive approval for JSON formatting options# [https://docs.google.com/document/d/1wAjG-xSJi227GBPUZtADAROSydIn3KuimoZarqO7xDQ/edit?hl=en_US Final Project Proposal]
===Phase VIII4. First Internal Code Review (DONE)===# Internally review code at NexJCDOT
===Phase IX6. Apply Changes from Code RewriteReview 1===# Estimated Duration: 3 Weeks (August 29, 2011)# [[JSON_Integration_Adapter_Code_Review_1_Changes | Changes to make]]'''Summary of [[JSON_Integration_Adapter_Code_Review_1_Changes | changes]]'''# Allowing modes for all Composite message parts, not just the root.# Refactoring methods to check for != right condition instead of checking for the wrong condition to throw an exception. (whitelist instead of blacklist)# Formatting all primitives before writing or storing them (e.g. timestamps, decimal numbers.)# Creating a RootJSONMessagePartMapping extending JSONMessagePartMapping
===Phase X8. Second Apply Changes from Code Review at NexJ2===*[[JSON_Integration_Adapter_Code_Review_2_Changes | Changes to make]]
===Phase XI10. Project CompletionApply Changes from Code Review 3===*[[JSON_Integration_Adapter_Code_Review_3_Changes | Changes to make]]
== Resources ==
JSON RFC : http://www.ietf.org/rfc/rfc4627.txt<br />
Introduction to NexJ Studio Express : https://www.projects.openhealthtools.org/sf/go/doc1771?nav=1<br />
NexJ Developer's Guide<br />
NexJ Integration Fundamentals<br />Open Health Tools Integration Platform https://www.projects.openhealthtools.org/sf/projects/oht_aip/<br />