use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class FMSEImport method shredder.
/**
* Shredder new revision as temporal resource.
*
* @param resNewRev {@link File} reference for new revision (XML resource)
* @param newRev {@link File} reference for shreddered new revision (sirix resource)
* @throws SirixException if sirix fails to shredder the file
* @throws IOException if file couldn't be read
* @throws XMLStreamException if XML document isn't well formed
* @throws NullPointerException if {@code resNewRev} or {@code newRev} is {@code null}
*/
private void shredder(final Path resNewRev, @Nonnull Path newRev) throws SirixException, IOException, XMLStreamException {
assert resNewRev != null;
assert newRev != null;
final DatabaseConfiguration conf = new DatabaseConfiguration(newRev);
Databases.truncateDatabase(conf);
Databases.createDatabase(conf);
try (final Database db = Databases.openDatabase(newRev)) {
db.createResource(new ResourceConfiguration.Builder("shredded", conf).build());
try (final ResourceManager resMgr = db.getResourceManager(new ResourceManagerConfiguration.Builder("shredded").build());
final XdmNodeWriteTrx wtx = resMgr.beginNodeWriteTrx()) {
final XMLEventReader fileReader = XMLShredder.createFileReader(resNewRev);
final XMLShredder shredder = new XMLShredder.Builder(wtx, fileReader, Insert.ASFIRSTCHILD).commitAfterwards().build();
shredder.call();
}
}
}
use of org.sirix.api.XdmNodeWriteTrx 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.XdmNodeWriteTrx in project sirix by sirixdb.
the class HashTest method testRollingSetter.
@Test
public void testRollingSetter() throws SirixException {
final XdmNodeWriteTrx wtx = createWtx(HashKind.ROLLING);
testSetter(wtx);
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class HashTest method testRollingDeep.
@Test
public void testRollingDeep() throws SirixException {
final XdmNodeWriteTrx wtx = createWtx(HashKind.ROLLING);
testDeepTree(wtx);
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class DBCollection method add.
public DBNode add(final String resourceName, final XMLEventReader reader) throws OperationNotSupportedException, DocumentException {
try {
mDatabase.createResource(ResourceConfiguration.newBuilder(resourceName, mDatabase.getDatabaseConfig()).useDeweyIDs(true).build());
final ResourceManager resource = mDatabase.getResourceManager(ResourceManagerConfiguration.newBuilder(resourceName).build());
final XdmNodeWriteTrx wtx = resource.beginNodeWriteTrx();
wtx.insertSubtreeAsFirstChild(reader);
wtx.moveToDocumentRoot();
return new DBNode(wtx, this);
} catch (final SirixException e) {
LOGGER.error(e.getMessage(), e);
return null;
}
}
Aggregations