Jump to content
  • TIBCO Flogo for TIBCO BusinessWorks Developers - Mapping


    JenVay Chong

    Preface

    The TIBCO Flogo for TIBCO BusinessWorks Developers series of articles aims to familiarize BusinessWorks developers with TIBCO Flogo in order to better utilize these complementary technologies. Each article is focused on a specific key common behavior or feature that is often used in a BusinessWorks project. It takes that common behavior and replicates that in Flogo. 

    Mapping

    In this article, we will take a look at Mapping. There are multiple different mapping types within BusinessWorks that are commonly used. We will touch on each of these. 

    To further help us illustrate these mappings, we will make use of two simplistic schemas. The first schema is of customers. This schema is set with initial data in the first activity of the process or flow. Each element of the schema is named and should be self-explanatory. 

    BW5

    nHELytEDO--T7tyv7777YuG3VWXXxGGU5I6UIUIV4ilcxAa99ku4M9y_ylwuK7rnAvCIae_WGIoxXa79-XI1670BQkusERDArf_Raw0iUWA7HyaSYKpgp4WO056z4kl8eiKxNS_vY6LPkHampjvhW3EAQoRqq9RBVTWempE2lZKZ_zSs3ZiPlefo8ptGWUZDqXQK5w-rAv27wIzbiuoYZx_jcW5W5lN7B8BSyyOQptmHS3F7th9QfsY-V_b6kP2RL_hpbhUIXgr85E3cqnVdLL6Kb-8v5Lf0l1NPZg7nVRVuP0

    BW6/CE

    1Xrf5CGEo7MVZSd299Xn1ucZ0xT0Yxu1gfNcocMQ-Vhje-e5AwZoYRQokvwx86PjRGaHUmMXg3TqHW-LcScXTLAzYbfUEaiVq6KYUc5m_cONyYwkkdX09OKdvLhJxmfontx4yTl1uzmQmmUoh4NDong

    Q5mfnYsmK-SrSPxfjyp_okAPRTHlZH7gp67cRjOlAGiXUDeLFJPLHTtNQpMOagl6AbI2gogIkIVrv_897p4o81MU4xiIK5P_uqR2uyTN_jy51Tz1gBwyRMFwD9IKz0jcXDdmkzNS-7HZrYQDaE7WGyI

    Flogo

    4QuFiAd0yHoCbSarwTxezNZfnn6GtcANnirBNU7EKzb5Jm7bjvt2-v4oYy8-DoCg8-lvBWZGjet71HlLxLAcfjPfFMk1TmBs2etqNfrmJz7KFgY1_p2WhRBEpAXkhd_28qlaG104r8iS9n4mtA31GYg

    The second schema is a membership schema. This groups the customers from the customers schema into a goldMember or platinumMember based on some business logic that we will get into later. 

    BW5

    jW7_FT14ZjRWi_rlI567VweqU4uta4OuiDSQYF4rtnQLwKVJJvr_v-laoQY0HLbGLEGYNq25QiC0qDgsUIjXN3SHA_LwXDWgcSdpcGHSOD0gbqkGpPXJJp5p7GUWKwU3DbKz0VFho804LBmI_K0207Q

    BW6/CE

    abxJxfCbcwc7pVZh9UEKFj04BrMw-co0u_mIrjEnhl786LcicPv87OYDck9moIuJR15sBnIrYn_Su1vhWw0JfMjR1pobCFnpOMfxVeSgq2xPlWUGxO2Nko-eiiwKQ8Vk9fAammDWsW6aUipiNZ2sE8c

    Flogo

    kiL7f7sc0uHPKOZ-cbVjNQS7I2Pvhkq93bXye1_QdGA24vvmvy-Lf03CANecbKBzjUyoQtQ0yDVqjnCmXGWnzOHmevHnxGkfeFRbvYcZpCe5g1_9cCOf56w6N01mHq1j7QBSJZ84UPoGXWBqDiqXw_4

    These schemas are used in the applications in BW5, BW6/CE and Flogo. The application logic is simple. It is triggered by a run-once timer. It will then proceed to initialize the Customers schema using a Mapper activity with the initial data as shown above. The next activity uses another mapper to map the values from the Customers schema to the Membership schema using various methods. It then prints out the result of the initial Customers Schema and the mapped Membership Schema. 

    BW5

    S9wkZqs_MBY0Zknehhgx-uO77f0B1w0FdI3Sf_YyjrF4lLfVwW-WHp2hynXrc9Ux0nO97LKao9IEE4_SUHjyOxQx8S7ESh2aaD3qVkGjrILhK45rb2GXwnDovlODGdAzsDOTKcqdGhBYraZ7gkA7xKs

    BW6/CE

    ASiQzFpC-w8GE3XEl8KgIWJ_e4gW3mGcYZ_tNv1A3Nw0VxLUI-ufwPApT1s-pV4eO3NtVJxXWyrT3DPCPLbuM5BaZyjyFpj_so1CJFizzdTFtg_QHr1mlLpzniJnUkzcj7h98DisBR6PpqY72H_VPhk

    Flogo

    jPUmE5dXbXMObzhFhQSKkQ8R-zZKWViGn9OXbvwi406ARr0Rzl2QxIYEumZO4kvoRwk_91IDgrLzOOP7fpkovWNxRrKr-kWT1jc_R_07JhhDB4A4pTbiutcRzJwbMOOXjvHSoyfW4zgR8rBPRufqH5I

    Let us focus on the details of the mapping in the MappedData activity. Below, we will show the full mapping done in both BW5 and BW6/CE.

    BW5

    GIoT5q7Q8_0-hdMA8t6r1x-XrXJUH4j5ywT1g9Pmg_noF4XxVmYnPPaE2o-gOB-QyKS3hawOQMzuQkrpDNDsfsVBlLEuMc2hnfrYZFw34TP_lf5B6qpFgv4IGe3xIft3BmQVFYaDZmiz7UlRYQbLVkg

    BW6/CE

    pdymV_ki_V2K3iv9FqAKcrUdSyA7gAPkbo6buR48pq8tkuzpUK0OsiNUcuP_msfZHDRlOluguW5JAfrTqNtuSHpU_-ini-bOzcq8CV8dO-WT6ZGRn6fVZTpeKfEJmDoEwYo3ItYfwONvgwOwQcUJZYA

    We will go through each of these in detail when done in Flogo.

    The goldMember mapping is really an iteration of the Customers element. It will allow customers with a dollarSpent of more than 0 and less than 10000. In Flogo, we achieve this by dragging the Customers array to the goldMember array. This will establish an iteration like the for-each in BW. Additionally, the filter logic within BW housed in the square brackets is represented in the Filter By section of this iteration. 

    A few things to note. The exists() function in BW is the isdefined() function in Flogo. When we establish the iteration, in this case from the Customers element, the scope of the Customers is put in the $loop object. So, to refer to elements within the iteration, we use the $loop with the subsequent element name. For example, $loop.Customer.dollarSpent refers to dollarSpent element of the current iteration of Customer under Customers. The keyword “and” is represented by “&&” in Flogo. Also take note that the iteration is assigned a Loop Name of goldMember. The Loop Name uses the same name as the element by default but can be changed. We will refer back to the loop name in subsequent mapping.

    gLQmmaEpUbqPv10b-D5Qkh_TQdJhazMRt54DV_7jWRpC4Rmku6rE7-4ArCzUVn7bUYXzWZ-EclagzvdQ14uI2BMs35ejuYhRFjQjRCvSo3kkrRISG47FQLRRAu27oZ8SsxoZRuZkVWyVd_xs7YnEyJM

    Once this iteration is established, we can then map the name element from the Customer over to the name element of the goldMember like below.

    Va9q0aBXguPDLEh_SYvA3VeDYEbxsMbIzP35aiGmSfBmfTf7ehXoFtfofWKD1cHdYjyo8L0mV686deu8iUtZeMlloIDizTrSnvDgqdOer5DG1B599a4t2v9eQaz7ZHeDTTL2qr2TjrCmIzS-2XvYHSA

    We next need to map the altName or alternate name. Notice that this is a repeating element on both schemas. In BW, we use a for-each to map this over. In Flogo, we can map this over like any other element. Given that the name and type is the same, it is implied that the whole array is mapped over. Another thing to take note here is that the loop name is used. Because this is an array to array mapping, the implicit context in $loop is now changed to that level. So, in order for us to refer to the parent loop, in this case, the Loop Name goldMember, we specify $loop[goldMember] instead of just using $loop.

    iazy3NDHc_tuNqvIq7EyzpjGQX4tpt4LUaUh2nCRg4cFWh2yQMAF6CO1uaMBvkPApXDDXmtbrifbBBTJeVsP_wvw2D6Euu-MTdplt9aLKeWKfioRBFgn3pSwpuo2nkZGhxq4BWItmWSqJcKFLGRLd-4

    The next element that we need to map is the homeMailLabel.This draws from the repeating address element from the Customer. Specifically for the homeMailLabel, we only want to map the address of the type “home” and an address with an activeFlag of true. We specify these conditions in the Filter By configuration.

    -iCyW5o7QWFb-g6qmAJlW1vf-nrudiJLr0O7PIH4N7EZ7NQYkt69bIpyRXKaAxcqXT7IC8JsdWhdZhbxBqUk81XV2PwmQvQyjEMUj-f4YQsZC3tvBXET_ZhY9LWZ3M3k6d5QhtN0QtCZZSqJ9AVRQ24

    Looking further into this mapping, we have the name element under the homeMailLabel that needs to get the value from the parent element of the iteration. In BW, we use “../<<element name>>” to get to this value. In Flogo we use the “$loop[<<parent loop name>>]” or “$loop[goldMember]” to get to this parent value.

    6Fsobep4KcUYIENPhdSAjsVFsLVZDnYoi4lD08vuXJCqhkwdZCel_JDMMyloM6A7dG632o543WfsFq1YXI7hbWbWnBr9_8MhM_oETrif6eWbE7Dd_GTm0YCu8RIC6zrLdkSyBNSNRCJFVqk2bX5egrA

    To map the platinumMember, the rest of the logic is generally the same. This illustrates that a single array data source can be used to map to multiple arrays with different criterias.

    _79JzZqJ7PgSfc5KeYaYpmrGFEZt8c9n2UAoAQwzOgcghYAEZKPZN_HHJD5VcVq0fEsu1wOuVf70KBkUzLqqu-kG3g6TQEIutBR9QosBk1voGHlMXgwqfOR5mlHvo63yFeVP3gIPUFjEYoIrbXiJnus

    With these mapping done, we see that all three projects, produces the same result (barring that BW is XML based and Flogo is JSON based).

    BW5

    QJXvL2_HYMUZSaQbcQkk4vTYJEVUus2CO3PeI2EB6_W8dsrq2z0rildG9_HR8kGVOXz_psTSc3WcqFY8VyI65NUFHcym-K9nlvOMe3ga1dzsAdJE_2EiozTYrfyQEUpJP_2IA7B-4ck1jr7Ohk1voa0

    BW6/CE

    nKCXNn5cHo5hQswVi4idHXNhgn9IEfzQd6cUf9Y3QgArqVQzM1tmC0PQh7OUgU5G2y0As43kSXC8adGG73qRA58rr-DuTXMLiznDr4tP5aQsB8vtLVHgTBXMGASZZtrlfwIMKBKx5b65M6wZVC_eyis

    Flogo

    Oxz_CiOb4Ua6D3fgLAlbihlfZUJSHYfpMPEamKegwOwEDenyVDCHo5_0sg_-ffK3hYw7FzQd63aWgUWgDALHMKlh1n0jrmAwdaaniRbz7N-rrbpMElcoLhmXSU-Eiudf5UgmKwtjIBn9e7aorYiOLU8

    All three projects coded in BW 5.15.1, BWCE 2.9.1 and Flogo  2.24.0 using the Visual Studio Code Extension are provided below for your reference.

    BW_5_15_1-F4BWDev-Mapping.zip BWCE_2_9_1-F4BWDev-Mapping.zip F4BWDev-Mapping.flogo


    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...