From f2371e79799fb4f85287701ad8af6c01db50774f Mon Sep 17 00:00:00 2001 From: kowatsch Date: Wed, 16 May 2018 15:25:33 +0200 Subject: [PATCH] implementing method to make some objects empty, if null --- .../inputProcessing/InputProcessor.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/heigit/bigspatialdata/ohsome/ohsomeApi/inputProcessing/InputProcessor.java b/src/main/java/org/heigit/bigspatialdata/ohsome/ohsomeApi/inputProcessing/InputProcessor.java index bd6276f4..3118021a 100644 --- a/src/main/java/org/heigit/bigspatialdata/ohsome/ohsomeApi/inputProcessing/InputProcessor.java +++ b/src/main/java/org/heigit/bigspatialdata/ohsome/ohsomeApi/inputProcessing/InputProcessor.java @@ -92,7 +92,8 @@ else if (DbConnData.igniteDb == null) this.showMetadata = false; else if (showMetadata.equalsIgnoreCase("true") || showMetadata.equalsIgnoreCase("yes")) this.showMetadata = true; - else if (showMetadata.equalsIgnoreCase("false") || showMetadata.equals("") || showMetadata.equalsIgnoreCase("no")) + else if (showMetadata.equalsIgnoreCase("false") || showMetadata.equals("") + || showMetadata.equalsIgnoreCase("no")) this.showMetadata = false; else throw new BadRequestException( @@ -353,6 +354,29 @@ private String createEmptyStringIfNull(String toCheck) { return toCheck; } + /** + * Looks at specific objects within the RequestParameters object and makes them empty, if they are + * null. Needed for the /ratio computation using POST requests. + */ + public RequestParameters fillWithEmptyIfNull(RequestParameters rPs) { + + String[] types = rPs.getTypes(); + if (types == null) + types = new String[0]; + String[] keys = rPs.getKeys(); + if (keys == null) + keys = new String[0]; + String[] values = rPs.getValues(); + if (values == null) + values = new String[0]; + + RequestParameters rPs2 = new RequestParameters(rPs.isPost(), rPs.isSnapshot(), rPs.isDensity(), + rPs.getBboxes(), rPs.getBcircles(), rPs.getBpolys(), types, keys, values, + rPs.getUserids(), rPs.getTime(), rPs.getShowMetadata()); + + return rPs2; + } + /* * Getters start here */