-
Notifications
You must be signed in to change notification settings - Fork 7
Rework sequence querying & updating #7169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f2d6584
Rework sequence querying & updating
labkey-adam 71f05f9
Copy assay results. Fix Sample Type delete of ObjectIds. Fix not-copi…
labkey-adam 72d955f
Merge remote-tracking branch 'origin/develop' into fb_clone8
labkey-adam fc618de
Improve not-copied queries - combine multiple into one query, always …
labkey-adam 5e4c448
ExperimentDeleteService that allows assay results handler to delete e…
labkey-adam 86ed8c5
Use a small batch size for attachments
labkey-adam f909993
More sensible method hierarchy for filtering: getTableFilterClause() …
labkey-adam 55809eb
Use joins instead of sub-selects
labkey-adam 36557ae
Delete not-copied SampleIds from inventory.Item
labkey-adam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
assay/src/org/labkey/assay/AssayResultMigrationSchemaHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.labkey.assay; | ||
|
|
||
| import org.apache.logging.log4j.Logger; | ||
| import org.labkey.api.assay.AbstractTsvAssayProvider; | ||
| import org.labkey.api.data.DatabaseMigrationService.DataFilter; | ||
| import org.labkey.api.data.DatabaseMigrationService.DefaultMigrationSchemaHandler; | ||
| import org.labkey.api.data.DatabaseMigrationService.ExperimentDeleteService; | ||
| import org.labkey.api.data.DbSchema; | ||
| import org.labkey.api.data.DbSchemaType; | ||
| import org.labkey.api.data.SQLFragment; | ||
| import org.labkey.api.data.SimpleFilter; | ||
| import org.labkey.api.data.SimpleFilter.FilterClause; | ||
| import org.labkey.api.data.SimpleFilter.OrClause; | ||
| import org.labkey.api.data.SimpleFilter.SQLClause; | ||
| import org.labkey.api.data.SqlSelector; | ||
| import org.labkey.api.data.TableInfo; | ||
| import org.labkey.api.util.GUID; | ||
| import org.labkey.api.util.logging.LogHelper; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Set; | ||
|
|
||
| class AssayResultMigrationSchemaHandler extends DefaultMigrationSchemaHandler | ||
| { | ||
| private static final Logger LOG = LogHelper.getLogger(AssayResultMigrationSchemaHandler.class, "Assay result migration status"); | ||
|
|
||
| public AssayResultMigrationSchemaHandler() | ||
| { | ||
| super(DbSchema.get(AbstractTsvAssayProvider.ASSAY_SCHEMA_NAME, DbSchemaType.Provisioned)); | ||
| } | ||
|
|
||
| // Provisioned assay result tables occasionally have no DataId column; hopefully they have an LSID column. | ||
| private boolean hasDataIdColumn(TableInfo sourceTable) | ||
| { | ||
| return sourceTable.getColumn("DataId") != null; | ||
| } | ||
|
|
||
| @Override | ||
| public FilterClause getContainerClause(TableInfo sourceTable, Set<GUID> containers) | ||
| { | ||
| return new SQLClause( | ||
| new SQLFragment(hasDataIdColumn(sourceTable) ? "DataId IN (SELECT RowId" : "LSID IN (SELECT LSID") | ||
| .append(" FROM exp.Data WHERE Container") | ||
| .appendInClause(containers, sourceTable.getSqlDialect()) | ||
| .append(")") | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void addDomainDataFilterClause(OrClause orClause, DataFilter filter, TableInfo sourceTable, Set<String> selectColumnNames) | ||
| { | ||
| // We want no rows from containers with a domain data filter, so don't add any clauses | ||
| } | ||
|
|
||
| @Override | ||
| public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilter notCopiedFilter) | ||
| { | ||
| SQLFragment objectIdSql = new SQLFragment("SELECT ObjectId FROM exp.Data WHERE ") | ||
| .append(hasDataIdColumn(sourceTable) ? "RowId IN (SELECT DataId" : "LSID IN (SELECT LSID") | ||
| .append(" FROM ") | ||
| .appendIdentifier(sourceTable.getSelectName()) | ||
| .append(" ") | ||
| .append(notCopiedFilter.getSQLFragment(sourceTable.getSqlDialect())) | ||
| .append(")"); | ||
|
|
||
| Collection<Long> notCopiedObjectIds = new SqlSelector(sourceTable.getSchema(), objectIdSql).getCollection(Long.class); | ||
|
|
||
| if (notCopiedObjectIds.isEmpty()) | ||
| { | ||
| LOG.info(rowsNotCopied(0)); | ||
| } | ||
| else | ||
| { | ||
| LOG.info("{} -- deleting associated rows from exp.Data, exp.Object, etc.", rowsNotCopied(notCopiedObjectIds.size())); | ||
|
|
||
| // Delete exp.Data, exp.Object, etc. rows associated with the rows that weren't copied | ||
| ExperimentDeleteService.get().deleteDataRows(notCopiedObjectIds); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they have an LSID, I think it would be for the assay result row and not an
exp.datarow. Do we know anything about these domains without aDataId? Are they very old?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@labkey-jeckels it's a single assayresult provisioned table named
c5d21781_assayplatereplicatestats(all other provisioned tables in the schema end with_data_fields). The table is empty, making it impossible to verify via data. It doesn't look old... the domain ("AssayPlateReplicateStats", unsurprisingly) and properties (18 of them) were all created 7/29/2025.I implemented this guess as a precaution, and you likely have a better guess than I. I could just log a warning about this case and skip it. Let's discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see that this is associated with
PlateReplicateStatsDomainKind. I'll take a look at that class to understand how it's hooked up to everything else.