uk.ac.ic.doc.automed.util.graph.impl
Class HDMGraph

java.lang.Object
  extended by uk.ac.ic.doc.automed.util.graph.impl.Graph
      extended by uk.ac.ic.doc.automed.util.graph.impl.DataGraph
          extended by uk.ac.ic.doc.automed.util.graph.impl.HDMGraph
All Implemented Interfaces:
java.io.Serializable, GVisualisable, SchemaI, GraphI
Direct Known Subclasses:
ObjectMapping

public class HDMGraph
extends DataGraph
implements SchemaI, GVisualisable

See Also:
Serialized Form

Field Summary
private static java.lang.String COMMA
           
static int CONSTRAINT_CANDIDATE_KEY
           
static int CONSTRAINT_FK_KEY
           
static int CONSTRAINT_MANDATORY
           
static int CONSTRAINT_PK_KEY
           
static int CONSTRAINT_REFLEXIVE
           
static int CONSTRAINT_UNIQUE
           
private  java.util.List k2oNodes
           
private  java.util.List knodes
           
private static java.lang.String model
           
private static java.text.NumberFormat nf
           
private static java.lang.String OPEN_SCHEME
           
private  java.lang.String peer
           
private  double rank
           
private  java.lang.String schema
           
private static long serialVersionUID
           
 
Fields inherited from class uk.ac.ic.doc.automed.util.graph.impl.DataGraph
constraint, constraints, edge, node, propObjs
 
Fields inherited from class uk.ac.ic.doc.automed.util.graph.impl.Graph
EDGE, idCounter, LEFT_BRACE, METADATA, NEW_LINE, RIGHT_ARROW, RIGHT_BRACE, SPACE, VERTICAL_BAR
 
Constructor Summary
HDMGraph(java.lang.String peer, java.lang.String schema)
           
 
Method Summary
private  void addConstraint(HDMObject c)
           
 HDMObject addConstraintObject(java.lang.Object[] schemeDef)
           
private  HDMObject addConstraintObject(java.lang.Object[] schemeDef, boolean replaceIfExist)
           
 HDMObject addConstraintObject(java.lang.String schemeDef)
          Add a new HDM constraint object given its AutoMed scheme definition.
 HDMObject addEdgeObject(java.lang.Object[] schemeDef)
           
private  HDMObject addEdgeObject(java.lang.Object[] schemeDef, boolean replaceIfExist)
           
 HDMObject addEdgeObject(java.lang.String schemeDef)
          Add a new HDM edge object given its AutoMed scheme definition.
 Edge addK2ONode(Node knode, HDMObject nobj)
          Add a mapping between a k-node and an HDM Object of this graph.
The k-node must have already been added to the graph via method {#link addKNode(Node knode)}.
 void addKNode(Node knode)
          Add a k-node to this graph.
 HDMObject addNodeObject(java.lang.String schemeDef, java.lang.String dtype)
          Add a new HDM node object given its AutoMed scheme definition and data type.
 void addObject(HDMObject o)
           
 boolean containsConstraint(HDMObject obj)
           
 boolean containsEdge(HDMObject obj)
           
 boolean containsKNode(Node knode)
           
 boolean containsNode(HDMObject obj)
           
 boolean containsObject(SchemaObjectI so)
          Check if a schema object exists.
 boolean containsObject(java.lang.String schemeDef)
          Check if this graph contains an object with a given scheme definition
 HDMObject createObject(java.lang.String schemeDef)
          Recursively split an AutoMed scheme definition string into HDMObject.
Each scheme element is contained in a List object.
 SchemaObjectI createSchemaObject(SchemaObjectI so)
          Parse an edge- or constraint-type SchemeInfo object to create a new HDM non-node object.
 boolean equals(java.lang.Object other)
           
 HDMObject getDependentKeyEdge(HDMObject node)
          Return a key edge in the neighbourhood of an HDM node object.
The search order is: first key, then candidate key
 java.util.Collection getDependentObjects(java.lang.Object o)
          Returns edge and constraint objects that reference a given node object.
 java.util.Collection getDependentObjects(java.lang.Object o, java.lang.String construct)
          Returns edge and constraint objects that reference a given node object.
 SchemaObjectI[] getDependentSchemaObjects(SchemaObjectI o)
           
 SchemaObjectI[] getDependentSchemaObjects(SchemaObjectI o, java.lang.String constructName)
           
protected  HDMObject getHDMObject(java.lang.Object[] schemeDef, java.util.Collection objs)
           
 java.util.Collection getK2Nodes()
          Return the set of k-node-to-HDM object mappings in this graph.
Each mapping is represented by an Edge object.
 HDMObject getK2O(Edge mapEdge)
          Returns the target HDMObject to which a given k-node is mapped.
 HDMObject getK2O(Node n)
          Return the node object that is mapped to a given k-node
 HDMObject getK2OEdge(Edge e)
          Returns the target nodal HDMObject that is mapped to a given k-node.
 java.util.Collection getK2OMapEdge(Node knode)
          Returns a collection of Edge objects each of which represents a mapping between a k-node and an HDMObject of this graph.
 int getK2OMapPos(Edge e)
           
 java.util.Collection getKFromO(java.lang.Object o)
          Return k-node objects that are mapped to a given node HDM object.
 java.util.Collection getKFromO(java.lang.String oscheme)
           
 java.lang.String getLabel()
          The label to be displayed next to the object on the graph
 int getLength()
          Return the length of an HDMGraph.
 java.lang.String getModel()
           
 java.lang.String getName()
          Return the name of this graph.
 HDMObject getObject(java.lang.String schemeDef)
          Find an HDM node given its AutoMed scheme definition, e.g.
 SchemaObjectI[] getObjects()
          Return all HDMObjects of this graph.
 SchemaObjectI[] getObjects(java.lang.String constructName)
           
 java.lang.String getPeer()
          Return the peer name of this graph
 java.util.Collection getPropertyObjects()
          Must provide a collection of PropertyObject so that properties of a selected object can be displayed on the PropertyEditor
 double getRank()
           
 java.lang.String getRankFormatted()
           
 java.lang.String getSchemaName()
          Return the schema name
 java.lang.String getSchemeNamesString(HDMObject o, boolean peerID)
          Returns the scheme definition of an object with the schema prefix and an option to turn on/off peer identifier.
 boolean isEmpty()
           
 boolean isSameSchema(HDMGraph g)
          Check that this schema comes from the same schema as another HDM graph.
 void setProperty(java.lang.String propName, java.lang.String val)
           
 void setRank(double rank)
           
 void setSchemaName(java.lang.String schema)
           
 java.lang.String toString()
           
 
Methods inherited from class uk.ac.ic.doc.automed.util.graph.impl.DataGraph
addConstraint, clear, containsConstraint, copy, copy, getConstraints, getNodeObject, getObject, remove, removeConstraint
 
Methods inherited from class uk.ac.ic.doc.automed.util.graph.impl.Graph
addEdge, addMetadata, addNode, changeDirection, contains, containsEdge, containsEdge, containsEdge, containsNode, containsNode, edgeIterator, finalize, firstEdge, firstInEdge, firstNode, firstOutEdge, getAdjEdges, getAdjNodes, getEdge, getEdgeByID, getEdges, getID, getInEdges, getMetadata, getMetadata, getNode, getNode, getNodeByID, getNodeCount, getNodes, getOutDegree, getOutEdges, getOutNodes, getUndirectedEdge, getUndirectedEdge, hasMetadata, isFirstNode, lastEdge, lastNode, nodeIterator, numberOfEdges, numberOfNodes, predNode, removeEdge, removeEdge, removeNode, removeNode, reset, source, succNode, target
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

peer

private java.lang.String peer

schema

private java.lang.String schema

knodes

private java.util.List knodes

k2oNodes

private java.util.List k2oNodes

rank

private double rank

model

private static final java.lang.String model
See Also:
Constant Field Values

OPEN_SCHEME

private static final java.lang.String OPEN_SCHEME
See Also:
Constant Field Values

COMMA

private static final java.lang.String COMMA
See Also:
Constant Field Values

CONSTRAINT_UNIQUE

public static int CONSTRAINT_UNIQUE

CONSTRAINT_MANDATORY

public static int CONSTRAINT_MANDATORY

CONSTRAINT_REFLEXIVE

public static int CONSTRAINT_REFLEXIVE

CONSTRAINT_PK_KEY

public static int CONSTRAINT_PK_KEY

CONSTRAINT_CANDIDATE_KEY

public static int CONSTRAINT_CANDIDATE_KEY

CONSTRAINT_FK_KEY

public static int CONSTRAINT_FK_KEY

nf

private static transient java.text.NumberFormat nf
Constructor Detail

HDMGraph

public HDMGraph(java.lang.String peer,
                java.lang.String schema)
Method Detail

addConstraint

private void addConstraint(HDMObject c)

addKNode

public void addKNode(Node knode)
Add a k-node to this graph.

Parameters:
knode -

containsObject

public boolean containsObject(java.lang.String schemeDef)
Check if this graph contains an object with a given scheme definition

Parameters:
schemeDef -
Returns:

containsObject

public boolean containsObject(SchemaObjectI so)
Check if a schema object exists.

Specified by:
containsObject in interface SchemaI
Parameters:
so -
Returns:

containsKNode

public boolean containsKNode(Node knode)

containsNode

public boolean containsNode(HDMObject obj)

containsEdge

public boolean containsEdge(HDMObject obj)

containsConstraint

public boolean containsConstraint(HDMObject obj)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface SchemaI
Overrides:
isEmpty in class DataGraph

addK2ONode

public Edge addK2ONode(Node knode,
                       HDMObject nobj)
Add a mapping between a k-node and an HDM Object of this graph.
The k-node must have already been added to the graph via method {#link addKNode(Node knode)}.

Parameters:
knode -
obj -
mappedPos -

getK2OMapEdge

public java.util.Collection getK2OMapEdge(Node knode)
Returns a collection of Edge objects each of which represents a mapping between a k-node and an HDMObject of this graph.

Parameters:
knode -

getK2OMapPos

public int getK2OMapPos(Edge e)

getK2OEdge

public HDMObject getK2OEdge(Edge e)
Returns the target nodal HDMObject that is mapped to a given k-node.

Parameters:
n -
Returns:

getK2O

public HDMObject getK2O(Edge mapEdge)
Returns the target HDMObject to which a given k-node is mapped.

Parameters:
knode -
Returns:

getK2O

public HDMObject getK2O(Node n)
Return the node object that is mapped to a given k-node

Parameters:
n -
Returns:

getKFromO

public java.util.Collection getKFromO(java.lang.Object o)
Return k-node objects that are mapped to a given node HDM object.

Parameters:
o -
Returns:

getKFromO

public java.util.Collection getKFromO(java.lang.String oscheme)

getK2Nodes

public java.util.Collection getK2Nodes()
Return the set of k-node-to-HDM object mappings in this graph.
Each mapping is represented by an Edge object.

Returns:

getObjects

public SchemaObjectI[] getObjects()
Return all HDMObjects of this graph.

Specified by:
getObjects in interface SchemaI

getObjects

public SchemaObjectI[] getObjects(java.lang.String constructName)
Specified by:
getObjects in interface SchemaI

getDependentSchemaObjects

public SchemaObjectI[] getDependentSchemaObjects(SchemaObjectI o)
Specified by:
getDependentSchemaObjects in interface SchemaI

getDependentSchemaObjects

public SchemaObjectI[] getDependentSchemaObjects(SchemaObjectI o,
                                                 java.lang.String constructName)
Specified by:
getDependentSchemaObjects in interface SchemaI

getDependentObjects

public java.util.Collection getDependentObjects(java.lang.Object o,
                                                java.lang.String construct)
Returns edge and constraint objects that reference a given node object.

Overrides:
getDependentObjects in class DataGraph
Parameters:
o -
Returns:

getDependentObjects

public java.util.Collection getDependentObjects(java.lang.Object o)
Returns edge and constraint objects that reference a given node object.

Overrides:
getDependentObjects in class DataGraph
Parameters:
o -
Returns:

getDependentKeyEdge

public HDMObject getDependentKeyEdge(HDMObject node)
Return a key edge in the neighbourhood of an HDM node object.
The search order is: first key, then candidate key

Parameters:
node -
Returns:

createSchemaObject

public SchemaObjectI createSchemaObject(SchemaObjectI so)
Parse an edge- or constraint-type SchemeInfo object to create a new HDM non-node object.

Specified by:
createSchemaObject in interface SchemaI
Parameters:
si -

addObject

public void addObject(HDMObject o)

addNodeObject

public HDMObject addNodeObject(java.lang.String schemeDef,
                               java.lang.String dtype)
Add a new HDM node object given its AutoMed scheme definition and data type.

Overrides:
addNodeObject in class DataGraph
Parameters:
schemeDef -
dtype -
Returns:

addEdgeObject

public HDMObject addEdgeObject(java.lang.String schemeDef)
Add a new HDM edge object given its AutoMed scheme definition.

Parameters:
schemeDef -
dtype -
Returns:

addEdgeObject

private HDMObject addEdgeObject(java.lang.Object[] schemeDef,
                                boolean replaceIfExist)

addEdgeObject

public HDMObject addEdgeObject(java.lang.Object[] schemeDef)
Overrides:
addEdgeObject in class DataGraph

addConstraintObject

public HDMObject addConstraintObject(java.lang.String schemeDef)
Add a new HDM constraint object given its AutoMed scheme definition.

Parameters:
schemeDef -
dtype -
Returns:

addConstraintObject

private HDMObject addConstraintObject(java.lang.Object[] schemeDef,
                                      boolean replaceIfExist)

addConstraintObject

public HDMObject addConstraintObject(java.lang.Object[] schemeDef)
Overrides:
addConstraintObject in class DataGraph

getHDMObject

protected HDMObject getHDMObject(java.lang.Object[] schemeDef,
                                 java.util.Collection objs)

createObject

public HDMObject createObject(java.lang.String schemeDef)
Recursively split an AutoMed scheme definition string into HDMObject.
Each scheme element is contained in a List object. For example:
Scheme definition string: <<S,<<_,citation_author,<<_,citation,citation_cid1>>>>,<<_,author,author_name>>>> ; is splitted into:
[S, [_, citation_author, [_, citation, citation_cid1]], [_, author, author_name]] each scheme element is then used to create an HDMObject.


getObject

public HDMObject getObject(java.lang.String schemeDef)
Find an HDM node given its AutoMed scheme definition, e.g. <<author>>

Specified by:
getObject in interface SchemaI
Parameters:
schemeDef -
Returns:

getSchemeNamesString

public java.lang.String getSchemeNamesString(HDMObject o,
                                             boolean peerID)
Returns the scheme definition of an object with the schema prefix and an option to turn on/off peer identifier.

Parameters:
o -
full -
Returns:

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class DataGraph

getName

public java.lang.String getName()
Return the name of this graph. It is also used as a unique identifier of this graph.

Specified by:
getName in interface SchemaI
Overrides:
getName in class DataGraph
Returns:

getPeer

public java.lang.String getPeer()
Description copied from interface: SchemaI
Return the peer name of this graph

Specified by:
getPeer in interface SchemaI
Returns:

getSchemaName

public java.lang.String getSchemaName()
Description copied from interface: SchemaI
Return the schema name

Specified by:
getSchemaName in interface SchemaI
Returns:

setSchemaName

public void setSchemaName(java.lang.String schema)

getModel

public java.lang.String getModel()

isSameSchema

public boolean isSameSchema(HDMGraph g)
Check that this schema comes from the same schema as another HDM graph.

Parameters:
g -
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class DataGraph

getPropertyObjects

public java.util.Collection getPropertyObjects()
Description copied from interface: GVisualisable
Must provide a collection of PropertyObject so that properties of a selected object can be displayed on the PropertyEditor

Specified by:
getPropertyObjects in interface GVisualisable
Overrides:
getPropertyObjects in class DataGraph
Returns:

getLabel

public java.lang.String getLabel()
Description copied from interface: GVisualisable
The label to be displayed next to the object on the graph

Specified by:
getLabel in interface GVisualisable
Overrides:
getLabel in class DataGraph
Returns:

setRank

public void setRank(double rank)

getRank

public double getRank()

getRankFormatted

public java.lang.String getRankFormatted()

getLength

public int getLength()
Return the length of an HDMGraph.

Overrides:
getLength in class DataGraph
Returns:

setProperty

public void setProperty(java.lang.String propName,
                        java.lang.String val)
Specified by:
setProperty in interface GVisualisable
Overrides:
setProperty in class DataGraph