|
1 | 1 | package org.labkey.api.dataiterator; |
2 | 2 |
|
3 | 3 | import org.apache.commons.lang3.StringUtils; |
| 4 | +import org.jetbrains.annotations.NotNull; |
4 | 5 | import org.labkey.api.collections.IntHashMap; |
5 | 6 | import org.labkey.api.collections.Sets; |
6 | 7 | import org.labkey.api.data.ColumnInfo; |
@@ -33,17 +34,19 @@ public class SampleUpdateAddColumnsDataIterator extends WrapperDataIterator |
33 | 34 | final int _aliquotedFromColIndex; |
34 | 35 | final int _rootMaterialRowIdColIndex; |
35 | 36 | final int _currentSampleStateColIndex; |
| 37 | + final DataIteratorContext _context; |
36 | 38 |
|
37 | 39 | // prefetch of existing records |
38 | 40 | int lastPrefetchRowNumber = -1; |
39 | 41 | final IntHashMap<String> aliquotParents = new IntHashMap<>(); |
40 | 42 | final IntHashMap<Integer> aliquotRoots = new IntHashMap<>(); |
41 | 43 | final IntHashMap<Integer> sampleState = new IntHashMap<>(); |
42 | 44 |
|
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) |
44 | 46 | { |
45 | 47 | super(in); |
46 | 48 | this._unwrapped = (CachingDataIterator)in; |
| 49 | + this._context = context; |
47 | 50 | this.target = target; |
48 | 51 | this._sampleTypeId = sampleTypeId; |
49 | 52 |
|
@@ -167,11 +170,19 @@ else if (StringUtils.isEmpty((String) key)) |
167 | 170 | @Override |
168 | 171 | public boolean next() throws BatchValidationException |
169 | 172 | { |
| 173 | + if (_context.getErrors().hasErrors()) |
| 174 | + return false; |
| 175 | + |
170 | 176 | // NOTE: we have to call mark() before we call next() if we want the 'next' row to be cached |
171 | 177 | _unwrapped.mark(); // unwrapped _delegate |
172 | 178 | boolean ret = super.next(); |
173 | | - if (ret) |
| 179 | + if (!_context.getErrors().hasErrors() && ret) |
| 180 | + { |
174 | 181 | prefetchExisting(); |
| 182 | + if (_context.getErrors().hasErrors()) |
| 183 | + return false; |
| 184 | + } |
| 185 | + |
175 | 186 | return ret; |
176 | 187 | } |
177 | 188 | } |
0 commit comments