Skip to content

Add DomainUtil.getNamesAndLabels utility method for use in reserving variants of column names #7060

Merged
labkey-susanh merged 15 commits intodevelopfrom
fb_reservedFields
Sep 23, 2025
Merged

Add DomainUtil.getNamesAndLabels utility method for use in reserving variants of column names #7060
labkey-susanh merged 15 commits intodevelopfrom
fb_reservedFields

Conversation

@labkey-susanh
Copy link
Contributor

@labkey-susanh labkey-susanh commented Sep 22, 2025

Rationale

Because we generally allow users to provide either the name of a field or its label during import, we should consistently be reserving both the name and the label for each domain so there will not be ambiguity when trying to resolve a column during import. This PR gets us closer to consistency by adding a utility method that will create the set of reservable strings given a field's name and then uses that in various domains, also making more of the reserved field sets static constants.

Related Pull Requests

Changes

  • Add DomainUtil.getNamesAndLabels
  • Add DomainUtil.getNameAndLabels
  • Update various domains to use these new methods
  • Mark getReservedPropertyNames as @NotNull

Tasks 📍

  • Manual Testing
  • Code Review @XingY
  • Needs Automation

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds utility methods DomainUtil.getNamesAndLabels and DomainUtil.getNameAndLabels to consistently reserve both the name and label variants of column names across various domain implementations. This ensures consistency when resolving columns during import operations where users can provide either the field name or its label.

Key changes include:

  • Added new utility methods to DomainUtil for generating name and label variants
  • Updated numerous domain classes to use these utility methods instead of manual field name handling
  • Standardized reserved field collections to use CaseInsensitiveHashSet and made many static constants

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.

File Description
api/src/org/labkey/api/exp/property/DomainUtil.java Added getNameAndLabels and getNamesAndLabels utility methods
Multiple domain kind files Updated to use new utility methods and consistent collection handling
Multiple files with getReservedPropertyNames Added @NotNull annotations to method signatures
Comments suppressed due to low confidence (1)

filecontent/src/org/labkey/filecontent/FilePropertiesDomainKind.java:1

  • This method override has been removed but it's unclear if this change is intentional or related to the PR's purpose of adding name/label utilities. If this removal is unintentional, the method should be restored.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@XingY XingY left a comment

Choose a reason for hiding this comment

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

Could the getNamesAndLabels step be done in the centralized util instead?

RESERVED_NAMES = new CaseInsensitiveHashSet(DomainUtil.getNamesAndLabels(
BASE_PROPERTIES.stream().map(PropertyStorageSpec::getName).collect(Collectors.toSet()))
);
RESERVED_NAMES.addAll(DomainUtil.getNamesAndLabels(Arrays.stream(ExpSampleTypeTable.Column.values()).map(Enum::name).toList()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of each domain pass in NamesAndLabels as reservedNames, could we instead handle the getNamesAndLabels check in DomainUtil in a centralized place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think getNamesAndLabels does what you're asking for if used differently. I've adjusted usages so we aren't constructing as many sets from sets.

Or were you thinking that DomainKind.getReservedPropertyNames would call getNamesAndLabels? I think we want to keep the sets returned from getReservedPropertyNames static where we can so we aren't always constructing new sets.

}
}
));
Set<String> set = new CaseInsensitiveHashSet();
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is done in DomainUtil then this change is not needed.

@labkey-susanh labkey-susanh merged commit cf919be into develop Sep 23, 2025
19 of 21 checks passed
@labkey-susanh labkey-susanh deleted the fb_reservedFields branch September 23, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants