|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnz.ac.waikato.mcennis.rat.graph.model.ModelShell
nz.ac.waikato.mcennis.rat.graph.DerbyGraph
public class DerbyGraph
Class that implements all the JDBC code for a Derby backed graph model. This
model differs from persistance in that all loading of actors, links, and properties
is done using lazy techniques (they are not createde until requested). Provided
that the appropriate actor class (DBActor by default) is used, persistance is
maintained with generated references in a manner similar to hibernate.
The first time this system is utilized, it requires initialization to create
the appropriate tables in the database. This database must be the same for the
corresponding actor class, but is handled by default (unless the class is changed
between startup and actor request.)
The system requires two paramters - the directory of the database and the database
name. All JDBC calls are compiled and have auto-commit disabled. Periodic calls
to commit() are required to maintain consistancy between the database and
memory-resident components.
| Nested Class Summary | |
|---|---|
class |
DerbyGraph.ActorIterator
|
| Field Summary | |
|---|---|
static long |
serialVersionUID
|
| Fields inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell |
|---|
listener |
| Constructor Summary | |
|---|---|
DerbyGraph()
Creates a new instance of DerbyGraph |
|
| Method Summary | |
|---|---|
void |
add(Actor u)
Add a user to the graph. |
void |
add(Graph g)
Add a graph (g) to the graph. |
void |
add(Link link)
Adds a userlink to the graph. |
void |
add(PathSet pathSet)
Add a PathSet to this graph. |
void |
add(Property prop)
Add a property to this graph. |
void |
addChild(Graph g)
FIXME: Does not save to database |
void |
anonymize()
Replaces all actor IDs with an anonymous numeric ID. |
void |
clear()
Removes all data from the database. |
void |
close()
Attempts to release all resources created by the startup method |
void |
commit()
Aquire a set of properties from the database attached to a given actor. |
int |
compareTo(java.lang.Object o)
|
void |
deleteDatabase()
Attempts to remove the database tables so that initializeDatabase will be needed to utilize the graph again. |
protected void |
finalize()
|
java.util.List<Actor> |
getActor()
Retrieve an array of all actors of all types. |
java.util.List<Actor> |
getActor(java.lang.String type)
Retrieve an array of all actors of a given type. |
Actor |
getActor(java.lang.String type,
java.lang.String ID)
Retrieve the users that has the given ID. |
protected java.lang.String |
getActorClass()
Determine what class will be used for the creation of actor objects. |
int |
getActorCount(java.lang.String mode)
Returns the number of actors of the given type |
java.util.Iterator<Actor> |
getActorIterator()
|
java.util.Iterator<Actor> |
getActorIterator(java.lang.String type)
Create a read only iterator over all actors. |
java.util.List<java.lang.String> |
getActorTypes()
List all types - returns null if no actors exist. |
java.util.List<Graph> |
getChildren()
FIXME: Does not properly access database |
Graph |
getChildren(java.lang.String id)
FIXME: Does not properly access database |
java.util.Iterator<Graph> |
getChildrenIterator()
|
java.io.File |
getDirectory()
Return the directory that this object will or is using. |
java.lang.String |
getID()
Return the ID associated with this Graph |
java.util.List<Link> |
getLink()
Return all user to user links in this graph in an array. |
java.util.List<Link> |
getLink(java.lang.String type)
Retrieve an array of all userlinks of the given type from this graph or null if no such links are in this graph. |
java.util.List<Link> |
getLink(java.lang.String type,
Actor sourceActor,
Actor destActor)
Returns all links of the given type (relation) type going from actor sourceActor to actor destActor or null. |
java.util.Iterator<Link> |
getLinkByDesinationIterator(java.lang.String type,
Actor destActor)
|
java.util.List<Link> |
getLinkByDestination(java.lang.String type,
Actor destActor)
Returns all links (edges, arcs) of type (relation) type that point to the given actor. |
java.util.List<Link> |
getLinkBySource(java.lang.String type,
Actor sourceActor)
Returns all links (edges, arcs) of type (relation) type that go from the given actor to any destination. |
java.util.Iterator<Link> |
getLinkBySourceIterator(java.lang.String type,
Actor sourceActor)
|
java.util.Iterator<Link> |
getLinkIterator()
|
java.util.Iterator<Link> |
getLinkIterator(java.lang.String type)
|
java.util.Iterator<Link> |
getLinkIterator(java.lang.String type,
Actor sourceActor,
Actor destActor)
|
java.util.List<java.lang.String> |
getLinkTypes()
Returns all link types currently in this graph or null if no links are present. |
Properties |
getParameter()
Obtain a computer-readable description of the parameters and options this graph supports |
Parameter |
getParameter(java.lang.String name)
|
Graph |
getParent()
FIXME: Does not properly access database |
java.util.List<PathSet> |
getPathSet()
Return all PathSets associated with this graph. |
PathSet |
getPathSet(java.lang.String id)
Return the named PathSet. |
java.util.Iterator<PathSet> |
getPathSetIterator()
|
java.util.List<Property> |
getProperty()
Returns an array of all properties associated with this object or null if none exist |
Property |
getProperty(java.lang.String type)
Return a property named by the given string or null if no property by this name exists |
java.util.Iterator<Property> |
getPropertyIterator()
|
void |
init(Properties props)
Set the parameters of this graph from the following property object. |
protected void |
initActor()
Performs initialization of the DBActor class - a static call that prepares all subsequent calls for actor creation. |
void |
initializeDatabase()
The first call to be made if the database has never been used before. |
protected void |
initLink()
|
boolean |
isInitialized()
Determine if 'startup' has been called for this graph. |
protected void |
prepareStatement()
Prepares all statements utilized by DerbyGraph. |
DerbyGraph |
prototype()
|
void |
publishChange(Model m,
int type,
int argument)
Records changes in properties of this graph, updating the database as needed. |
void |
remove(Actor u)
Identifies the given user and removes it and all links involving it from the graph. |
void |
remove(Link ul)
remove all user links with the same type, user ID, and artist ID from the graph |
void |
removeProperty(java.lang.String ID)
|
protected Actor |
retrieveActor(int id)
Retrieve an actor object from the database with its database's numeric id. |
protected void |
setActorClass(java.lang.String actorClass)
Determine what class will be used for the creation of actor objects. |
void |
setDirectory(java.io.File f)
Set the directory that DerbyGraph will look for its database |
void |
setID(java.lang.String id)
Set this graph's ID to this value. |
void |
startup()
Starts the database Creates a database connection at the directory 'directory' with database name 'database' aquires the graph id of the root graph compiles all the prepared statements used in the class |
| Methods inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell |
|---|
addListener, fireChange |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface nz.ac.waikato.mcennis.rat.graph.model.Model |
|---|
addListener |
| Field Detail |
|---|
public static final long serialVersionUID
| Constructor Detail |
|---|
public DerbyGraph()
| Method Detail |
|---|
public void init(Properties props)
Graph
init in interface Graphprops - properties to be set
public void startup()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void initActor()
DBActorprotected void initLink()
protected void prepareStatement()
throws java.sql.SQLException
java.sql.SQLException
public void initializeDatabase()
throws java.sql.SQLException
java.sql.SQLException
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void close()
close in interface Graphpublic boolean isInitialized()
public void clear()
public void deleteDatabase()
public void add(Actor u)
Graph
add in interface Graphu - user to be included in the graph.public void add(Link link)
Graph
add in interface Graphlink - description of a named link between two userspublic void remove(Actor u)
Graph
remove in interface Graphu - user to be removed from the graph.public void remove(Link ul)
Graph
remove in interface Graphul - link to be removed from the graph.
public Actor getActor(java.lang.String type,
java.lang.String ID)
Graph
getActor in interface GraphID - ID string identifying an user
public java.util.List<Actor> getActor()
Graph
getActor in interface Graphpublic java.util.List<Actor> getActor(java.lang.String type)
Graph
getActor in interface Graphtype - class of actor to return
public java.util.Iterator<Actor> getActorIterator(java.lang.String type)
Graph
getActorIterator in interface Graphtype - type (mode) of actor to return
public java.util.List<java.lang.String> getActorTypes()
Graph
getActorTypes in interface Graphpublic java.util.List<Link> getLink()
Graph
getLink in interface Graphprotected Actor retrieveActor(int id)
id - numeric id of this object
public java.util.List<Link> getLink(java.lang.String type)
Graph
getLink in interface Graph
public java.util.List<Link> getLinkBySource(java.lang.String type,
Actor sourceActor)
Graph
getLinkBySource in interface Graphtype - type (relation) of link to returnsourceActor - starting point of the link
public java.util.List<Link> getLinkByDestination(java.lang.String type,
Actor destActor)
Graph
getLinkByDestination in interface Graphtype - type (relation) of link to returndestActor - actor pointed to by links
public java.util.List<Link> getLink(java.lang.String type,
Actor sourceActor,
Actor destActor)
Graph
getLink in interface Graphtype - type (relation) of the link to returnsourceActor - starting point of the linkdestActor - actor pointed to by links
public java.util.List<java.lang.String> getLinkTypes()
Graph
getLinkTypes in interface Graphpublic java.util.List<Property> getProperty()
Graph
getProperty in interface Graphpublic Property getProperty(java.lang.String type)
Graph
getProperty in interface Graphtype - property's name
public void add(Property prop)
throws java.lang.NullPointerException
Graph
add in interface Graphprop - property to be added.
java.lang.NullPointerExceptionpublic java.util.List<PathSet> getPathSet()
Graph
getPathSet in interface Graphpublic PathSet getPathSet(java.lang.String id)
Graph
getPathSet in interface Graphid - ID of the PathSet to return
public void add(PathSet pathSet)
Graph
add in interface GraphpathSet - PathSet to be added to this graphpublic void setID(java.lang.String id)
Graph
setID in interface Graphid - graph IDpublic java.lang.String getID()
Graph
getID in interface Graphpublic void setDirectory(java.io.File f)
f - file representing the target directory.public java.io.File getDirectory()
public void commit()
commit in interface Grapha - unique id of the actor whose properties are to be retrieved
java.sql.SQLExceptionpublic void add(Graph g)
Graph
add in interface Graphg - graph to be addedpublic void anonymize()
Graph
anonymize in interface Graph
public void publishChange(Model m,
int type,
int argument)
publishChange in interface Listenerm - property that is modifiedtype - currently only records adding a propertypublic Graph getParent()
getParent in interface Graphpublic java.util.List<Graph> getChildren()
getChildren in interface Graphpublic Graph getChildren(java.lang.String id)
getChildren in interface Graphid - ID of the graph to return
public void addChild(Graph g)
addChild in interface Graphg - Child Graphpublic void removeProperty(java.lang.String ID)
removeProperty in interface Graphprotected void setActorClass(java.lang.String actorClass)
actorClass - name of class of actorActorFactoryprotected java.lang.String getActorClass()
ActorFactorypublic Properties getParameter()
Graph
getParameter in interface Graphpublic int getActorCount(java.lang.String mode)
Graph
getActorCount in interface Graphmode - type of actor to query
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparablepublic DerbyGraph prototype()
prototype in interface Graphpublic java.util.Iterator<Actor> getActorIterator()
getActorIterator in interface Graphpublic java.util.Iterator<Link> getLinkIterator()
getLinkIterator in interface Graphpublic java.util.Iterator<Link> getLinkIterator(java.lang.String type)
getLinkIterator in interface Graph
public java.util.Iterator<Link> getLinkBySourceIterator(java.lang.String type,
Actor sourceActor)
getLinkBySourceIterator in interface Graph
public java.util.Iterator<Link> getLinkByDesinationIterator(java.lang.String type,
Actor destActor)
getLinkByDesinationIterator in interface Graph
public java.util.Iterator<Link> getLinkIterator(java.lang.String type,
Actor sourceActor,
Actor destActor)
getLinkIterator in interface Graphpublic java.util.Iterator<Property> getPropertyIterator()
getPropertyIterator in interface Graphpublic java.util.Iterator<PathSet> getPathSetIterator()
getPathSetIterator in interface Graphpublic java.util.Iterator<Graph> getChildrenIterator()
getChildrenIterator in interface Graphpublic Parameter getParameter(java.lang.String name)
getParameter in interface Graph
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||