Stardust/Knowledge Base/Modeling/String to SDT conversion and individual extraction and processing
Given a single string input (possible from an external system) with a delimiter of your choice, you are required to extract each individual string and perform additional processing on it. All the artifacts referenced in this article may be downloaded from here.
In the model above, a manual activity accepts a string input from the user. This could possible be replaced by a POJO or Web Service/JMS which integrates with an external system and passes in the input to the process.Thereafter, the process invokes a POJO which is responsible for individual string extraction based on the delimiter of choice (" " in this example) and creating an SDT to hold the list of strings. The SDT data and size of the list are set as process data outputs by the POJO. Thereafter a decision split is encountered. A counter variable ("Counter") which is initialized to 0 is used to iterate through the SDT string list and extract each individual string for display. The user could choose to do additional processing as desired after the string is extracted. Finally, the counter is incremented before the loop completes and the the decision split is revisited. The POJO and SDT types are discussed next.
POJO and SDTs
The "extractSubStrings" method of the POJO is invoked by the activity "Split Source String" and the string input is passed in as a parameter. This method is responsible for splitting up the string using the delimiter of choice and writing out the resultant string list to a map with the key "StringsHolder". Note that each element of this map itself happens to be a map with a single element having the key "myString". This structure is required to match the SDT definitions as shown below:
MTA for Individual String Extraction
The MTA shown above is invoked by the activity "Extract individual string" (see process model above). The application takes in 2 inputs viz. the current counter value ('Counter") and the SDT data ("SplitStrings") containing the string list. The above transformation is then applied to extract each individual string in turn. This string is written out as the process data "CurrentString" and then used in subsequent activities.