Commit e7cdf568 authored by igoshin's avatar igoshin

#14051 fix NPE when workspace loaded and query executed, number of columns

parent 141543d3
......@@ -93,6 +93,12 @@ public class DwcaBuilder extends AbstractModelObject {
String path = sourceFile.getFile().getPath();
file.put("path", path);
}else if (sourceFile instanceof JdbcDataSource){
JSONObject dataBaseSettings=new JSONObject();
dataBaseSettings.put("url",((JdbcDataSource) sourceFile).getSettings().getUrl());
dataBaseSettings.put("user",((JdbcDataSource) sourceFile).getSettings().getUser());
dataBaseSettings.put("password",((JdbcDataSource) sourceFile).getSettings().getPassword());
file.put("dataBaseSettings",dataBaseSettings);
file.put("name",sourceFile.getFileName());
}
......@@ -184,6 +190,12 @@ public class DwcaBuilder extends AbstractModelObject {
sourceFile.setFile(file);
}else {
sourceFile =new JdbcDataSource(sourceJ.getString("name"));
JSONObject dataBaseSettingsJ = sourceJ.getJSONObject("dataBaseSettings");
DatabaseSettings databaseSettings= new DatabaseSettings();
databaseSettings.setUrl(dataBaseSettingsJ.getString("url"));
databaseSettings.setUser(dataBaseSettingsJ.getString("user"));
databaseSettings.setPassword(dataBaseSettingsJ.getString("password"));
((JdbcDataSource)sourceFile).setSettings(databaseSettings);
}
JSONArray sheets = sourceJ.getJSONArray("sheets");
......
......@@ -103,7 +103,7 @@ public class JdbcDataSourceSheet extends AbstractModelObject implements IDataSou
private void ensureColumns(int columnCount, Object[] headerRow) {
boolean changed = false;
for (int i = columns.size() - 1; i >= 0 && i > columnCount; i--) {
for (int i = columns.size() - 1; i >= 0 && i > columnCount-1; i--) {
columns.remove(i);
changed = true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment