use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testSubtreeInsertAsRightSibling.
@Test
public void testSubtreeInsertAsRightSibling() throws SirixException, IOException, XMLStreamException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.insertSubtreeAsRightSibling(XMLShredder.createStringReader(DocumentCreater.XML_WITHOUT_XMLDECL));
testSubtreeInsertAsRightSibling(wtx);
wtx.commit();
wtx.moveTo(14);
testSubtreeInsertAsRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
rtx.moveTo(14);
testSubtreeInsertAsRightSibling(rtx);
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testFirstMoveToFirstChild.
@Test
public void testFirstMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(7);
wtx.moveSubtreeToFirstChild(6);
testFirstMoveToFirstChild(wtx);
wtx.commit();
testFirstMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstMoveToFirstChild(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
final ImmutableSet<SirixDeweyID> ids = builder.add(new SirixDeweyID("1")).add(new SirixDeweyID("1.3")).add(new SirixDeweyID("1.3.0.3")).add(new SirixDeweyID("1.3.1.3")).add(new SirixDeweyID("1.3.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.5.5.3")).add(new SirixDeweyID("1.3.7")).add(new SirixDeweyID("1.3.9")).add(new SirixDeweyID("1.3.9.1.3")).add(new SirixDeweyID("1.3.9.3")).add(new SirixDeweyID("1.3.9.5")).add(new SirixDeweyID("1.3.11")).build();
test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES)));
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class UpdateTest method testFirstMoveSubtreeToRightSibling.
@Test
public void testFirstMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
wtx.moveTo(7);
wtx.moveSubtreeToRightSibling(6);
testFirstMoveSubtreeToRightSibling(wtx);
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
wtx.commit();
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
testFirstMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstMoveSubtreeToRightSibling(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
final ImmutableSet<SirixDeweyID> ids = builder.add(new SirixDeweyID("1")).add(new SirixDeweyID("1.3")).add(new SirixDeweyID("1.3.0.3")).add(new SirixDeweyID("1.3.1.3")).add(new SirixDeweyID("1.3.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.5.7")).add(new SirixDeweyID("1.3.7")).add(new SirixDeweyID("1.3.9")).add(new SirixDeweyID("1.3.9.1.3")).add(new SirixDeweyID("1.3.9.3")).add(new SirixDeweyID("1.3.9.5")).add(new SirixDeweyID("1.3.11")).build();
test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES)));
rtx.close();
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class Holder method generateWtx.
/**
* Generate a {@link XdmNodeReaderWriter}.
*
* @return this holder instance
* @throws SirixException if an error occurs
*/
public static Holder generateWtx() throws SirixException {
final Holder holder = openResourceManager();
final XdmNodeWriteTrx writer = holder.mResMgr.beginNodeWriteTrx();
holder.setWriter(writer);
return holder;
}
use of org.sirix.api.XdmNodeWriteTrx in project sirix by sirixdb.
the class TestHelper method createPICommentTestDocument.
/**
* Creating a test document with comments and processing instructions at {@link PATHS#PATH1}.
*
* @throws SirixException
*/
public static void createPICommentTestDocument() throws SirixException {
try (final Database database = TestHelper.getDatabase(PATHS.PATH1.getFile())) {
database.createResource(new ResourceConfiguration.Builder(RESOURCE, PATHS.PATH1.config).build());
try (final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(RESOURCE).build());
final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx()) {
DocumentCreater.createCommentPI(wtx);
wtx.commit();
}
}
}
Aggregations