Skip to content

Commit d7eaa16

Browse files
authored
Merge pull request #42 from edmcouncil/28-suppressing-named-individuals
28 suppressing named individuals
2 parents f6780c1 + 8082b1f commit d7eaa16

File tree

4 files changed

+936
-865
lines changed

4 files changed

+936
-865
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.edmcouncil</groupId>
88
<artifactId>rdf-toolkit</artifactId>
9-
<version>1.14.1</version>
9+
<version>1.14.2</version>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/org/edmcouncil/rdf_toolkit/writer/SortedJsonLdWriter.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public class SortedJsonLdWriter extends SortedRdfWriter {
6666
// Turtle allows "values" in RDF collections
6767
private static final Class<Value> collectionClass = Value.class;
6868

69+
/**
70+
* RDF Types that are preferred to be used first.
71+
*/
72+
private final List<IRI> preferredRdfTypes = new ArrayList<>(PREFERRED_RDF_TYPES);
73+
6974
/**
7075
* Output stream for this JSON-LD writer.
7176
*/
@@ -147,6 +152,10 @@ public void startRDF() throws RDFHandlerException {
147152
*/
148153
@Override
149154
public void endRDF() throws RDFHandlerException {
155+
if (suppressNamedIndividuals) {
156+
preferredRdfTypes.remove(Constants.owlNamedIndividual);
157+
}
158+
150159
try {
151160
// Sort triples, etc.
152161
sortedOntologies = unsortedOntologies.toSorted(collectionClass, comparisonContext);
@@ -297,11 +306,14 @@ protected void writeSubjectTriples(Writer out, Resource subject) throws Exceptio
297306
List<Value> valuesList = new ArrayList<>();
298307
if (!values.isEmpty()) {
299308
if (predicate == Constants.RDF_TYPE) {
300-
for (IRI preferredType : PREFERRED_RDF_TYPES) {
309+
for (IRI preferredType : preferredRdfTypes) {
301310
if (values.contains(preferredType)) {
302311
valuesList.add(preferredType);
303312
values.remove(preferredType);
304313
}
314+
if (suppressNamedIndividuals) {
315+
values.remove(Constants.owlNamedIndividual);
316+
}
305317
}
306318
}
307319

0 commit comments

Comments
 (0)