Search in sources :

Example 21 with DatabaseConfiguration

use of org.sirix.access.conf.DatabaseConfiguration in project sirix by sirixdb.

the class DBStore method drop.

@Override
public void drop(final String name) throws DocumentException {
    final DatabaseConfiguration dbConfig = new DatabaseConfiguration(mLocation.resolve(name));
    if (Databases.existsDatabase(dbConfig)) {
        try {
            Databases.truncateDatabase(dbConfig);
            final Database database = Databases.openDatabase(dbConfig.getFile());
            mDatabases.remove(database);
            mCollections.remove(database);
        } catch (final SirixRuntimeException e) {
            throw new DocumentException(e);
        }
    }
    throw new DocumentException("No collection with the specified name found!");
}
Also used : SirixRuntimeException(org.sirix.exception.SirixRuntimeException) DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) DocumentException(org.brackit.xquery.xdm.DocumentException) Database(org.sirix.api.Database)

Example 22 with DatabaseConfiguration

use of org.sirix.access.conf.DatabaseConfiguration in project sirix by sirixdb.

the class BookShredding method shredder.

private static void shredder(final File pBooks) throws Exception {
    final DatabaseConfiguration config = new DatabaseConfiguration(TestHelper.PATHS.PATH1.getFile());
    Databases.truncateDatabase(config);
    Databases.createDatabase(config);
    final Database database = Databases.openDatabase(config.getFile());
    database.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, PATHS.PATH1.getConfig()).build());
    final Session session = database.getSession(new SessionConfiguration.Builder(TestHelper.RESOURCE).build());
    final NodeWriteTrx wtx = session.beginNodeWriteTrx();
    final XMLEventReader reader = XMLShredder.createFileReader(pBooks);
    final XMLShredder shredder = new XMLShredder.Builder(wtx, reader, Insert.ASFIRSTCHILD).commitAfterwards().build();
    shredder.call();
    wtx.close();
    session.close();
}
Also used : DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) Database(org.sirix.api.Database) NodeWriteTrx(org.sirix.api.NodeWriteTrx) XMLEventReader(javax.xml.stream.XMLEventReader) XMLShredder(org.sirix.service.xml.shredder.XMLShredder) Session(org.sirix.api.Session)

Example 23 with DatabaseConfiguration

use of org.sirix.access.conf.DatabaseConfiguration in project sirix by sirixdb.

the class TestNodeWrapper method generateSession.

@Ignore
public Session generateSession() throws SirixException {
    final DatabaseConfiguration dbConfig = new DatabaseConfiguration(TestHelper.PATHS.PATH2.getFile());
    Databases.truncateDatabase(dbConfig);
    Databases.createDatabase(dbConfig);
    mDatabase = Databases.openDatabase(dbConfig.getFile());
    mDatabase.createResource(new ResourceConfiguration.Builder(TestHelper.RESOURCE, dbConfig).build());
    return mDatabase.getSession(new SessionConfiguration.Builder(TestHelper.RESOURCE).build());
}
Also used : DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) Ignore(org.junit.Ignore)

Example 24 with DatabaseConfiguration

use of org.sirix.access.conf.DatabaseConfiguration in project sirix by sirixdb.

the class VersioningTest method setUp.

@Before
public void setUp() throws SirixException {
    TestHelper.deleteEverything();
    Databases.createDatabase(new DatabaseConfiguration(TestHelper.PATHS.PATH1.getFile()));
    mDatabase = Databases.openDatabase(TestHelper.PATHS.PATH1.getFile());
}
Also used : DatabaseConfiguration(org.sirix.access.conf.DatabaseConfiguration) Before(org.junit.Before)

Aggregations

DatabaseConfiguration (org.sirix.access.conf.DatabaseConfiguration)24 Database (org.sirix.api.Database)19 ResourceManager (org.sirix.api.ResourceManager)11 Path (java.nio.file.Path)10 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)7 DocumentException (org.brackit.xquery.xdm.DocumentException)5 SirixRuntimeException (org.sirix.exception.SirixRuntimeException)5 XMLEventReader (javax.xml.stream.XMLEventReader)4 SirixException (org.sirix.exception.SirixException)4 IOException (java.io.IOException)3 QName (javax.xml.namespace.QName)3 ResourceConfiguration (org.sirix.access.conf.ResourceConfiguration)3 XMLShredder (org.sirix.service.xml.shredder.XMLShredder)3 LinkedList (java.util.LinkedList)2 XMLEventFactory (javax.xml.stream.XMLEventFactory)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 StartElement (javax.xml.stream.events.StartElement)2 SubtreeListener (org.brackit.xquery.node.parser.SubtreeListener)2 AbstractTemporalNode (org.brackit.xquery.xdm.AbstractTemporalNode)2 Ignore (org.junit.Ignore)2