Skip to content

Commit

Permalink
Fixed null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Nov 20, 2024
1 parent 8cea595 commit 7688833
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ private static boolean jsonNodeHasFieldAndIsArray(JsonNode node, String fieldNam
return node.has(fieldName) && node.get(fieldName).isArray();
}

/**
* Replace with dina-base function when 0.132 is available.
*
* @param objNode
* @param fieldName
* @return
*/
private static String safeAsText(ObjectNode objNode, String fieldName) {
return objNode.has(fieldName) ? objNode.get(fieldName).asText() : "";
}

/**
* Gets all the text for the "attributes" specified by the columns and concatenate them using
* the default separator.
Expand All @@ -321,7 +332,7 @@ private static boolean jsonNodeHasFieldAndIsArray(JsonNode node, String fieldNam
private static String handleConcatFunction(ObjectNode attributeObjNod, List<String> columns) {
List<String> toConcat = new ArrayList<>();
for (String col : columns) {
toConcat.add(attributeObjNod.get(col).asText());
toConcat.add(safeAsText(attributeObjNod, col));
}
return String.join(DEFAULT_CONCAT_SEP, toConcat);
}
Expand All @@ -338,7 +349,7 @@ private static String handleConvertCoordinatesDecimalDegrees(ObjectNode attribut
String decimalDegreeCoordinates = null;
if (columns.size() == 1) {
JsonNode coordinates = attributeObjNod.get(columns.getFirst());
if (coordinates.isArray()) {
if (coordinates != null && coordinates.isArray()) {
List<JsonNode> longLatNode = IteratorUtils.toList(coordinates.iterator());
if (longLatNode.size() == 2) {
decimalDegreeCoordinates = String.format(COORDINATES_DD_FORMAT,
Expand Down

0 comments on commit 7688833

Please sign in to comment.