i3.dragos.gm.core.proxy
Class GraphProxy

java.lang.Object
  extended by i3.dragos.gm.core.proxy.GraphEntityProxy
      extended by i3.dragos.gm.core.proxy.GraphProxy
All Implemented Interfaces:
Graph, GraphEntity, ExistenceCheckable, MetaAttributable

public class GraphProxy
extends GraphEntityProxy
implements Graph

A GraphProxy delegates all method calls to the underlying graph except for those that access fields which are used after a graph has been deleted.

Author:
Boris Boehlen <boehlen@cs.rwth-aachen.de>

Field Summary
 
Fields inherited from class i3.dragos.gm.core.proxy.GraphEntityProxy
proxiedEntity
 
Constructor Summary
GraphProxy(Graph g)
          Constructs a new wrapper for a graph.
 
Method Summary
 void clear()
          Removes everything in the graph.
 boolean contains(GraphEntity ge)
          Returns true if the specified graph element is in the graph.
 Edge createEdge(GraphEntity source, GraphEntity target, EdgeClass type)
          Creates a new edge between the specified source and target graph element, which will belong to this graph and returns it.
 Graph createGraph(GraphClass type)
          Creates a new graph, which will belong to this graph, and returns it.
 Node createNode(NodeClass type)
          Creates a new node, which will belong to this graph and returns it.
 Relation createRelation(RelationClass type)
          Creates a new relation, which will belong to this graph and returns it.
 java.util.Collection<? extends Edge> getAllEdgesOfGraph()
          Returns a collection containing all edges stored in the graph.
 java.util.Collection<? extends Edge> getAllEdgesOfGraph(EdgeClass type, boolean includeSubClasses)
          Returns a collection containing all edges of the specified type stored in the graph.
 java.util.Collection<? extends GraphEntity> getAllGraphEntitiesOfGraph()
          Returns a collection containing all graph entities stored in the graph.
 java.util.Collection<? extends GraphEntity> getAllGraphEntitiesOfGraph(GraphEntityClass type, boolean includeSubClasses)
          Returns a collection containing all graph entities of the specified type stored in the graph.
 java.util.Collection<? extends Graph> getAllGraphsOfGraph()
          Returns a collection containing all graphs stored in the graph.
 java.util.Collection<? extends Graph> getAllGraphsOfGraph(GraphClass type, boolean includeSubClasses)
          Returns a collection containing the graphs of the specified type stored in the graph.
 java.util.Collection<? extends Node> getAllNodesOfGraph()
          Returns a collection containing all nodes stored in the graph.
 java.util.Collection<? extends Node> getAllNodesOfGraph(NodeClass type, boolean includeSubClasses)
          Returns a collection containing all nodes of the specified type stored in the graph.
 java.util.Collection<? extends Relation> getAllRelationsOfGraph()
          Returns a collection containing all relations stored in the graph.
 java.util.Collection<? extends Relation> getAllRelationsOfGraph(RelationClass type, boolean includeSubClasses)
          Returns a collection containing all relations of the specified type stored in the graph.
 GraphClass getGraphClass()
          Returns the type of the graph.
 java.util.Collection<? extends GraphEntity> getGraphEntitiesByAttributeValue(Attribute attribute, java.io.Serializable value)
          Returns a collection of graph elements (GraphEntity) which have the requested value for the attribute.
 java.lang.String getName()
          Returns the name of the graph.
 boolean hasParent()
          Returns true if the graph is contained in another graph, false otherwise.
 boolean isEmpty()
          Returns true if not even a single graph element (graph, node, edge, etc) is contained in the graph.
 void removeAllEdges()
          Removes all edges froms the graph.
 void removeAllEdges(EdgeClass type, boolean includeSubClasses)
          Removes all edges of the specified type from the graph.
 void removeAllGraphs()
          Removes all graphs froms the graph.
 void removeAllGraphs(GraphClass type, boolean includeSubClasses)
          Removes all graphs of the specified type from the graph.
 void removeAllNodes()
          Removes all nodes froms the graph.
 void removeAllNodes(NodeClass type, boolean includeSubClasses)
          Removes all nodes of the specified type from the graph.
 void removeAllRelations()
          Removes all relations froms the graph.
 void removeAllRelations(RelationClass type, boolean includeSubClasses)
          Removes all relations of the specified type from the graph.
 void removeGraphEntity(GraphEntity graphEntity)
          Removes the graph entity from this graph.
 
Methods inherited from class i3.dragos.gm.core.proxy.GraphEntityProxy
checkExistence, checkExistenceOptional, equals, getAdjacentGraphEntities, getAdjacentRelations, getAdjacentRelations, getAllMetaAttributes, getAllValidAttributeValues, getAttributeValue, getDataSourceURL, getEdges, getEdges, getGraphEntityClass, getInternalIdentifier, getMetaAttribute, getParent, getProxyGraphEntity, getRelationEnds, getRelationEnds, getRelationEnds, getWrappedGraphEntity, hashCode, isAttributeValid, isIncident, isIncident, isMetaAttributeKeyReserved, isMetaAttributeSet, putAttributeValue, setAttributeInvalid, setMetaAttribute, toString, unsetMetaAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface i3.dragos.gm.core.GraphEntity
equals, getAdjacentGraphEntities, getAdjacentRelations, getAdjacentRelations, getAllValidAttributeValues, getAttributeValue, getDataSourceURL, getEdges, getEdges, getGraphEntityClass, getInternalIdentifier, getParent, getRelationEnds, getRelationEnds, getRelationEnds, getWrappedGraphEntity, hashCode, isAttributeValid, isIncident, isIncident, putAttributeValue, setAttributeInvalid
 
Methods inherited from interface i3.dragos.gm.core.schema.MetaAttributable
getAllMetaAttributes, getMetaAttribute, isMetaAttributeKeyReserved, isMetaAttributeSet, setMetaAttribute, unsetMetaAttribute
 
Methods inherited from interface i3.dragos.gm.core.schema.ExistenceCheckable
checkExistence, checkExistenceOptional
 

Constructor Detail

GraphProxy

public GraphProxy(Graph g)
Constructs a new wrapper for a graph.

Parameters:
g - The graph to wrap.
Method Detail

getGraphClass

public GraphClass getGraphClass()
                         throws DragosException
Returns the type of the graph.

Specified by:
getGraphClass in interface Graph
Returns:
the GraphClass.
Throws:
DragosException - if something went wrong.

getName

public java.lang.String getName()
Returns the name of the graph. For non top-level graphs null is always returned.

Specified by:
getName in interface Graph
Returns:
the name of the graph.

hasParent

public boolean hasParent()
                  throws DragosException
Returns true if the graph is contained in another graph, false otherwise.

Specified by:
hasParent in interface Graph
Returns:
true if the graph is contained in another graph, false otherwise.
Throws:
DragosException - if something went wrong.

isEmpty

public boolean isEmpty()
                throws DragosException
Returns true if not even a single graph element (graph, node, edge, etc) is contained in the graph.

Specified by:
isEmpty in interface Graph
Returns:
true if the graph is empty, false otherwise.
Throws:
DragosException - if something went wrong.

clear

public void clear()
           throws DragosException
Removes everything in the graph.

Note: This method follows the same rules as the methods for removing edges, nodes, graphs and relations individually!

Specified by:
clear in interface Graph
Throws:
DragosException - if something went wrong.

contains

public boolean contains(GraphEntity ge)
                 throws DragosException
Returns true if the specified graph element is in the graph.

Specified by:
contains in interface Graph
Parameters:
ge - The requested graph element (must not be null).
Returns:
true if the graph element is contained in the graph and false otherwise.
Throws:
DragosException - if anything went wrong.

removeGraphEntity

public void removeGraphEntity(GraphEntity graphEntity)
                       throws EntityNotFoundException,
                              DragosException
Removes the graph entity from this graph.

Deletion proceeds as follows:

  1. All relation ends connected to the graph entity (as determined by GraphEntity.getRelationEnds(ConnectionMode) using ConnectionMode.ANY_SET as parameter) are removed.
  2. All edges connected to the graph entity are removed.
  3. If the entity to remove is a Graph, it will be cleared using Graph.clear().
  4. If the entity to remove is a Relation, all its RelationEnds are removed using Relation.removeAllRelationEndsOfRelation().
  5. All attributes are removed.
  6. All meta attributes are removed.
  7. The entity itself is deleted.

Implementation notice: Some edges and relation ends might already be deleted due to cascading removal of entities processed before, so take care when iterating through the instances.

Specified by:
removeGraphEntity in interface Graph
Parameters:
graphEntity - The graph, which shall be deleted.
Throws:
EntityNotFoundException - if the graph entity could not be found in the graph.
DragosException - if something else went wrong.

getAllGraphEntitiesOfGraph

public java.util.Collection<? extends GraphEntity> getAllGraphEntitiesOfGraph()
                                                                       throws EntityNotFoundException,
                                                                              DragosException
Returns a collection containing all graph entities stored in the graph.

Specified by:
getAllGraphEntitiesOfGraph in interface Graph
Returns:
A collection containing the all graph entities contained in the graph (ignoring sub graphs).
Throws:
DragosException - if anything went wrong.
EntityNotFoundException

getAllGraphEntitiesOfGraph

public java.util.Collection<? extends GraphEntity> getAllGraphEntitiesOfGraph(GraphEntityClass type,
                                                                              boolean includeSubClasses)
                                                                       throws EntityNotFoundException,
                                                                              DragosException
Returns a collection containing all graph entities of the specified type stored in the graph.

Specified by:
getAllGraphEntitiesOfGraph in interface Graph
Parameters:
type - The type of the edges (null means "any type").
includeSubClasses - If and only if true, this method will also match graph entities whose GraphEntityClass is a subclass of the specified type.
Returns:
A collection containing all graph entities of the specified type contained in the graph (ignoring sub graphs).
Throws:
EntityNotFoundException - if the requested type could not be found.
DragosException - if anything went wrong.

createGraph

public Graph createGraph(GraphClass type)
                  throws EntityNotFoundException,
                         DragosException,
                         java.lang.IllegalArgumentException
Creates a new graph, which will belong to this graph, and returns it. The graph will have the requested type.

Since graphs created in other graphs are not top-level graphs, their name will be null by definition.

Specified by:
createGraph in interface Graph
Parameters:
type - The graph's type.
Returns:
the new graph which is a sub-graph of this one.
Throws:
EntityNotFoundException - if the type for the graph couldn't be found.
GraphEntityInstantiationException - if type is declared as an abstract class.
DragosException - if something else went wrong.
java.lang.IllegalArgumentException - if type is null.

removeAllGraphs

public void removeAllGraphs(GraphClass type,
                            boolean includeSubClasses)
                     throws EntityNotFoundException,
                            DragosException
Removes all graphs of the specified type from the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllGraphs in interface Graph
Parameters:
type - The type of the graphs to be deleted (null means "any type").
includeSubClasses - If and only if true, this method will also match graphs whose graph class is a subclass of the specified type.
Throws:
EntityNotFoundException - if the type could not be found.
DragosException - if something else went wrong.

removeAllGraphs

public void removeAllGraphs()
                     throws DragosException
Removes all graphs froms the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllGraphs in interface Graph
Throws:
DragosException - if anything went wrong.

getAllGraphsOfGraph

public java.util.Collection<? extends Graph> getAllGraphsOfGraph(GraphClass type,
                                                                 boolean includeSubClasses)
                                                          throws EntityNotFoundException,
                                                                 DragosException
Returns a collection containing the graphs of the specified type stored in the graph.

Specified by:
getAllGraphsOfGraph in interface Graph
Parameters:
type - The type of the graphs (null means "any type").
includeSubClasses - If and only if true, this method will also match graphs whose GraphClass is a subclass of the specified type.
Returns:
A collection containing all graphs of the specified type contained in the graph (ignoring sub graphs).
Throws:
EntityNotFoundException - if the requested type could not be found.
DragosException - if anything went wrong.

getAllGraphsOfGraph

public java.util.Collection<? extends Graph> getAllGraphsOfGraph()
                                                          throws DragosException
Returns a collection containing all graphs stored in the graph.

Specified by:
getAllGraphsOfGraph in interface Graph
Returns:
A collection containing all graphs contained in the graph (ignoring sub graphs).
Throws:
DragosException - if anything went wrong.

createNode

public Node createNode(NodeClass type)
                throws EntityNotFoundException,
                       DragosException,
                       java.lang.IllegalArgumentException
Creates a new node, which will belong to this graph and returns it. The node will have the requested type.

Specified by:
createNode in interface Graph
Parameters:
type - The type of the new node.
Returns:
the new node.
Throws:
EntityNotFoundException - if the type for the node couldn't be found.
GraphEntityInstantiationException - if type is declared as an abstract class.
DragosException - if something else went wrong.
java.lang.IllegalArgumentException - if type is null.

removeAllNodes

public void removeAllNodes(NodeClass type,
                           boolean includeSubClasses)
                    throws EntityNotFoundException,
                           DragosException
Removes all nodes of the specified type from the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllNodes in interface Graph
Parameters:
type - The type of the nodes to be deleted (null means "any type").
includeSubClasses - If and only if true, this method will also match nodes whose NodeClass is a subclass of the specified type.
Throws:
EntityNotFoundException - if the type could not be found.
DragosException - if something else went wrong.

removeAllNodes

public void removeAllNodes()
                    throws EntityInUseException,
                           DragosException
Removes all nodes froms the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllNodes in interface Graph
Throws:
EntityInUseException - if one of the nodes is in use.
DragosException - if anything went wrong.

getAllNodesOfGraph

public java.util.Collection<? extends Node> getAllNodesOfGraph(NodeClass type,
                                                               boolean includeSubClasses)
                                                        throws EntityNotFoundException,
                                                               DragosException
Returns a collection containing all nodes of the specified type stored in the graph.

Specified by:
getAllNodesOfGraph in interface Graph
Parameters:
type - The type of the nodes (null means "any type").
includeSubClasses - If and only if true, this method will also match nodes whose NodeClass is a subclass of the specified type.
Returns:
A collection containing the all nodes of the specified type contained in the graph (ignoring sub graphs).
Throws:
EntityNotFoundException - if the requested type could not be found.
DragosException - if anything went wrong.

getAllNodesOfGraph

public java.util.Collection<? extends Node> getAllNodesOfGraph()
                                                        throws DragosException
Returns a collection containing all nodes stored in the graph.

Specified by:
getAllNodesOfGraph in interface Graph
Returns:
A collection containing the all nodes contained in the graph (ignoring sub graphs).
Throws:
DragosException - if anything went wrong.

createEdge

public Edge createEdge(GraphEntity source,
                       GraphEntity target,
                       EdgeClass type)
                throws EntityNotFoundException,
                       DragosException,
                       java.lang.IllegalArgumentException
Creates a new edge between the specified source and target graph element, which will belong to this graph and returns it. The edge will have the requested type. Source and target may be contained in any graph, as long as they are in the same graph pool as this graph.

Specified by:
createEdge in interface Graph
Parameters:
source - The source graph element of the edge (may be null).
target - The target graph element of the edge (may be null).
type - The type of the new edge (must not be null).
Returns:
the new edge.
Throws:
EntityNotFoundException - if the source or the target were not null and could not be found, or if the type for the edge could not be found.
GraphEntityInstantiationException - if type is declared as an abstract class.
DragosException - if something else went wrong.
java.lang.IllegalArgumentException - if type is null.

removeAllEdges

public void removeAllEdges(EdgeClass type,
                           boolean includeSubClasses)
                    throws EntityNotFoundException,
                           DragosException
Removes all edges of the specified type from the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllEdges in interface Graph
Parameters:
type - The type of the edges to be deleted (null means "any type").
includeSubClasses - If and only if true, this method will also match edges whose EdgeClass is a subclass of the specified type.
Throws:
EntityNotFoundException - if the type could not be found.
DragosException - if something else went wrong.

removeAllEdges

public void removeAllEdges()
                    throws EntityInUseException,
                           DragosException
Removes all edges froms the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllEdges in interface Graph
Throws:
EntityInUseException - if one of the edges is in use.
DragosException - if anything went wrong.

getAllEdgesOfGraph

public java.util.Collection<? extends Edge> getAllEdgesOfGraph(EdgeClass type,
                                                               boolean includeSubClasses)
                                                        throws EntityNotFoundException,
                                                               DragosException
Returns a collection containing all edges of the specified type stored in the graph.

Specified by:
getAllEdgesOfGraph in interface Graph
Parameters:
type - The type of the edges (null means "any type").
includeSubClasses - If and only if true, this method will also match edges whose EdgeClass is a subclass of the specified type.
Returns:
A collection containing all edges of the specified type contained in the graph (ignoring sub graphs).
Throws:
EntityNotFoundException - if the requested type could not be found.
DragosException - if anything went wrong.

getAllEdgesOfGraph

public java.util.Collection<? extends Edge> getAllEdgesOfGraph()
                                                        throws DragosException
Returns a collection containing all edges stored in the graph.

Specified by:
getAllEdgesOfGraph in interface Graph
Returns:
A collection containing all edges contained in the graph (ignoring sub graphs).
Throws:
DragosException - if anything went wrong.

createRelation

public Relation createRelation(RelationClass type)
                        throws EntityNotFoundException,
                               DragosException,
                               java.lang.IllegalArgumentException
Creates a new relation, which will belong to this graph and returns it. The relation will have the requested type.

Specified by:
createRelation in interface Graph
Parameters:
type - The type of the new relation.
Returns:
the new relation.
Throws:
EntityNotFoundException - if the type for the relation couldn't be found.
GraphEntityInstantiationException - if type is declared as an abstract class.
DragosException - if something else went wrong.
java.lang.IllegalArgumentException - if type is null.

removeAllRelations

public void removeAllRelations(RelationClass type,
                               boolean includeSubClasses)
                        throws EntityNotFoundException,
                               DragosException
Removes all relations of the specified type from the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllRelations in interface Graph
Parameters:
type - The type of the relations to be deleted (null means "any type").
includeSubClasses - If and only if true, this method will also match relations whose RelationClass is a subclass of the specified type.
Throws:
EntityNotFoundException - if the type could not be found.
DragosException - if something else went wrong.

removeAllRelations

public void removeAllRelations()
                        throws EntityInUseException,
                               DragosException
Removes all relations froms the graph. See Graph.removeGraphEntity(GraphEntity) for details.

Specified by:
removeAllRelations in interface Graph
Throws:
EntityInUseException - if one of the edges is in use.
DragosException - if anything went wrong.

getAllRelationsOfGraph

public java.util.Collection<? extends Relation> getAllRelationsOfGraph(RelationClass type,
                                                                       boolean includeSubClasses)
                                                                throws EntityNotFoundException,
                                                                       DragosException
Returns a collection containing all relations of the specified type stored in the graph.

Specified by:
getAllRelationsOfGraph in interface Graph
Parameters:
type - The type of the relations (null means "any type").
includeSubClasses - If and only if true, this method will also match relations whose RelationClass is a subclass of the specified type.
Returns:
A collection containing all relations of the specified type contained in the graph (ignoring sub graphs).
Throws:
EntityNotFoundException - if the requested type could not be found.
DragosException - if anything went wrong.

getAllRelationsOfGraph

public java.util.Collection<? extends Relation> getAllRelationsOfGraph()
                                                                throws DragosException
Returns a collection containing all relations stored in the graph.

Specified by:
getAllRelationsOfGraph in interface Graph
Returns:
A collection containing all relations contained in the graph (ignoring sub graphs).
Throws:
DragosException - if anything went wrong.

getGraphEntitiesByAttributeValue

public java.util.Collection<? extends GraphEntity> getGraphEntitiesByAttributeValue(Attribute attribute,
                                                                                    java.io.Serializable value)
                                                                             throws EntityNotFoundException,
                                                                                    DragosException
Returns a collection of graph elements (GraphEntity) which have the requested value for the attribute.

Specified by:
getGraphEntitiesByAttributeValue in interface Graph
Parameters:
attribute - The attribute.
value - The requested value. May be null.
Returns:
collection of graph elements (GraphEntity) which have the requested value for the attribute.
Throws:
EntityNotFoundException - if the attribute could not be found.
DragosException - if anything went wrong.


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.