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

Convert file ids in resource fileset to pcdm files in AF fileset #4055

Merged
merged 2 commits into from
Jan 23, 2020

Conversation

elrayle
Copy link
Contributor

@elrayle elrayle commented Sep 30, 2019

Description

Add convert_files to the process that converts a resource to af object

Related to Issue #4060 Wings: Round trip conversion of files does not maintain file relationships

Description of Issue with this PR

When round tripping from AF to Valk to AF, the existing file is assigned a new ID while being set on the FileSet

Behaviors

The described behaviors assume the same starting fileset1 object created in Issue #3406

fileset1.class # FileSet
fileset1.id #  abc12345
fileset1.original_file.id # ab/c1/23/45/abc12345/files/xyz67890

rt_fileset is the round trip fileset from the conversion from fileset1 to a valkyrie resource and back to an ActiveFedora based fileset.

Expected behavior

rt_fileset.class # FileSet
rt_fileset.id # abc12345
rt_fileset.original_file # <Hydra::PCDM::file uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/xyz67890">
rt_fileset.filter_files_by_type(RDF::URI.new('http://pcdm.org/use#OriginalFile')) # [<Hydra::PCDM::File uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/xyz67890">]
rt_fileset.original_file.id # "ab/c1/23/45/abc12345/files/xyz67890"
rt_fileset.original_file.uri # "http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/xyz67890"
rt_fileset.files # [#<Hydra::PCDM::File uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/xyz67890" >]
rt_fileset.original_file.id == fileset1.original_file.id # true

Actual behavior using this PR's ActiveFedoraConverter #convert_file method

rt_fileset.class # FileSet
rt_fileset.id # abc12345
rt_fileset.original_file # <Hydra::PCDM::file uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/DIFFERENT_ID">
rt_fileset.filter_files_by_type(RDF::URI.new('http://pcdm.org/use#OriginalFile')) # [<Hydra::PCDM::file uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/DIFFERENT_ID">]
rt_fileset.original_file.id # "ab/c1/23/45/abc12345/files/DIFFERENT_ID"
rt_fileset.original_file.uri # "http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/DIFFERENT_ID"
rt_fileset.files # [<Hydra::PCDM::file uri="http://127.0.0.1:8986/rest/test/ab/c1/23/45/abc12345/files/DIFFERENT_ID">]
rt_fileset.original_file.id == fileset1.original_file.id # false

NOTE: The original_file's ID and URI show the file in the same fileset, but it has a different unique identifier extension for the file.

To Reproduce

fileset1 = FileSet.new
binary = StringIO.new("hey")
Hydra::Works::AddFileToFileSet.call(fileset1, binary, :original_file)
resource = fileset1.valkyrie_resource
rt_fileset = ActiveFedoraConverter.new(resource: resource).convert

Trace of significant method calls causing the IDs to be different

In Wings::ActiveFedoraConverter #convert_files call #convert_file with line...

      af_object[relation] = pcdm_file

calls ActiverFedora::Attributes #[]= with line...

      assoc.replace(value)

calls ActiveFedora::Associations::DirectlyContainsOneAssociation #replace with line...

      add_to_container(record)

calls ActiveFedora::Associations::DirectlyContainsOneAssociation #add_to_container with line...

      container_association.send(:initialize_attributes, record)

calls ActiveFedora::Associations::DirectlyContainsAssociation #initialize_attributes with line...

      record.uri = ActiveFedora::Base.id_to_uri(container.mint_id)

which mints the new id for the existing PCDM File

@elrayle elrayle self-assigned this Sep 30, 2019
@elrayle elrayle added the wings label Sep 30, 2019
elrayle added a commit that referenced this pull request Sep 30, 2019
Allows CharacterizeJob to receive a Valkyrie::Resource and immediately convert it to an AF object.  This allows callers of this job to be fully valkyrized.

PR #4055 Convert file ids in resource fileset to pcdm files in AF fileset

Make CharacterizationJob able to process a Valkyrie::Resource.

This supports full valkyrization of new service Hyrax::Files::IngestFileService (replacing FileActor #ingest_file method).
elrayle added a commit that referenced this pull request Sep 30, 2019
Allows CharacterizeJob to receive a Valkyrie::Resource and immediately convert it to an AF object.  This allows callers of this job to be fully valkyrized.

PR #4055 Convert file ids in resource fileset to pcdm files in AF fileset

Make CharacterizationJob able to process a Valkyrie::Resource.

This supports full valkyrization of new service Hyrax::Files::IngestFileService (replacing FileActor #ingest_file method).
@elrayle elrayle force-pushed the wings/af_converter_files branch 2 times, most recently from 4459c18 to b4c514e Compare October 14, 2019 20:38
@cjcolvar cjcolvar removed the wings label Oct 24, 2019
@stale
Copy link

stale bot commented Nov 23, 2019

This issue has been automatically marked as stale because it has not had activity for 30 days. It will be closed if no further activity occurs within 14 days. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2019
@stale stale bot closed this Dec 7, 2019
@elrayle elrayle reopened this Jan 22, 2020
@stale stale bot removed the stale label Jan 22, 2020
@elrayle elrayle force-pushed the wings/af_converter_files branch 3 times, most recently from dba5dc2 to e9d650b Compare January 22, 2020 22:42
elrayle and others added 2 commits January 22, 2020 18:06
Co-authored-by: cjcolvar <cjcolvard@indiana.edu>
Tests:
* PASS versioning: false
* PASS versioning: true and first file
* FAIL versioning: true and second file (test marked pending)
@elrayle elrayle changed the title [WIP] Convert file ids in resource fileset to pcdm files in AF fileset Convert file ids in resource fileset to pcdm files in AF fileset Jan 23, 2020
@elrayle
Copy link
Contributor Author

elrayle commented Jan 23, 2020

Solution:

Instead of...

      af_object[relation] = pcdm_file

We switched to using...

        af_object.association(relation).target = pcdm_file

@jeremyf jeremyf merged commit a7202a1 into master Jan 23, 2020
@jeremyf jeremyf deleted the wings/af_converter_files branch January 23, 2020 16:23
@elrayle
Copy link
Contributor Author

elrayle commented Jan 23, 2020

fixes #4060

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