package eu.dnetlib.r2d2.neo4j.util;

/**
 * A simple class to hold the transaction status of this thread.
 * 
 * @author antleb
 *
 */
public class TransactionStatusHolder {

	private static ThreadLocal<Boolean> writeTx = new ThreadLocal<Boolean>() {
		protected Boolean initialValue() {
			return false;
		}
	};

	/**
	 * Call this when a write occurs during this transaction
	 */
	public static void setWriteStatus() {
		writeTx.set(true);
	}

	/**
	 * Get the write status of the current transaction
	 * @return
	 */
	public static boolean getWriteStatus() {
		return writeTx.get();
	}

	/**
	 * Reset the write status 
	 */
	public static void reset() {
		writeTx.remove();
	}
}
