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

Method writeResources

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

Write DCAT dataset / service / series @param w XML writer @param con RDF triple store connection @param type RDF type @param cl RDF class as string @param prop wrapper property @throws XMLStreamException

(XMLStreamWriter w, RepositoryConnection con, IRI type, String cl, String prop)

Source from the content-addressed store, hash-verified

788 * @throws XMLStreamException
789 */
790 private static void writeResources(XMLStreamWriter w, RepositoryConnection con, IRI type, String cl, String prop)
791 throws XMLStreamException {
792 int nr = 0;
793 int duplicates = 0;
794 int incomplete = 0;
795
796 try (RepositoryResult<Statement> res = con.getStatements(null, RDF.TYPE, type)) {
797 while (res.hasNext()) {
798 IRI subj = (IRI) res.next().getSubject();
799 if (!isUnique(con, subj)) {
800 duplicates++;
801 continue;
802 }
803 if (!hasTitle(con,subj)) {
804 incomplete++;
805 continue;
806 }
807 nr++;
808 if (prop != null) {
809 w.writeStartElement(prop);
810 writeResource(w, con, cl, subj);
811 w.writeEndElement();
812 } else {
813 writeResource(w, con, cl, subj);
814 }
815 }
816 }
817 LOG.info("Wrote {} {}, {} duplicates, {} incompletes", nr, cl, duplicates, incomplete);
818 }
819
820 /**
821 * Write multiple file formats

Callers 1

writeCatalogMethod · 0.95

Calls 3

isUniqueMethod · 0.95
hasTitleMethod · 0.95
writeResourceMethod · 0.95

Tested by

no test coverage detected