Skip to content

Commit

Permalink
adding sample new mappings, #38
Browse files Browse the repository at this point in the history
  • Loading branch information
sagIoTPower committed Jul 7, 2023
1 parent 22ab6fa commit 719e717
Show file tree
Hide file tree
Showing 7 changed files with 1,237 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -39,3 +39,4 @@ bin/
.vscode/settings.json
resources/script/createSampleMappings_private.sh
resources/script/attic/createSampleMappings_private.sh
attic/*
Expand Up @@ -62,8 +62,12 @@ public Object typedValue() {
switch (type) {
case OBJECT:
case ARRAY:
dc = JsonPath.parse(value.toString());
result = dc.read("$");
if (value != null && !value.isNull()) {
dc = JsonPath.parse(value.toString());
result = dc.read("$");
} else {
result= value;
}
return result;
case IGNORE:
return null;
Expand Down
Expand Up @@ -219,8 +219,9 @@ public ProcessingContext<T> substituteInTargetAndSend(ProcessingContext<T> conte

public void substituteValueInObject(SubstituteValue sub, DocumentContext jsonObject, String keys)
throws JSONException {
boolean subValueEmpty = sub.value == null || sub.value.isEmpty();
if (( sub.repairStrategy.equals(RepairStrategy.REMOVE_IF_MISSING) || sub.repairStrategy.equals(RepairStrategy.REMOVE_IF_NULL)) && subValueEmpty) {
boolean subValueMissing = sub.value == null ;
boolean subValueNull = sub.value.isNull() ;
if (( sub.repairStrategy.equals(RepairStrategy.REMOVE_IF_MISSING) && subValueMissing ) || ( sub.repairStrategy.equals(RepairStrategy.REMOVE_IF_NULL) && subValueNull)) {
jsonObject.delete(keys);
} else {
jsonObject.set(keys, sub.typedValue());
Expand Down
Expand Up @@ -684,7 +684,7 @@ export class MappingStepperComponent implements OnInit, AfterContentChecked {
label: "Repair strategy",
description: `Strategy defining what should happen when extracted arrays in
different expressions do not have the same size. How are missing values handled?`,
options: Object.keys(RepairStrategy).map((key) => {
options: Object.keys(RepairStrategy).filter( (key) => key != 'IGNORE' ).map((key) => {
return {
label: key,
value: key,
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 719e717

Please sign in to comment.