Jump to content
We have recently updated our Privacy Statement, available here ×
  • Samples for Mapper


    Ana Bahr

    Storing a variable (or state) of fields/values, multiple entities, and child records can be complex to design and even more difficult to maintain using out-of-the-box functions. In addition, you may want to store a JSON format of your data when using Connectors such as Files, HTTP, and Variables. Using the TIBCO Scribe Online connector for Mapper, you can help you create a blueprint for your dataset, such as JSON, and provide the ability to get and set the entities and fields in that variable/state.

    These simple flows attempt to demonstrate some concepts and how they can be achieved using the Mapper Connector. Review the Group Block labels in the flows that explain the purpose of the Blocks inside the Group.

    Prerequisites

    You can import the Sample App from the marketplace listing by searching for Samples for Mapper Connector and selecting Get. You will also need to Install the other prerequisite Connectors (if not installed already):

    • Sample - CRM Connector and an associated Connection named SampleCRM with no spaces or special characters. On the Connection Configuration dialog set the Use Sample Data field to true to use the sample data distributed with the Connector.
    • Variables Connector and an associated Connection named Variables.
    • Tools Connector and an associated Connection named Tools.
    • HTTP Connector and an associated Connection named HTTP.
    • Mapper Connector and an associated Connection named Mapper.

    Sample CRM Connector

    Note the following when using the Sample CRM Connector:

    • A sample database is installed in the agent folder when the Connector is installed.
    • If you have more than one Connect on-premise agent installed, there is a separate database for each agent. In this case, the database associated with the agent that runs an app using the Sample CRM Connection is the database that is updated. If you have multiple agents, you can expect the databases to be different over time.
    • If you are using a Connect cloud agent, there is a separate database for each app that uses the Connect cloud agent. In this case, you can expect the database for each app to be different over time.

    Mapper Connector

    The Mapper Connection configuration includes the names of the entities used in the Maps/flows as well as a JSON sample for each entity.  Configure the following three entities and copy/paste the associated JSON sample into the Mapper Connection dialog.

    Entity Name: customer

    Sample JSON:

     {     true,     "string",     "string",     "string",     "string",     "string",         "string",         "string",         "string",         "string"     },     "string",         "string",         "string"     },     "string",         "string",         "string",         "string"     },     10000,         true,         "string",         "string"     } }[/code]  
    Entity Name: array_of_customer

    Sample JSON:

     [     {         true,         null,         null,         "North",         null,         "Aberdeen Inc.",             "ABERDEEN0001",             "(617) 832-9863",             "(617) 832-7300",             "Main"         },         "Mr. Harold Michaelson",             "President",             null         },         "SYSTEM_USER",             "2016-04-01 00:00:00",             "SYSTEM_USER",             "2016-04-07 11:07:43"         },         10000.0,             false,             "Net30",             "Retail"         }     } ][/code]  
    Entity Name: response_array_customer

    Sample JSON:

     {     true,             null,             null,             "North",             null,             "Aberdeen Inc.",                 "ABERDEEN0001",                 "(617) 832-9863",                 "(617) 832-7300",                 "Main"             },             "Mr. Harold Michaelson",                 "President",                 null             },             "SYSTEM_USER",                 "2016-04-01 00:00:00",                 "SYSTEM_USER",                 "2016-04-07 11:07:43"             },             10000.0,                 false,                 "Net30",                 "Retail"             }         }     ] } [/code]  

    Serialize and Deserialize (JSON)

    This flow demonstrates the following:

    Starting a flow with no source data for the Query Block.Using a Fetch Block to retrieve Account records from a Sample CRM database.Serializing an Account record input to output JSON. The customer entity in the Serialize Block uses the customer entity JSON sample configured on the Mapper Connection dialog to determine how to map the Account record fields to a JSON format. The objects on the Serialize Block Properties Include tab represent how TIBCO Cloud? Integration - Connect interprets the objects in the JSON sample.Writing the results to the Agent log.Using an Upsert Block to create a variable that stores the JSON so it can be used later in the flow since Fetch Block results cannot be accessed outside of the Fetch Block.Using a Loop Exit Block to exit the Fetch Block. This forces the Fetch Block to only process one record at a time instead of all of the records returned by the Fetch. The flow can then process the record stored in the variable before processing any additional Account records.Using a Lookup Block to retrieve the customer record from the variable.Using a Fetch Block to deserialize the JSON. The Filter tab captures the JSON returned from the variable retrieved in the previous Block and deserializes it based on the sample JSON in the Mapper connection dialog.Using an Execute Block to write the response to the Agent log.
    mppr_srlz_dsrlz.thumb.png.cb94e4b636b55c465ec2932d292928f5.png
     

    Working with Arrays

    This flow demonstrates the following:

    When configuring sample JSON in the Mapper Connection dialog, the square brackets [ ] indicate that the sample is an array. The top-level of this array corresponds to the object labeled Anonymous in the Include tab of the Serialize and Fetch Blocks. To reveal and access the objects within the array, you must select the Anonymous object on the Include tab. The Include tab displays the format of the JSON as TIBCO Cloud? Integration - Connect interprets it.

    Starting a flow with no source data for the Query Block.Using the Serialize Block to establish the format of the array_of_customer JSON output by selecting the objects on the Include tab. Errors display because there are no fields mapped on the fields tab, but for this scenario, no field mappings are required.Using a Fetch Block to retrieve Account records from a Sample CRM database.Using an Add Block to map Account fields to the correct array_of_customer JSON objects and add each customer record into the array.Using an Execute Block to write the output to the Agent log.Using a Fetch Block to deserialize the JSON. The mapper_input field on the Filter tab captures the JSON output generated by the Serialize Block and deserializes it based on the sample JSON in the Mapper Connection dialog.Using the For Each Child Block to retrieve one customer record at a time from the deserialized JSON.Using an Execute Block to write a message for each record to the Agent log. mppr_arrays.thumb.png.ed1f581560a00108e4619b580679dc21.png

    Working with HTTP

    This flow is a more complete scenario and demonstrates the following: 

    Starting a flow with no source data for the Query Block.Using the Serialize Block to establish the format of the array_of_customerJSON output by selecting the objects on the Include tab. Errors display because there are no fields mapped on the fields tab, but for this scenario, no field mappings are required.Using a Fetch Block to retrieve Account records from a Sample CRM database.Using an Add Block to map Account fields to the correct JSON objects and add each Account record into the array.Using a Send Block with the POST HTTP verb to send the JSON array in an HTTP request. This Block uses Postman Echo to echo the HTTP request back to TIBCO Cloud? Integration - Connect.Using a Fetch Block to deserialize the JSON in the HTTP response. The mapper_input field on the Filter tab captures the JSON response from the Send POST Block and deserializes it based on the sample JSON in the Mapper Connection dialog.Using the For Each Child Block to retrieve one customer record at a time from the deserialized JSON.Using an Execute Block to write a message for each record to the Agent log.
    mppr_smpl_http.thumb.png.29e982b63666f5098f3911e869984932.png

    DISCLAIMER

    Copyright © 2022, TIBCO Software Inc. All rights reserved.

    No Support. You acknowledge that TIBCO will not provide any maintenance or support for this software. You have no right to receive any upgrades, patches, enhancements, bug fixes, new versions or new releases of the software.

    Internal Use Only License Grant. TIBCO hereby grants you a limited, non?transferable, non?exclusive license to use the software solely for your internal business purposes. The name of TIBCO Software Inc. may not be used to endorse or promote products derived from this software without specific prior written permission of TIBCO Software Inc.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...