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

Method writeLocations

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

Write location info @param w XML writer @param con RDF triple store connection @throws XMLStreamException

(XMLStreamWriter w, RepositoryConnection con)

Source from the content-addressed store, hash-verified

901 * @throws XMLStreamException
902 */
903 private static void writeLocations(XMLStreamWriter w, RepositoryConnection con) throws XMLStreamException {
904 int nr = 0;
905
906 try (RepositoryResult<Statement> res = con.getStatements(null, RDF.TYPE, DCTERMS.LOCATION)) {
907 while (res.hasNext()) {
908 IRI location = (IRI) res.next().getSubject();
909 if (con.hasStatement(null, null, location, false)) {
910 Value bbox = null;
911 try(RepositoryResult<Statement> bboxes = con.getStatements(location, DCAT.BBOX, null)) {
912 while (bboxes.hasNext()) {
913 Value val = bboxes.next().getObject();
914 if (val.stringValue().startsWith("POLYGON")) {
915 bbox = val;
916 }
917 }
918 }
919 if (bbox != null) {
920 nr++;
921 w.writeStartElement("dct:Location");
922 w.writeAttribute("rdf:about", location.toString());
923 writeLiteral(w, "dcat:bbox", bbox);
924 w.writeEndElement();
925 }
926 }
927 }
928 }
929 LOG.info("Wrote {} locations", nr);
930 }
931
932 /**
933 * Write FOAF organization

Callers 1

writeCatalogMethod · 0.95

Calls 1

writeLiteralMethod · 0.95

Tested by

no test coverage detected