根据条件添加默认值的JOLT规范

时间:2019-09-25 05:03:15

标签: jolt

如果我的输入在“元数据”中包含“ WorkflowCategory”,则输出应包含具有指定默认值的工作流.workflowInputProperties-具有重复值(如“”字符串,3等)。如果没有,则不应添加workflow.workflowInputProperties。

输入1

A=0
-B=0
--D=100
--E=100
-C=0
--F=200
--G=200

输入2

A=600
-B=200
--D=100
--E=100
-C=400
--F=200
--G=200

对于输入1,输出应为

    {
      "template": false,
      "active": true,
      "metadata": [
       {
         "value": "bank_",
         "key": "AssetNamePrefix"
       },
       {
         "value": "-BERG",
         "key": "SuffixForPublicId"
       },
       {
         "value": "false",
         "key": "CORSEnabled"
       },
       {
         "value": "Capture",
         "key": "WorkflowCategory"
       },
       {
         "value": "HD",
         "key": "Features"
       }
   ],
   "description": "Template for working with PRI",
   "name": "prof_name",
   "type": "Live",
   "id": "BNK056003413",
   "version": 6
 }

对于输入2,输出应如下所示,且没有工作流程。workflowInputProperties

{
  "template": false,
  "active": true,
  "metadata": [
    {
      "value": "HD",
      "key": "Features"
    }
  ],
  "description": "Live Template",
  "name": "Live_HD",
  "type": "Live",
  "id": "BNK007596994",
  "version": 1
}

1 个答案:

答案 0 :(得分:0)

您应将以下代码添加到其余规范中。唯一的问题是我不能放置空字符串,而是将其更改为空格。我会尽力解决的。

[
  {
    "operation": "shift",
    "spec": {
      "metadata": {
        "*": {
          "key": {
            "WorkflowCategory": {
              "#bank_": "workflow.workflowInputProperties.assetNamePrefix",
              "# ": [
              "workflow.workflowInputProperties.recordId",
              "workflow.workflowInputProperties.sourceUri",
              "workflow.workflowInputProperties.processingUri"
                    ],
              "#ABC": "workflow.workflowInputProperties.recorderType",
              "#600": "workflow.workflowInputProperties.completionTimeout",
              "#10": "workflow.workflowInputProperties.loopBackTimer",
              "#3": ["workflow.workflowInputProperties.numberOfRetries",
              "workflow.workflowInputProperties.numberOfRetriesForScheduling"],
              "#3600": "workflow.workflowInputProperties.scheduleDelay"
            }
          }
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "workflow": {
        "workflowInputProperties": {
          "completionTimeout": "=toInteger",
          "loopBackTimer": "=toInteger",
          "numberOfRetries": "=toInteger",
          "numberOfRetriesForScheduling": "=toInteger",
          "scheduleDelay": "=toInteger"
        }
      }
    }
  }
]