MarcusBarnes / mik

The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
GNU General Public License v3.0
34 stars 11 forks source link

Work on #363. #364

Closed mjordan closed 7 years ago

mjordan commented 7 years ago

Github issue: (#363)

What does this Pull Request do?

Adds a new metadata parser class that generates output from Twig templates.

What's new?

A new metadata parser class that generates its output from Twig templates. It is a drop-in replacement for existing metadata parsers. This parser does not use field mappings; instead, source field values from the fetcher are interpolated directly into the templates.

How should this be tested?

  1. Check out the issue-363 branch.
  2. Run composer dump-autoload.
  3. Run PHPUnit tests: phpunit --exclude-group inputvalidators --bootstrap vendor/autoload.php tests. There should be no failures.
  4. Unzip the attached configuration files and run mik: ./mik -c templated.ini.
  5. Look in the output directory. The XML files should correspond to the templated_mods_twig.xml template.
  6. In the templated.ini file, comment out template = templated_mods_twig.xml and uncomment ; template = templated_dc_twig.xml.
  7. Delete your output directory.
  8. Rerun mik.
  9. Look in the output directory. The XML files should correspond to the templated_dc_twig.xml template.

To test the accompanying metadata manipulator:

  1. Delete the MIK output and temp directories.
  2. Add the following options to the .ini file:
    
    [MANIPULATORS]
    metadatamanipulators[] = "SimpleReplaceTemplated|/Island/|Peninsula"

[LOGGING] path_to_manipulator_log = /tmp/templated_output/manipulator.log


3. Rerun MIK. 
4. In image02.xml and image05.xml, the word 'Island' will be replaced by the word 'Peninsula'.

# Additional Notes

We would need to document this metadata parser and accompanying manipulator. It should work with CONTENTdm and CSV toolchains. This metadata parser will also serve as a good example of how to extend MIK.

# Interested parties
@MarcusBarnes. Other MIK users may want to test this new parser class as well and offer feedback.

[templated.zip](https://github.com/MarcusBarnes/mik/files/871591/templated.zip)
mjordan commented 7 years ago

Woops, forgot to add PHPUnit tests. Please hold off on merging until I do so.

mjordan commented 7 years ago

Tests added: phpunit --exclude-group inputvalidators --bootstrap vendor/autoload.php tests.

MarcusBarnes commented 7 years ago

Note running --checkconfig all will result in an error as mapping _csv_path setting is expected with the provided test files. We'll need to adjust the checkconfig logic.

MarcusBarnes commented 7 years ago

@mjordan Works as expected, thank you. The only issue is that --checkconfig expects a mappings path. I'm good with merging this code and then addressing that as a separate issue. What do you think @mjordan?

mjordan commented 7 years ago

Yes, sorry about that, we need to update --checkconfig. Open a separate issue and assign it to me if you want.