I have some simple XML data coming into a service as a string which I need to convert to some user defined documents. The format of the XML is like this:
There are different objects with different fields. There are documents defined for each object type. For example:
- String object1field1
- String object1field2
- String object2field1
Through flow services and JDBC Adapter services, these documents are written to a DB. These flow services convert the fields from string to the appropriate format, for example, a date.
Since we have several objects, I want to create a somewhat generic mechanism where the XML data is parsed, the values are stored in the appropriate document and then by calling the specific service for that object type the data gets stored into the DB.
I am looking for ideas on how to best implement this.
So far, I have created a service to
- call pub.xml:xmlStringToXMLNode
- call pub.xml:xmlNodeToDocument
- call a java service that takes the document, walks through the IData nodes, gets the object type, gets the parameter name/value pairs and writes them to the pipeline
- check the type variable and call the service that writes that type of data to the DB
If in the java service I can load the name/value pairs into the document and put the document in the pipeline (independent of knowing what the name/value pairs are) it would make the service generic and easily expandable when new object types are introduced.
I tried using the document name followed by slash and parameter name but that did not work. For example, before calling the java service, I initialize a document reference in a map step:
Set object1Document->object1field1 to blank.
Then in the java service I do this:
IDataUtil.put( pipelineCursor_1, “object1Document” + “/” + parmName, parmValue );
object1Document1/object1field1 appears in the pipeline with the right value, however, it is not a member of the object1Document which I initialized to blank.
Is there a trick to loading values into a document reference in a java service?
Is there a better way of accomplishing this?