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)
| 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 |
no test coverage detected