feat(dwc): export backend — 25 API endpoints, cache engine, EML, RSS#7938
Open
foozleface wants to merge 1 commit intospecify:mainfrom
Open
feat(dwc): export backend — 25 API endpoints, cache engine, EML, RSS#7938foozleface wants to merge 1 commit intospecify:mainfrom
foozleface wants to merge 1 commit intospecify:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributed by @foozleface
Implements the full server-side DwC export pipeline: 21 new API endpoints (25 total with the 4 existing), a cache engine for pre-built query results, two archive generation paths, EML/RSS support, and a 217-term DwC vocabulary. Builds on the schema models from the DwC schema PR.
Implementation
specifyweb/backend/export/urls.py) covering mapping CRUD (create_mapping,update_mapping,delete_mapping,save_mapping_fields,clone_mapping,create_mapping_from_query), dataset CRUD (create_dataset,update_dataset,delete_dataset,clone_dataset), archive generation (generate_dwca,build_cache,cache_status), queries (list_queries,list_mappings,list_export_datasets), schema terms (schema_terms), OccurrenceID validation (validate_occurrence_ids), EML preview (preview_eml), RSS feed (rss_feed,download_feed), and feed updates (force_update,force_update_packages).dwca_from_mapping.py) — executes the backingSpQuerylive, writes CSV into a DwCA ZIP. Supports core + extension mappings with coreid linking.dwca_from_cache.py) — reads from pre-built cache tables for faster archive generation when data has not changed.cache.py) — creates/drops/rebuilds MySQL cache tables using stream-and-batch-insert. Tracks build status (idle/building/error) inCacheTableMeta. Usesbuild_query()from the stored queries engine via SQLAlchemy.dwca_utils.py) —build_meta_xml()andbuild_eml_xml()generate standards-compliantmeta.xmlandeml.xmlfor the archive. Term name sanitization for safe column/file names.field_adapter.py) — bridges DjangoSpqueryfield(lowercase attrs) to theEphemeralFieldinterface (camelCase) expected byQueryField.from_spqueryfield()in the stored queries engine.schema_terms.json) — 217 DwC terms across 14 groups (Occurrence, Event, Location, Taxon, Identification, GeologicalContext, Record-level, Organism, MeasurementOrFact, ResourceRelationship, MaterialEntity, MaterialSample, Media, Record), each with suggested Specify mapping paths.default_mappings.py) — pre-configured field sets for common DwC profiles.download_feed— validates filenames against directory escape.ExportDataSet.isrssflag instead of XML config files, with IPT-compatible<ipt:eml>and<ipt:dwca>elements.tests/) — unit tests for models, cache operations, archive generation, attachment URLs, and feed output.This is part of the DwC export pipeline addressing issues #7709-#7748 (40 GitHub issues for Darwin Core Archive support).
Testing instructions
python manage.py test specifyweb.backend.exportPOST /export/create_mapping/, assign DwC terms viaPOST /export/save_mapping_fields/<id>/, then generate an archive viaPOST /export/generate_dwca/<id>/meta.xml,eml.xml, andoccurrence.csvGET /export/schema_terms/returns the full vocabularyGET /export/validate_occurrence_ids/<id>/catches duplicate GUIDsGET /export/rss_feed/returns valid RSS XML for datasets withisRss=trueGET /export/download_feed/../etc/passwdreturns 404 (path traversal protection)