From c1992b3b164ee839b48a2e1bedf00897cfbc2e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 23 Jun 2020 11:46:51 +0300 Subject: [PATCH 1/4] Change info -> debug for JSONHelper.getters --- .../src/main/java/fi/nls/oskari/util/JSONHelper.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/service-base/src/main/java/fi/nls/oskari/util/JSONHelper.java b/service-base/src/main/java/fi/nls/oskari/util/JSONHelper.java index f0b0ecbb14..3fe2cd10c0 100755 --- a/service-base/src/main/java/fi/nls/oskari/util/JSONHelper.java +++ b/service-base/src/main/java/fi/nls/oskari/util/JSONHelper.java @@ -49,7 +49,7 @@ public static final JSONObject createJSONObject(final String content) { try { return new JSONObject(content); } catch (Exception e) { - log.info("Error generating JSONObject from ", content); + log.debug("Error generating JSONObject from ", content); } return null; } @@ -57,7 +57,7 @@ public static final JSONObject createJSONObject4Tokener(final JSONTokener conten try { return new JSONObject(content); } catch (Exception e) { - log.info("Error generating JSONObject from JSONTokener ", content); + log.debug("Error generating JSONObject from JSONTokener ", content); } return null; } @@ -68,7 +68,7 @@ public static final JSONObject getJSONObject(final JSONObject content, String ke try { return content.getJSONObject(key); } catch (Exception e) { - log.info("Couldn't get JSONObject from ", content, " with key =", key); + log.debug("Couldn't get JSONObject from ", content, " with key =", key); return null; } } @@ -79,7 +79,7 @@ public static final Object get(final JSONObject content, String key) { try { return content.get(key); } catch (Exception e) { - log.info("Couldn't get Object from ", content, " with key =", key); + log.debug("Couldn't get Object from ", content, " with key =", key); return null; } } @@ -90,7 +90,7 @@ public static final JSONObject getJSONObject(final JSONArray content, int key) { try { return content.getJSONObject(key); } catch (Exception e) { - log.warn("Couldn't get JSONObject from ", content, " with key =", key, " - error: ", e); + log.debug("Couldn't get JSONObject from ", content, " with key =", key, " - error: ", e); return null; } } @@ -101,7 +101,7 @@ public static final JSONArray getJSONArray(final JSONObject content, String key) try { return content.getJSONArray(key); } catch (JSONException e) { - log.info("Couldn't get JSONArray from " + content + " with key = " + key); + log.debug("Couldn't get JSONArray from " + content + " with key = " + key); return null; } } From 7208bd5ab38742f94e747a5127f3980d04a953d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 23 Jun 2020 13:47:44 +0300 Subject: [PATCH 2/4] Change link to last attribute and enable formatting --- .../oskari/geoserver/GeoserverPopulator.java | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java b/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java index 1db85d38cc..409fa199c9 100755 --- a/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java +++ b/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java @@ -149,7 +149,7 @@ public static JSONObject addMyplacesAttributes(JSONObject attributes) { JSONObject filter = new JSONObject(); JSONHelper.putValue(data, "filter", filter); - Set fields = ConversionHelper.asSet("name", "place_desc", "link", "image_url"); + Set fields = ConversionHelper.asSet("name", "place_desc", "image_url", "link"); JSONHelper.putValue(filter, "default", new JSONArray(fields)); JSONHelper.putValue(filter, "fi", new JSONArray(fields)); @@ -169,6 +169,65 @@ public static JSONObject addMyplacesAttributes(JSONObject attributes) { JSONHelper.putValue(fi, "link", "linkki"); JSONHelper.putValue(fi, "image_url", "kuva-linkki"); + /* + + "name": { + "type": "h3", + "noLabel": true + }, + "place_desc": { + "type": "p", + "noLabel": true, + "skipEmpty": true + }, + "attention_text": { + "type": "hidden" + }, + "image_url": { + "type": "image", + "noLabel": true, + "params": { + "link": true + }, + "skipEmpty": true + }, + "link": { + "type": "link", + "skipEmpty": true + } + */ + JSONObject format = new JSONObject(); + JSONHelper.putValue(data, "format", format); + + JSONObject name = new JSONObject(); + JSONHelper.putValue(format, "name", name); + JSONHelper.putValue(name, "type", "h3"); + JSONHelper.putValue(name, "noLabel", true); + + JSONObject place_desc = new JSONObject(); + JSONHelper.putValue(format, "place_desc", place_desc); + JSONHelper.putValue(place_desc, "type", "p"); + JSONHelper.putValue(place_desc, "noLabel", true); + JSONHelper.putValue(place_desc, "skipEmpty", true); + + JSONObject attention_text = new JSONObject(); + JSONHelper.putValue(format, "attention_text", attention_text); + JSONHelper.putValue(attention_text, "type", "hidden"); + + JSONObject image_url = new JSONObject(); + JSONHelper.putValue(format, "image_url", image_url); + JSONHelper.putValue(image_url, "type", "image"); + JSONHelper.putValue(image_url, "noLabel", true); + JSONHelper.putValue(image_url, "skipEmpty", true); + JSONObject image_params = new JSONObject(); + JSONHelper.putValue(image_params, "link", true); + JSONHelper.putValue(image_url, "params", image_params); + + JSONObject link = new JSONObject(); + JSONHelper.putValue(format, "link", link); + JSONHelper.putValue(link, "type", "link"); + JSONHelper.putValue(link, "skipEmpty", true); + return attributes; } From 423626458afd814e915ea3bac351b573243d5043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 23 Jun 2020 13:58:58 +0300 Subject: [PATCH 3/4] Update attributes for myplaces baselayer --- .../V1_0_13__add_formatting_metadata.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 content-resources/src/main/java/flyway/myplaces/V1_0_13__add_formatting_metadata.java diff --git a/content-resources/src/main/java/flyway/myplaces/V1_0_13__add_formatting_metadata.java b/content-resources/src/main/java/flyway/myplaces/V1_0_13__add_formatting_metadata.java new file mode 100644 index 0000000000..0fed4667da --- /dev/null +++ b/content-resources/src/main/java/flyway/myplaces/V1_0_13__add_formatting_metadata.java @@ -0,0 +1,31 @@ +package flyway.myplaces; + +import fi.nls.oskari.db.DatasourceHelper; +import fi.nls.oskari.geoserver.GeoserverPopulator; +import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.json.JSONObject; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class V1_0_13__add_formatting_metadata implements JdbcMigration { + + public void migrate(Connection ignored) throws Exception { + // myplaces _can_ use other db than the default one + // -> Use connection to default db for this migration + DataSource ds = DatasourceHelper.getInstance().getDataSource(); + if (ds == null) { + ds = DatasourceHelper.getInstance().createDataSource(); + } + Connection conn = ds.getConnection(); + JSONObject attributes = GeoserverPopulator.addMyplacesAttributes(GeoserverPopulator.createUserContentAttributes()); + final String sql = "update oskari_maplayer set attributes =? where name = 'oskari:my_places';"; + + try (final PreparedStatement statement = conn.prepareStatement(sql)) { + statement.setString(1, attributes.toString()); + statement.execute(); + } + } + +} From 6df9b89aecb3b4ea86a2dbd731bda998ae1dd226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kinen?= Date: Tue, 23 Jun 2020 14:09:01 +0300 Subject: [PATCH 4/4] Update translations --- .../oskari/geoserver/GeoserverPopulator.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java b/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java index 409fa199c9..d69604cb64 100755 --- a/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java +++ b/content-resources/src/main/java/fi/nls/oskari/geoserver/GeoserverPopulator.java @@ -157,20 +157,30 @@ public static JSONObject addMyplacesAttributes(JSONObject attributes) { JSONHelper.putValue(data, "locale", locale); JSONObject en = new JSONObject(); JSONHelper.putValue(locale, "en", en); - JSONHelper.putValue(en, "name", "name"); - JSONHelper.putValue(en, "place_desc", "description"); - JSONHelper.putValue(en, "link", "link"); - JSONHelper.putValue(en, "image_url", "image"); + JSONHelper.putValue(en, "name", "Name"); + JSONHelper.putValue(en, "place_desc", "Description"); + JSONHelper.putValue(en, "link", "URL"); + JSONHelper.putValue(en, "image_url", "Image URL"); + JSONHelper.putValue(en, "attention_text", "Text on map"); JSONObject fi = new JSONObject(); JSONHelper.putValue(locale, "fi", fi); - JSONHelper.putValue(fi, "name", "nimi"); - JSONHelper.putValue(fi, "place_desc", "kuvaus"); - JSONHelper.putValue(fi, "link", "linkki"); - JSONHelper.putValue(fi, "image_url", "kuva-linkki"); + JSONHelper.putValue(fi, "name", "Nimi"); + JSONHelper.putValue(fi, "place_desc", "Kuvaus"); + JSONHelper.putValue(fi, "link", "Linkki"); + JSONHelper.putValue(fi, "image_url", "Kuvalinkki"); + JSONHelper.putValue(fi, "attention_text", "Teksti kartalla"); + + JSONObject sv = new JSONObject(); + JSONHelper.putValue(locale, "sv", sv); + JSONHelper.putValue(sv, "name", "Namn"); + JSONHelper.putValue(sv, "place_desc", "Beskrivelse"); + JSONHelper.putValue(sv, "link", "Webbaddress"); + JSONHelper.putValue(sv, "image_url", "Bild-URL"); + JSONHelper.putValue(sv, "attention_text", "Placera text på kartan"); /* - + Format is: "name": { "type": "h3", "noLabel": true