@@ -0,0 +1,2007 @@
+package flyway.myplaces;%0A%0Aimport fi.nls.oskari.domain.map.OskariLayer;%0Aimport org.flywaydb.core.api.migration.BaseJavaMigration;%0Aimport org.flywaydb.core.api.migration.Context;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0Aimport org.oskari.usercontent.LayerHelper;%0A%0A/**%0A * The label for field %22link%22 on my places layers for english, finnish and swedish%0A */%0Apublic class V1_0_14__change_link_label extends BaseJavaMigration %7B%0A%0A    private static final String NAME = %22oskari:my_places%22;%0A%0A    public void migrate(Context ignored) throws Exception %7B%0A        OskariLayer layer = LayerHelper.getLayerWithName(NAME);%0A        JSONObject attrs = layer.getAttributes();%0A        modifyAttributes(attrs);%0A        layer.setAttributes(attrs);%0A        LayerHelper.update(layer);%0A    %7D%0A%0A    /**%0A     * Set up for overriding to make future migration easier%0A     * @param attrs%0A     * @throws JSONException%0A     */%0A    void modifyAttributes(JSONObject attrs) throws JSONException %7B%0A        String field = %22link%22;%0A        // this repeats digging the locale from attributes multiple times%0A        // but allows developers to easily adjust other fields and languages as well in the future%0A        changeLabel(attrs, %22en%22, field, %22More information%22);%0A        changeLabel(attrs, %22fi%22, field, %22Lis%C3%A4tiedot%22);%0A        changeLabel(attrs, %22sv%22, field, %22Mera information%22);%0A    %7D%0A%0A    /**%0A     * Note! This can throw null pointer if the database was modified outside the%0A     * Flyway migrations and these blocks were removed.%0A     *%0A     * But it's better to catch that with failing migration than%0A     * let the migration die silently%0A     *%0A     * @param attrs%0A     * @return%0A     * @throws JSONException%0A     */%0A    void changeLabel(JSONObject attrs, String lang, String field, String label) throws JSONException %7B%0A        JSONObject data = attrs.optJSONObject(%22data%22);%0A        JSONObject locale = data.optJSONObject(%22locale%22);%0A        JSONObject en = locale.optJSONObject(lang);%0A        en.put(field, label);%0A    %7D%0A%7D%0A

Change label for myplaces link