com.jgraph.example.adapter
Class JGraphSQLBackend

java.lang.Object
  extended by com.jgraph.example.adapter.JGraphSQLBackend
All Implemented Interfaces:
JGraphAdapterBackend

public class JGraphSQLBackend
extends java.lang.Object
implements JGraphAdapterBackend

Maps changes to the graph model to a custom backend, eg. an SQL database. (This should use prepared statements.)


Constructor Summary
JGraphSQLBackend(java.sql.Connection conn, java.lang.Object vertexPrototype, java.lang.Object edgePrototype)
           
 
Method Summary
 void attributesChanged(JGraphAdapterModel sender, java.lang.Object cell, java.util.Map attributes, boolean validate)
           
 void cellRemoved(JGraphAdapterModel sender, java.lang.Object cell, boolean validate)
           
 void commit()
          Invoked after no exception has been thrown during a non-validating calling sequence on the backend.
 java.lang.Object createCell(JGraphAdapterModel context, JGraphSQLEntity entity)
           
 void dump(java.sql.ResultSet rs)
           
 void edgeAdded(JGraphAdapterModel sender, java.lang.Object object, java.lang.Object source, java.lang.Object target, boolean validate)
           
 java.util.Collection findEdges(JGraphAdapterModel sender, java.lang.Object query, java.lang.Object parent, java.lang.Object source, java.lang.Object target, boolean directed)
           
 java.util.Collection findVertices(JGraphAdapterModel sender, java.lang.Object query, java.lang.Object parent)
           
 JGraphSQLEntity get(java.lang.Object id)
           
 java.lang.Object getParent(java.lang.Object object)
           
 java.lang.Object getSource(java.lang.Object object)
           
 java.lang.Object getTarget(java.lang.Object object)
           
 void parentChanged(JGraphAdapterModel sender, java.lang.Object child, java.lang.Object parent, boolean validate)
           
 void propertiesChanged(java.lang.Object object, java.util.Map properties)
           
 void propertyAdded(JGraphSQLEntity entity, java.lang.Object key, java.lang.Object value)
           
 void propertyChanged(JGraphSQLEntity entity, java.lang.Object key, java.lang.Object value)
           
 void query(java.lang.String expression)
           
 void rollback()
          Invoked when an exception has been thrown during a non-validating calling sequence on the backend.
 void sourceChanged(JGraphAdapterModel sender, java.lang.Object edge, java.lang.Object source, boolean validate)
           
 void targetChanged(JGraphAdapterModel sender, java.lang.Object edge, java.lang.Object target, boolean validate)
           
 void update(java.lang.String expression)
           
 void vertexAdded(JGraphAdapterModel sender, java.lang.Object vertex, boolean validate)
          Invoked when a vertex has been added to the sender model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGraphSQLBackend

public JGraphSQLBackend(java.sql.Connection conn,
                        java.lang.Object vertexPrototype,
                        java.lang.Object edgePrototype)
                 throws java.lang.ClassNotFoundException,
                        java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException
Method Detail

commit

public void commit()
            throws java.lang.Exception
Description copied from interface: JGraphAdapterBackend
Invoked after no exception has been thrown during a non-validating calling sequence on the backend.

Specified by:
commit in interface JGraphAdapterBackend
Throws:
java.lang.Exception

rollback

public void rollback()
              throws java.lang.Exception
Description copied from interface: JGraphAdapterBackend
Invoked when an exception has been thrown during a non-validating calling sequence on the backend.

Specified by:
rollback in interface JGraphAdapterBackend
Throws:
java.lang.Exception

vertexAdded

public void vertexAdded(JGraphAdapterModel sender,
                        java.lang.Object vertex,
                        boolean validate)
                 throws java.lang.Exception
Description copied from interface: JGraphAdapterBackend
Invoked when a vertex has been added to the sender model. If validate is true then the change should not be performed yet. If the validation or the actual change fail on the backend, you should throw an exception.

Specified by:
vertexAdded in interface JGraphAdapterBackend
Throws:
java.lang.Exception

edgeAdded

public void edgeAdded(JGraphAdapterModel sender,
                      java.lang.Object object,
                      java.lang.Object source,
                      java.lang.Object target,
                      boolean validate)
               throws java.lang.Exception
Specified by:
edgeAdded in interface JGraphAdapterBackend
Throws:
java.lang.Exception

cellRemoved

public void cellRemoved(JGraphAdapterModel sender,
                        java.lang.Object cell,
                        boolean validate)
                 throws java.lang.Exception
Specified by:
cellRemoved in interface JGraphAdapterBackend
Throws:
java.lang.Exception

parentChanged

public void parentChanged(JGraphAdapterModel sender,
                          java.lang.Object child,
                          java.lang.Object parent,
                          boolean validate)
                   throws java.lang.Exception
Specified by:
parentChanged in interface JGraphAdapterBackend
Throws:
java.lang.Exception

sourceChanged

public void sourceChanged(JGraphAdapterModel sender,
                          java.lang.Object edge,
                          java.lang.Object source,
                          boolean validate)
                   throws java.lang.Exception
Specified by:
sourceChanged in interface JGraphAdapterBackend
Throws:
java.lang.Exception

targetChanged

public void targetChanged(JGraphAdapterModel sender,
                          java.lang.Object edge,
                          java.lang.Object target,
                          boolean validate)
                   throws java.lang.Exception
Specified by:
targetChanged in interface JGraphAdapterBackend
Throws:
java.lang.Exception

attributesChanged

public void attributesChanged(JGraphAdapterModel sender,
                              java.lang.Object cell,
                              java.util.Map attributes,
                              boolean validate)
                       throws java.lang.Exception
Specified by:
attributesChanged in interface JGraphAdapterBackend
Throws:
java.lang.Exception

propertiesChanged

public void propertiesChanged(java.lang.Object object,
                              java.util.Map properties)
                       throws java.lang.Exception
Throws:
java.lang.Exception

propertyChanged

public void propertyChanged(JGraphSQLEntity entity,
                            java.lang.Object key,
                            java.lang.Object value)
                     throws java.lang.Exception
Throws:
java.lang.Exception

propertyAdded

public void propertyAdded(JGraphSQLEntity entity,
                          java.lang.Object key,
                          java.lang.Object value)
                   throws java.lang.Exception
Throws:
java.lang.Exception

findVertices

public java.util.Collection findVertices(JGraphAdapterModel sender,
                                         java.lang.Object query,
                                         java.lang.Object parent)
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

getParent

public java.lang.Object getParent(java.lang.Object object)

getSource

public java.lang.Object getSource(java.lang.Object object)

getTarget

public java.lang.Object getTarget(java.lang.Object object)

createCell

public java.lang.Object createCell(JGraphAdapterModel context,
                                   JGraphSQLEntity entity)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

findEdges

public java.util.Collection findEdges(JGraphAdapterModel sender,
                                      java.lang.Object query,
                                      java.lang.Object parent,
                                      java.lang.Object source,
                                      java.lang.Object target,
                                      boolean directed)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

get

public JGraphSQLEntity get(java.lang.Object id)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

query

public void query(java.lang.String expression)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

dump

public void dump(java.sql.ResultSet rs)
          throws java.sql.SQLException
Throws:
java.sql.SQLException

update

public void update(java.lang.String expression)
            throws java.sql.SQLException
Throws:
java.sql.SQLException