public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VTKNodeMap<DBObject,E>, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{
- private static final boolean DEBUG = true;
-
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractVTKNodeMap.class);
protected Session session;
undoOpCount = undoContext.getAll().size();
redoOpCount = undoContext.getRedoList().size();
} catch(DatabaseException e) {
- e.printStackTrace();
+ LOGGER.error("Error reading from undo context", e);
}
}
UndoContext undoContext = undoRedoSupport.getUndoContext(session);
int ucount = undoContext.getAll().size();
int rcount = undoContext.getRedoList().size();
- if (DEBUG) System.out.println("Previous U:" + undoOpCount +" R:" + redoOpCount +" Current U:"+ucount+" R:"+rcount);
+
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Previous U:" + undoOpCount +" R:" + redoOpCount +" Current U:"+ucount+" R:"+rcount);
if (ucount < undoOpCount) {
runUndo = true;
} else {
undoOpCount = ucount;
redoOpCount = rcount;
- if (DEBUG) System.out.println("Undo " + runUndo + " Redo " + runRedo);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Undo " + runUndo + " Redo " + runRedo);
} catch (DatabaseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@SuppressWarnings("unchecked")
private void receiveAdd(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveAdd " + debugString(node) + " " + id + " " + db);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveAdd " + debugString(node) + " " + id + " " + db);
synchronized (syncMutex) {
for (Pair<E, String> n : added) {
if (n.first.equals(node))
@SuppressWarnings("unchecked")
private void receiveRemove(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveRemove " + debugString(node) + " " + id + " " + db);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveRemove " + debugString(node) + " " + id + " " + db);
synchronized (syncMutex) {
for (Pair<E, String> n : removed) {
if (n.first.equals(node))
}
private void receiveUpdate(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveUpdate " + debugString(node) + " " + id + " " + db);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("receiveUpdate " + debugString(node) + " " + id + " " + db);
synchronized (syncMutex) {
// for (Pair<E, String> n : updated) {
// if (n.first.equals(node))
session.syncRequest(new WriteRequest() {
@Override
public void perform(WriteGraph graph) throws DatabaseException {
- if (DEBUG) System.out.println("Commit " + commitMessage);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit " + commitMessage);
if (commitMessage != null) {
Layer0Utils.addCommentMetadata(graph, commitMessage);
graph.markUndoPoint();
protected void commit(WriteGraph graph) throws DatabaseException {
synchronized(syncMutex) {
- if (DEBUG) System.out.println("Commit");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit");
graphUpdates = true;
mapping.updateDomain(graph);
graphUpdates = false;
clearDeletes();
- if (DEBUG) System.out.println("Commit done");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Commit done");
}
}
public void domainModified() {
if (graphUpdates)
return;
- if (DEBUG)System.out.println("domainModified");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("domainModified");
session.asyncRequest(new UniqueRead<Object>() {
@Override
public Object perform(ReadGraph graph) throws DatabaseException {
}
protected void reset(ReadGraph graph) throws MappingException {
- if (DEBUG) System.out.println("Reset");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Reset");
graphUpdates = true;
mapping.getRangeModified().clear();
private boolean useFullSyncWithUndo = false;
protected void update(ReadGraph graph) throws DatabaseException {
- if (DEBUG) System.out.println("Graph update start");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Graph update start");
if (runUndo && useFullSyncWithUndo) {
synchronized (syncMutex) {
if (mapping.isRangeModified() && !runUndo && !runRedo)
commit((String)null);
- if (DEBUG) System.out.println("Graph update done");
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Graph update done");
}
@Override
public void rangeModified() {
- //System.out.println("rangeModified");
+ //LOGGER.trace("rangeModified");
}
for (Pair<E, String> n : added) {
deleteUC.remove(n.first);
}
- if (DEBUG && deleteUC.size() > 0) {
- System.out.println("Delete sync");
+ if (LOGGER.isTraceEnabled() && deleteUC.size() > 0) {
+ LOGGER.trace("Delete sync");
for (E n : delete) {
- System.out.println(debugString(n));
+ LOGGER.trace(debugString(n));
}
}
delete.addAll(deleteUC);
* Clears deletable objects from mapping cache.
*/
protected void clearDeletes() {
- if (DEBUG && delete.size() > 0) System.out.println("Delete");
+ if (LOGGER.isTraceEnabled() && delete.size() > 0) LOGGER.trace("Delete");
for (E n : delete) {
- if (DEBUG) System.out.println(debugString(n));
+ if (LOGGER.isTraceEnabled()) LOGGER.trace(debugString(n));
mapping.getRange().remove(n);
stopListening(n);
}
E n = stack.pop();
boolean conflict = filterChange(removed, n);
if (conflict) {
- if (DEBUG) System.out.println("Prevent removing " + n);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Prevent removing " + n);
//filterChange(added, n)
if (filterChange(added, n))
- if (DEBUG) System.out.println("Prevent adding " + n);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Prevent adding " + n);
}
if (n instanceof ParentNode) {
ParentNode<INode> pn = (ParentNode<INode>)n;
@Override
public <T extends INode> void nodeAdded(ParentNode<T> node, INode child,
String rel) {
- if (DEBUG) System.out.println("Node added " + child + " parent " + node);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Node added " + child + " parent " + node);
//receiveAdd((E)child, rel ,graphUpdates);
receiveAdd((E)child, rel ,graphModified.contains(node));
}
@Override
public <T extends INode> void nodeRemoved(ParentNode<T> node, INode child,
String rel) {
- if (DEBUG) System.out.println("Node removed " + child + " parent " + node);
+ if (LOGGER.isTraceEnabled()) LOGGER.trace("Node removed " + child + " parent " + node);
//receiveRemove((E)child, rel, graphUpdates);
receiveRemove((E)child, rel, graphModified.contains(node));