Loading new/src/main/java/it/inaf/oats/ia2/tap/tsm/datalayer/TapSchemaDL.java +18 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package it.inaf.oats.ia2.tap.tsm.datalayer; import it.inaf.oats.ia2.tap.tsm.model.*; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; Loading @@ -14,8 +13,8 @@ import java.util.List; */ public class TapSchemaDL { public static ArrayList<String> getAllSchemasNames(Connection connection) throws SQLException { final ArrayList<String> allSchemas = new ArrayList<String>(); public static List<String> getAllSchemasNames(Connection connection) throws SQLException { final List<String> allSchemas = new ArrayList<String>(); (new ResultSetReader("SHOW DATABASES;") { @Override Loading @@ -27,7 +26,7 @@ public class TapSchemaDL { return allSchemas; } public static ArrayList<String> getAllTAPSchemasNames(Connection connection, final ArrayList<String> allSchemas) throws SQLException { public static List<String> getAllTAPSchemasNames(Connection connection, final List<String> allSchemas) throws SQLException { class TAPSchemaChecker { Loading @@ -44,7 +43,7 @@ public class TapSchemaDL { } } final ArrayList<String> allTAPSchemas = new ArrayList<String>(); final List<String> allTAPSchemas = new ArrayList<String>(); for (String schemaName : allSchemas) { Loading Loading @@ -82,6 +81,20 @@ public class TapSchemaDL { return allTAPSchemas; } public static List<String> getExposedSchemas(Connection connection, final String tapSchemaName) throws SQLException { final List<String> exposedSchemas = new ArrayList<String>(); (new ResultSetReader("SELECT schema_name FROM " + tapSchemaName + ".`schemas`") { @Override public void manipulateItem(ResultSet resultSet) throws SQLException { exposedSchemas.add(resultSet.getString(1)); } }).read(connection); return exposedSchemas; } public static void loadSelectedSchemas(final Connection connection, TapSchema tapSchema, List<String> selectedSchemas) throws SQLException { for (String schemaName : selectedSchemas) { Schema schema = new Schema(connection, schemaName, tapSchema.getName(), tapSchema.toCreate()); Loading new/src/main/java/it/inaf/oats/ia2/tap/tsm/datalayer/UpdateManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -403,6 +403,8 @@ public class UpdateManager { } connection.commit(); tapSchema.update(); } catch (SQLException e) { try { if (connection != null && !connection.getAutoCommit()) { Loading new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/Column.java +1 −7 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ public class Column extends DbEntity { // uneditable properties //public static final String DESCRIPTION = "description"; private String tableName; private String name; Loading @@ -29,7 +27,6 @@ public class Column extends DbEntity { // private final EditableValue<String> unit; // private final EditableValue<String> description; // private final EditableValue<Boolean> std; private String datatype; private int size; Loading Loading @@ -83,7 +80,6 @@ public class Column extends DbEntity { // return null; // } // private boolean checked; public String getTableName() { return tableName; } Loading Loading @@ -132,7 +128,6 @@ public class Column extends DbEntity { // public void setDescription(String description) { // setValue(DESCRIPTION, description); // } public String getDatatype() { return datatype; } Loading Loading @@ -208,7 +203,6 @@ public class Column extends DbEntity { // } // return null; // } @Override public void update(Connection connection) throws SQLException { PreparedStatement statement = null; Loading new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/Credentials.java +0 −2 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ public class Credentials implements Serializable { private String password; public Credentials() { this.hostname = "localhost"; this.port = 3306; this.username = "root"; } public Credentials(String hostname, int port, String username, String password) { Loading new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/DbEntity.java +18 −3 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class EditableValue { boolean isChanged() { if (originalValue == null) { return newValue != null && !((String) newValue).equals(""); return newValue != null && !newValue.equals(""); } return !originalValue.equals(newValue); } Loading Loading @@ -108,8 +108,8 @@ public abstract class DbEntity { return false; } public Map<String, String> getChanges() { Map<String, String> changes = new HashMap<String, String>(); public Map<String, Object> getChanges() { Map<String, Object> changes = new HashMap<String, Object>(); for (String key : values.keySet()) { EditableValue editableValue = values.get(key); if (editableValue != null) { Loading @@ -119,6 +119,21 @@ public abstract class DbEntity { return changes; } public void setUpdated() { if (getStatus() == Status.SELECTED_TO_SAVE) { setStatus(Status.SELECTED_SAVED); } for (EditableValue value : values.values()) { value.setValue(value.getValue()); } } public void setOriginalValues() { for (EditableValue value : values.values()) { value.newValue = value.originalValue; } } public abstract String getName(); public abstract void insert(Connection connection) throws SQLException; Loading Loading
new/src/main/java/it/inaf/oats/ia2/tap/tsm/datalayer/TapSchemaDL.java +18 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package it.inaf.oats.ia2.tap.tsm.datalayer; import it.inaf.oats.ia2.tap.tsm.model.*; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; Loading @@ -14,8 +13,8 @@ import java.util.List; */ public class TapSchemaDL { public static ArrayList<String> getAllSchemasNames(Connection connection) throws SQLException { final ArrayList<String> allSchemas = new ArrayList<String>(); public static List<String> getAllSchemasNames(Connection connection) throws SQLException { final List<String> allSchemas = new ArrayList<String>(); (new ResultSetReader("SHOW DATABASES;") { @Override Loading @@ -27,7 +26,7 @@ public class TapSchemaDL { return allSchemas; } public static ArrayList<String> getAllTAPSchemasNames(Connection connection, final ArrayList<String> allSchemas) throws SQLException { public static List<String> getAllTAPSchemasNames(Connection connection, final List<String> allSchemas) throws SQLException { class TAPSchemaChecker { Loading @@ -44,7 +43,7 @@ public class TapSchemaDL { } } final ArrayList<String> allTAPSchemas = new ArrayList<String>(); final List<String> allTAPSchemas = new ArrayList<String>(); for (String schemaName : allSchemas) { Loading Loading @@ -82,6 +81,20 @@ public class TapSchemaDL { return allTAPSchemas; } public static List<String> getExposedSchemas(Connection connection, final String tapSchemaName) throws SQLException { final List<String> exposedSchemas = new ArrayList<String>(); (new ResultSetReader("SELECT schema_name FROM " + tapSchemaName + ".`schemas`") { @Override public void manipulateItem(ResultSet resultSet) throws SQLException { exposedSchemas.add(resultSet.getString(1)); } }).read(connection); return exposedSchemas; } public static void loadSelectedSchemas(final Connection connection, TapSchema tapSchema, List<String> selectedSchemas) throws SQLException { for (String schemaName : selectedSchemas) { Schema schema = new Schema(connection, schemaName, tapSchema.getName(), tapSchema.toCreate()); Loading
new/src/main/java/it/inaf/oats/ia2/tap/tsm/datalayer/UpdateManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -403,6 +403,8 @@ public class UpdateManager { } connection.commit(); tapSchema.update(); } catch (SQLException e) { try { if (connection != null && !connection.getAutoCommit()) { Loading
new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/Column.java +1 −7 Original line number Diff line number Diff line Loading @@ -19,8 +19,6 @@ public class Column extends DbEntity { // uneditable properties //public static final String DESCRIPTION = "description"; private String tableName; private String name; Loading @@ -29,7 +27,6 @@ public class Column extends DbEntity { // private final EditableValue<String> unit; // private final EditableValue<String> description; // private final EditableValue<Boolean> std; private String datatype; private int size; Loading Loading @@ -83,7 +80,6 @@ public class Column extends DbEntity { // return null; // } // private boolean checked; public String getTableName() { return tableName; } Loading Loading @@ -132,7 +128,6 @@ public class Column extends DbEntity { // public void setDescription(String description) { // setValue(DESCRIPTION, description); // } public String getDatatype() { return datatype; } Loading Loading @@ -208,7 +203,6 @@ public class Column extends DbEntity { // } // return null; // } @Override public void update(Connection connection) throws SQLException { PreparedStatement statement = null; Loading
new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/Credentials.java +0 −2 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ public class Credentials implements Serializable { private String password; public Credentials() { this.hostname = "localhost"; this.port = 3306; this.username = "root"; } public Credentials(String hostname, int port, String username, String password) { Loading
new/src/main/java/it/inaf/oats/ia2/tap/tsm/model/DbEntity.java +18 −3 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class EditableValue { boolean isChanged() { if (originalValue == null) { return newValue != null && !((String) newValue).equals(""); return newValue != null && !newValue.equals(""); } return !originalValue.equals(newValue); } Loading Loading @@ -108,8 +108,8 @@ public abstract class DbEntity { return false; } public Map<String, String> getChanges() { Map<String, String> changes = new HashMap<String, String>(); public Map<String, Object> getChanges() { Map<String, Object> changes = new HashMap<String, Object>(); for (String key : values.keySet()) { EditableValue editableValue = values.get(key); if (editableValue != null) { Loading @@ -119,6 +119,21 @@ public abstract class DbEntity { return changes; } public void setUpdated() { if (getStatus() == Status.SELECTED_TO_SAVE) { setStatus(Status.SELECTED_SAVED); } for (EditableValue value : values.values()) { value.setValue(value.getValue()); } } public void setOriginalValues() { for (EditableValue value : values.values()) { value.newValue = value.originalValue; } } public abstract String getName(); public abstract void insert(Connection connection) throws SQLException; Loading