Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions protein/api-src/org/labkey/api/protein/go/GoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,25 @@ public void load()
});
}

private void loadGoFromGz() throws SQLException, IOException, ServletException
public static void dropGoIndexes()
{
DbSchema schema = ProteinSchema.getSchema();
new SqlExecutor(schema).execute(schema.getSqlDialect().execute(schema, "drop_go_indexes", ""));
}

public static void createGoIndexes()
{
DbSchema schema = ProteinSchema.getSchema();
new SqlExecutor(schema).execute(schema.getSqlDialect().execute(schema, "create_go_indexes", ""));
}

private void loadGoFromGz() throws SQLException, IOException, ServletException
{
Map<String, GoLoadBean> map = getGoLoadMap();
long start = System.currentTimeMillis();

clearGoLoaded();
new SqlExecutor(schema).execute(schema.getSqlDialect().execute(schema, "drop_go_indexes", ""));
dropGoIndexes();

logStatus("Starting to load GO annotation files");
logStatus("");
Expand All @@ -175,7 +186,7 @@ private void loadGoFromGz() throws SQLException, IOException, ServletException
}
}

new SqlExecutor(schema).execute(schema.getSqlDialect().execute(schema, "create_go_indexes", ""));
createGoIndexes();
long elapsed = System.currentTimeMillis() - start;

logStatus("Successfully loaded all GO annotation files (" + DateUtil.formatDuration(elapsed) + ")");
Expand Down
26 changes: 20 additions & 6 deletions protein/src/org/labkey/protein/ProteinModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DatabaseMigrationService;
import org.labkey.api.data.DatabaseMigrationService.DefaultMigrationHandler;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.SqlExecutor;
import org.labkey.api.data.TableInfo;
import org.labkey.api.data.TableSelector;
import org.labkey.api.files.FileContentService;
import org.labkey.api.files.TableUpdaterFileListener;
Expand All @@ -36,9 +36,11 @@
import org.labkey.api.protein.annotation.CustomAnnotationSetManager;
import org.labkey.api.protein.annotation.ProteinAnnotationPipelineProvider;
import org.labkey.api.protein.fasta.FastaDbLoader;
import org.labkey.api.protein.go.GoLoader;
import org.labkey.api.protein.query.CustomAnnotationSchema;
import org.labkey.api.protein.query.ProteinUserSchema;
import org.labkey.api.protein.search.MSSearchWebpart;
import org.labkey.api.query.FieldKey;
import org.labkey.api.usageMetrics.UsageMetricsService;
import org.labkey.api.view.BaseWebPartFactory;
import org.labkey.api.view.Portal;
Expand Down Expand Up @@ -129,18 +131,30 @@ public void doStartup(ModuleContext moduleContext)
}

ProteinService.get().registerProteinSearchView(new ProteinSearchViewProvider());
DatabaseMigrationService.get().registerHandler(ProteinSchema.getSchema(), new DefaultMigrationHandler()
DatabaseMigrationService.get().registerHandler(new DefaultMigrationHandler(ProteinSchema.getSchema())
{
@Override
public void beforeSchema(DbSchema targetSchema)
public void beforeSchema()
{
new SqlExecutor(targetSchema).execute("ALTER TABLE prot.Organisms DROP CONSTRAINT FK_ProtOrganisms_ProtIdentifiers");
new SqlExecutor(getSchema()).execute("ALTER TABLE prot.Organisms DROP CONSTRAINT FK_ProtOrganisms_ProtIdentifiers");
GoLoader.dropGoIndexes();
}

@Override
public void afterSchema(DbSchema targetSchema)
public @Nullable FieldKey getContainerFieldKey(TableInfo sourceTable)
{
new SqlExecutor(targetSchema).execute("ALTER TABLE prot.Organisms ADD CONSTRAINT FK_ProtOrganisms_ProtIdentifiers FOREIGN KEY (IdentId) REFERENCES prot.Identifiers (IdentId)");
return switch (sourceTable.getName())
{
case "CustomAnnotation", "CustomAnnotationSet" -> super.getContainerFieldKey(sourceTable);
default -> SITE_WIDE_TABLE;
};
}

@Override
public void afterSchema()
{
new SqlExecutor(getSchema()).execute("ALTER TABLE prot.Organisms ADD CONSTRAINT FK_ProtOrganisms_ProtIdentifiers FOREIGN KEY (IdentId) REFERENCES prot.Identifiers (IdentId)");
GoLoader.createGoIndexes();
}
});
}
Expand Down