Skip to content

Commit 27ce7d6

Browse files
committed
GH-3654 reverted removal of generalized rdf
1 parent c9f6b06 commit 27ce7d6

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

core/repository/api/src/main/java/org/eclipse/rdf4j/repository/config/AbstractRepositoryImplConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import static org.eclipse.rdf4j.model.util.Values.literal;
1515
import static org.eclipse.rdf4j.repository.config.RepositoryConfigSchema.REPOSITORYTYPE;
1616

17+
import java.util.Arrays;
18+
import java.util.Set;
19+
1720
import org.eclipse.rdf4j.model.BNode;
1821
import org.eclipse.rdf4j.model.Literal;
1922
import org.eclipse.rdf4j.model.Model;
@@ -112,7 +115,8 @@ public static RepositoryImplConfig create(Model model, Resource resource) throws
112115
RepositoryFactory factory = RepositoryRegistry.getInstance()
113116
.get(typeLit.getLabel())
114117
.orElseThrow(() -> new RepositoryConfigException(
115-
"Unsupported repository type: " + typeLit.getLabel()));
118+
"Unsupported repository type: '" + typeLit.getLabel() + "' supported types are: "
119+
+ Arrays.toString(RepositoryRegistry.getInstance().getKeys().toArray())));
116120

117121
RepositoryImplConfig implConfig = factory.getConfig();
118122
implConfig.parse(model, resource);

core/rio/jsonld/src/main/java/org/eclipse/rdf4j/rio/jsonld/JSONLDSettings.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ public class JSONLDSettings {
112112
public static final RioSetting<Boolean> HIERARCHICAL_VIEW = new BooleanRioSetting(
113113
"org.eclipse.rdf4j.rio.jsonld.hierarchical_view", "Hierarchical representation of the JSON", Boolean.FALSE);
114114

115+
/**
116+
* If set to true, the JSON-LD processor may emit blank nodes for triple predicates, otherwise they will be omitted.
117+
* <p>
118+
* Note: the use of blank node identifiers to label properties is obsolete, and may be removed in a future version
119+
* of JSON-LD,
120+
* <p>
121+
* Defaults to false.
122+
* <p>
123+
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.jsonld.produce_generalized_rdf}.
124+
*
125+
* @see <a href="http://json-ld.org/spec/latest/json-ld-api/#data-structures">JSONLD Data Structures</a>
126+
*/
127+
public static final RioSetting<Boolean> PRODUCE_GENERALIZED_RDF = new BooleanRioSetting(
128+
"org.eclipse.rdf4j.rio.jsonld.produce_generalized_rdf", "Produce generalized RDF", Boolean.FALSE);
129+
115130
/**
116131
* Private default constructor.
117132
*/

core/rio/jsonld/src/main/java/org/eclipse/rdf4j/rio/jsonld/JSONLDWriter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public void endRDF() throws RDFHandlerException {
156156
opts.setCompactArrays(writerConfig.get(JSONLDSettings.COMPACT_ARRAYS));
157157
opts.setUseRdfType(writerConfig.get(JSONLDSettings.USE_RDF_TYPE));
158158
opts.setUseNativeTypes(writerConfig.get(JSONLDSettings.USE_NATIVE_TYPES));
159+
opts.setProduceGeneralizedRdf(writerConfig.get(JSONLDSettings.PRODUCE_GENERALIZED_RDF));
159160
opts.setUriValidation(false);
160161
opts.setExceptionOnWarning(writerConfig.get(JSONLDSettings.EXCEPTION_ON_WARNING));
161162

@@ -393,6 +394,7 @@ public Collection<RioSetting<?>> getSupportedSettings() {
393394
result.add(JSONLDSettings.JSONLD_MODE);
394395
result.add(JSONLDSettings.USE_RDF_TYPE);
395396
result.add(JSONLDSettings.USE_NATIVE_TYPES);
397+
result.add(JSONLDSettings.PRODUCE_GENERALIZED_RDF);
396398
result.add(JSONLDSettings.EXCEPTION_ON_WARNING);
397399

398400
return result;

core/rio/jsonld/src/main/java/org/eclipse/rdf4j/rio/ndjsonld/NDJSONLDWriter.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.IOException;
1515
import java.io.OutputStream;
1616
import java.io.OutputStreamWriter;
17+
import java.io.StringWriter;
1718
import java.io.Writer;
1819
import java.nio.charset.StandardCharsets;
1920
import java.util.Arrays;
@@ -126,14 +127,6 @@ public RDFFormat getRDFFormat() {
126127

127128
@Override
128129
public Collection<RioSetting<?>> getSupportedSettings() {
129-
Collection<RioSetting<?>> result = new HashSet<>(Arrays.asList(
130-
BasicWriterSettings.BASE_DIRECTIVE,
131-
JSONLDSettings.COMPACT_ARRAYS,
132-
JSONLDSettings.HIERARCHICAL_VIEW,
133-
JSONLDSettings.JSONLD_MODE,
134-
JSONLDSettings.USE_RDF_TYPE,
135-
JSONLDSettings.USE_NATIVE_TYPES
136-
));
137-
return result;
130+
return new JSONLDWriter(new StringWriter()).getSupportedSettings();
138131
}
139132
}

core/rio/jsonld/src/test/java/org/eclipse/rdf4j/rio/jsonld/JSONLDWriterBackgroundTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ protected RioSetting<?>[] getExpectedSupportedSettings() {
121121
BasicWriterSettings.PRETTY_PRINT,
122122
JSONLDSettings.COMPACT_ARRAYS,
123123
JSONLDSettings.JSONLD_MODE,
124+
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
124125
JSONLDSettings.USE_RDF_TYPE,
125126
JSONLDSettings.USE_NATIVE_TYPES,
126127
JSONLDSettings.EXCEPTION_ON_WARNING

core/rio/jsonld/src/test/java/org/eclipse/rdf4j/rio/jsonld/JSONLDWriterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ protected RioSetting<?>[] getExpectedSupportedSettings() {
245245
BasicWriterSettings.PRETTY_PRINT,
246246
JSONLDSettings.COMPACT_ARRAYS,
247247
JSONLDSettings.JSONLD_MODE,
248+
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
248249
JSONLDSettings.USE_RDF_TYPE,
249250
JSONLDSettings.USE_NATIVE_TYPES,
250251
JSONLDSettings.EXCEPTION_ON_WARNING

core/rio/jsonld/src/test/java/org/eclipse/rdf4j/rio/ndjsonld/NDJSONLDWriterTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ protected void setupParserConfig(ParserConfig config) {
5252
protected RioSetting<?>[] getExpectedSupportedSettings() {
5353
return new RioSetting[] {
5454
BasicWriterSettings.BASE_DIRECTIVE,
55+
BasicWriterSettings.PRETTY_PRINT,
5556
JSONLDSettings.COMPACT_ARRAYS,
56-
JSONLDSettings.HIERARCHICAL_VIEW,
5757
JSONLDSettings.JSONLD_MODE,
58+
JSONLDSettings.PRODUCE_GENERALIZED_RDF,
5859
JSONLDSettings.USE_RDF_TYPE,
59-
JSONLDSettings.USE_NATIVE_TYPES
60+
JSONLDSettings.USE_NATIVE_TYPES,
61+
JSONLDSettings.EXCEPTION_ON_WARNING
6062
};
6163
}
6264
}

0 commit comments

Comments
 (0)