Commit 76db66a0df36dd0f9db7a3eae17ffe5e2a843e84

Authored by Nathanael Jourdane
1 parent eb483599
Exists in master

auto-remove null parameters from the map

src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java
... ... @@ -50,14 +50,12 @@ public final class Queries {
50 50 public static String getQuery(String tableName, Map<String, Object> params, int nbRow) {
51 51 StringJoiner join = new StringJoiner(" AND ");
52 52 for (Map.Entry<String, Object> param : params.entrySet()) {
53   - if (param.getValue() != null) {
54   - Class paramClass = param.getValue().getClass();
  53 + Class paramClass = param.getValue().getClass();
55 54  
56   - if (paramClass == String.class && !"".equals(param.getValue())) {
57   - join.add(param.getKey() + " LIKE '%" + param.getValue() + "%'");
58   - } else if (paramClass == Float.class || paramClass == Integer.class) {
59   - join.add(param.getKey() + " = " + param.getValue().toString());
60   - }
  55 + if (paramClass == String.class && !"".equals(param.getValue())) {
  56 + join.add(param.getKey() + " LIKE '%" + param.getValue() + "%'");
  57 + } else {
  58 + join.add(param.getKey() + " = " + param.getValue().toString());
61 59 }
62 60 }
63 61 String where = "".equals(join.toString()) ? "" : " WHERE " + join.toString();
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/RequestView.java
... ... @@ -131,8 +131,13 @@ public class RequestView extends JPanel implements ActionListener {
131 131 }
132 132  
133 133 public void updateParam(String paramName, Object value) {
134   - logger.info("uploading " + paramName + ": " + value);
135   - paramValues.put(paramName, value);
  134 + if (value == null) {
  135 + paramValues.remove(paramName);
  136 + logger.info("removed " + paramName);
  137 + } else {
  138 + paramValues.put(paramName, value);
  139 + logger.info("uploaded " + paramName + ": " + value);
  140 + }
136 141 updateQueryArea();
137 142 }
138 143  
... ...