diff --git a/api/src/org/labkey/api/audit/AuditHandler.java b/api/src/org/labkey/api/audit/AuditHandler.java index 2c765844544..0212dce7002 100644 --- a/api/src/org/labkey/api/audit/AuditHandler.java +++ b/api/src/org/labkey/api/audit/AuditHandler.java @@ -91,8 +91,6 @@ static Pair, Map> getOldAndNewRecordForMerge if (col != null && (col.isMultiValued() || col.getFk() instanceof MultiValuedForeignKey)) isMultiValued = true; - boolean isMultiChoice = col != null && col.getPropertyType() == PropertyType.MULTI_CHOICE; - String nameFromAlias = key; if (null != col) nameFromAlias = col.getName(); @@ -104,9 +102,13 @@ static Pair, Map> getOldAndNewRecordForMerge { if (aliasColumn.getFk() != null && (aliasColumn.isMultiValued() || aliasColumn.getFk() instanceof MultiValuedForeignKey)) isMultiValued = true; + col = aliasColumn; // GitHub Issue 913: Updating a sample details page shows an update to the MVTC field nameFromAlias = aliasColumn.getName(); } } + + boolean isMultiChoice = col != null && col.getPropertyType() == PropertyType.MULTI_CHOICE; + String lcName = nameFromAlias.toLowerCase(); // Preserve casing of inputs so we can show the names properly boolean isExpInput = false; // TODO: extract lineage handling out of this generic method diff --git a/api/src/org/labkey/api/data/NameGeneratorState.java b/api/src/org/labkey/api/data/NameGeneratorState.java index db50e3715af..7f69e445fcc 100644 --- a/api/src/org/labkey/api/data/NameGeneratorState.java +++ b/api/src/org/labkey/api/data/NameGeneratorState.java @@ -353,6 +353,11 @@ else if (parentObject instanceof ExpData data) { rawObj = (Double) rawObj < 1.0 ? Boolean.FALSE : Boolean.TRUE; } + else if (PropertyType.MULTI_CHOICE.equals(pt) && rawObj == null) + { + // GitHub Issue 914: Using MVTC field in Ancestry Naming Pattern is always blank + rawObj = prop.getArrayValue(); + } properties.put(prop.getName(), pt.convert(rawObj)); } diff --git a/api/src/org/labkey/api/exp/ObjectProperty.java b/api/src/org/labkey/api/exp/ObjectProperty.java index 72a61647493..5c3b0c3d4be 100644 --- a/api/src/org/labkey/api/exp/ObjectProperty.java +++ b/api/src/org/labkey/api/exp/ObjectProperty.java @@ -169,6 +169,11 @@ public PropertyType getPropertyType() return PropertyType.getFromURI(getConceptURI(), getRangeURI()); } + public MultiChoice.Array getArrayValue() + { + return arrayValue; + } + public Container getContainer() { return ContainerManager.getForId(containerId); diff --git a/api/src/org/labkey/api/exp/PropertyType.java b/api/src/org/labkey/api/exp/PropertyType.java index 8d42cc373a2..b3ab3c8017a 100644 --- a/api/src/org/labkey/api/exp/PropertyType.java +++ b/api/src/org/labkey/api/exp/PropertyType.java @@ -204,7 +204,7 @@ public Object getPreviewValue(@Nullable String prefix) return prefix + "Value"; } }, - MULTI_CHOICE("http://cpas.fhcrc.org/exp/xml#multiChoice", "MultiChoice", '?' /* unsupported in exp.PropertyValues */, JdbcType.ARRAY, 0, "textarea", CellType.STRING, List.class) + MULTI_CHOICE("http://cpas.fhcrc.org/exp/xml#multiChoice", "MultiChoice", '?' /* unsupported in exp.PropertyValues */, JdbcType.ARRAY, 0, "textarea", CellType.STRING, MultiChoice.Array.class) { @Override protected Object convertExcelValue(Cell cell) throws ConversionException diff --git a/api/src/org/labkey/api/exp/property/DomainUtil.java b/api/src/org/labkey/api/exp/property/DomainUtil.java index 0485923059c..303b4445766 100644 --- a/api/src/org/labkey/api/exp/property/DomainUtil.java +++ b/api/src/org/labkey/api/exp/property/DomainUtil.java @@ -935,8 +935,16 @@ public static ValidationException updateDomainDescriptor(GWTDomain> propTextChoiceValueUpdates = updatePropertyValidators(p, old, pd); - if (propTextChoiceValueUpdates != null) + if (propTextChoiceValueUpdates != null && !propTextChoiceValueUpdates.isEmpty()) + { + if (PropertyType.MULTI_CHOICE.getTypeUri().equals(old.getRangeURI()) || PropertyType.MULTI_CHOICE.getTypeUri().equals(pd.getRangeURI())) + { + // GitHub Issue 923: Renamed text choice option while converting MV to SV text choice results in bad values + validationException.addError(new SimpleValidationError("Text choice value updates are not supported for multi-choice field: " + p.getName())); + return validationException; + } textChoiceValueUpdates.put(p, propTextChoiceValueUpdates); + } if (old.equals(pd)) continue; @@ -1377,8 +1385,11 @@ private static void updateTextChoiceValueRows(Domain domain, User user, String p Set rowContainers = rows.stream().map((row) -> (String) row.get(containerFieldName)).collect(Collectors.toSet()); for (String rowContainer : rowContainers) { + // GitHub Issue 924: Updating Single Text choice values errors when there are child folders + var dataContainer = ContainerManager.getForId(rowContainer); + var domainTable_ = domain.getDomainKind().getTableInfo(user, dataContainer, domain, ContainerFilter.getUnsafeEverythingFilter()); List> containerRows = rows.stream().filter((row) -> row.get(containerFieldName).equals(rowContainer)).collect(Collectors.toList()); - domainTable.getUpdateService().updateRows(user, ContainerManager.getForId(rowContainer), containerRows, containerRows, batchErrors, Map.of(AuditBehavior, AuditBehaviorType.DETAILED), null); + domainTable_.getUpdateService().updateRows(user, dataContainer, containerRows, containerRows, batchErrors, Map.of(AuditBehavior, AuditBehaviorType.DETAILED), null); } } else diff --git a/api/src/org/labkey/api/reader/DataLoader.java b/api/src/org/labkey/api/reader/DataLoader.java index fa3df2b0052..a500d443ea4 100644 --- a/api/src/org/labkey/api/reader/DataLoader.java +++ b/api/src/org/labkey/api/reader/DataLoader.java @@ -33,6 +33,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ImportAliasable; import org.labkey.api.data.JdbcType; +import org.labkey.api.data.MultiChoice; import org.labkey.api.data.MvUtil; import org.labkey.api.dataiterator.DataIterator; import org.labkey.api.dataiterator.DataIteratorBuilder; @@ -825,6 +826,12 @@ else if (column.isMvIndicator()) values[i] = mvWrapper; } } + else if (column.clazz == MultiChoice.Array.class) + { + // GitHub Issue 925: Not providing a MVTC value in an assay result throws error + // convert blank to empty array, not null + values[i] = column.converter.convert(column.clazz, fld); + } else { values[i] = ("".equals(fld)) ? diff --git a/experiment/src/org/labkey/experiment/api/property/StorageProvisionerImpl.java b/experiment/src/org/labkey/experiment/api/property/StorageProvisionerImpl.java index 933824eadd2..b799e59ad83 100644 --- a/experiment/src/org/labkey/experiment/api/property/StorageProvisionerImpl.java +++ b/experiment/src/org/labkey/experiment/api/property/StorageProvisionerImpl.java @@ -601,7 +601,9 @@ public void changePropertyType(Domain domain, DomainProperty prop) throws Change throw new ChangePropertyDescriptorException("Unable to change property type. There are rows with multiple values stored for '" + prop.getName() + "'."); } } - oldPropTypes.put(prop.getName(), oldPd.getPropertyType()); + // GitHub Issue 935: Changing from MVTC to TC wraps all values in curly braces + // This is due to StorageColumnName differ from column name, resulting in column update skipped + oldPropTypes.put(prop.getPropertyDescriptor().getStorageColumnName(), oldPd.getPropertyType()); } }