Skip to content

Conversation

@laritakr
Copy link
Contributor

@laritakr laritakr commented Oct 30, 2025

Summary

Creates a service which generates a sample CSV file to be used as a template for creating imports. This is Hyku tenant-specific because Hyku stores the Bulkrax field mappings at a tenant level, and should work for current Hyku with both flexible metadata false and true

Sample File & Caveats

  • Sample file below was created through base hyku with flexible true and using the default m3 profile.
  • Nonstandard bulkrax mappings may affect the validity of the resulting file, but efforts were taken to ensure valid results in the majority of cases.
  • Sample CSV requires Hyrax. Use outside of Hyrax will return an error.
Sample CSV created by service

bulkrax_template_20260127_015533.csv

Note

Using the schema's form definition to determine which terms to include may allow us to remove the ignore list. However while we are attempting to support (with no guarantee that it will work) ActiveFedora's defined models, this wouldn't work, so the ignored properties in CsvBuilder class remain for now.

@laritakr laritakr force-pushed the create-sample-csv-service branch from dd6591a to 4713fa6 Compare October 30, 2025 02:27
This file can be used as a template for creating imports.
@christhepianist
Copy link

christhepianist commented Oct 30, 2025 via email

@laritakr laritakr added enhancement for release notes (New feature or request) patch-ver for release notes labels Oct 30, 2025
@laritakr laritakr force-pushed the create-sample-csv-service branch 4 times, most recently from 6412b8e to 6084196 Compare October 30, 2025 17:12
@laritakr laritakr force-pushed the create-sample-csv-service branch 2 times, most recently from 218adfe to 629610f Compare December 11, 2025 16:28
@laritakr laritakr force-pushed the create-sample-csv-service branch from 75e67b8 to 8332b79 Compare December 17, 2025 23:14
@laritakr laritakr marked this pull request as ready for review January 27, 2026 02:05
@laritakr laritakr force-pushed the create-sample-csv-service branch from 5513b32 to df68a31 Compare January 27, 2026 02:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new SampleCsvService that generates tenant-specific CSV import templates for Bulkrax. The service creates sample CSV files with appropriate headers, field descriptions, and example values based on the repository's work types and field mappings, supporting both ActiveFedora and Valkyrie models.

Changes:

  • Adds a modular SampleCsvService with 12 supporting classes that analyze schemas, build columns/rows, and generate CSV templates
  • Implements a "Generate CSV Import Template" button in the importer creation UI with corresponding controller action and route
  • Removes the deprecated generate_test_csvs rake task that created fake test data

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
app/services/bulkrax/sample_csv_service.rb Main orchestrator service that coordinates CSV generation through specialized components
app/services/bulkrax/sample_csv_service/*.rb Supporting classes for model loading, field analysis, column/row building, and CSV output
app/controllers/bulkrax/importers_controller.rb Adds sample_csv_file action to generate and download CSV template
app/views/bulkrax/importers/new.html.erb Adds "Generate CSV Import Template" button and updates submit button styling
app/views/bulkrax/exporters/new.html.erb Updates submit button styling for consistency
config/routes.rb Adds POST route for sample_csv_file action
config/locales/bulkrax.en.yml Adds translation for "Generate Sample CSV" action
lib/tasks/bulkrax_tasks.rake Removes deprecated generate_test_csvs rake task
spec/services/bulkrax/sample_csv_service/*.rb Test coverage for service classes (some files are empty stubs)
app/assets/stylesheets/bulkrax/import_export.scss Minor whitespace cleanup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -14,108 +14,6 @@ namespace :bulkrax do
end
end

Copy link
Contributor

@ShanaLMoore ShanaLMoore Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooo I didn't know we had a rake task for this. Is it no longer valid? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know either! It was set up to create test data of some sort I believe, but it was very out of date and did not work when I tried it. I decided it was probably best to remove it - keeping it felt misleading. I could be persuaded otherwise if there's any valid reason to keep it around.

Copy link
Contributor

@ShanaLMoore ShanaLMoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate all the specs added to Bulkrax! 👏🏿

@laritakr laritakr changed the title Creates a sample CSV file 🎁 Creates a sample CSV file Jan 28, 2026
@laritakr laritakr changed the title 🎁 Creates a sample CSV file 🎁 Creates a sample CSV importing template file Jan 28, 2026
The sample CSV generation only works if Hyrax is defined in the
application, so the button should only appear if Hyrax is defined as well.
@laritakr laritakr merged commit 920e978 into main Jan 28, 2026
9 checks passed
@laritakr laritakr deleted the create-sample-csv-service branch January 28, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement for release notes (New feature or request) patch-ver for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants