samvera / hydra-pcdm

Samvera implementation of the PCDM model
Other
11 stars 10 forks source link

After deleting an ordered_member object, getting errors in the parent object #196

Closed ojlyytinen closed 5 years ago

ojlyytinen commented 8 years ago

If I destroy an object that's in ordered_members of another, then that seems to break the parent object. I'm using v0.3.1.

parent = Hydra::PCDM::Object.create
child = Hydra::PCDM::Object.create
parent.ordered_members << child
parent.save
child.destroy
parent.reload
parent.save
NoMethodError: undefined method `pcdm_object?' for #<ActiveTriples::Resource:0x000000059bfc80>
    from /home/######/.rvm/gems/ruby-2.2.1/gems/rdf-1.99.0/lib/rdf/mixin/enumerable.rb:724:in `method_missing'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/rdf-1.99.0/lib/rdf/mixin/mutable.rb:181:in `method_missing'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/models/concerns/pcdm_behavior.rb:43:in `select'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/models/concerns/pcdm_behavior.rb:43:in `ordered_objects'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/models/concerns/pcdm_behavior.rb:47:in `ordered_object_ids'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/object_indexer.rb:8:in `block in generate_solr_document'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/object_indexer.rb:4:in `tap'
    from /home/######/.rvm/gems/ruby-2.2.1/bundler/gems/hydra-pcdm-2b43e91ca293/lib/hydra/pcdm/object_indexer.rb:4:in `generate_solr_document'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/active-fedora-9.6.1/lib/active_fedora/indexing.rb:23:in `to_solr'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/active-fedora-9.6.1/lib/active_fedora/indexing.rb:32:in `update_index'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/active-fedora-9.6.1/lib/active_fedora/indexing.rb:61:in `update_record'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/active-fedora-9.6.1/lib/active_fedora/callbacks.rb:243:in `block (2 levels) in update_record'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:553:in `block (2 levels) in compile'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
... 24 levels...
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/commands/rails.rb:6:in `call'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/command_wrapper.rb:38:in `call'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:183:in `block in serve'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:156:in `fork'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:156:in `serve'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:131:in `block in run'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:125:in `loop'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application.rb:125:in `run'
    from /home/######/.rvm/gems/ruby-2.2.1/gems/spring-1.4.0/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /home/######/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/######/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'
jcoyne commented 8 years ago

This is related to https://github.com/projecthydra-labs/activefedora-aggregation/issues/72 somewhat.

val99erie commented 8 years ago

A possible hint. (I'm not sure if my bug is the same problem as this issue)

In heliotrope (a curation_concerns based Rails app), when I delete the representative FileSet from a GenericWork, there is a callback that is supposed to remove the representative relationship from the parent GenericWork.

It does that by looping through all the parent works and updating them, but I've noticed that when I delete the FileSet, it never enters the loop because the list of parent works is (incorrectly) empty: https://github.com/projecthydra-labs/curation_concerns/blob/master/curation_concerns-models/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb#L40

It's using the hydra-pcdm in_objects method to find the list of parent works: https://github.com/projecthydra-labs/curation_concerns/blob/master/curation_concerns-models/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb#L11

jrgriffiniii commented 5 years ago

https://github.com/mlibrary/heliotrope/issues/116#issuecomment-218491025 seems to confirm that this was fixed, and https://github.com/samvera-deprecated/activefedora-aggregation/issues/72 seems to have been resolved with updates to CurationConcerns (https://github.com/pulibrary/plum/issues/249)