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
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static void logUnseenAttachmentTypes()
Set<AttachmentType> unseen = new HashSet<>(AttachmentService.get().getAttachmentTypes());
unseen.removeAll(SEEN);

if (SEEN.isEmpty())
if (unseen.isEmpty())
DatabaseMigrationService.LOG.info("All AttachmentTypes have been seen");
else
DatabaseMigrationService.LOG.info("These AttachmentTypes have not been seen: {}", unseen.stream().map(type -> type.getClass().getSimpleName()).collect(Collectors.joining(", ")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
import org.labkey.api.data.SimpleFilter.SQLClause;
import org.labkey.api.data.SqlSelector;
import org.labkey.api.data.TableInfo;
import org.labkey.api.data.TableSelector;
import org.labkey.api.migration.AssaySkipContainers;
import org.labkey.api.migration.DatabaseMigrationService.DataFilter;
import org.labkey.api.migration.DefaultMigrationSchemaHandler;
import org.labkey.api.migration.ExperimentDeleteService;
import org.labkey.api.util.GUID;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.assay.plate.PlateReplicateStatsDomainKind;

import java.util.Collection;
import java.util.Collections;
import java.util.Set;

class AssayResultMigrationSchemaHandler extends DefaultMigrationSchemaHandler
Expand All @@ -38,7 +35,7 @@ public AssayResultMigrationSchemaHandler()
private boolean skipTable(TableInfo sourceTable)
{
// For now, we're ignoring this table since it's empty in our first migration client's database
return Strings.CI.endsWith(sourceTable.getName(), PlateReplicateStatsDomainKind.ASSAY_PLATE_REPLICATE);
return Strings.CI.endsWith(sourceTable.getName(), PlateReplicateStatsDomainKind.NAME);
}

@Override
Expand All @@ -63,8 +60,8 @@ public FilterClause getContainerClause(TableInfo sourceTable, Set<GUID> containe
@Override
public void addDomainDataFilterClause(OrClause orClause, DataFilter filter, TableInfo sourceTable, Set<String> selectColumnNames)
{
// No filtering on assay results for now; just add the passed in containers. Note that these will be filtered
// if AssaySkipContainers is configured.
// No row-by-row filtering on assay results for now; just add the passed in containers. Note that these will be
// filtered by container if AssaySkipContainers is configured.
orClause.addClause(getContainerClause(sourceTable, filter.containers()));
}

Expand Down Expand Up @@ -92,9 +89,6 @@ public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilte
// Delete exp.Data, exp.Object, etc. rows associated with the rows that weren't copied
ExperimentDeleteService.get().deleteDataRows(notCopiedObjectIds);
}

// TODO: Temp!
LOG.info(" " + StringUtilsLabKey.pluralize(new TableSelector(sourceTable, Collections.singleton("DataId")).stream(Integer.class).distinct().count(), "distinct DataId"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ public void addDomainDataFilterClause(OrClause orClause, DataFilter filter, Tabl
@Override
public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilter notCopiedFilter)
{
// Select all ObjectIds associated with the not-copied rows from the source database. Our notCopiedFilter
// works on the data class provisioned table, so we need to use a sub-select (as opposed to a join) to avoid
// ambiguous column references.
SQLFragment objectIdSql = new SQLFragment("SELECT ObjectId FROM exp.Object WHERE ObjectURI IN (SELECT LSID FROM ")
.appendIdentifier(sourceTable.getSelectName())
.append(" ")
.append(notCopiedFilter.getSQLFragment(sourceTable.getSqlDialect()))
.append(")");
// Select LSIDs from the just-copied rows in the target table
Collection<String> copiedLsids = new TableSelector(targetTable, Collections.singleton("LSID")).getCollection(String.class);

// Select all ObjectIds associated with the not-copied rows from the source database
SQLFragment objectIdSql = new SQLFragment("SELECT ObjectId FROM exp.Data d INNER JOIN ")
.appendIdentifier(sourceTable.getSelectName())
.append(" dc ON d.LSID = dc.LSID");

// Don't create an empty IN clause; need to work around issue where "NOT xxx IN (NULL)" evaluates to NULL.
if (!copiedLsids.isEmpty())
objectIdSql.append(" AND NOT dc.LSID").appendInClause(copiedLsids, sourceTable.getSqlDialect());

Collection<Long> notCopiedObjectIds = new SqlSelector(sourceTable.getSchema(), objectIdSql).getCollection(Long.class);

if (notCopiedObjectIds.isEmpty())
Expand Down
Loading