Skip to content

ExpObjectDataIterator: consolidate iterator logic #6788

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

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/data/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2099,13 +2099,13 @@ public static class NameGenerationException extends Exception
{
private final int _rowNumber;

NameGenerationException(String message, int rowNumber)
public NameGenerationException(String message, int rowNumber)
{
super(message);
_rowNumber = rowNumber;
}

NameGenerationException(int rowNumber, Throwable t)
public NameGenerationException(int rowNumber, Throwable t)
{
super(t);
_rowNumber = rowNumber;
Expand Down
25 changes: 12 additions & 13 deletions api/src/org/labkey/api/data/NameGeneratorState.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ public class NameGeneratorState implements AutoCloseable
{
private final @NotNull NameGenerator _nameGenerator;
private final boolean _incrementSampleCounts;
private final User _user;
protected final User _user;
private final Map<String, Object> _batchExpressionContext;
private Function<Map<String,Long>,Map<String,Long>> getSampleCountsFunction;
private final Map<String, Integer> _newNames = new CaseInsensitiveHashMap<>();

private int _rowNumber = 0;
protected int _rowNumber = 0;
private final Map<Tuple3<String, Object, FieldKey>, Object> _lookupCache;
private final Map<String, ArrayList<Object>> _ancestorCache;
private final Map<String, ArrayList<Object>> _ancestorSearchCache;
private final Map<String, Map<String, DbSequence>> _prefixCounterSequences;

private final NameGenerator.ProjectSampleCounters _sampleCounters;
private boolean _counterSequencesCleaned = false;
private final Container _container;
protected final Container _container;

private final Map<Integer, ExpMaterial> materialCache = new HashMap<>();
private final Map<Integer, ExpData> dataCache = new HashMap<>();
private final RemapCache renameCache;
protected final Map<Integer, ExpMaterial> materialCache = new HashMap<>();
protected final Map<Integer, ExpData> dataCache = new HashMap<>();
protected final RemapCache renameCache;
private final Map<String, Map<String, Object>> objectPropertiesCache = new HashMap<>();

public NameGeneratorState(@NotNull NameGenerator nameGenerator, boolean incrementSampleCounts, NameGenerator.SampleNameExpressionSummary expressionSummary)
Expand Down Expand Up @@ -292,8 +292,8 @@ private String genName(@NotNull Map<String, Object> rowMap,

StringExpressionFactory.FieldKeyStringExpression expression = activeNameGenerator.getParsedNameExpression();
String name;
if (expression instanceof NameGenerator.NameGenerationExpression)
name = ((NameGenerator.NameGenerationExpression) expression).eval(ctx, _prefixCounterSequences);
if (expression instanceof NameGenerator.NameGenerationExpression nge)
name = nge.eval(ctx, _prefixCounterSequences);
else
name = expression.eval(ctx);
if (name == null || name.isEmpty())
Expand Down Expand Up @@ -417,14 +417,14 @@ private void addAncestorLookupValues(
String parentType = ancestorOptions.parentType();
if (!StringUtils.isEmpty(parentType))
{
if (parentObject instanceof ExpMaterial)
if (parentObject instanceof ExpMaterial expMaterial)
{
if (!((ExpMaterial) parentObject).getSampleType().getName().equalsIgnoreCase(parentType))
if (!expMaterial.getSampleType().getName().equalsIgnoreCase(parentType))
continue;
}
else if (parentObject instanceof ExpData)
else if (parentObject instanceof ExpData expData)
{
if (!((ExpData) parentObject).getDataClass(_user).getName().equalsIgnoreCase(parentType))
if (!expData.getDataClass(_user).getName().equalsIgnoreCase(parentType))
continue;
}
}
Expand Down Expand Up @@ -490,7 +490,6 @@ else if (parentObject instanceof ExpData)
}
}
}

}

private void addParentLookupContext(String parentTypeName/* already decoded */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public NameExpressionDataIterator(DataIterator di, DataIteratorContext context,
_container = container;
_getNonConflictCountFn = getNonConflictCountFn;
_counterSeqPrefix = counterSeqPrefix;

}

public NameExpressionDataIterator setAllowUserSpecifiedNames(boolean allowUserSpecifiedNames)
Expand All @@ -80,7 +79,7 @@ public NameExpressionDataIterator addExtraPropsFn(Supplier<Map<String, Object>>

MapDataIterator getInput()
{
return (MapDataIterator)_delegate;
return (MapDataIterator) _delegate;
}

private BatchValidationException getErrors()
Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/exp/query/ExpMaterialTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum Column
Folder,
Inputs,
IsAliquot,
IsPlated,
LSID,
MaterialExpDate,
MaterialSourceId,
Expand All @@ -60,8 +61,7 @@ enum Column
SourceProtocolApplication,
SourceProtocolLSID,
StoredAmount,
Units,
IsPlated;
Units;

public FieldKey fieldKey()
{
Expand Down
Loading