use of org.openrdf.repository.sail.SailRepository in project blueprints by tinkerpop.
the class PropertyGraphSailTest method testRDFDump.
@Test
public void testRDFDump() throws Exception {
Repository repo = new SailRepository(sail);
RepositoryConnection rc = repo.getConnection();
try {
RDFWriter w = Rio.createWriter(RDFFormat.TURTLE, System.out);
rc.export(w);
} finally {
rc.close();
}
}
use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.
the class Database method setRepository.
public synchronized void setRepository(Repository repo) {
// break encapsulation to simplify data upload integration
_repository = repo;
// all repos should be sail repos, but our Java master must be served
try {
SailRepository sr = (SailRepository) repo;
_sail = sr.getSail();
} catch (ClassCastException e) {
// pass
}
}
use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.
the class BackstageModule method createRepository.
public Repository createRepository(HttpServletRequest request, String repoType, String slug) throws Exception {
ExtendedProperties properties = getProperties();
String dbDir = properties.getString("backstage.databaseDir", "databases");
SailRepository repository = null;
File thisDbDir = new File(new File(dbDir, repoType), slug);
if (repoType.equals(REPOTYPE_MEM)) {
DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createMemoryRepository(thisDbDir);
repository = (SailRepository) rs.repository;
rs = null;
} else if (repoType.equals(REPOTYPE_DISK)) {
DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createNativeRepository(thisDbDir);
repository = (SailRepository) rs.repository;
rs = null;
} else {
return null;
}
String lang = DataLoadingUtilities.contentTypeToLang(request.getContentType());
if (lang == null) {
throw new Exception("Unsupported content type");
}
DataLoadingUtilities.loadDataFromStream((InputStream) request.getInputStream(), request.getRequestURL().toString(), lang, repository.getSail());
return repository;
}
use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.
the class DataLoadingUtilities method createNativeRepository.
public static RepoSailTuple createNativeRepository(File dir) {
try {
Sail sail = new NativeStore();
sail.setDataDir(dir);
((NativeStore) sail).setTripleIndexes("spoc,posc,opsc");
Repository r = new SailRepository(sail);
r.initialize();
return new RepoSailTuple(r, sail);
} catch (Exception e) {
_logger.error("Exception caught while creating Sesame native repository", e);
return null;
}
}
use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.
the class DataLoadingUtilities method createMemoryRepository.
public static RepoSailTuple createMemoryRepository(File dir) {
try {
Repository r = null;
Sail s = null;
if (dir != null) {
s = new MemoryStore(dir);
r = new SailRepository(s);
} else {
s = new MemoryStore();
r = new SailRepository(new MemoryStore());
}
r.initialize();
return new RepoSailTuple(r, s);
} catch (Exception e) {
_logger.error("Exception caught while creating Sesame in-memory repository", e);
return null;
}
}
Aggregations