|
151 | 151 | import static org.labkey.api.exp.query.ExpMaterialTable.Column.StoredAmount;
|
152 | 152 | import static org.labkey.api.exp.query.ExpMaterialTable.Column.Units;
|
153 | 153 | import static org.labkey.api.exp.query.SamplesSchema.SCHEMA_SAMPLES;
|
154 |
| -import static org.labkey.experiment.ExpDataIterators.AliquotResolutionDataIterator.ALIQUOT_FROM_IS_ALIQUOT; |
155 |
| -import static org.labkey.experiment.ExpDataIterators.AliquotResolutionDataIterator.ALIQUOT_FROM_RESOLVED_NAME; |
156 | 154 | import static org.labkey.experiment.ExpDataIterators.incrementCounts;
|
157 | 155 | import static org.labkey.experiment.api.SampleTypeServiceImpl.SampleChangeType.insert;
|
158 | 156 | import static org.labkey.experiment.api.SampleTypeServiceImpl.SampleChangeType.rollup;
|
@@ -1102,7 +1100,7 @@ private record ExistingRowSelect(TableInfo tableInfo, Set<String> columns, boole
|
1102 | 1100 | remap = CaseInsensitiveHashMap.of();
|
1103 | 1101 |
|
1104 | 1102 | // AliquotRollupDataIterator needs "samplestate", "storedamount", "rootmaterialrowId", "units" for MERGE option
|
1105 |
| - Set<String> includedColumns = new CaseInsensitiveHashSet("name", "lsid", "rowid", "samplestate", "storedamount", "rootmaterialrowId", "units"); |
| 1103 | + Set<String> includedColumns = new CaseInsensitiveHashSet(Name.name(), LSID.name(), RowId.name(), SampleState.name(), StoredAmount.name(), RootMaterialRowId.name(), Units.name()); |
1106 | 1104 | for (ColumnInfo column : getQueryTable().getColumns())
|
1107 | 1105 | {
|
1108 | 1106 | if (dataColumns.contains(column.getColumnName()))
|
@@ -1533,9 +1531,6 @@ public DataIterator getDataIterator(DataIteratorContext context)
|
1533 | 1531 | DataIteratorBuilder dib = ExpDataIterators.CounterDataIteratorBuilder.create(dataIterator, sampleType.getContainer(), materialTable, ExpSampleType.SEQUENCE_PREFIX, sampleType.getRowId());
|
1534 | 1532 | dataIterator = dib.getDataIterator(context);
|
1535 | 1533 |
|
1536 |
| - // AliquotedFrom resolution |
1537 |
| - dataIterator = LoggingDataIterator.wrap(new ExpDataIterators.AliquotResolutionDataIterator(dataIterator, context, container, user, sampleType)); |
1538 |
| - |
1539 | 1534 | // sampleset.createSampleNames() + generate lsid
|
1540 | 1535 | // TODO: does not handle insertIgnore
|
1541 | 1536 | DataIterator names = new _GenerateNamesDataIterator(sampleType, container, user, DataIteratorUtil.wrapMap(dataIterator, false), context, batchSize);
|
@@ -1681,6 +1676,25 @@ protected void processNextInput()
|
1681 | 1676 | {
|
1682 | 1677 | Map<String, Object> map = new HashMap<>(((MapDataIterator)getInput()).getMap());
|
1683 | 1678 |
|
| 1679 | + String aliquotedFrom = null; |
| 1680 | + Object aliquotedFromObj = map.get(ExpMaterial.ALIQUOTED_FROM_INPUT); |
| 1681 | + if (aliquotedFromObj != null) |
| 1682 | + { |
| 1683 | + if (aliquotedFromObj instanceof String) |
| 1684 | + { |
| 1685 | + // Issue 45563: We need the AliquotedFrom name to be quoted so we can properly find the parent, |
| 1686 | + // but we don't want to include the quotes in the name we generate using AliquotedFrom |
| 1687 | + aliquotedFrom = StringUtilsLabKey.unquoteString((String) aliquotedFromObj).trim(); |
| 1688 | + map.put(ExpMaterial.ALIQUOTED_FROM_INPUT, aliquotedFrom); |
| 1689 | + } |
| 1690 | + else if (aliquotedFromObj instanceof Number) |
| 1691 | + { |
| 1692 | + aliquotedFrom = aliquotedFromObj.toString(); |
| 1693 | + } |
| 1694 | + } |
| 1695 | + |
| 1696 | + boolean isAliquot = !StringUtils.isEmpty(aliquotedFrom); |
| 1697 | + |
1684 | 1698 | try
|
1685 | 1699 | {
|
1686 | 1700 | Object currNameObj = map.get("Name");
|
@@ -1710,19 +1724,14 @@ protected void processNextInput()
|
1710 | 1724 | catch (NameGenerator.NameGenerationException e)
|
1711 | 1725 | {
|
1712 | 1726 | // Failed to generate a name due to some part of the expression not in the row
|
1713 |
| - if ((boolean) map.getOrDefault(ALIQUOT_FROM_IS_ALIQUOT, false)) |
1714 |
| - { |
| 1727 | + if (isAliquot) |
1715 | 1728 | addRowError("Failed to generate name for aliquot on row " + e.getRowNumber() + " using aliquot naming pattern " + _sampleType.getAliquotNameExpression() + ". Check the syntax of the aliquot naming pattern and the data values for the aliquot.");
|
1716 |
| - } |
| 1729 | + else if (_sampleType.hasNameExpression()) |
| 1730 | + addRowError("Failed to generate name for sample on row " + e.getRowNumber() + " using naming pattern " + _sampleType.getNameExpression() + ". Check the syntax of the naming pattern and the data values for the sample."); |
| 1731 | + else if (_sampleType.hasNameAsIdCol()) |
| 1732 | + addRowError("SampleID or Name is required for sample on row " + e.getRowNumber()); |
1717 | 1733 | else
|
1718 |
| - { |
1719 |
| - if (_sampleType.hasNameExpression()) |
1720 |
| - addRowError("Failed to generate name for sample on row " + e.getRowNumber() + " using naming pattern " + _sampleType.getNameExpression() + ". Check the syntax of the naming pattern and the data values for the sample."); |
1721 |
| - else if (_sampleType.hasNameAsIdCol()) |
1722 |
| - addRowError("SampleID or Name is required for sample on row " + e.getRowNumber()); |
1723 |
| - else |
1724 |
| - addRowError("All id columns are required for sample on row " + e.getRowNumber()); |
1725 |
| - } |
| 1734 | + addRowError("All id columns are required for sample on row " + e.getRowNumber()); |
1726 | 1735 | }
|
1727 | 1736 | }
|
1728 | 1737 |
|
|
0 commit comments