Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Multi-Value Metadata Values via CSV Import #904

Open
kposey1 opened this issue Jan 29, 2024 · 3 comments
Open

Removing Multi-Value Metadata Values via CSV Import #904

kposey1 opened this issue Jan 29, 2024 · 3 comments

Comments

@kposey1
Copy link

kposey1 commented Jan 29, 2024

According to the documentation, a user should be able to delete metadata values by importing a csv with a specified column header with no value.

When the column header is present and the value is empty, the metadata will be deleted

However, our user is unable to do this with multi-value fields.

This is the configuration for the metadata field in bulkrax.rb:
'sub_collection' => { from: ['sub_collection'], join: true, split: true }

The specified optional customization in Bulkrax::ObjectFactory (transformation_removes_blank_hash_values) did not enable this either.

I do see this line on the documentation, so I assume the csv import should delete all the values for the multi-value metadata field.

If a non-numerated column is imported with an empty value, it will delete all values in that property

Is it possible to delete the value of multi-valued metadata fields via csv import? Are there additional configuration options that enable this feature?

Please note we are using version 5.3.0 of Bulkrax and 3.6.0 of Hyrax.

@orangewolf
Copy link
Member

@kposey1 there has been quite a bit of tug-o-war over blanks in Bulkrax. The behavior you describe (if the header is present and the value is empty, the meta data field should be cleared) is the correct behavior. So this sounds very much like a bug. the problem basically comes down to many cooks trying to solve a variety of problems around blanks in the various ways they can present.

There are a few paths forward in the meantime in my mind:

  1. a patch would surely be appreciated, especially if it came with spec
  2. even just the spec would be helpful in getting this fixed
  3. as a temporary fix, has_local_processing is a great place to put the logic you need to make sure that if 'sub_collection' is present in the raw data that it is in turn present (but nil) in the parsed_metadata.

@kposey1
Copy link
Author

kposey1 commented Jan 30, 2024

Thank you @orangewolf for the direction!

~~If you don't mind elaborating, what is the recommended way to access the raw data from has_local_processing? ~~

After further investigation, it seems we had added a customization that cleared out nil values early in the processing. Removing this corrects the issue.

@orangewolf
Copy link
Member

@kposey1 sorry for vanishing on you, got crazy behind for a bit. The module "has_local_processing" is included in the Bulkrax::Entry class and then then the method add_local is called from the build_metadata method. build_metadata is the method responsible for transforming raw_metadata in to parsed_metadata. Both raw_metadata and parsed_metadata are available. So something like this might work:

in app/models/concerns/bulkrax/has_local_processing.rb

def add_local
  # this would need to be your field names and whatever the right logic to detect blankness is
 # this sudocode is off the top of my head and though the method name and method for changing parsed_metadata
# are correct, I have no idea if the rest of it is
  parsed_metadata['my_multi_field'] = nil if parsed_metadata['my_multi_field']&.all?(&:blank?)
end

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

No branches or pull requests

2 participants