Skip to content

Commit 312a13c

Browse files
committed
Make sample consistent with data for failfast
1 parent 2a91cc6 commit 312a13c

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

api/src/org/labkey/api/dataiterator/SampleUpdateAddColumnsDataIterator.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.labkey.api.dataiterator;
22

33
import org.apache.commons.lang3.StringUtils;
4+
import org.jetbrains.annotations.NotNull;
45
import org.labkey.api.collections.IntHashMap;
56
import org.labkey.api.collections.Sets;
67
import org.labkey.api.data.ColumnInfo;
@@ -33,17 +34,19 @@ public class SampleUpdateAddColumnsDataIterator extends WrapperDataIterator
3334
final int _aliquotedFromColIndex;
3435
final int _rootMaterialRowIdColIndex;
3536
final int _currentSampleStateColIndex;
37+
final DataIteratorContext _context;
3638

3739
// prefetch of existing records
3840
int lastPrefetchRowNumber = -1;
3941
final IntHashMap<String> aliquotParents = new IntHashMap<>();
4042
final IntHashMap<Integer> aliquotRoots = new IntHashMap<>();
4143
final IntHashMap<Integer> sampleState = new IntHashMap<>();
4244

43-
public SampleUpdateAddColumnsDataIterator(DataIterator in, TableInfo target, long sampleTypeId, String keyColumnName)
45+
public SampleUpdateAddColumnsDataIterator(DataIterator in, @NotNull DataIteratorContext context, TableInfo target, long sampleTypeId, String keyColumnName)
4446
{
4547
super(in);
4648
this._unwrapped = (CachingDataIterator)in;
49+
this._context = context;
4750
this.target = target;
4851
this._sampleTypeId = sampleTypeId;
4952

@@ -167,11 +170,19 @@ else if (StringUtils.isEmpty((String) key))
167170
@Override
168171
public boolean next() throws BatchValidationException
169172
{
173+
if (_context.getErrors().hasErrors())
174+
return false;
175+
170176
// NOTE: we have to call mark() before we call next() if we want the 'next' row to be cached
171177
_unwrapped.mark(); // unwrapped _delegate
172178
boolean ret = super.next();
173-
if (ret)
179+
if (!_context.getErrors().hasErrors() && ret)
180+
{
174181
prefetchExisting();
182+
if (_context.getErrors().hasErrors())
183+
return false;
184+
}
185+
175186
return ret;
176187
}
177188
}

experiment/src/org/labkey/experiment/api/SampleTypeUpdateServiceDI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ public DataIterator getDataIterator(DataIteratorContext context)
13451345
context.getErrors().addRowError(new ValidationException(String.format(DUPLICATE_COLUMN_IN_DATA_ERROR, RowId.name())));
13461346
return null;
13471347
}
1348-
di = new SampleUpdateAddColumnsDataIterator(new CachingDataIterator(addAliquotedFrom), materialTable, sampleType.getRowId(), keyColumnAlias);
1348+
di = new SampleUpdateAddColumnsDataIterator(new CachingDataIterator(addAliquotedFrom), context, materialTable, sampleType.getRowId(), keyColumnAlias);
13491349

13501350
di = new _SamplesCoerceDataIterator(di, context, sampleType, materialTable);
13511351
context.setWithLookupRemapping(false);

0 commit comments

Comments
 (0)