Skip to content

Commit

Permalink
Set schema before backup is attempted
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Apr 30, 2024
1 parent a5a6e87 commit 8a41592
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ private ExitStatus run() {
Set<String> tables = _writers.stream()
.map(writer -> writer.getTableNamesForBackup(userSchema))
.flatMap(Collection::stream)
.peek(name -> {
if (name == null)
throw new RuntimeException(getClass().getName() + " returned a null table name for backup.");
})
.collect(Collectors.toSet());
// create backup tables
backUpTables(userDb.getDataSource(), tables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void configure(WdkModel wdkModel, List<String> additionalArgs) throws Exc

@Override
public TableRowUpdater<AnalysisRow> getTableRowUpdater(WdkModel wdkModel) {
AnalysisRecordFactory factory = new AnalysisRecordFactory();
AnalysisRecordFactory factory = new AnalysisRecordFactory(wdkModel.getProjectId());
return new TableRowUpdater<AnalysisRow>(factory, factory, this, wdkModel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public class AnalysisRecordFactory implements TableRowFactory<AnalysisRow>, Tabl

private String _schema;

@Override
public String getRecordsSql(String schema, String projectId) {
// reset schema based on project (userdb schema is not where eda data lives
public AnalysisRecordFactory(String projectId) {
// set schema based on project (userdb schema is not where eda data lives
switch(projectId) {
case "ClinEpiDB": _schema = "edauserce"; break;
case "MicrobiomeDB": _schema = "edausermb"; break;
default: _schema = "edauservb"; break;
}
}

@Override
public String getRecordsSql(String schema, String projectId) {
return
"select analysis_id, study_id, analysis_descriptor, num_filters, num_computations, num_visualizations" +
" from " + _schema + ".analysis";
Expand Down

0 comments on commit 8a41592

Please sign in to comment.