use of org.openrdf.sail.memory.MemoryStore in project frames by tinkerpop.
the class SailFramesTest method setUp.
@Before
public void setUp() throws Exception {
sail = new MemoryStore();
sailGraph = new SailGraph(sail);
}
use of org.openrdf.sail.memory.MemoryStore 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;
}
}
use of org.openrdf.sail.memory.MemoryStore in project stanbol by apache.
the class RdfIndexingSource method loadRepositoryConfig.
/**
* @param repoConfigFile
* @return
*/
private RepositoryConfig loadRepositoryConfig(File repoConfigFile) {
Repository configRepo = new SailRepository(new MemoryStore());
RepositoryConnection con = null;
try {
configRepo.initialize();
con = configRepo.getConnection();
//We need to load the configuration into a context
org.openrdf.model.URI configContext = con.getValueFactory().createURI("urn:stanbol.entityhub:indexing.source.sesame:config.context");
RDFFormat format = Rio.getParserFormatForFileName(repoConfigFile.getName());
try {
con.add(new InputStreamReader(new FileInputStream(repoConfigFile), Charset.forName("UTF-8")), baseUri, format, configContext);
} catch (RDFParseException e) {
throw new IllegalArgumentException("Unable to parsed '" + repoConfigFile + "' using RDF format '" + format + "'!", e);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to access '" + repoConfigFile + "'!", e);
}
con.commit();
} catch (RepositoryException e) {
throw new IllegalStateException("Unable to load '" + repoConfigFile + "' to inmemory Sail!", e);
} finally {
if (con != null) {
try {
con.close();
} catch (RepositoryException e) {
/* ignore */
}
}
}
Set<String> repoNames;
RepositoryConfig repoConfig;
try {
repoNames = RepositoryConfigUtil.getRepositoryIDs(configRepo);
if (repoNames.size() == 1) {
repoConfig = RepositoryConfigUtil.getRepositoryConfig(configRepo, repoNames.iterator().next());
repoConfig.validate();
} else if (repoNames.size() > 1) {
throw new IllegalArgumentException("Repository configuration file '" + repoConfigFile + "' MUST only contain a single repository configuration!");
} else {
throw new IllegalArgumentException("Repository configuration file '" + repoConfigFile + "' DOES NOT contain a repository configuration!");
}
} catch (RepositoryException e) {
throw new IllegalStateException("Unable to read RepositoryConfiguration form the " + "in-memory Sail!", e);
} catch (RepositoryConfigException e) {
throw new IllegalArgumentException("Repository Configuration in '" + repoConfigFile + "is not valid!", e);
} finally {
try {
configRepo.shutDown();
} catch (RepositoryException e) {
/* ignore */
}
}
if (repoConfig.getRepositoryImplConfig() == null) {
throw new IllegalArgumentException("Missing RepositoryImpl config for " + "config " + repoConfig.getID() + " of file " + repoConfigFile + "!");
}
return repoConfig;
}
use of org.openrdf.sail.memory.MemoryStore in project stanbol by apache.
the class SesameYardTest method initYard.
@BeforeClass
public static final void initYard() throws RepositoryException {
SesameYardConfig config = new SesameYardConfig("testYardId");
config.setName("Sesame Yard Test");
config.setDescription("The Sesame Yard instance used to execute the Unit Tests defined for the Yard Interface");
repo = new SailRepository(new MemoryStore());
repo.initialize();
yard = new SesameYard(repo, config);
}
use of org.openrdf.sail.memory.MemoryStore in project gocd by gocd.
the class InMemoryRepositoryFactory method emptyRepository.
public static Repository emptyRepository() {
try {
Repository repo = new SailRepository(new MemoryStore());
repo.initialize();
return repo;
} catch (RepositoryException ex) {
throw new ShineRuntimeException(ex);
}
}
Aggregations