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
2 changes: 0 additions & 2 deletions api/src/org/labkey/api/data/DatabaseMigrationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.collections.CopyOnWriteCaseInsensitiveHashMap;
import org.labkey.api.data.DatabaseMigrationConfiguration.DefaultDatabaseMigrationConfiguration;
import org.labkey.api.data.SimpleFilter.AndClause;
import org.labkey.api.data.SimpleFilter.FilterClause;
Expand All @@ -22,7 +21,6 @@
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down
33 changes: 32 additions & 1 deletion experiment/src/org/labkey/experiment/ExperimentModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.labkey.api.audit.SampleTimelineAuditEvent;
import org.labkey.api.collections.CsvSet;
import org.labkey.api.collections.LongHashMap;
import org.labkey.api.collections.Sets;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.ContainerManager;
Expand Down Expand Up @@ -936,20 +937,50 @@ public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilte
}
});

// Data classes have a built-in Flag field
DatabaseMigrationService.get().registerSchemaHandler(new DefaultMigrationSchemaHandler(DataClassDomainKind.getSchema()) {
@Override
public void addDomainDataFilter(OrClause orClause, DomainFilter filter, TableInfo sourceTable, FieldKey fKey, Set<String> selectColumnNames)
{
// Data classes have a built-in Flag field
addDomainDataFlagFilter(orClause, filter, sourceTable, fKey, selectColumnNames);
}

private static final Set<String> SEQUENCE_TABLES = Sets.newCaseInsensitiveHashSet("protsequence", "nucsequence", "molecule");
private static final Set<Long> SEQUENCE_IDS = new HashSet<>();

@Override
public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilter notCopiedFilter)
{
Collection<String> notCopiedLsids = new TableSelector(sourceTable, Collections.singleton("LSID"), notCopiedFilter, null).getCollection(String.class);
if (!notCopiedLsids.isEmpty())
LOG.info(" {} rows not copied", Formats.commaf0.format(notCopiedLsids.size()));

String name = sourceTable.getName();
int idx = name.indexOf('_');
name = name.substring(idx + 1);

if (SEQUENCE_TABLES.contains(name))
{
new TableSelector(targetTable, Collections.singleton("Ident")).stream(String.class)
.map(ident -> {
int i = ident.indexOf(':');
try
{
return Long.parseLong(ident.substring(i + 1));
}
catch (Exception e)
{
throw new RuntimeException("Exception trying to split ident on ':' (" + ident + ")", e);
}
})
.forEach(SEQUENCE_IDS::add);
}
}

@Override
public void afterSchema()
{
LOG.info("This is where we'll copy {} sequences into biologics.SequenceIdentity", SEQUENCE_IDS.size());
}
});
}
Expand Down