Skip to content

Commit

Permalink
GH-3654 reverted removal of generalized rdf
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Mar 20, 2024
1 parent c9f6b06 commit 27ce7d6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import static org.eclipse.rdf4j.model.util.Values.literal;
import static org.eclipse.rdf4j.repository.config.RepositoryConfigSchema.REPOSITORYTYPE;

import java.util.Arrays;
import java.util.Set;

import org.eclipse.rdf4j.model.BNode;
import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Model;
Expand Down Expand Up @@ -112,7 +115,8 @@ public static RepositoryImplConfig create(Model model, Resource resource) throws
RepositoryFactory factory = RepositoryRegistry.getInstance()
.get(typeLit.getLabel())
.orElseThrow(() -> new RepositoryConfigException(
"Unsupported repository type: " + typeLit.getLabel()));
"Unsupported repository type: '" + typeLit.getLabel() + "' supported types are: "
+ Arrays.toString(RepositoryRegistry.getInstance().getKeys().toArray())));

RepositoryImplConfig implConfig = factory.getConfig();
implConfig.parse(model, resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ public class JSONLDSettings {
public static final RioSetting<Boolean> HIERARCHICAL_VIEW = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.hierarchical_view", "Hierarchical representation of the JSON", Boolean.FALSE);

/**
* If set to true, the JSON-LD processor may emit blank nodes for triple predicates, otherwise they will be omitted.
* <p>
* Note: the use of blank node identifiers to label properties is obsolete, and may be removed in a future version
* of JSON-LD,
* <p>
* Defaults to false.
* <p>
* 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>
*/
public static final RioSetting<Boolean> PRODUCE_GENERALIZED_RDF = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.jsonld.produce_generalized_rdf", "Produce generalized RDF", Boolean.FALSE);

/**
* Private default constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void endRDF() throws RDFHandlerException {
opts.setCompactArrays(writerConfig.get(JSONLDSettings.COMPACT_ARRAYS));
opts.setUseRdfType(writerConfig.get(JSONLDSettings.USE_RDF_TYPE));
opts.setUseNativeTypes(writerConfig.get(JSONLDSettings.USE_NATIVE_TYPES));
opts.setProduceGeneralizedRdf(writerConfig.get(JSONLDSettings.PRODUCE_GENERALIZED_RDF));
opts.setUriValidation(false);
opts.setExceptionOnWarning(writerConfig.get(JSONLDSettings.EXCEPTION_ON_WARNING));

Expand Down Expand Up @@ -393,6 +394,7 @@ public Collection<RioSetting<?>> getSupportedSettings() {
result.add(JSONLDSettings.JSONLD_MODE);
result.add(JSONLDSettings.USE_RDF_TYPE);
result.add(JSONLDSettings.USE_NATIVE_TYPES);
result.add(JSONLDSettings.PRODUCE_GENERALIZED_RDF);
result.add(JSONLDSettings.EXCEPTION_ON_WARNING);

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
Expand Down Expand Up @@ -126,14 +127,6 @@ public RDFFormat getRDFFormat() {

@Override
public Collection<RioSetting<?>> getSupportedSettings() {
Collection<RioSetting<?>> result = new HashSet<>(Arrays.asList(
BasicWriterSettings.BASE_DIRECTIVE,
JSONLDSettings.COMPACT_ARRAYS,
JSONLDSettings.HIERARCHICAL_VIEW,
JSONLDSettings.JSONLD_MODE,
JSONLDSettings.USE_RDF_TYPE,
JSONLDSettings.USE_NATIVE_TYPES
));
return result;
return new JSONLDWriter(new StringWriter()).getSupportedSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ protected RioSetting<?>[] getExpectedSupportedSettings() {
BasicWriterSettings.PRETTY_PRINT,
JSONLDSettings.COMPACT_ARRAYS,
JSONLDSettings.JSONLD_MODE,
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
JSONLDSettings.USE_RDF_TYPE,
JSONLDSettings.USE_NATIVE_TYPES,
JSONLDSettings.EXCEPTION_ON_WARNING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ protected RioSetting<?>[] getExpectedSupportedSettings() {
BasicWriterSettings.PRETTY_PRINT,
JSONLDSettings.COMPACT_ARRAYS,
JSONLDSettings.JSONLD_MODE,
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
JSONLDSettings.USE_RDF_TYPE,
JSONLDSettings.USE_NATIVE_TYPES,
JSONLDSettings.EXCEPTION_ON_WARNING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ protected void setupParserConfig(ParserConfig config) {
protected RioSetting<?>[] getExpectedSupportedSettings() {
return new RioSetting[] {
BasicWriterSettings.BASE_DIRECTIVE,
BasicWriterSettings.PRETTY_PRINT,
JSONLDSettings.COMPACT_ARRAYS,
JSONLDSettings.HIERARCHICAL_VIEW,
JSONLDSettings.JSONLD_MODE,
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
JSONLDSettings.USE_RDF_TYPE,
JSONLDSettings.USE_NATIVE_TYPES
JSONLDSettings.USE_NATIVE_TYPES,
JSONLDSettings.EXCEPTION_ON_WARNING
};
}
}

0 comments on commit 27ce7d6

Please sign in to comment.