use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class DBNode method isDocumentOf.
@Override
public boolean isDocumentOf(final Node<?> other) {
moveRtx();
boolean retVal = false;
if (getKind() == Kind.DOCUMENT && other instanceof DBNode) {
final DBNode node = (DBNode) other;
assert node.getNodeClassID() == this.getNodeClassID();
final XdmNodeReadTrx rtx = node.getTrx();
if (rtx.getRevisionNumber() == mRtx.getRevisionNumber() && rtx.getResourceManager().getResourceConfig().getID() == mRtx.getResourceManager().getResourceConfig().getID()) {
retVal = true;
}
}
return retVal;
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class DBNode method isFirstOf.
@Override
public boolean isFirstOf(TemporalNode<?> other) {
moveRtx();
if (other instanceof DBNode) {
final DBNode otherNode = (DBNode) other;
final XdmNodeReadTrx otherTrx = otherNode.getTrx();
// Revision 0 is just the bootstrap revision and not accessed over here.
return otherTrx.getRevisionNumber() == 1;
}
return false;
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class DBNode method replaceWith.
private DBNode replaceWith(XdmNodeWriteTrx wtx, Node<?> node) throws DocumentException {
if (node instanceof DBNode) {
final DBNode other = (DBNode) node;
try {
final XdmNodeReadTrx rtx = other.getTrx();
rtx.moveTo(other.getNodeKey());
wtx.replaceNode(rtx);
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
return new DBNode(wtx, mCollection);
} else {
final SubtreeBuilder builder = createBuilder(wtx);
node.parse(builder);
try {
return replace(builder.getStartNodeKey(), wtx);
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class FindCASIndex method execute.
@Override
public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) throws QueryException {
final DBNode doc = (DBNode) args[0];
final XdmNodeReadTrx rtx = doc.getTrx();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final QNm name = new QNm(Namespaces.XS_NSURI, ((Str) args[1]).stringValue());
final Type type = sctx.getTypes().resolveAtomicType(name);
final Path<QNm> path = Path.parse(((Str) args[2]).stringValue());
final Optional<IndexDef> indexDef = controller.getIndexes().findCASIndex(path, type);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class FindPathIndex method execute.
@Override
public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) throws QueryException {
final DBNode doc = (DBNode) args[0];
final XdmNodeReadTrx rtx = doc.getTrx();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final Path<QNm> path = Path.parse(((Str) args[1]).stringValue());
final Optional<IndexDef> indexDef = controller.getIndexes().findPathIndex(path);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
Aggregations