2025-04-17 - LinkPath structure and examples

From Izara Wiki
Jump to navigation Jump to search

Service - Search Results

requiredData normalize structure

  • component => requiredDataObjects , linkPathObjects, linkPathSteps
{
  requiredDataObjects: {
     hash_requiredDataObjectA: { //* normal requiredData
       fieldName: "fieldname if main objType or last fieldName for linkPath",
     },
     hash_requiredDataObjectB: { //* has LinkPath
       fieldName: "fieldname if main objType or last fieldName for linkPath",
       linkPathObjectId: "hash_linkPathA",
       complexFilterCombinationIds: [ //* has applyCombinations
         "xxxxx",
         "xxxxx"
       ]
     }
  },
  linkPathObjects: {
    hash_linkPathA: {
      initialObjType: {
        serviceTag: "ProductManager",
        objectType: "product"
      },
      linkSteps: [
        "hash_linkStepB_1",
        "hash_linkStepB_2"
      ]
    }
  },
  linkPathSteps: {
    hash_linkStepB_1: {
      pathLinkType: {
         objType: {
           serviceTag: "SellOfferManager",
           objectType: "sellOffer"
         },
         relType: {
           serviceTag: "SellOfferManager",
           relationshipTag: "hasSellOffer"
         },
         direction: "from"
      },

      //------ conditions by link ------// : optional
      filterElementId: "ref_filterMainIdA",
      aggregate: "max",
      sortFields: [
        {
          fieldName: "xxx",
          dataType: "string"
        }
      ],
    },
    hash_linkStepB_2: {
      pathLinkType: {
         objType: {
           serviceTag: "SellOfferPlan",
           objectType: "sellOfferPlan"
         },
         relType: {
           serviceTag: "SellOfferManager",
           relationshipTag: "usesSellOfferPlan"
         },
         direction: "from"
      },
      //------ conditions by link ------//
      filterElementId: "ref_filterMainIdA",
      aggregate: "max",
      sortFields: [
        {
          fieldName: "xxx",
          dataType: "string"
        }
      ],
      requiredDataObjects: [ //* for use to create linkPath in linkPath
        {
          fieldName: "xxx",
        }
      ]
      combine: "true",
      comparison: "greaterThan",
      comparisonSortField: "upToValue",
      comparisonSortDataType: "string",
      comparisonValue: "50",
      requestProperties: {
        tag_xxxx: "value"
      },
      perParentCombinationIds: [
        {
          tag: "tag_xxxxx",
          filterMainId: "xxxxx"
        }
      ],
      applyCombinations: [
        {
          tag: "tag_xxxxx",
          filterMainId: "xxxxx"
        }
      ]
    }
  }
}



== ProcessSearchResultMessage ==
* Fetch and Sort Product Sizes by Language with Fallback
<syntaxhighlight lang="js">

Need to fetch all sizes, sorted by language order 'en', 'th'.
If a translation is missing for any language in sortArray: ['en', 'th'],
fallback to the defaultTranslationLink of that productAttribute.
ProductAttributeLabel with labelId = 'Id_X' represents a size.
identifiersIdArray contains all productAttributeIds linked to ProductAttributeLabel where labelId='Id_X'.


let processSearchResultMessage = {
  objType: {
    serviceTag: 'ProductAttribute',
    objectType: 'productAttribute'
  },
  requiredData: [
    {
      fieldName: 'text', //all sizes by languageId, where text is the identifiers of the translation objectType, which is the final link step of this requiredData
      linkPath: [
        {
          link: {
            relType: {
              serviceTag: 'Translations',
              relationshipTag: 'hasTranslationLink'
              // Must use hasTranslationLink because it will be automatically added by inserting a filterElement with logicalType: "translateIds"
              // where identifiers come from identifiersIdArray (Process-ComplexFilter), along with a filterElement of type: "logicalOperator" and operator: "and"
            },
            objType: {
              serviceTag: 'Translations',
              objectType: 'translationLink'
            },
            direction: 'from'
          },
          aggregate: 'min',   //if 'min' sorts languages in order 'en', 'th', //if max sorts languages in order 'th', 'en
          sortFields: {
            fieldName: 'languageId',
            dataType: 'array',
            sortArray: ['en', 'th']  // sorts languages according to sortArray
          },
          filterElements: [
            {
              type: 'group',
              elements: [
                {
                  type: 'traversal',
                  traversals: [
                    {
                      fields: {
                        languageId: { anyValue: ['en', 'th'] },
                        textTag: 'productAttributeValue'
                      },
                      link: {
                        relationshipDirection: 'from',
                        relType: {
                          serviceTag: 'Translations',
                          relationshipTag: 'currentTranslationLink'
                        }
                      }
                    },
                    {
                      objType: {
                        serviceTag: 'ProductAttribute',
                        objectType: 'productAttribute'
                      }
                    }
                  ]
                },
                {
                  type: 'logicalOperator', operator: 'or'
                },
                {
                  type: 'traversal',
                  traversals: [
                    {
                      fields: {
                        textTag: 'productAttributeValue'
                      },
                      link: {
                        relationshipDirection: 'from',
                        relType: {
                          serviceTag: 'Translations',
                          relationshipTag: 'defaultTranslationLink'
                        }
                      }
                    },
                    {
                      objType: {
                        serviceTag: 'ProductAttribute',
                        objectType: 'productAttribute'
                      }
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          link: {
            relType: {
              serviceTag: 'Translations',
              relationshipTag: 'isTranslation'
            },
            objType: {
              serviceTag: 'Translations',
              objectType: 'translation'
            },
            direction: 'from'
          }
        }
      ]
    }
  ],
  filter: {
    objType: {
      serviceTag: 'ProductAttribute',
      objectType: 'productAttribute'
    },
    elements: [
      {
        type: 'complexFilter',
        complexFilter: {
          objType: {
            serviceTag: 'ProductAttribute',
            objectType: 'ProductAttributeLabel'
          },
          relType: {
            serviceTag: 'ProductAttribute',
            relationshipTag: 'isProductAttributeLabel'
          },
          direction: 'from',
          elements: [
            {
              type: 'logical',
              fieldName: 'labelId',
              comparison: 'equals',
              value: 'Id_X'
            }
          ]
        }
      }
    ]
  },
  requestProperties: {},
  identifiersIdArray: [
    {
      identifiersId: 'hashOfIdentifiersObject_1',
      identifiers: {
        productAttributeId: 'productAttributeId_uuid_1'
      }
    },
    {
      identifiersId: 'hashOfIdentifiersObject_2',
      identifiers: {
        productAttributeId: 'productAttributeId_uuid_2'
      }
    },
    {
      identifiersId: 'hashOfIdentifiersObject_3',
      identifiers: {
        productAttributeId: 'productAttributeId_uuid_3'
      }
    }
  ]
}

example search and sort request

{
   "objType":{
      "objectType":"sellOffer",
      "serviceTag":"SellOfferManager"
   },
   "searchResultId":"8e5fecd40a27e47f89cd2743916c0044f0f69bc6",
   "searchDetailId":"3462d3248d3af9406554f1c218b63442d26ac2e5",
   "requiredDataObjects":{
      "4c8e7879d26e6fa7ab85ded25a79a541754c5a3c":{
         "fieldName":"productId",
         "linkPathObjectId":"1a8a3f9c2c3ea5eaad1f42385362de5dd11cde8a"
      },
      "c799f11507529f0fb6fa712568596d24b6507d40":{
         "fieldName":"sellOfferHandlerServiceTag",
         "linkPathObjectId":"5909f82f27bd6c1f921e95b88a65b6e4727a6532",
         "complexFilterCombinationIds":[
            "88d9c5b9ab36d8c3ebf17e8322541b9c64cae25b",
            "51509dea0a7ba2746dbd24769b8e777f1411f3ff",
            "d7a7f875254e856b4205075826631ec042b4c821",
            "b96447ae98c95858694ca5ec407750c559825930"
         ]
      }
   },
   "searchParams":{
      "filterObjectId":"8e5fecd40a27e47f89cd2743916c0044f0f69bc6"
   },
   "filterElements":{
      "8e5fecd40a27e47f89cd2743916c0044f0f69bc6":{
         "objType":{
            "objectType":"sellOffer",
            "serviceTag":"SellOfferManager"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"sellOfferId",
            "comparison":"equals",
            "value":"sellOfferId_001"
         }
      },
      "d92ca4f68dc0d474cfdc10a6c702a5c7224a822c":{
         "objType":{
            "serviceTag":"DeliveryMethodRAT",
            "objectType":"rateTable"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"rateTableId",
            "comparison":"highLow",
            "valueType":"perParentIdentifier",
            "perParentIdentifierFieldname":"sellOfferId"
         }
      },
      "cd378bc32fbc9a46929c9a9d590e7d77243a839c":{
         "objType":{
            "serviceTag":"DeliveryMethodRAT",
            "objectType":"rateTable"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"rateTableId",
            "comparison":"lessThanEquals",
            "value":"cccc"
         }
      },
      "0c287df25d6ff203be7cc9faa2390f6ab0df3878":{
         "objType":{
            "serviceTag":"DeliveryMethodRAT",
            "objectType":"rateTable"
         },
         "filterElement":{
            "filterType":"operation",
            "filterElementLeft":"d92ca4f68dc0d474cfdc10a6c702a5c7224a822c",
            "filterElementRight":"cd378bc32fbc9a46929c9a9d590e7d77243a839c",
            "operator":"AND"
         }
      },
      "e0b8534452e98796f144c83a221764ef32db5ab6":{
         "objType":{
            "serviceTag":"Locations",
            "objectType":"locationNode"
         },
         "filterElement":{
            "filterType":"childComplexFilter",
            "childFilterElementId":"0c287df25d6ff203be7cc9faa2390f6ab0df3878",
            "pathLinkType":{
               "relType":{
                  "serviceTag":"DeliveryMethodRAT",
                  "relationshipTag":"disabledDeliversTolocationNode"
               },
               "objType":{
                  "serviceTag":"DeliveryMethodRAT",
                  "objectType":"rateTable"
               },
               "direction":"to"
            },
            "requestProperties":{}
         }
      },
      "88d9c5b9ab36d8c3ebf17e8322541b9c64cae25b":{
         "objType":{
            "serviceTag":"SellOfferPlan",
            "objectType":"sellOfferPlan"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"currencyId",
            "comparison":"lessThan",
            "value":"bbbb"
         }
      },
      "51509dea0a7ba2746dbd24769b8e777f1411f3ff":{
         "objType":{
            "serviceTag":"SellOfferPlan",
            "objectType":"sellOfferPlanUserPaymentMethodLink"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"sellOfferPlanUserPaymentMethodLinkId",
            "comparison":"lessThan",
            "value":"bbbb"
         }
      },
      "a5491ba3deb74e523741c8cfeb845f49db444a9c":{
         "objType":{
            "serviceTag":"Locations",
            "objectType":"locationNode"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"locationNodeId",
            "comparison":"lessThan",
            "value":"cccc"
         }
      },
      "7820aef170ae6c3e723382d6bc81d7b12a674974":{
         "objType":{
            "serviceTag":"DeliveryMethodRAT",
            "objectType":"rateTable"
         },
         "filterElement":{
            "filterType":"logical",
            "fieldName":"rateTableId",
            "comparison":"highLow",
            "value":"aaaa"
         }
      },
      "554fc368ec36c13a93e3c71c8081951060965bb2":{
         "objType":{
            "serviceTag":"Locations",
            "objectType":"locationNode"
         },
         "filterElement":{
            "filterType":"childComplexFilter",
            "childFilterElementId":"7820aef170ae6c3e723382d6bc81d7b12a674974",
            "pathLinkType":{
               "relType":{
                  "serviceTag":"DeliveryMethodRAT",
                  "relationshipTag":"deliversToLocationNode"
               },
               "objType":{
                  "serviceTag":"DeliveryMethodRAT",
                  "objectType":"rateTable"
               },
               "direction":"to"
            },
            "requestProperties":{}
         }
      },
      "d7a7f875254e856b4205075826631ec042b4c821":{
         "objType":{
            "serviceTag":"Locations",
            "objectType":"locationNode"
         },
         "filterElement":{
            "filterType":"operation",
            "filterElementLeft":"a5491ba3deb74e523741c8cfeb845f49db444a9c",
            "filterElementRight":"554fc368ec36c13a93e3c71c8081951060965bb2",
            "operator":"OR"
         }
      },
      "b96447ae98c95858694ca5ec407750c559825930":{
         "objType":{
            "serviceTag":"SellOfferPlan",
            "objectType":"sellOfferPlanUserPaymentMethodLink"
         },
         "filterElement":{
            "filterType":"operation",
            "filterElementLeft":"5faa4000cfb72e7aa28603a7740c212f6d6db5e0",
            "filterElementRight":"a1aa8d2907f8b6f24e7b66116129838e978bcaee",
            "operator":"OR"
         }
      }
   },
   "linkPathObjects":{
      "1a8a3f9c2c3ea5eaad1f42385362de5dd11cde8a":{
         "initialObjType":{
            "objectType":"sellOffer",
            "serviceTag":"SellOfferManager"
         },
         "linkSteps":[
            "fa9a637eb09df71d939b3d914eb9ee27ae83048e",
            "d3e2d36cab6d9441db10a7c983834cf9196398b3",
            "fa9a637eb09df71d939b3d914eb9ee27ae83048e"
         ]
      },
      "2794814ec253fc93496bfcb50ea18ebfe640bf4d":{
         "initialObjType":{
            "serviceTag":"SellOfferManager",
            "objectType":"sellOffer"
         },
         "linkSteps":[
            "fa9a637eb09df71d939b3d914eb9ee27ae83048e",
            "11704ae9a828b4709300964e2e0361bad13db5c3",
            "964050f23f92b45a1ea573a573c50ae3ca2bae18"
         ]
      },
      "5909f82f27bd6c1f921e95b88a65b6e4727a6532":{
         "initialObjType":{
            "objectType":"sellOffer",
            "serviceTag":"SellOfferManager"
         },
         "linkSteps":[
            "fa9a637eb09df71d939b3d914eb9ee27ae83048e",
            "634dd9295fcb1834de0a6ed1f1ab8a9fa06c4d7f",
            "d3fc84fa4444406cef2de49baf53d38ab86cd2e0",
            "2b0537fa34ee1d259488fce12204dd549e1c98a3"
         ]
      }
   },
   "linkPathSteps":{
      "fa9a637eb09df71d939b3d914eb9ee27ae83048e":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasSellOffer"
            },
            "objType":{
               "serviceTag":"ProductManager",
               "objectType":"product"
            },
            "direction":"to"
         }
      },
      "d3e2d36cab6d9441db10a7c983834cf9196398b3":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasSellOffer"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"sellOffer"
            },
            "direction":"from"
         },
         "comparison":"lessThan",
         "comparisonSortField":"productId",
         "comparisonSortDataType":"string",
         "comparisonValue":"eeee"
      },
      "634dd9295fcb1834de0a6ed1f1ab8a9fa06c4d7f":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasSellOffer"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"sellOffer"
            },
            "direction":"from"
         },
         "aggregate":"min",
         "sortFields":[
            {
               "fieldName":"SellOfferManager_CalCombinedPricingUniqueRequestId",
               "dataType":"string"
            }
         ],
         "requiredDataObjects":[
            {
               "fieldName":"SellOfferManager_CalCombinedPricingUniqueRequestId",
               "linkPathObjectId":"2794814ec253fc93496bfcb50ea18ebfe640bf4d"
            }
         ]
      },
      "d3fc84fa4444406cef2de49baf53d38ab86cd2e0":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasOrderPrice"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"orderPrice"
            },
            "direction":"from"
         },
         "requestProperties":{
            "tag_sellOfferPlan":"bbbb",
            "tag_sellOfferPlanDeliveryMethodLink":"bbbb"
         },
         "perParentCombinationIds":[
            {
               "tag":"tag_deliverTo",
               "filterMainId":"e0b8534452e98796f144c83a221764ef32db5ab6"
            }
         ],
         "applyCombinations":[
            {
               "tag":"tag_sellOfferPlanUserPaymentMethodLink",
               "filterMainId":"51509dea0a7ba2746dbd24769b8e777f1411f3ff"
            }
         ]
      },
      "2b0537fa34ee1d259488fce12204dd549e1c98a3":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasOrderPrice"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"sellOffer"
            },
            "direction":"to"
         },
         "requestProperties":{
            "tag_deliverTo":"aaaa",
            "tag_sellOfferPlanDeliveryMethodLink":"bbbb"
         },
         "applyCombinations":[
            {
               "tag":"tag_sellOfferPlan",
               "filterMainId":"88d9c5b9ab36d8c3ebf17e8322541b9c64cae25b"
            },
            {
               "tag":"tag_sellOfferPlanUserPaymentMethodLink",
               "filterMainId":"51509dea0a7ba2746dbd24769b8e777f1411f3ff"
            }
         ]
      },
      "11704ae9a828b4709300964e2e0361bad13db5c3":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasSellOffer"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"sellOffer"
            },
            "direction":"from"
         },
         "aggregate":"average",
         "sortFields":[
            {
               "fieldName":"sellOfferHandlerServiceTag",
               "dataType":"string"
            }
         ],
         "requiredDataObjects":[
            {
               "fieldName":"sellOfferHandlerServiceTag",
               "linkPathObjectId":"cae7f8604e62fd4ac09146f5bdd512d9db668c70"
            }
         ],
         "combine":true
      },
      "964050f23f92b45a1ea573a573c50ae3ca2bae18":{
         "pathLinkType":{
            "relType":{
               "serviceTag":"SellOfferManager",
               "relationshipTag":"hasOrderPrice"
            },
            "objType":{
               "serviceTag":"SellOfferManager",
               "objectType":"orderPrice"
            },
            "direction":"from"
         },
         "requestProperties":{
            "tag_sellOfferPlan":"aaaa",
            "tag_sellOfferPlanDeliveryMethodLink":"bbbb"
         },
         "applyCombinations":[
            {
               "tag":"tag_deliverTo",
               "filterMainId":"d7a7f875254e856b4205075826631ec042b4c821"
            },
            {
               "tag":"tag_sellOfferPlanUserPaymentMethodLink",
               "filterMainId":"b96447ae98c95858694ca5ec407750c559825930"
            }
         ],
         "comparison":"highLow",
         "comparisonSortField":"sellOfferHandlerServiceTag",
		 "comparisonSortDataType": "string"
         "comparisonValue":"aaaa"
      }
   },
   "sortFields":[
      {
         "fieldName":"productId",
         "dataType":"string"
      },
      {
         "fieldName":"productId",
         "dataType":"array",
         "sortArray":[
            "ffff",
            "eeee"
         ]
      }
   ]
}