MCPcopy Create free account
hub / github.com/Fedict/dcattools / writeResource

Method writeResource

tools/src/main/java/be/gov/data/tools/EDP.java:655–743  ·  view source on GitHub ↗

Write DCAT Dataset / Dataservice / Series @param w XML writer @param con RDF triple store connection @param cl class name (used for element tag) @param uri URI of the dataset @throws XMLStreamException

(XMLStreamWriter w, RepositoryConnection con, String cl, IRI uri)

Source from the content-addressed store, hash-verified

653 * @throws XMLStreamException
654 */
655 private static void writeResource(XMLStreamWriter w, RepositoryConnection con, String cl, IRI uri)
656 throws XMLStreamException {
657 w.writeStartElement(cl);
658 w.writeAttribute("rdf:about", uri.toString());
659
660 writeGeneric(w, con, uri);
661
662 writeLiterals(w, con, uri, DCAT.VERSION, "dcat:version");
663 writeLiterals(w, con, uri, ADMS.VERSION_NOTES, "adms:versionNotes");
664 writeLiterals(w, con, uri, DCAT.KEYWORD, "dcat:keyword");
665 writeSubjects(w, con, uri, DCTERMS.SUBJECT, "dct:subject");
666 writeReferences(w, con, uri, DCAT.THEME, "dcat:theme");
667 writeReferences(w, con, uri, DCAT.LANDING_PAGE, "dcat:landingPage", "foaf:Document", false);
668 writeReferences(w, con, uri, FOAF.PAGE, "foaf:page", "foaf:Document", false);
669 writeReferences(w, con, uri, DCAT.ENDPOINT_URL, "dcat:endpointURL");
670 writeReferences(w, con, uri, DCAT.SERVES_DATASET, "dcat:servesDataset");
671 writeReferences(w, con, uri, DCAT.IN_SERIES, "dcat:inSeries");
672 writeReferences(w, con, uri, FOAF.PRIMARY_TOPIC, "foaf:isPrimaryTopicOf", "dcat:CatalogRecord", false);
673
674 // samples (geo-dcat-ap)
675 try (RepositoryResult<Statement> res = con.getStatements(uri, ADMS.SAMPLE, null)) {
676 while (res.hasNext()) {
677 w.writeStartElement("adms:sample");
678 writeDist(w, con, (IRI) res.next().getObject());
679 w.writeEndElement();
680 }
681 }
682 // citations
683 writeLiterals(w, con, uri, DCTERMS.BIBLIOGRAPHIC_CITATION, "dct:bibliographicCitation");
684 try (RepositoryResult<Statement> res = con.getStatements(uri, BIBO.CITED_BY, null)) {
685 while (res.hasNext()) {
686 w.writeStartElement("bibo:citedBy");
687 writeCited(w, con, "bibo:Document", (Resource) res.next().getObject());
688 w.writeEndElement();
689 }
690 }
691 writeReferences(w, con, uri, CITEDCAT.IS_COMPILED_BY, "citedcat:isCompiledBy");
692 writeReferences(w, con, uri, CITEDCAT.COMPILES, "citedcat:compiles");
693
694 // funding
695 try (RepositoryResult<Statement> res = con.getStatements(uri, CITEDCAT.IS_FUNDED_BY, null)) {
696 while (res.hasNext()) {
697 Statement stmt = res.next();
698 if (stmt.getObject() instanceof Resource) {
699 w.writeStartElement("citedcat:isFundedBy");
700 writeFunding(w, con, "foaf:Project", (Resource) stmt.getObject());
701 w.writeEndElement();
702 } else {
703 LOG.error("Not a funding resource, removing {}", stmt);
704 }
705 }
706 }
707
708 writeContacts(w, con, uri, DCAT.CONTACT_POINT);
709
710 writeReferences(w, con, uri, DCTERMS.SPATIAL, "dct:spatial");
711 writeReferences(w, con, uri, DCTERMS.ACCRUAL_PERIODICITY, "dct:accrualPeriodicity", "dct:Frequency", true);
712 writeReferences(w, con, uri, DCTERMS.PROVENANCE, "dct:provenance");

Callers 1

writeResourcesMethod · 0.95

Calls 13

writeGenericMethod · 0.95
writeLiteralsMethod · 0.95
writeSubjectsMethod · 0.95
writeReferencesMethod · 0.95
writeDistMethod · 0.95
writeCitedMethod · 0.95
writeFundingMethod · 0.95
writeContactsMethod · 0.95
writeProvenancesMethod · 0.95
writeDatesMethod · 0.95
writeRoleMethod · 0.95
writeMeasurementsMethod · 0.95

Tested by

no test coverage detected