use of org.openntf.domino.transactions.DatabaseTransaction in project org.openntf.domino by OpenNTF.
the class Document method queueRemove.
private boolean queueRemove() {
if (!isRemoveQueued_) {
DatabaseTransaction txn = getParentDatabase().getTransaction();
if (txn != null) {
// System.out.println("DEBUG: Found a transaction: " + txn + " from parent Database " + getParentDatabase().getApiPath());
txn.queueRemove(this);
isRemoveQueued_ = true;
// we queued this, so whoever asked shouldn't do it yet.
return true;
} else {
// calling function should just go ahead and execute
return false;
}
} else {
// we already queued this for removal.
return false;
}
}
use of org.openntf.domino.transactions.DatabaseTransaction in project org.openntf.domino by OpenNTF.
the class DocumentSyncHelper method process.
/**
* Process a specific DocumentCollection.
*
* WARNING: Does not currently check that all properties of the SyncHelper have been set up
*
* @param coll
* DocumentCollection of source documents
* @since org.openntf.domino 1.0.0
*/
public void process(final DocumentCollection coll) {
// TODO Check to make sure properties are all set up before running
Session session = coll.getAncestorSession();
Database targetDb = session.getDatabase(getTargetServer(), getTargetFilepath());
View targetView = targetDb.getView(getTargetLookupView());
Strategy strategy = getStrategy();
DatabaseTransaction txn = null;
if (getTransactionRule() == TransactionRule.COMMIT_AT_END) {
txn = targetDb.startTransaction();
}
for (Document source : coll) {
txn = processDocument(targetDb, targetView, strategy, txn, source);
}
if (getTransactionRule() == TransactionRule.COMMIT_AT_END && txn != null) {
txn.commit();
txn = null;
}
}
use of org.openntf.domino.transactions.DatabaseTransaction in project org.openntf.domino by OpenNTF.
the class DominoGraph method commit.
public void commit(final boolean clearCache) {
DatabaseTransaction txn = getTxn();
if (txn != null) {
if (getCache().size() > 0) {
// System.out.println("Reapplying cache to " + getCache().size() + " elements...");
int vCount = 0;
Set<Element> elems = getCacheValues();
for (Element elem : elems) {
if (elem instanceof DominoElement) {
((DominoElement) elem).reapplyChanges();
}
}
} else {
// System.out.println("Element cache is empty (so what are we committing?)");
}
txn.commit();
// setTxn(null);
}
if (clearCache)
clearCache();
// System.out.println("Transaction complete");
}
use of org.openntf.domino.transactions.DatabaseTransaction in project org.openntf.domino by OpenNTF.
the class Connect17Transaction method run.
@Override
public void run() {
Session sess = Factory.getSession(SessionType.NATIVE);
Database extLib = sess.getDatabase("odademo/oda_1.nsf");
Database extLib2 = sess.getDatabase("odademo/oda_2.nsf");
View states = extLib.getView("AllStates");
Document stateDoc = states.getFirstDocument();
DatabaseTransaction txn = extLib.startTransaction();
extLib2.setTransaction(txn);
boolean successOrFail = false;
String state = stateDoc.getItemValueString("Key");
System.out.println("Processing state " + state);
// Update some documents
queueTransaction(extLib, state);
// Update some documents
queueTransaction(extLib2, state);
if (successOrFail) {
txn.commit();
System.out.println("...Committed");
} else {
txn.rollback();
System.out.println("rolled back");
}
}
use of org.openntf.domino.transactions.DatabaseTransaction in project org.openntf.domino by OpenNTF.
the class Document method markDirtyInt.
protected void markDirtyInt() {
isDirty_ = true;
if (!isQueued_) {
DatabaseTransaction txn = getParentDatabase().getTransaction();
if (txn != null) {
txn.queueUpdate(this);
isQueued_ = true;
}
}
}