Skip to content

Commit

Permalink
Merge pull request #551 from KavinduZoysa/datamap-bug
Browse files Browse the repository at this point in the history
Delete array element in datamap view
  • Loading branch information
KavinduZoysa authored Jan 28, 2025
2 parents 602ba59 + 04a5c05 commit fea9c91
Show file tree
Hide file tree
Showing 7 changed files with 452 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,17 +633,17 @@ private void genSourceFromMappingThroughElements(MappingElements mappingElements
String[] splits = substring.split("\\.");
int length = splits.length;
String lastSplit = splits[length - 1];
if (length == 1 && lastSplit.matches("^-?\\d+$")) {
if (length == 1 && lastSplit.matches("\\d+")) {
elements.add(mapping.expression());
return;
continue;
}
Map<String, Object> currentMapping = m;
String key = splits[0];
for (int i = 0; i < length; i++) {
String split = splits[i];
Object o = currentMapping.get(key);
if (o == null) {
if (!split.matches("^-?\\d+$")) {
if (!split.matches("\\d+")) {
if (i == length - 1) {
Object o1 = genExprFromMapping(mapping);
currentMapping.put(split, o1);
Expand All @@ -659,7 +659,9 @@ private void genSourceFromMappingThroughElements(MappingElements mappingElements
}
}
}
elements.add(m);
if (!m.isEmpty()) {
elements.add(m);
}
}

public String getSource(JsonElement mp, JsonElement fNode, String targetField) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ protected Object[] getConfigsList() {
{Path.of("variable12.json")},
{Path.of("variable13.json")},
{Path.of("variable14.json")},
{Path.of("variable15.json")},
{Path.of("variable16.json")},
{Path.of("variable17.json")},
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"source": "variable14.bal",
"description": "Sample diagram node",
"diagram": {
"id": "31",
"metadata": {
"label": "Variable",
"description": "New variable with type"
},
"codedata": {
"node": "VARIABLE",
"lineRange": {
"startLine": {
"line": 16,
"offset": 36
},
"endLine": {
"line": 16,
"offset": 36
}
}
},
"returning": false,
"properties": {
"variable": {
"metadata": {
"label": "Name",
"description": "Name of the variable"
},
"valueType": "IDENTIFIER",
"value": "var1",
"optional": false,
"editable": true,
"advanced": false
},
"type": {
"metadata": {
"label": "Type",
"description": "Type of the variable"
},
"valueType": "TYPE",
"value": "Students",
"placeholder": "var",
"optional": false,
"editable": true,
"advanced": false
},
"expression": {
"metadata": {
"label": "Expression",
"description": "Initialize with value"
},
"valueType": "EXPRESSION",
"value": "{names:[\"1\",\"2\", \"4\"]}",
"optional": true,
"editable": true,
"advanced": false
}
},
"flags": 0
},
"propertyKey": "expression",
"position": {
"line": 17,
"offset": 30
},
"mappings": [
{
"output": "var1.names",
"inputs": [],
"expression": "[\"1\", \"2\"]",
"diagnostics": [],
"elements": [
{
"mappings": [
{
"output": "var1.names.0",
"inputs": [],
"expression": "\"1\"",
"diagnostics": [],
"elements": []
},
{
"output": "var1.names.1",
"inputs": [],
"expression": "\"2\"",
"diagnostics": [],
"elements": []
}
]
}
]
}
],
"output": "{names:[\"1\",\"2\"]}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"source": "variable15.bal",
"description": "Sample diagram node",
"diagram": {
"id": "31",
"metadata": {
"label": "Variable",
"description": "New variable with type"
},
"codedata": {
"node": "VARIABLE",
"lineRange": {
"startLine": {
"line": 16,
"offset": 36
},
"endLine": {
"line": 16,
"offset": 36
}
}
},
"returning": false,
"properties": {
"variable": {
"metadata": {
"label": "Name",
"description": "Name of the variable"
},
"valueType": "IDENTIFIER",
"value": "var1",
"optional": false,
"editable": true,
"advanced": false
},
"type": {
"metadata": {
"label": "Type",
"description": "Type of the variable"
},
"valueType": "TYPE",
"value": "Students",
"placeholder": "var",
"optional": false,
"editable": true,
"advanced": false
},
"expression": {
"metadata": {
"label": "Expression",
"description": "Initialize with value"
},
"valueType": "EXPRESSION",
"value": "{names:[[\"1\", \"6\"],[\"10\", \"60\"],[\"10\", \"60\", \"70\"]]}",
"optional": true,
"editable": true,
"advanced": false
}
},
"flags": 0
},
"propertyKey": "expression",
"position": {
"line": 17,
"offset": 30
},
"mappings": [
{
"output": "var1.names",
"inputs": [],
"expression": "[[\"1\", \"6\"], [\"10\", \"60\"], [\"10\", \"61\"]]",
"diagnostics": [],
"elements": [
{
"mappings": [
{
"output": "var1.names.0",
"inputs": [],
"expression": "[\"1\", \"6\"]",
"diagnostics": [],
"elements": [
{
"mappings": [
{
"output": "var1.names.0.0",
"inputs": [],
"expression": "\"1\"",
"diagnostics": [],
"elements": []
},
{
"output": "var1.names.0.1",
"inputs": [],
"expression": "\"6\"",
"diagnostics": [],
"elements": []
}
]
}
]
},
{
"output": "var1.names.1",
"inputs": [],
"expression": "[\"10\", \"60\"]",
"diagnostics": [],
"elements": [
{
"mappings": [
{
"output": "var1.names.1.0",
"inputs": [],
"expression": "\"10\"",
"diagnostics": [],
"elements": []
},
{
"output": "var1.names.1.1",
"inputs": [],
"expression": "\"60\"",
"diagnostics": [],
"elements": []
}
]
}
]
},
{
"output": "var1.names.2",
"inputs": [],
"expression": "[\"10\", \"61\"]",
"diagnostics": [],
"elements": [
{
"mappings": [
{
"output": "var1.names.2.0",
"inputs": [],
"expression": "\"10\"",
"diagnostics": [],
"elements": []
},
{
"output": "var1.names.2.1",
"inputs": [],
"expression": "\"61\"",
"diagnostics": [],
"elements": []
}
]
}
]
}
]
}
]
}
],
"output": "{names:[[\"1\", \"6\"],[\"10\", \"60\"],[\"10\", \"61\"]]}"
}
Loading

0 comments on commit fea9c91

Please sign in to comment.