Skip to content

Commit 3467d8e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_deriveActions
2 parents 1f8e4d4 + 4fe2d86 commit 3467d8e

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

api/src/org/labkey/api/exp/OntologyManager.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,22 +749,32 @@ public static boolean validateProperty(List<? extends IPropertyValidator> valida
749749
{
750750
boolean ret = true;
751751

752-
Object value = objectProperty.getObjectValue();
752+
boolean isArray = prop.getPropertyType() == PropertyType.MULTI_CHOICE;
753753

754-
if (prop.isRequired() && value == null && objectProperty.getMvIndicator() == null)
754+
Object value = isArray ? objectProperty.arrayValue : objectProperty.getObjectValue();
755+
boolean isNull = value == null;
756+
757+
// GitHub Issue 995: Unable to import assay run with required MVTC values
758+
if (isArray && value instanceof MultiChoice.Array array)
759+
isNull = array.isEmpty();
760+
761+
if (prop.isRequired() && isNull && objectProperty.getMvIndicator() == null)
755762
{
756763
errors.add(new PropertyValidationError("Field '" + prop.getName() + "' is required", prop.getName()));
757764
ret = false;
758765
}
759766

760767
// Check if the string is too long. Use either the PropertyDescriptor's scale or VARCHAR(4000) for ontology managed values
761-
int stringLengthLimit = prop.getScale() > 0 ? prop.getScale() : getTinfoObjectProperty().getColumn("StringValue").getScale();
762-
int stringLength = value == null ? 0 : value.toString().length();
763-
if (value != null && prop.isStringType() && stringLength > stringLengthLimit)
768+
if (!isArray)
764769
{
765-
String s = stringLength <= 100 ? value.toString() : StringUtilsLabKey.leftSurrogatePairFriendly(value.toString(), 100);
766-
errors.add(new PropertyValidationError("Field '" + prop.getName() + "' is limited to " + stringLengthLimit + " characters, but the value is " + stringLength + " characters. (The value starts with '" + s + "...')", prop.getName()));
767-
ret = false;
770+
int stringLengthLimit = prop.getScale() > 0 ? prop.getScale() : getTinfoObjectProperty().getColumn("StringValue").getScale();
771+
int stringLength = value == null ? 0 : value.toString().length();
772+
if (value != null && prop.isStringType() && stringLength > stringLengthLimit)
773+
{
774+
String s = stringLength <= 100 ? value.toString() : StringUtilsLabKey.leftSurrogatePairFriendly(value.toString(), 100);
775+
errors.add(new PropertyValidationError("Field '" + prop.getName() + "' is limited to " + stringLengthLimit + " characters, but the value is " + stringLength + " characters. (The value starts with '" + s + "...')", prop.getName()));
776+
ret = false;
777+
}
768778
}
769779

770780
// TODO: check date is within postgres date range

0 commit comments

Comments
 (0)