samvera / hydra-pcdm

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

Can't get files from a FileSet loaded from solr #197

Closed jcoyne closed 5 years ago

jcoyne commented 8 years ago
p solr_document.to_model.files
[]
fs = FileSet.find(solr_document.id)
fs.files
[#<Hydra::PCDM::File uri="http://localhost:8983/fedora/rest/test/j6/73/14/30/j6731430t/files/559e2a4c-16e0-4001-b2fb-58b72921444f" >]
jcoyne commented 8 years ago

The problem is that ActiveFedora::DirectlyContainsAssocation#find_target attempts to get the resources from the graph by doing:

query_node.resource.query(predicate: container_predicate)

When the object is loaded from solr, the query_node.resource evaluates to an object of type ActiveFedora::LoadableFromJson::SolrBackedResource. When you run the query, for http://pcdm.org/models#hasFile, it returns an empty set.

jcoyne commented 8 years ago

The :files reflection doesn't have a :predicate, instead it has a has_member_relation. So the SolrBackedResource can't find the correct reflection. Even if it did find the correct reflection, the values are not indexed, so there's nothing to retrieve.

jcoyne commented 8 years ago

This PR should keep this from happening in a silent way: https://github.com/projecthydra/active_fedora/pull/951