Write multiple file formats @param w XML writer @param con RDF triple store connection @param uri URI of the dataset @param pred RDF predicate @throws XMLStreamException
(XMLStreamWriter w, RepositoryConnection con, IRI pred, String classWrap)
| 827 | * @throws XMLStreamException |
| 828 | */ |
| 829 | private static void writeConcepts(XMLStreamWriter w, RepositoryConnection con, IRI pred, String classWrap) |
| 830 | throws XMLStreamException { |
| 831 | |
| 832 | Set<IRI> concepts; |
| 833 | |
| 834 | try (RepositoryResult<Statement> res = con.getStatements(null, pred, null)) { |
| 835 | concepts = res.stream() |
| 836 | .map(Statement::getObject) |
| 837 | .filter(IRI.class::isInstance) |
| 838 | .map(IRI.class::cast) |
| 839 | .filter(i -> i.toString().startsWith("http")) |
| 840 | .filter(i -> con.hasStatement(null, null, i, false)) |
| 841 | .collect(Collectors.toSet()); |
| 842 | } |
| 843 | |
| 844 | if (concepts == null || concepts.isEmpty()) { |
| 845 | return; |
| 846 | } |
| 847 | for (IRI concept: concepts) { |
| 848 | w.writeStartElement(classWrap); |
| 849 | w.writeAttribute("rdf:about", concept.toString()); |
| 850 | if(! classWrap.equals("skos:Concept")) { |
| 851 | w.writeEmptyElement("rdf:type"); |
| 852 | w.writeAttribute("rdf:resource", SKOS.CONCEPT.stringValue()); |
| 853 | } |
| 854 | writeLiterals(w, con, concept, SKOS.PREF_LABEL, "skos:prefLabel"); |
| 855 | writeReferences(w, con, concept, SKOS.IN_SCHEME, "skos:inScheme"); |
| 856 | w.writeEndElement(); |
| 857 | } |
| 858 | LOG.info("Wrote {} {} concepts", concepts.size(), classWrap); |
| 859 | |
| 860 | } |
| 861 | |
| 862 | /** |
| 863 | * Write document (license, standard...) info |
no test coverage detected