Loading TapSchemaManagerAPI/src/main/java/it/inaf/oats/ia2/tapschemamanager/api/Dao.java +12 −0 Original line number Diff line number Diff line Loading @@ -521,15 +521,27 @@ public class Dao { for (Column column : operations.getColumnsToRemove()) { column.setStatus(Status.LOADED); } for (Column column : operations.getColumnsToClean()) { column.setStatus(Status.LOADED); } for (Table table : operations.getTablesToRemove()) { Schema schema = tapSchema.getChild(table.getSchemaName()); if (schema != null) { ((SchemaImpl) schema).cleanTable(table.getName()); } } for (Table table : operations.getTablesToClean()) { Schema schema = tapSchema.getChild(table.getSchemaName()); if (schema != null) { ((SchemaImpl) schema).cleanTable(table.getName()); } } for (Schema schema : operations.getSchemasToRemove()) { ((TapSchemaImpl) tapSchema).cleanSchema(schema.getName()); } for (Schema schema : operations.getSchemasToClean()) { ((TapSchemaImpl) tapSchema).cleanSchema(schema.getName()); } // updated for (Key key : operations.getKeysToUpdate()) { Loading TapSchemaManagerAPI/src/main/java/it/inaf/oats/ia2/tapschemamanager/api/UpdateOperations.java +33 −3 Original line number Diff line number Diff line Loading @@ -37,9 +37,9 @@ import org.slf4j.LoggerFactory; * List of operations that have to be performed by the * {@link it.inaf.oats.ia2.tapschemamanager.contract.TapSchema#save()} method, * in terms of adding, updating or removing * {@link it.inaf.oats.ia2.tapschemamanager.api.contract.TapSchemaEntity} entities. * Could be used stand-alone to obtain a preview of the operations that will be * performed on the database. * {@link it.inaf.oats.ia2.tapschemamanager.api.contract.TapSchemaEntity} * entities. Could be used stand-alone to obtain a preview of the operations * that will be performed on the database. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ Loading @@ -50,12 +50,15 @@ public class UpdateOperations { private final List<Schema> schemasToRemove; private final List<Schema> schemasToAdd; private final List<Schema> schemasToUpdate; private final List<Schema> schemasToClean; // REMOVED_NOT_PERSISTED private final List<Table> tablesToRemove; private final List<Table> tablesToAdd; private final List<Table> tablesToUpdate; private final List<Table> tablesToClean; // REMOVED_NOT_PERSISTED private final List<Column> columnsToRemove; private final List<Column> columnsToAdd; private final List<Column> columnsToUpdate; private final List<Column> columnsToClean; // REMOVED_NOT_PERSISTED private final List<Key> keysToRemove; private final List<Key> keysToAdd; private final List<Key> keysToUpdate; Loading @@ -66,18 +69,24 @@ public class UpdateOperations { // children columns can have only the following status: // ADDED_NOT_PERSISTED, REMOVED_NOT_PERSISTED, LOADED columnsToAdd.addAll(table.getChildren(Status.ADDED_NOT_PERSISTED)); for (Column column : table.getChildren(Status.REMOVED_NOT_PERSISTED)) { columnsToClean.add(column); } } public UpdateOperations(TapSchema tapSchema) { schemasToRemove = new ArrayList<>(); schemasToAdd = new ArrayList<>(); schemasToUpdate = new ArrayList<>(); schemasToClean = new ArrayList<>(); tablesToRemove = new ArrayList<>(); tablesToAdd = new ArrayList<>(); tablesToUpdate = new ArrayList<>(); tablesToClean = new ArrayList<>(); columnsToRemove = new ArrayList<>(); columnsToAdd = new ArrayList<>(); columnsToUpdate = new ArrayList<>(); columnsToClean = new ArrayList<>(); keysToRemove = new ArrayList<>(); keysToAdd = new ArrayList<>(); keysToUpdate = new ArrayList<>(); Loading Loading @@ -147,6 +156,8 @@ public class UpdateOperations { case TO_REMOVE: columnsToRemove.add(column); break; case REMOVED_NOT_PERSISTED: columnsToClean.add(column); } } break; Loading @@ -158,6 +169,9 @@ public class UpdateOperations { } } break; case REMOVED_NOT_PERSISTED: tablesToClean.add(table); break; } } Loading @@ -178,6 +192,10 @@ public class UpdateOperations { } break; case REMOVED_NOT_PERSISTED: schemasToClean.add(schema); break; } } } Loading @@ -194,6 +212,10 @@ public class UpdateOperations { return schemasToUpdate; } public List<Schema> getSchemasToClean() { return schemasToClean; } public List<Table> getTablesToRemove() { return tablesToRemove; } Loading @@ -206,6 +228,10 @@ public class UpdateOperations { return tablesToUpdate; } public List<Table> getTablesToClean() { return tablesToClean; } public List<Column> getColumnsToRemove() { return columnsToRemove; } Loading @@ -218,6 +244,10 @@ public class UpdateOperations { return columnsToUpdate; } public List<Column> getColumnsToClean() { return columnsToClean; } public List<Key> getKeysToRemove() { return keysToRemove; } Loading TapSchemaManagerAPI/src/test/java/it/inaf/oats/ia2/tapschemamanager/api/TestAll.java +5 −0 Original line number Diff line number Diff line Loading @@ -687,6 +687,11 @@ public class TestAll { sch0table2 = tapSchema.getChild("sch0").getChild("table2"); assertEquals(1, sch0table2.getVisibleFromKeys().size()); checkKey(sch0table2.getVisibleFromKeys().get(0), "sch0.table2", "value1", "sch0.table0", "value1", true); tapSchema.removeChild("sch1"); assertEquals(1, tapSchema.getChildren(Status.TO_REMOVE).size()); tapSchema.save(); assertEquals(0, tapSchema.getChildren(Status.TO_REMOVE).size()); } } catch (SQLException e) { throw e; Loading TapSchemaManagerWebApp/pom.xml +16 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,22 @@ </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/version.txt</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/version.txt</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> Loading TapSchemaManagerWebApp/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java +3 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,9 @@ public class SchemaSelectionBean implements Serializable { public String create() { try { TapSchema tapSchema = TapSchemaFactory.getTapSchema(TapSchemaVersion.TAP_SCHEMA_1_IA2, dbWrapper, tapSchemaName, false); for (String schemaName : selectedSchemas) { tapSchema.addChild(schemaName); } return loadTapSchema(tapSchema); } catch (SQLException e) { throw new RuntimeException(e); Loading Loading
TapSchemaManagerAPI/src/main/java/it/inaf/oats/ia2/tapschemamanager/api/Dao.java +12 −0 Original line number Diff line number Diff line Loading @@ -521,15 +521,27 @@ public class Dao { for (Column column : operations.getColumnsToRemove()) { column.setStatus(Status.LOADED); } for (Column column : operations.getColumnsToClean()) { column.setStatus(Status.LOADED); } for (Table table : operations.getTablesToRemove()) { Schema schema = tapSchema.getChild(table.getSchemaName()); if (schema != null) { ((SchemaImpl) schema).cleanTable(table.getName()); } } for (Table table : operations.getTablesToClean()) { Schema schema = tapSchema.getChild(table.getSchemaName()); if (schema != null) { ((SchemaImpl) schema).cleanTable(table.getName()); } } for (Schema schema : operations.getSchemasToRemove()) { ((TapSchemaImpl) tapSchema).cleanSchema(schema.getName()); } for (Schema schema : operations.getSchemasToClean()) { ((TapSchemaImpl) tapSchema).cleanSchema(schema.getName()); } // updated for (Key key : operations.getKeysToUpdate()) { Loading
TapSchemaManagerAPI/src/main/java/it/inaf/oats/ia2/tapschemamanager/api/UpdateOperations.java +33 −3 Original line number Diff line number Diff line Loading @@ -37,9 +37,9 @@ import org.slf4j.LoggerFactory; * List of operations that have to be performed by the * {@link it.inaf.oats.ia2.tapschemamanager.contract.TapSchema#save()} method, * in terms of adding, updating or removing * {@link it.inaf.oats.ia2.tapschemamanager.api.contract.TapSchemaEntity} entities. * Could be used stand-alone to obtain a preview of the operations that will be * performed on the database. * {@link it.inaf.oats.ia2.tapschemamanager.api.contract.TapSchemaEntity} * entities. Could be used stand-alone to obtain a preview of the operations * that will be performed on the database. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ Loading @@ -50,12 +50,15 @@ public class UpdateOperations { private final List<Schema> schemasToRemove; private final List<Schema> schemasToAdd; private final List<Schema> schemasToUpdate; private final List<Schema> schemasToClean; // REMOVED_NOT_PERSISTED private final List<Table> tablesToRemove; private final List<Table> tablesToAdd; private final List<Table> tablesToUpdate; private final List<Table> tablesToClean; // REMOVED_NOT_PERSISTED private final List<Column> columnsToRemove; private final List<Column> columnsToAdd; private final List<Column> columnsToUpdate; private final List<Column> columnsToClean; // REMOVED_NOT_PERSISTED private final List<Key> keysToRemove; private final List<Key> keysToAdd; private final List<Key> keysToUpdate; Loading @@ -66,18 +69,24 @@ public class UpdateOperations { // children columns can have only the following status: // ADDED_NOT_PERSISTED, REMOVED_NOT_PERSISTED, LOADED columnsToAdd.addAll(table.getChildren(Status.ADDED_NOT_PERSISTED)); for (Column column : table.getChildren(Status.REMOVED_NOT_PERSISTED)) { columnsToClean.add(column); } } public UpdateOperations(TapSchema tapSchema) { schemasToRemove = new ArrayList<>(); schemasToAdd = new ArrayList<>(); schemasToUpdate = new ArrayList<>(); schemasToClean = new ArrayList<>(); tablesToRemove = new ArrayList<>(); tablesToAdd = new ArrayList<>(); tablesToUpdate = new ArrayList<>(); tablesToClean = new ArrayList<>(); columnsToRemove = new ArrayList<>(); columnsToAdd = new ArrayList<>(); columnsToUpdate = new ArrayList<>(); columnsToClean = new ArrayList<>(); keysToRemove = new ArrayList<>(); keysToAdd = new ArrayList<>(); keysToUpdate = new ArrayList<>(); Loading Loading @@ -147,6 +156,8 @@ public class UpdateOperations { case TO_REMOVE: columnsToRemove.add(column); break; case REMOVED_NOT_PERSISTED: columnsToClean.add(column); } } break; Loading @@ -158,6 +169,9 @@ public class UpdateOperations { } } break; case REMOVED_NOT_PERSISTED: tablesToClean.add(table); break; } } Loading @@ -178,6 +192,10 @@ public class UpdateOperations { } break; case REMOVED_NOT_PERSISTED: schemasToClean.add(schema); break; } } } Loading @@ -194,6 +212,10 @@ public class UpdateOperations { return schemasToUpdate; } public List<Schema> getSchemasToClean() { return schemasToClean; } public List<Table> getTablesToRemove() { return tablesToRemove; } Loading @@ -206,6 +228,10 @@ public class UpdateOperations { return tablesToUpdate; } public List<Table> getTablesToClean() { return tablesToClean; } public List<Column> getColumnsToRemove() { return columnsToRemove; } Loading @@ -218,6 +244,10 @@ public class UpdateOperations { return columnsToUpdate; } public List<Column> getColumnsToClean() { return columnsToClean; } public List<Key> getKeysToRemove() { return keysToRemove; } Loading
TapSchemaManagerAPI/src/test/java/it/inaf/oats/ia2/tapschemamanager/api/TestAll.java +5 −0 Original line number Diff line number Diff line Loading @@ -687,6 +687,11 @@ public class TestAll { sch0table2 = tapSchema.getChild("sch0").getChild("table2"); assertEquals(1, sch0table2.getVisibleFromKeys().size()); checkKey(sch0table2.getVisibleFromKeys().get(0), "sch0.table2", "value1", "sch0.table0", "value1", true); tapSchema.removeChild("sch1"); assertEquals(1, tapSchema.getChildren(Status.TO_REMOVE).size()); tapSchema.save(); assertEquals(0, tapSchema.getChildren(Status.TO_REMOVE).size()); } } catch (SQLException e) { throw e; Loading
TapSchemaManagerWebApp/pom.xml +16 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,22 @@ </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/version.txt</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/version.txt</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> Loading
TapSchemaManagerWebApp/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java +3 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,9 @@ public class SchemaSelectionBean implements Serializable { public String create() { try { TapSchema tapSchema = TapSchemaFactory.getTapSchema(TapSchemaVersion.TAP_SCHEMA_1_IA2, dbWrapper, tapSchemaName, false); for (String schemaName : selectedSchemas) { tapSchema.addChild(schemaName); } return loadTapSchema(tapSchema); } catch (SQLException e) { throw new RuntimeException(e); Loading