Skip to content

Commit

Permalink
changed rest of the datatypes to LogicalEntity, minor fix for fk
Browse files Browse the repository at this point in the history
  • Loading branch information
flurfis committed Nov 23, 2023
1 parent 7710167 commit 549b7f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,25 @@ public class BackupInformationObject {
*/

//namespace id, list of entities for the namespace
private ImmutableMap<Long, List<LogicalView>> views;
private ImmutableMap<Long, List<LogicalEntity>> views;

private ImmutableMap<Long, List<BackupEntityWrapper<LogicalView>>> wrappedViews;
private ImmutableMap<Long, List<BackupEntityWrapper<LogicalEntity>>> wrappedViews;

private ImmutableMap<Long, List<LogicalMaterializedView>> materializedViews;
private ImmutableMap<Long, List<LogicalEntity>> materializedViews;

private ImmutableMap<Long, List<BackupEntityWrapper<LogicalMaterializedView>>> wrappedMaterializedViews;
private ImmutableMap<Long, List<BackupEntityWrapper<LogicalEntity>>> wrappedMaterializedViews;

private ImmutableMap<Long, List<LogicalEntity>> tables; //TODO: cast all to logicaltable - LogicalEntity.unwrap(logicalTable.class) to get logicalTAble, for everything here logicalEntity

private ImmutableMap<Long, List<BackupEntityWrapper<LogicalEntity>>> wrappedTables;

private ImmutableMap<Long, List<LogicalCollection>> collections;
private ImmutableMap<Long, List<LogicalEntity>> collections;

private ImmutableMap<Long, List<BackupEntityWrapper<LogicalCollection>>> wrappeedCollections;
private ImmutableMap<Long, List<BackupEntityWrapper<LogicalEntity>>> wrappedCollections;

private ImmutableMap<Long, LogicalGraph> graphs;
private ImmutableMap<Long, LogicalEntity> graphs;

private ImmutableMap<Long, List<BackupEntityWrapper<LogicalGraph>>> wrappedGraphs;
private ImmutableMap<Long, List<BackupEntityWrapper<LogicalEntity>>> wrappedGraphs;

//table id, list of views for the table
private ImmutableMap<Long, List<LogicalColumn>> columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public class GatherSchema {
//namespace id, list of tables for the namespace
ImmutableMap<Long, List<LogicalEntity>> tables;
//TODO(FF): make views and materialized views not (? deleted?)... views and materialized views can be over several tables -> over several namespaces??
ImmutableMap<Long, List<LogicalView>> views;
ImmutableMap<Long, List<LogicalMaterializedView>> materializedViews;
ImmutableMap<Long, List<LogicalCollection>> collections;
ImmutableMap<Long, LogicalGraph> graphs;
ImmutableMap<Long, List<LogicalEntity>> views;
ImmutableMap<Long, List<LogicalEntity>> materializedViews;
ImmutableMap<Long, List<LogicalEntity>> collections;
ImmutableMap<Long, LogicalEntity> graphs;

//table id, list of views for the table
ImmutableMap<Long, List<LogicalColumn>> columns;
Expand Down Expand Up @@ -201,7 +201,7 @@ private void getRelSchema() {
//this.tables = ImmutableMap.copyOf( (Map<? extends Long, ? extends List<LogicalEntity>>) tables );
//this.tables = ImmutableMap.copyOf( (Map<Long, ? extends List<LogicalEntity>>) tables );
this.backupInformationObject.setTables( this.tables );
this.views = ImmutableMap.copyOf( views );
this.views = ImmutableMap.copyOf( views.entrySet().stream().collect(Collectors.toMap(v -> v.getKey(), v -> v.getValue().stream().map( e -> e.unwrap( LogicalEntity.class ) ).collect(Collectors.toList() ) )) );
this.backupInformationObject.setViews( this.views );
this.columns = ImmutableMap.copyOf( columns );
this.backupInformationObject.setColumns( this.columns );
Expand Down Expand Up @@ -269,7 +269,7 @@ private void getDocSchema() {
}

//safes the gathered information in the class variables
this.collections = ImmutableMap.copyOf( nsCollections );
this.collections = ImmutableMap.copyOf( nsCollections.entrySet().stream().collect(Collectors.toMap(v -> v.getKey(), v -> v.getValue().stream().map( e -> e.unwrap( LogicalEntity.class ) ).collect(Collectors.toList() ) )) );
this.backupInformationObject.setCollections( this.collections );
this.backupInformationObject.setCollectedDocSchema( true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ private void insertAlterTableFK( ImmutableMap<Long, List<BackupEntityWrapper<Log
Long tableId = fkListPerTable.getKey();

for ( LogicalForeignKey foreignKey : fkListPerTable.getValue() ) {
// get the table where the foreign key is safet
BackupEntityWrapper<LogicalEntity> table = bupTables.get( backupInformationObject.getWrappedTables().get( tableId ).get( 0 ).getEntityObject().namespaceId ).stream().filter( e -> e.getEntityObject().unwrap( LogicalTable.class ).getId() == tableId ).findFirst().get();

// get the table where the foreign key is saved
Long nsId = foreignKey.namespaceId;
BackupEntityWrapper<LogicalEntity> table = backupInformationObject.getWrappedTables().get( nsId ).stream().filter( e -> e.getEntityObject().unwrap( LogicalTable.class ).getId() == tableId ).findFirst().get();
//boolean lol = table.getToBeInserted();
// check if the table is marked to be inserted
if (table.getToBeInserted()) {
String namespaceName = backupInformationObject.getWrappedNamespaces().get( foreignKey.namespaceId ).getNameForQuery();
Expand Down

0 comments on commit 549b7f7

Please sign in to comment.