use of org.sirix.api.Database in project sirix by sirixdb.
the class TestHelper method getDatabase.
/**
* Getting a database and create one of not existing. This includes the creation of a resource
* with the settings in the builder as standard.
*
* @param file to be created
* @return a database-obj
*/
@Ignore
public static final Database getDatabase(final Path file) {
if (INSTANCES.containsKey(file)) {
return INSTANCES.get(file);
} else {
try {
final DatabaseConfiguration config = new DatabaseConfiguration(file);
if (!Files.exists(file)) {
Databases.createDatabase(config);
}
final Database database = Databases.openDatabase(file);
database.createResource(new ResourceConfiguration.Builder(RESOURCE, config).build());
INSTANCES.put(file, database);
return database;
} catch (final SirixRuntimeException e) {
fail(e.toString());
return null;
}
}
}
use of org.sirix.api.Database in project sirix by sirixdb.
the class TestHelper method closeEverything.
/**
* Closing all resources as defined in the enum {@link PATHS}.
*
* @throws SirixException
*/
@Ignore
public static final void closeEverything() throws SirixException {
if (INSTANCES.containsKey(PATHS.PATH1.getFile())) {
final Database database = INSTANCES.remove(PATHS.PATH1.getFile());
database.close();
}
if (INSTANCES.containsKey(PATHS.PATH2.getFile())) {
final Database database = INSTANCES.remove(PATHS.PATH2.getFile());
database.close();
}
}
use of org.sirix.api.Database in project sirix by sirixdb.
the class HashTest method createWtx.
private XdmNodeWriteTrx createWtx(final HashKind kind) throws SirixException {
final Database database = TestHelper.getDatabase(TestHelper.PATHS.PATH1.getFile());
database.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, PATHS.PATH1.getConfig()).build());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeWriteTrx wTrx = manager.beginNodeWriteTrx();
return wTrx;
}
use of org.sirix.api.Database in project sirix by sirixdb.
the class Holder method generateDeweyIDResourceMgr.
/**
* Generate a resource with deweyIDs for resources and open a resource.
*
* @return this holder instance
* @throws SirixException if an error occurs
*/
public static Holder generateDeweyIDResourceMgr() throws SirixException {
final Path file = PATHS.PATH1.getFile();
final DatabaseConfiguration config = new DatabaseConfiguration(file);
if (!Files.exists(file)) {
Databases.createDatabase(config);
}
final Database database = Databases.openDatabase(PATHS.PATH1.getFile());
database.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, PATHS.PATH1.getConfig()).useDeweyIDs(true).build());
final ResourceManager resourceManager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final Holder holder = new Holder();
holder.setDatabase(database);
holder.setResourceManager(resourceManager);
return holder;
}
use of org.sirix.api.Database in project sirix by sirixdb.
the class Holder method generatePathSummary.
/**
* Generate a resource with a path summary.
*
* @return this holder instance
* @throws SirixException if an error occurs
*/
public static Holder generatePathSummary() throws SirixException {
final Path file = PATHS.PATH1.getFile();
final DatabaseConfiguration config = new DatabaseConfiguration(file);
if (!Files.exists(file)) {
Databases.createDatabase(config);
}
final Database database = Databases.openDatabase(PATHS.PATH1.getFile());
database.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, PATHS.PATH1.getConfig()).buildPathSummary(true).build());
final ResourceManager resourceManager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final Holder holder = new Holder();
holder.setDatabase(database);
holder.setResourceManager(resourceManager);
return holder;
}
Aggregations