Skip to content
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
6 changes: 4 additions & 2 deletions api/src/org/labkey/api/audit/AuditHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ static Pair<Map<String, Object>, Map<String, Object>> 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();
Expand All @@ -104,9 +102,13 @@ static Pair<Map<String, Object>, Map<String, Object>> 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
Expand Down
5 changes: 5 additions & 0 deletions api/src/org/labkey/api/data/NameGeneratorState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions api/src/org/labkey/api/exp/ObjectProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/exp/PropertyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions api/src/org/labkey/api/exp/property/DomainUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,16 @@ public static ValidationException updateDomainDescriptor(GWTDomain<? extends GWT
if (old == null)
continue;
List<Map<String, Object>> propTextChoiceValueUpdates = updatePropertyValidators(p, old, pd);
if (propTextChoiceValueUpdates != null)
if (propTextChoiceValueUpdates != null && !propTextChoiceValueUpdates.isEmpty())
{
if (PropertyType.MULTI_CHOICE.getTypeUri().equals(old.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;

Expand Down Expand Up @@ -1377,8 +1385,11 @@ private static void updateTextChoiceValueRows(Domain domain, User user, String p
Set<String> 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<Map<String, Object>> 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
Expand Down
7 changes: 7 additions & 0 deletions api/src/org/labkey/api/reader/DataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, another example of why I'd love if DataLoader stopped doing conversions altogether.

else
{
values[i] = ("".equals(fld)) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}
Expand Down
Loading