Skip to content

Commit

Permalink
Merge pull request #42 from edmcouncil/28-suppressing-named-individuals
Browse files Browse the repository at this point in the history
28 suppressing named individuals
  • Loading branch information
mereolog authored Jan 27, 2023
2 parents f6780c1 + 8082b1f commit d7eaa16
Show file tree
Hide file tree
Showing 4 changed files with 936 additions and 865 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.edmcouncil</groupId>
<artifactId>rdf-toolkit</artifactId>
<version>1.14.1</version>
<version>1.14.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public class SortedJsonLdWriter extends SortedRdfWriter {
// Turtle allows "values" in RDF collections
private static final Class<Value> collectionClass = Value.class;

/**
* RDF Types that are preferred to be used first.
*/
private final List<IRI> preferredRdfTypes = new ArrayList<>(PREFERRED_RDF_TYPES);

/**
* Output stream for this JSON-LD writer.
*/
Expand Down Expand Up @@ -147,6 +152,10 @@ public void startRDF() throws RDFHandlerException {
*/
@Override
public void endRDF() throws RDFHandlerException {
if (suppressNamedIndividuals) {
preferredRdfTypes.remove(Constants.owlNamedIndividual);
}

try {
// Sort triples, etc.
sortedOntologies = unsortedOntologies.toSorted(collectionClass, comparisonContext);
Expand Down Expand Up @@ -297,11 +306,14 @@ protected void writeSubjectTriples(Writer out, Resource subject) throws Exceptio
List<Value> valuesList = new ArrayList<>();
if (!values.isEmpty()) {
if (predicate == Constants.RDF_TYPE) {
for (IRI preferredType : PREFERRED_RDF_TYPES) {
for (IRI preferredType : preferredRdfTypes) {
if (values.contains(preferredType)) {
valuesList.add(preferredType);
values.remove(preferredType);
}
if (suppressNamedIndividuals) {
values.remove(Constants.owlNamedIndividual);
}
}
}

Expand Down
Loading

0 comments on commit d7eaa16

Please sign in to comment.