Hi All, It is a difficult issue, and has been discussed in a few places in relation to SPARQL, but not really in relation to the Statement or Repository/Sail APIs:
http://www.openrdf.org/issues/browse/SES-848 http://www.openrdf.org/issues/browse/SES-850 https://openrdf.atlassian.net/browse/SES-850 >From experience on the sesame mailing list, it seems that most users have found it fairly simple to either use "null" for all statements, or avoid using the default context for any statements. I don't use the null context in my permanent repository instances for my projects. There are some users who specifically use the default context as a management graph referencing the other named graphs, but personally I prefer to use well-known URI graph names for that purpose as it is clearer what is happening in SPARQL queries and when using the Repository API. Cheers, Peter On 8 January 2014 05:45, Sebastian Schaffert <[email protected]> wrote: > Forward to mailing list for everyone to follow :-) > Am 07.01.2014 19:43 schrieb "Sebastian Schaffert" <[email protected]>: > >> The change is necessary because some Sesame functionality depends on the >> default context being null. In this case it was a contextual SPARQL update >> which went wrong because of the default not being null. >> >> The triple store supported the null context already for quite some time >> because otherwise the Sesame test suite would not work. The current change >> only affects the platform, which in my tests worked just fine (only thing >> is the default context no longer appears in the context manager). >> >> To keep backwards compatibility the default context is now configurable - >> when contexts.default is empty null is used, the default is the old URI >> value. >> >> In the long run we should either use the Sesame way or Sesame needs some >> extensions to support configurable defaults. Other backends than KiWi don't >> support this anyways. >> >> Greetings >> >> Sebastian >> Am 07.01.2014 18:09 schrieb "Sergio Fernández" < >> [email protected]>: >> >>> should we discuss this change? >>> >>> On Jan 7, 2014 5:23 PM, [email protected] wrote: >>> > >>> > Updated Branches: >>> > refs/heads/develop 38620a9e4 -> 030a0a1df >>> > >>> > >>> > switched to "null" as default context (as Sesame does) >>> > >>> > >>> > Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo >>> > Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/030a0a1d >>> > Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/030a0a1d >>> > Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/030a0a1d >>> > >>> > Branch: refs/heads/develop >>> > Commit: 030a0a1df27fa22423c4dad643430269154e9ec2 >>> > Parents: 38620a9 >>> > Author: Sebastian Schaffert <[email protected]> >>> > Authored: Tue Jan 7 17:23:34 2014 +0100 >>> > Committer: Sebastian Schaffert <[email protected]> >>> > Committed: Tue Jan 7 17:23:34 2014 +0100 >>> > >>> > ---------------------------------------------------------------------- >>> > .../kiwi/sparql/test/KiWiSparqlJoinTest.java | 12 ++++++++ >>> > .../config/ConfigurationServiceImpl.java | 10 ++----- >>> > .../triplestore/ContextServiceImpl.java | 30 >>> +++++++++++--------- >>> > 3 files changed, 31 insertions(+), 21 deletions(-) >>> > ---------------------------------------------------------------------- >>> > >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/marmotta/blob/030a0a1d/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java >>> > ---------------------------------------------------------------------- >>> > diff --git >>> a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java >>> b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java >>> > index 63f452e..b5a2028 100644 >>> > --- >>> a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java >>> > +++ >>> b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java >>> > @@ -37,7 +37,9 @@ import org.junit.runner.Description; >>> > import org.junit.runner.RunWith; >>> > import org.openrdf.model.Statement; >>> > import org.openrdf.model.URI; >>> > +import org.openrdf.model.impl.URIImpl; >>> > import org.openrdf.query.*; >>> > +import org.openrdf.query.impl.DatasetImpl; >>> > import org.openrdf.repository.Repository; >>> > import org.openrdf.repository.RepositoryConnection; >>> > import org.openrdf.repository.RepositoryException; >>> > @@ -381,6 +383,16 @@ public class KiWiSparqlJoinTest { >>> > con1.begin(); >>> > >>> > Update query1 = con1.prepareUpdate(QueryLanguage.SPARQL, >>> queryString); >>> > + // workaround for a Sesame bug: we explicitly set the >>> context for the query in the dataset >>> > + >>> > + URI context = new URIImpl("http://localhost/mycontext"); >>> > + DatasetImpl ds = new DatasetImpl(); >>> > + //ds.addDefaultGraph(context); >>> > + //ds.addNamedGraph(context); >>> > + //ds.addDefaultRemoveGraph(context); >>> > + ds.setDefaultInsertGraph(context); >>> > + query1.setDataset(ds); >>> > + >>> > query1.execute(); >>> > >>> > con1.commit(); >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/marmotta/blob/030a0a1d/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java >>> > ---------------------------------------------------------------------- >>> > diff --git >>> a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java >>> b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java >>> > index 752fe74..df13c5e 100644 >>> > --- >>> a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java >>> > +++ >>> b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java >>> > @@ -19,12 +19,7 @@ package >>> org.apache.marmotta.platform.core.services.config; >>> > >>> > import com.google.common.base.Preconditions; >>> > import com.google.common.collect.Lists; >>> > -import org.apache.commons.configuration.AbstractConfiguration; >>> > -import org.apache.commons.configuration.CompositeConfiguration; >>> > -import org.apache.commons.configuration.Configuration; >>> > -import org.apache.commons.configuration.ConfigurationException; >>> > -import org.apache.commons.configuration.MapConfiguration; >>> > -import org.apache.commons.configuration.PropertiesConfiguration; >>> > +import org.apache.commons.configuration.*; >>> > import org.apache.commons.lang3.ObjectUtils; >>> > import org.apache.commons.lang3.StringUtils; >>> > import >>> org.apache.marmotta.platform.core.api.config.ConfigurationService; >>> > @@ -1260,7 +1255,8 @@ public class ConfigurationServiceImpl implements >>> ConfigurationService { >>> > */ >>> > @Override >>> > public String getDefaultContext() { >>> > - return getBaseUri() + CONTEXT_PATH + "/" + CONTEXT_DEFAULT; >>> > + //return getBaseUri() + CONTEXT_PATH + "/" + CONTEXT_DEFAULT; >>> > + return null; >>> > } >>> > >>> > /** >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/marmotta/blob/030a0a1d/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java >>> > ---------------------------------------------------------------------- >>> > diff --git >>> a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java >>> b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java >>> > index 63c958e..b49c556 100644 >>> > --- >>> a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java >>> > +++ >>> b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java >>> > @@ -17,20 +17,6 @@ >>> > */ >>> > package org.apache.marmotta.platform.core.services.triplestore; >>> > >>> > -import static >>> org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException; >>> > - >>> > -import java.io.InputStream; >>> > -import java.net.URISyntaxException; >>> > -import java.util.ArrayList; >>> > -import java.util.List; >>> > -import java.util.Set; >>> > - >>> > -import javax.enterprise.context.ApplicationScoped; >>> > -import javax.enterprise.context.RequestScoped; >>> > -import javax.enterprise.inject.Produces; >>> > -import javax.inject.Inject; >>> > -import javax.inject.Named; >>> > - >>> > import org.apache.commons.lang3.StringUtils; >>> > import org.apache.marmotta.commons.http.UriUtil; >>> > import org.apache.marmotta.commons.sesame.repository.ResourceUtils; >>> > @@ -54,6 +40,19 @@ import org.openrdf.repository.RepositoryException; >>> > import org.openrdf.repository.RepositoryResult; >>> > import org.slf4j.Logger; >>> > >>> > +import javax.enterprise.context.ApplicationScoped; >>> > +import javax.enterprise.context.RequestScoped; >>> > +import javax.enterprise.inject.Produces; >>> > +import javax.inject.Inject; >>> > +import javax.inject.Named; >>> > +import java.io.InputStream; >>> > +import java.net.URISyntaxException; >>> > +import java.util.ArrayList; >>> > +import java.util.List; >>> > +import java.util.Set; >>> > + >>> > +import static >>> org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException; >>> > + >>> > /** >>> > * The context (named graphs in Apache Marmotta, formerly "knowledge >>> space" in KiWi) service offers convenience >>> > * functions for working with Apache Marmotta Contexts. Low level >>> manipulation of contexts is offered by >>> > @@ -177,6 +176,9 @@ public class ContextServiceImpl implements >>> ContextService { >>> > >>> > @Override >>> > public URI createContext(String uri, String label) throws >>> URISyntaxException { >>> > + if(uri == null) { >>> > + return null; >>> > + } >>> > if (!UriUtil.validate(uri)) { >>> > uri = configurationService.getBaseContext() + uri; >>> > if (!UriUtil.validate(uri)) { >>> > >>> >>
