Check circular references (object same as subject) @param con
(RepositoryConnection con)
| 1057 | * @param con |
| 1058 | */ |
| 1059 | private static void checkCircular(RepositoryConnection con) { |
| 1060 | int circulars = 0; |
| 1061 | |
| 1062 | try(RepositoryResult<Statement> res = con.getStatements(null, RDF.TYPE, null)) { |
| 1063 | while(res.hasNext()) { |
| 1064 | Resource subj = res.next().getSubject(); |
| 1065 | try(RepositoryResult<Statement> res2 = con.getStatements(subj, null, subj)) { |
| 1066 | while(res2.hasNext()) { |
| 1067 | Resource obj = res2.next().getPredicate(); |
| 1068 | LOG.warn("Circular reference {} {}", subj, obj); |
| 1069 | circulars++; |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | LOG.info("Detected {} circulars", circulars); |
| 1075 | } |
| 1076 | |
| 1077 | private static boolean isValidIRI(IRI iri) { |
| 1078 | String str = iri.stringValue(); |