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