Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jan 31, 2024
1 parent f55b0d4 commit 8ef2367
Show file tree
Hide file tree
Showing 22 changed files with 282 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.eclipse.rdf4j.model.vocabulary.SPIN;
import org.eclipse.rdf4j.rio.helpers.BasicParserSettings;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.JSONLDMode;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.BufferedGroupingRDFHandler;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.jsonld.legacy.JSONLDSettings;
import org.eclipse.rdf4j.rio.jsonld.legacy.JSONLDWriter;

public class NDJSONLDWriter extends AbstractRDFWriter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
* Copyright (c) 2022 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
Expand All @@ -8,16 +8,16 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.rio.helpers;
package org.eclipse.rdf4j.rio.jsonld.legacy;

/**
* Specifies constants to identify various modes that are relevant to JSONLD documents.
*
* @author Peter Ansell
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#features">JSONLD Features</a>
*
* @since 4.3.0
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public enum JSONLDMode {

EXPAND("Expansion", "http://json-ld.org/spec/latest/json-ld-api/index.html#expansion"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.RioSetting;
import org.eclipse.rdf4j.rio.helpers.AbstractRDFParser;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.helpers.JSONSettings;

import com.fasterxml.jackson.core.JsonFactory;
Expand Down Expand Up @@ -125,7 +124,17 @@ valueFactory, getParserConfig(), getParseErrorListener(), nodeID -> createNode(n
final JsonLdOptions options = baseURI != null ? new JsonLdOptions(baseURI) : new JsonLdOptions();
options.useNamespaces = true;

DocumentLoader loader = getParserConfig().get(JSONLDSettings.DOCUMENT_LOADER);
Object o = getParserConfig().get(JSONLDSettings.DOCUMENT_LOADER);
DocumentLoader loader;
if (o instanceof DocumentLoader) {
loader = ((DocumentLoader) o);
} else if (o == null) {
loader = null;
} else {
throw new RDFParseException("Document loader is wrong class. Expected " + DocumentLoader.class.getName()
+ ", got " + o.getClass().getName() + ".");
}

if (loader != null) {
options.setDocumentLoader(loader);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Eclipse RDF4J contributors, Aduna, and others.
* Copyright (c) 2022 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
Expand All @@ -8,9 +8,12 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.rio.helpers;
package org.eclipse.rdf4j.rio.jsonld.legacy;

import org.eclipse.rdf4j.rio.RioSetting;
import org.eclipse.rdf4j.rio.helpers.BooleanRioSetting;
import org.eclipse.rdf4j.rio.helpers.ClassRioSetting;
import org.eclipse.rdf4j.rio.helpers.RioSettingImpl;

import com.github.jsonldjava.core.DocumentLoader;

Expand All @@ -19,6 +22,8 @@
*
* @author Peter Ansell
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
* @since 4.3.0
*/
public class JSONLDSettings {

Expand All @@ -31,18 +36,14 @@ public class JSONLDSettings {
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.compact_arrays}.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> COMPACT_ARRAYS = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.compact_arrays", "Compact arrays", Boolean.TRUE);

/**
* If specified, it is used to retrieve remote documents and contexts; otherwise the processor's built-in loader is
* used.
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<DocumentLoader> DOCUMENT_LOADER = new ClassRioSetting<>(
"org.eclipse.rdf4j.rio.jsonld.document_loader", "Document loader", null);

Expand All @@ -56,9 +57,7 @@ public class JSONLDSettings {
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.optimize}.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> OPTIMIZE = new BooleanRioSetting("org.eclipse.rdf4j.rio.jsonld.optimize",
"Optimize output", Boolean.FALSE);

Expand All @@ -73,9 +72,7 @@ public class JSONLDSettings {
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.produce_generalized_rdf}.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> PRODUCE_GENERALIZED_RDF = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.produce_generalized_rdf", "Produce generalized RDF", Boolean.FALSE);

Expand All @@ -89,9 +86,7 @@ public class JSONLDSettings {
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.use_native_types}.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> USE_NATIVE_TYPES = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.use_native_types", "Use Native JSON Types", Boolean.FALSE);

Expand All @@ -104,9 +99,7 @@ public class JSONLDSettings {
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.use_rdf_type}.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> USE_RDF_TYPE = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.use_rdf_type", "Use RDF Type", Boolean.FALSE);

Expand All @@ -116,9 +109,7 @@ public class JSONLDSettings {
* Defaults to {@link JSONLDMode#EXPAND} to provide maximum RDF compatibility.
*
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#features">JSONLD Features</a>
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<JSONLDMode> JSONLD_MODE = new RioSettingImpl<>(
"org.eclipse.rdf4j.rio.jsonld_mode", "JSONLD Mode", JSONLDMode.EXPAND);

Expand All @@ -128,9 +119,7 @@ public class JSONLDSettings {
* Default to false
* <p>
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.hierarchical_view}.
*
*/
@Deprecated(since = "4.3.0", forRemoval = true)
public static final RioSetting<Boolean> HIERARCHICAL_VIEW = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.hierarchical_view", "Hierarchical representation of the JSON", Boolean.FALSE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.eclipse.rdf4j.rio.WriterConfig;
import org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.JSONLDMode;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;

import com.github.jsonldjava.core.JsonLdConsts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.eclipse.rdf4j.rio.WriterConfig;
import org.eclipse.rdf4j.rio.helpers.BasicParserSettings;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.JSONLDMode;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.jsonld.legacy.JSONLDMode;
import org.eclipse.rdf4j.rio.jsonld.legacy.JSONLDSettings;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.rdf4j.rio.RDFWriter;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.rio.WriterConfig;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.rio.helpers.ContextStatementCollector;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.helpers.JSONSettings;
import org.eclipse.rdf4j.rio.helpers.ParseErrorCollector;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.eclipse.rdf4j.rio.WriterConfig;
import org.eclipse.rdf4j.rio.helpers.BasicParserSettings;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.JSONLDMode;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.eclipse.rdf4j.rio.WriterConfig;
import org.eclipse.rdf4j.rio.helpers.BasicParserSettings;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
import org.eclipse.rdf4j.rio.helpers.JSONLDMode;
import org.eclipse.rdf4j.rio.helpers.JSONLDSettings;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
///*******************************************************************************
// * Copyright (c) 2022 Eclipse RDF4J contributors.
// *
// * All rights reserved. This program and the accompanying materials
// * are made available under the terms of the Eclipse Distribution License v1.0
// * which accompanies this distribution, and is available at
// * http://www.eclipse.org/org/documents/edl-v10.php.
// *
// * SPDX-License-Identifier: BSD-3-Clause
// *******************************************************************************/
//package org.eclipse.rdf4j.rio.jsonld;
//
///**
// * Specifies constants to identify various modes that are relevant to JSONLD documents.
// *
// * @author Peter Ansell
// * @see <a href="http://json-ld.org/spec/latest/json-ld-api/#features">JSONLD Features</a>
// *
// * @since 4.3.0
// */
//public enum JSONLDMode {
//
// EXPAND("Expansion", "http://json-ld.org/spec/latest/json-ld-api/index.html#expansion"),
//
// COMPACT("Compaction", "http://json-ld.org/spec/latest/json-ld-api/index.html#compaction"),
//
// FLATTEN("Flattening", "http://json-ld.org/spec/latest/json-ld-api/index.html#flattening"),
//
// ;
//
// private final String label;
//
// private final String reference;
//
// JSONLDMode(String label, String reference) {
// this.label = label;
// this.reference = reference;
// }
//
// /**
// * @return Returns the label.
// */
// public String getLabel() {
// return label;
// }
//
// /**
// * @return Returns the reference URL for the given mode.
// */
// public String getReference() {
// return reference;
// }
//}
/*******************************************************************************
* Copyright (c) 2022 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.rio.jsonld;

/**
* Specifies constants to identify various modes that are relevant to JSONLD documents.
*
* @author Peter Ansell
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#features">JSONLD Features</a>
*
* @since 4.3.0
*/
public enum JSONLDMode {

EXPAND("Expansion", "http://json-ld.org/spec/latest/json-ld-api/index.html#expansion"),

COMPACT("Compaction", "http://json-ld.org/spec/latest/json-ld-api/index.html#compaction"),

FLATTEN("Flattening", "http://json-ld.org/spec/latest/json-ld-api/index.html#flattening"),

;

private final String label;

private final String reference;

JSONLDMode(String label, String reference) {
this.label = label;
this.reference = reference;
}

/**
* @return Returns the label.
*/
public String getLabel() {
return label;
}

/**
* @return Returns the reference URL for the given mode.
*/
public String getReference() {
return reference;
}
}
Loading

0 comments on commit 8ef2367

Please sign in to comment.