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

Method writeDocuments

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

Write document (license, standard...) info @param w XML writer @param con RDF triple store connection @throws XMLStreamException

(XMLStreamWriter w, RepositoryConnection con, IRI pred, String classWrap)

Source from the content-addressed store, hash-verified

867 * @throws XMLStreamException
868 */
869 private static void writeDocuments(XMLStreamWriter w, RepositoryConnection con, IRI pred, String classWrap) throws XMLStreamException {
870
871 Set<IRI> documents;
872
873 try (RepositoryResult<Statement> res = con.getStatements(null, pred, null)) {
874 documents = res.stream()
875 .map(Statement::getObject)
876 .filter(IRI.class::isInstance)
877 .map(IRI.class::cast)
878 .filter(i -> i.toString().startsWith("http"))
879 .filter(i -> con.hasStatement(null, null, i, false))
880 .collect(Collectors.toSet());
881 }
882
883 if (documents == null || documents.isEmpty()) {
884 return;
885 }
886
887 for (IRI document: documents) {
888 w.writeStartElement(classWrap);
889 w.writeAttribute("rdf:about", document.toString());
890 writeGenericInfo(w, con, document);
891 w.writeEndElement();
892 }
893 LOG.info("Wrote {} {} documents", documents.size(), classWrap);
894 }
895
896 /**
897 * Write location info

Callers 1

writeCatalogMethod · 0.95

Calls 2

writeGenericInfoMethod · 0.95
filterMethod · 0.45

Tested by

no test coverage detected