Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,35 @@ This webserver also exposes the follwing paths:
- `/full_update`: send a `POST` here to run the full_update script. Note that
this will not delete any files (yet).

## Resource IRIs

Every IRI gg2rdf mints for a Plazi resource uses the `https://` scheme:

| Resource | IRI |
| ------------------------- | ------------------------------------------------------- |
| treatment | `https://treatment.plazi.org/id/<treatment-id>` |
| material citation | `https://tb.plazi.org/GgServer/dwcaRecords/<id>.mc.<n>` |
| taxon name | `https://taxon-name.plazi.org/id/<kingdom>/<name>` |
| taxon concept | `https://taxon-concept.plazi.org/id/<kingdom>/<name>` |
| publication without a DOI | `https://publication.plazi.org/id/<masterDocId>` |

`https://` is canonical: it is the scheme that resolves on every Plazi host, and
it is the scheme the loaders (`turtle-hook`, `turtle-hook-nq`) name their graphs
with, so a treatment and the graph it lands in share one IRI. A `httpUri`
attribute TreatmentBank supplies with `http://` is rewritten to `https://` when
it points at a Plazi host; identifiers of other publishers (DOIs, GBIF) are
taken as they are.

Vocabulary namespaces are a different matter and stay as they are — `trt:` is
`http://plazi.org/vocab/treatment#`, alongside `dwc:`, `cito:` and `fabio:`,
which are `http://` by convention. Changing a vocabulary namespace breaks every
consumer's prefix declarations and belongs to a redesign of the ontologies, not
to this pipeline.

Output produced before this change (plazi/gg2rdf#33) carries `http://` subjects.
Rewriting a store that holds such data in place, without replaying every file,
is described in turtle-hook's README.

## Usage

Build as a docker container.
Expand Down
19 changes: 12 additions & 7 deletions src/gg2rdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function gg2rdf(
*
* replaces <xsl:template match="document"> and <xsl:template match="treatment"> */
function makeTreatment() {
const t = new Subject(URI(`http://treatment.plazi.org/id/${id}`));
const t = new Subject(URI(`https://treatment.plazi.org/id/${id}`));

if (treatmentTaxon) {
const taxon = treatmentTaxon.el;
Expand Down Expand Up @@ -772,16 +772,21 @@ export function gg2rdf(
/** replaces <xsl:template match="materialsCitation[@specimenCode]" mode="subject"> */
function makeCitedMaterial(c: Element): string {
const mcId = c.getAttribute("id");
const httpUri = c.getAttribute("httpUri");
// TreatmentBank still hands out http:// for its own resources; https:// is
// the canonical scheme for everything under plazi.org (see issue #33)
const httpUri = c.getAttribute("httpUri")?.replace(
/^http:\/\/(?=[a-z0-9-]+\.plazi\.org\/)/,
Comment thread
retog marked this conversation as resolved.
"https://",
);
const gbifOccurrenceId = c.getAttribute("ID-GBIF-Occurrence");
const specimenCode = c.getAttribute("specimenCode");

const uri = mcId
? URI(`http://tb.plazi.org/GgServer/dwcaRecords/${id}.mc.${mcId}`)
? URI(`https://tb.plazi.org/GgServer/dwcaRecords/${id}.mc.${mcId}`)
: (gbifOccurrenceId
? URI(`https://www.gbif.org/occurrence/${gbifOccurrenceId}`)
: (httpUri ? URI(httpUri) : URI(
`http://treatment.plazi.org/id/${id}/${partialURI(specimenCode)}`,
`https://treatment.plazi.org/id/${id}/${partialURI(specimenCode)}`,
"_",
)));

Expand Down Expand Up @@ -1247,7 +1252,7 @@ export function gg2rdf(

/** replaces <xsl:call-template name="taxonNameBaseURI"> */
function taxonNameBaseURI({ kingdom }: { kingdom: string }) {
return `http://taxon-name.plazi.org/id/${
return `https://taxon-name.plazi.org/id/${
kingdom ? partialURI(kingdom) : "INVALID"
}`;
}
Expand Down Expand Up @@ -1374,7 +1379,7 @@ export function gg2rdf(
*
* replaces <xsl:call-template name="taxonConceptBaseURI"> */
function taxonConceptBaseURI({ kingdom }: { kingdom: string }) {
return `http://taxon-concept.plazi.org/id/${kingdom}`;
return `https://taxon-concept.plazi.org/id/${kingdom}`;
}

/** returns valid turtle uri
Expand Down Expand Up @@ -1423,7 +1428,7 @@ export function gg2rdf(
const doiID: string | undefined = doc.getAttribute("ID-DOI");
if (!doiID) {
return URI(
`http://publication.plazi.org/id/${
`https://publication.plazi.org/id/${
partialURI(doc.getAttribute("masterDocId"))
}`,
);
Expand Down
Loading