I made the change below, and now I notice that the setNsPrefix() method doesn't
seem to work. More specifically, when I later retrieve the stored model,
getNsPrefix("") returns null.
-----Original Message-----
From: Andy Seaborne [mailto:[email protected]]
Sent: Thursday, January 16, 2014 1:16 PM
To: [email protected]
Subject: Re: Another Problem: can't set default graph
On 16/01/14 17:55, Ed Swing wrote:
> Onto another problem...
>
> File dir = new File(baseDir + "/" + projName);
> if (!dir.exists()) {
> dir.mkdirs();s
> Dataset dataset =
> TDBFactory.createDataset(baseDir + "/" + projName);
The dataset now exists.
> dataset.begin(ReadWrite.WRITE);
> OntModel project =
> ModelFactory
> .createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
> model.setNsPrefix("", SemanticStoreService.BASE_URI + projName
> + "/");
> dataset.setDefaultModel(project);
Same issue - a dataset in TDB is not something you flip graphs on - they have
to be copied in and out because they are bytes on disk (+caching).
The default graph is already there. You need to add to it.
dataset.getDefaultModel().add(project);
>
> throws the following exception:
> Exception in thread "main" java.lang.UnsupportedOperationException: Can't set
> default graph via GraphStore on a TDB-backed dataset
> at
> com.hp.hpl.jena.tdb.store.DatasetGraphTDB.setDefaultGraph(DatasetGraphTDB.java:314)
> at
> com.hp.hpl.jena.sparql.core.DatasetGraphTrackActive.setDefaultGraph(DatasetGraphTrackActive.java:115)
> at
> com.hp.hpl.jena.sparql.core.DatasetImpl.setDefaultModel(DatasetImpl.java:215)
> at
> com.sas.store.service.SemanticStoreService.createProject(SemanticStore
> Service.java:203)
>
> I'm not sure what's going on here. How would you set the default graph of a
> newly created dataset? Note that this code is for the case when the dataset
> does not exist yet.
>
> On a side note, it might be nice to add a method for
> TDBFactory.createDataset(File dir)...
Fore now, you can use:
TDBFactory.createDataset(dir.getAbsolutePath()) ;
>
>
> Edward Swing
> Applied Research Technologist
> Vision Systems + Technology, Inc., a SAS Company
> 6021 University Boulevard * Suite 360 * Ellicott City * Maryland *
> 21043
> Tel: 410.418.5555 Ext: 919 * Fax: 410.418.8580
> Email: [email protected]<mailto:[email protected]>
> Web: http://www.vsticorp.com<http://www.vsticorp.com/>
>
>