From 1306b1bdfeb4ee94117c5f509b7b2f6b5b2f925b Mon Sep 17 00:00:00 2001 From: "m.lettere" Date: Tue, 18 Jul 2023 12:33:27 +0200 Subject: [PATCH] added ID extraction and check --- templates/record_context_to_is.json.j2 | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/templates/record_context_to_is.json.j2 b/templates/record_context_to_is.json.j2 index 54973ba..fa96335 100644 --- a/templates/record_context_to_is.json.j2 +++ b/templates/record_context_to_is.json.j2 @@ -64,6 +64,15 @@ "Authorization" : "Bearer ${authorize_uma_rootvo.output.body.access_token}" } } + }, + { + "name" : "pyeval", + "taskReferenceName" : "extract_infrastructure_id", + "type" : "SIMPLE", + "inputParameters" : { + "code" : "exec('import xml.etree.ElementTree as ET') or list(map(lambda n: n.text, ET.fromstring(data['xmlstring']).findall('Resource[Profile/SecondaryType = \"INFRASTRUCTURE\"]/ID')))", + "xmlstring" : "${retrieve_vre.output.body}" + } } ], [ @@ -97,6 +106,15 @@ "Authorization" : "Bearer ${authorize_uma_paarent_vo.output.body.access_token}" } } + }, + { + "name" : "pyeval", + "taskReferenceName" : "extract_vre_id", + "type" : "SIMPLE", + "inputParameters" : { + "code" : "exec('import xml.etree.ElementTree as ET') or list(map(lambda n: n.text, ET.fromstring(data['xmlstring']).findall('Resource/ID')))", + "xmlstring" : "${retrieve_vre.output.body}" + } } ] ] @@ -105,7 +123,17 @@ "name": "notification_join", "taskReferenceName": "notification_join_ref", "type": "JOIN", - "joinOn": ["retrieve_infrastructure", "retrieve_vre"] + "joinOn": ["extract_infrastructure_id", "extract_vre_id"] + }, + { + "type" : "LAMBDA", + "name": "LAMBDA_TASK", + "taskReferenceName": "check", + "inputParameters": { + "vre": "${extract_vre_id.output.result}", + "infra": "${extract_vre_id.output.result}", + "scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} if(e($.vre) || e($.infra)) throw('VRE ID and Infra ID must not be empty'); var tree = $.ctx.split('%2F'); return { child : tree[tree.length - 1], parent : tree[tree.length-2], decoded_root_vo : $.root_vo.replace('%2F', '/') }" + } }, { "name" : "pyrest",