Skip to content

Commit

Permalink
API / CSV export / Add support for custom export. (#7132)
Browse files Browse the repository at this point in the history
* API / CSV export / Add support for custom export.

Current CSV export is based on XSL transformations and can be hard to use when user is interested in element with multiple values (eg. online source, contacts).

Default CSV export remains the same but add the possibility to customize the export with 2 additional parameters to create custom export:

* `loopElementXpath`: element to loop on eg. use
`.` for the metadata
`.//gmd:CI_ResponsibleParty` for all contacts in ISO19139,
`.//gmd:transferOptions/*/gmd:onLine/*` for all online resources in ISO19139.

* `propertiesXpath`: columns to extract eg.
`gmd:identificationInfo/*/gmd:citation/*/gmd:title//text()` for the title.

Also add parameters for defining separators:
* `sep` for column separator
* `internalSep` when multiple values are stored in a field

User can then build custom reports from the API:

eg. Export Contact with role,org,email
http://localhost:8080/srv/api/records/csv?bucket=s101&loopElementXpath=.//gmd:CI_ResponsibleParty&propertiesXpath=gmd:role/*/@codeListValue&propertiesXpath=gmd:organisationName/*/text()&propertiesXpath=.//gmd:electronicMailAddress/*/text()

eg. Export Online source with protocol,url,name,desc
http://localhost:8080/srv/api/records/csv?bucket=s101&loopElementXpath=.//gmd:transferOptions/*/gmd:onLine/*&propertiesXpath=gmd:protocol/*/text()&propertiesXpath=gmd:linkage/*/text()&propertiesXpath=gmd:name/*/text()&propertiesXpath=gmd:description/*/text()

eg. Export Metadata with title,alternateTitle,status,maintenanceFreq,...
http://localhost:8080/srv/api/records/csv?bucket=s101&loopElementXpath=.&propertiesXpath=gmd:identificationInfo/*/gmd:citation/*/gmd:title//text()&propertiesXpath=gmd:identificationInfo/*/gmd:citation/*/gmd:alternateTitle//text()&propertiesXpath=gmd:identificationInfo/*/gmd:status/*/@codeListValue&propertiesXpath=gmd:identificationInfo/*//gmd:maintenanceAndUpdateFrequency/*/@codeListValue&propertiesXpath=gmd:identificationInfo/*//gmd:otherConstraints//text()&propertiesXpath=gmd:identificationInfo/*/gmd:topicCategory//text()&propertiesXpath=gmd:identificationInfo/*/gmd:language/*/@codeListValue&propertiesXpath=gmd:identificationInfo/*/gmd:graphicOverview/*/gmd:fileName/*/text()

Functions from XPath v1 can also be used eg. `count`
http://localhost:8080/srv/api/records/csv?bucket=s101&loopElementXpath=.&propertiesXpath=count(gmd:identificationInfo/*/gmd:descriptiveKeywords)

For all exports 2 columns are added first:
* UUID
* permalink

When using XPath, it is recommended to export records in same schema (or at least same base schema). If not, then XPath error messages are returned in cells unless XPath provided do not require namespaces. Users have to configure a proper selection to avoid mixing schema.

* Sonarlint.

* API / CSV export / Add support for custom export / Resolve XLinks if enabled.
  • Loading branch information
fxprunayre committed Aug 24, 2023
1 parent 3129a88 commit 51de002
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 55 deletions.

0 comments on commit 51de002

Please sign in to comment.