@@ -0,0 +1,2908 @@
+package flyway.olcesium;%0A%0Aimport fi.nls.oskari.domain.map.view.Bundle;%0Aimport fi.nls.oskari.domain.map.view.View;%0Aimport fi.nls.oskari.log.LogFactory;%0Aimport fi.nls.oskari.log.Logger;%0Aimport fi.nls.oskari.map.view.ViewException;%0Aimport fi.nls.oskari.map.view.ViewService;%0Aimport fi.nls.oskari.map.view.ViewServiceIbatisImpl;%0Aimport fi.nls.oskari.util.JSONHelper;%0Aimport org.flywaydb.core.api.migration.jdbc.JdbcMigration;%0Aimport org.json.JSONArray;%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class V1_12__add_wfs_plugin implements JdbcMigration %7B%0A%0A    private static final Logger LOG = LogFactory.getLogger(V1_12__add_wfs_plugin.class);%0A    private static final String CESIUM_VIEW_NAME = %22Geoportal Ol Cesium%22;%0A    private static final String MAP_BUNDLE_NAME = %22mapfull%22;%0A    private static final String WFS_PLUGIN_ID = %22Oskari.wfsvector.WfsVectorLayerPlugin%22;%0A%0A    private ViewService viewService = null;%0A%0A    public void migrate(Connection connection) %7B%0A        viewService =  new ViewServiceIbatisImpl();%0A        updateCesiumViews(connection);%0A    %7D%0A%0A    private void updateCesiumViews(Connection connection) %7B%0A        try %7B%0A            List%3CLong%3E viewIds = getCesiumViewIds(connection);%0A            LOG.info(%22Updating Cesium views - count:%22, viewIds.size());%0A%0A            for(Long viewId : viewIds) %7B%0A                View modifyView = viewService.getViewWithConf(viewId);%0A                updateMapFullBundle(modifyView);%0A            %7D%0A        %7D catch (Exception e) %7B%0A            LOG.error(e, %22Could not update 3D view%22);%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    private void updateMapFullBundle(View view) throws JSONException, ViewException %7B%0A        Bundle mapfull = view.getBundleByName(MAP_BUNDLE_NAME);%0A        JSONObject config = mapfull.getConfigJSON();%0A        JSONArray plugins = config.getJSONArray(%22plugins%22);%0A        JSONObject plugin = JSONHelper.createJSONObject(%22id%22, WFS_PLUGIN_ID);%0A        plugins.put(plugin);%0A        mapfull.setConfig(config.toString());%0A        viewService.updateBundleSettingsForView(view.getId(), mapfull);%0A    %7D%0A%0A    private List%3CLong%3E getCesiumViewIds(Connection conn) throws SQLException %7B%0A        List%3CLong%3E list = new ArrayList%3C%3E();%0A        final String sql = %22SELECT id FROM portti_view WHERE name=?%22;%0A%0A        try (PreparedStatement statement = conn.prepareStatement(sql)) %7B%0A            statement.setString(1, CESIUM_VIEW_NAME);%0A            try (ResultSet rs = statement.executeQuery()) %7B%0A                while (rs.next()) %7B%0A                    list.add(rs.getLong(%22id%22));%0A                %7D%0A            %7D%0A        %7D catch (Exception e) %7B%0A            LOG.error(e, %22Error getting Cesium portti views%22);%0A        %7D%0A        return list;%0A    %7D%0A%7D%0A

Fix already used migration number