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