2022-10-29 Example Import Data feed and config
Overview
Sample for importing a DeliveryMethod, RateTable (including versioned data), and location nodes for both from (DeliveryMethod) and to (rateTable - multiple) relationships.
- DeliveryMethod must be created before RateTable
- DeliveryMethod's from LocationNode must be created before DeliveryMethod
- to LocationNodes can be created at same time as (or before) RateTable
example Config table items
{
configKey: "objectType",
configTag: "deliveryMethodStandard"
configValue: {
createObjectServiceName: "DeliveryMethodStandard",
parentLinks: {
"locationNode": {
"fromLocationNode": {
linkType: "Dependent",
separateDependentLinkCreate: false,
createLinkServiceNames:"DeliveryMethodStandard"
// createLinkServiceNames: "DeliveryMethodStandard",
},
},
},
childObjectTypes:[
"deliveryMethodRateTable",
]
}
},
{
configKey: "objectType",
configTag: "deliveryMethodRateTable"
configValue: {
createObjectServiceName: "DeliveryMethodStandard", //?
parentLinks: {
"locationNode": {
"toLocationNode": {
linkType: "Independent",
createLinkServiceNames: "DeliveryMethodRateTable",
},
},
"deliveryMethodStandard": {
"ownsRateTable": {
linkType: "Dependent",
separateDependentLinkCreate: false
// createLinkServiceNames: "DeliveryMethodStandard",
},
},
},
childObjectTypes:[
]
}
},
{
configKey: "objectType",
configTag: "locationNode"
configValue: {
createObjectServiceName: "Locations",
parentLinks: {
},
childObjectTypes:[
"deliveryMethodStandard",
"deliveryMethodRateTable"
]
}
},
example data
ImportBatchMain
{
importBatchId: "xx",
userId: "uu",
startTime: "..",
batchConfig: {
// ..
},
status: "processingObjects",
// countPendingObjectMain: 5, // not yet saved
// countPendingLinks: 4, // not yet saved
}
PendingObjectMain
{
importBatchId: "xx",
pendingObjectId: "aa",
objectType: "deliveryMethodStandard",
fields: {
deliveryMethodName: [
{
"en": "Post Office",
"th": "Braisanee"
}
],
},
reference: "delMeth",
recordNumber: 1,
status: "processing",
errorsFound: {},
},
{
importBatchId: "xx",
pendingObjectId: "bb",
objectType: "deliveryMethodRateTable",
fields: {
rates: [
//..
],
},
recordNumber: 2,
status: "processing",
errorsFound: {}
},
{
importBatchId: "xx",
pendingObjectId: "cc",
objectType: "locationNode",
fields: {
locationName: [
{
"en": "Chiang Mai",
"th": "เชียงใหม่"
}
],
},
recordNumber: 3,
status: "processing",
errorsFound: {}
},
{
importBatchId: "xx",
pendingObjectId: "dd",
objectType: "locationNode",
identifier: {
locationNodeId: "sdsd",
},
recordNumber: 4,
status: "processing",
errorsFound: {}
},
{
importBatchId: "xx",
pendingObjectId: "ee",
objectType: "locationNode",
fields: {
locationName: [
{
"en": "UdonThani",
"th": "อุดรธานี"
}
],
},
recordNumber: 4,
status: "processing",
errorsFound: {}
},
PendingObjectReference
{
importBatchId: "xx",
referenceId: "delMeth",
pendingObjectId: "aa"
},
{
importBatchId: "xx",
referenceId: "fromLoc",
pendingObjectId: "cc"
},
{
importBatchId: "xx",
referenceId: "toLocA",
pendingObjectId: "dd"
},
{
importBatchId: "xx",
referenceId: "toLocB",
pendingObjectId: "ee"
},
PendingLink
{
importBatchId: "xx",
pendingLinkId: "bb_delMeth",
linkTag: "ownsRateTable"
status: "processing",
},
{
importBatchId: "xx",
pendingLinkId: "aa_fromLoc",
linkTag: "fromLocationNode"
status: "processing",
},
{
importBatchId: "xx",
pendingLinkId: "bb_toLocA",
linkTag: "toLocationNode"
status: "processing",
},
{
importBatchId: "xx",
pendingLinkId: "bb_toLocB",
linkTag: "toLocationNode"
status: "processing",
},
Example csv
objectType,deliveryMenthodName.th,deliveryMenthodName.en,reference,rates,link.1.reference,link.1.linkTag,locationNodeId,locationName.en,locationName.th,notStopOnDuplicate,Link.2.reference,Link.2.linkTag,Link.3.reference,Link.3.linkTag
deliveryMethodStandard,Baisanee,Post Office,delMeth,,fromLoc,fromLocationNode,,,,,,,,
deliveryMethodRateTable,,,,"[
//..
]",delMeth,ownsRateTable,,,,,toLocA,toLocationNode,toLocB,toLocationNode
deliveryMethodRateTable,,,,"[
//..
]",delMeth,ownsRateTable,,,,,,,,
locationNode,,,fromLoc,,delMeth,fromLocationNode,,Chiang Mai,เชียงใหม่,TRUE,,,,
locationNode,,,toLocA,,,,,Bangkok,กรุงเทพฯ,,,,,
locationNode,,,toLocB,,,,,UdonThani,อุดรธานี,,,,,