-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix conditions check #128
base: development
Are you sure you want to change the base?
Fix conditions check #128
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"sourceId": "1", | ||
"sourceType": "api", | ||
"sourceHash": "", | ||
"sourceHashMapping": "1", | ||
"sourceTargetMapping": "1", | ||
"sourceConfig": { | ||
"idPosition": "identificatie", | ||
|
@@ -13,6 +14,7 @@ | |
"headers": [], | ||
"query.startdatum__gte": "2024-08-01", | ||
"query.einddatum__lt": "2025-01-01", | ||
"query.maximaleVertrouwelijkheidaanduiding": "openbaar", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moet "aanduiding" niet met een hoofdletter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nee dit is een veld vanuit xxllnc suite, ik heb het niet verzonnen |
||
"usesPagination": "false", | ||
"extraDataConfigs.0.staticEndpoint": "/tlb/zaaksysteem/api/v1/zaken/{{ originId }}/informatieobjecten", | ||
"extraDataConfigs.0.mergeExtraData": "true", | ||
|
@@ -21,5 +23,17 @@ | |
"extraDataConfigs.0.extraDataConfigPerResult.staticEndpoint": "/tlb/zaaksysteem/api/v1/informatieobjecten/{{ originId }}" | ||
}, | ||
"targetId": "1/1", | ||
"targetType": "register/schema" | ||
"targetType": "register/schema", | ||
"conditions": { | ||
"if": [ | ||
{ | ||
"or": [ | ||
{ "in": [{ "var": "zaaktypecode" }, ["LP00000431", "B1873"]] }, | ||
{ "in": [{ "var": "zaaktypecode" }, ["LP00000091", "LP00001132", "LP00000121", "B0757", "LP00000832", "LP00001096"]] } | ||
] | ||
}, | ||
true, | ||
false | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,16 @@ public function synchronize(Synchronization $synchronization, ?bool $isTest = fa | |
$objectList = $this->getAllObjectsFromSource(synchronization: $synchronization, isTest: $isTest); | ||
|
||
foreach ($objectList as $key => $object) { | ||
|
||
// Check if object adheres to conditions. | ||
// Take note, JsonLogic::apply() returns a range of return types, so checking it with '=== false' or '!== true' does not work properly. | ||
if ($synchronization->getConditions() !== [] && !JsonLogic::apply($synchronization->getConditions(), $object)) { | ||
|
||
// @todo log that this object is not valid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo, create a log |
||
unset($objectList[$key]); | ||
continue; | ||
} | ||
|
||
// If the source configuration contains a dot notation for the id position, we need to extract the id from the source object | ||
$originId = $this->getOriginId($synchronization, $object); | ||
|
||
|
@@ -340,12 +350,6 @@ public function synchronizeContract(SynchronizationContract $synchronizationCont | |
$synchronizationContract->setSourceLastChanged(new DateTime()); | ||
$synchronizationContract->setSourceLastChecked(new DateTime()); | ||
|
||
// Check if object adheres to conditions. | ||
// Take note, JsonLogic::apply() returns a range of return types, so checking it with '=== false' or '!== true' does not work properly. | ||
if ($synchronization->getConditions() !== [] && !JsonLogic::apply($synchronization->getConditions(), $object)) { | ||
return $synchronizationContract; | ||
} | ||
|
||
// If no source target mapping is defined, use original object | ||
if (empty($synchronization->getSourceTargetMapping()) === true) { | ||
$targetObject = $object; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field is added in a other pull request but adding it here is harmless