pulibrary / dspace-cli

command line scripts accessing and modifying DSpace content
0 stars 0 forks source link

`#getValueId` is not implemented for the DSpace::CLI::Metadatum Class #120

Closed jrgriffiniii closed 3 years ago

jrgriffiniii commented 3 years ago

When attempting to update individual Metadatum objects, there are failures tracing to the following:

dspace-cli/dspace/cli/metadatum.rb:313:in `update'
dspace-cli/dspace/cli/metadatum.rb:303:in `persisted?'
dspace-cli/dspace/cli/metadatum.rb:286:in `database_row'
dspace-cli/dspace/cli/metadatum.rb:29:in `id'
NoMethodError (undefined method `getValueId' for #<Java::OrgDspaceContent::Metadatum:0x69a2b3b6>)
jrgriffiniii commented 3 years ago

This is indeed an expected error, as this method is not implemented on the underlying DSpace Class:

https://github.com/DSpace/DSpace/blob/dspace-5.5/dspace-api/src/main/java/org/dspace/content/Metadatum.java#L20

jrgriffiniii commented 3 years ago

This is also going to block all updates for Item metadata, as the following would, then, raise the same error for DSpace::CLI::MetadataArray (please see https://github.com/pulibrary/dspace-cli/blob/main/dspace/cli/metadata_array.rb#L79).

jrgriffiniii commented 3 years ago

https://github.com/pulibrary/dspace-cli/tree/issues-120-jrgriffiniii-metadatum-update advances this to the point where metadata records are being updated when tested on the staging environment.

jrgriffiniii commented 3 years ago
> query = DSpace::CLI::Query.new
> query.find_by_handle('88435/dsp01cr56n3903')
> item = query.results.first
> item.metadata.elements.first.value
 => "Li, Sophia Hsin-Jung"
> item.metadata.elements.first.value = 'test author'
 => "test author"
> item.metadata.elements.first.value
 => "test author"
> item.metadata.update
 => [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]
 > item.metadata.elements.first.value
 => "test author"