Version 7

    (Smooks Configuration Editor - Flows)


    NOTE: See the New File Wizard Flow before reading this flow.



    While browsing the flow Screen by Screen (see next section) is very useful in terms of being able to analyse the individual steps in the flow, it's very useful to be able to walk through the flow in animated form.  For this we use a flash recordings:


    1. Creating the new Smooks config using the New File Wizard...
    2. Working with the new Smooks config inside the Editor...


    Screen by Screen


    This section details each screen in the flow.


    New Configuration Editor

    After creating a New Configuration file using the New File Wizard Flow, the editor will open on the "Processing" tab.  If we open with the Package Explorer on the LHS, we should provide a "Tip" to the user, drawing their attention to the "Smooks Palatte" tab:



    Smooks Palette

    Then on to the "Smooks Palatte" so we can add some processing tasks/steps to our Smooks configuration.

    Adding a Task

    Once the "Smooks Palatte" is open, the user can start adding tasks to the Smooks "Process".


    In the case of a JSON to XML Transform, we need toperform the following tasks:

    1. Bind the message data into Java Objects in the Smooks Java Bean Context.
    2. Apply a template to the data in the Smooks Java Bean Context to produce the required XML output.


    So we drag a "Bind to Java" task from the palatte and onto the edito canvas:


    Activating the Prcess Task View


    When we select the "Bind to Java" task on the editor canvas, it splits into two panes.  The process flow remains on top.  On the bottom, we can see the input message model, as well as a button for adding beans into the bean context (Dart is working on a possible alternative to this button).


    Adding Beans to the Bean Context

    Clicking on the "Add Bean" button (or whatever we use) brings up the normal dialog for finding a class.  In this case, we select the Order class, but Smooks supports the concept of a Virtual Object Model, whereby you can simply drop Map instances into the bean context and populate data into them from the message (Vs having to define a conrete class).


    So we select the Order class:


    Once the class is selected, complete object model associated with this class is dropped into the canvas:


    Mapping Data Into the Bean Context


    Now we can bind data from the input message model (seen on the left) into the Java objects in the Bean Context (seen on the right) using drag and drop:


    Applying a Template


    Once we have the data from the input message in the beans in the bean context, we can do all sorts of things with it.  In this case, we want to apply a template to the data and produce some XML i.e. we want to "transform" it.


    So, from the Smooks Pallate, we drag an "Apply Template" task onto the canvas:


    When we select the "Apply Template" task, the bottom half of the Editor canvas changes.  The Bean Context View moves to the left and a new "Tempate" form becomes visible.  Select the "Browse" button:


    The template selection will depend on the type of otput you are trying to produce:

    • XML: The user should be able to select an XSD or a Sample XML message.  WSDL would also be an option (for the future perhaps).
    • CSV: I'm not aware of any "schema" spec for CSV, but in any case, the format is very simple - a set of fields onto which we will map data, with the underlying template generating CSV from the mappings.  We could use a sample CSV file.
    • EDI: Smooks uses EDI Mapping Models as a "schema" of sorts.  We could use these to describe the target EDI and from it, generate a view of the model into which we map the data from the bean context.
    • JSON: We could use a sample JSON target message.


    In this case, want to produce XML as the result, so we select e.g. an XSD:


    Once we select the template definition source, a model view of the output is displayed in the editor:


    And using drag and drop (again), we map the data from the bean context onto the output format model view: