Module graph

Class GraphManager

All Implemented Interfaces:
Graph, SharedObjectProvider, Lockable

public class GraphManager extends PersistenceManager implements Graph, SharedObjectProvider
  • Field Details

    • I18N

      public static final I18NBundle I18N
    • META_GRAPH

      public static final String META_GRAPH
      See Also:
    • STATIC

      public static final GraphManager STATIC
    • STATIC_STATE

      public static final GraphState STATIC_STATE
    • rate

      public double[] rate
      Stores a reference to the rate vector. When integration starts, a reference to the rate vector is stored here, so that PropertyRuntime.GraphProperty can access the rate vector.
      See Also:
      • de.grogra.rgg.model.PropertyRuntime.GraphProperty#defRateAssign()
    • baseMap

      public final LongToIntHashMap baseMap
      A mapping of each node ID (participating in integration) to an index into the rate vector is stored here. It is assumed, that all properties of a node participating in integration are stored in the rate array in a continuous block, where the start index of the block is the number stored in this mapping.
  • Constructor Details

  • Method Details

    • initMainState

      public void initMainState(Executor sync)
    • getMainState

      public GraphState getMainState()
      Description copied from interface: Graph
      Returns the main graph state. The main graph state is the only graph state within which modifications to the graph may be done. The notification of event listeners is done in the context of this state, too.
      Specified by:
      getMainState in interface Graph
      Returns:
      this graph's main graph state
      See Also:
    • getStateMap

      public Map getStateMap()
      Specified by:
      getStateMap in interface Graph
    • addChangeBoundaryListener

      public void addChangeBoundaryListener(ChangeBoundaryListener l)
      Specified by:
      addChangeBoundaryListener in interface Graph
    • removeChangeBoundaryListener

      public void removeChangeBoundaryListener(ChangeBoundaryListener l)
      Specified by:
      removeChangeBoundaryListener in interface Graph
    • addAttributeChangeListener

      public void addAttributeChangeListener(AttributeChangeListener l)
      Specified by:
      addAttributeChangeListener in interface Graph
    • addEdgeChangeListener

      public void addEdgeChangeListener(EdgeChangeListener l)
      Specified by:
      addEdgeChangeListener in interface Graph
    • removeAttributeChangeListener

      public void removeAttributeChangeListener(AttributeChangeListener l)
      Specified by:
      removeAttributeChangeListener in interface Graph
    • removeEdgeChangeListener

      public void removeEdgeChangeListener(EdgeChangeListener l)
      Specified by:
      removeEdgeChangeListener in interface Graph
    • addAttributeChangeListener

      public void addAttributeChangeListener(Object object, boolean asNode, AttributeChangeListener l)
      Specified by:
      addAttributeChangeListener in interface Graph
    • removeAttributeChangeListener

      public void removeAttributeChangeListener(Object object, boolean asNode, AttributeChangeListener l)
      Specified by:
      removeAttributeChangeListener in interface Graph
    • addEdgeChangeListener

      public void addEdgeChangeListener(Object object, boolean asNode, EdgeChangeListener l)
      Specified by:
      addEdgeChangeListener in interface Graph
    • removeEdgeChangeListener

      public void removeEdgeChangeListener(Object object, boolean asNode, EdgeChangeListener l)
      Specified by:
      removeEdgeChangeListener in interface Graph
    • setRoot

      public void setRoot(String key, Node root)
    • getRoot

      public Node getRoot()
      Returns the root node of the Graph.MAIN_GRAPH of this graph.
      Returns:
      root node of main graph
    • getRoot

      public Object getRoot(String key)
      Description copied from interface: Graph
      Returns the root node for the given root key.
      Specified by:
      getRoot in interface Graph
      Parameters:
      key - a root key, one of Graph.getRootKeys()
      Returns:
      the root node of the graph identified by key, or null if no such root node exists
      See Also:
    • getRootKeys

      public String[] getRootKeys()
      Description copied from interface: Graph
      Returns the root keys for the graph.
      Specified by:
      getRootKeys in interface Graph
      Returns:
      an array of root keys
      See Also:
    • logDataOnPersistenceChange

      public void logDataOnPersistenceChange(boolean value)
    • suppressLogging

      public void suppressLogging(boolean value)
    • createXAApplier

      protected TransactionApplier createXAApplier()
      Specified by:
      createXAApplier in class PersistenceManager
    • createTransaction

      protected Transaction createTransaction(Thread thread)
      Specified by:
      createTransaction in class PersistenceManager
    • isAllowedThread

      protected boolean isAllowedThread(boolean write)
      Overrides:
      isAllowedThread in class LockableImpl
    • executeInAllowedThread

      protected void executeInAllowedThread(Runnable r)
      Overrides:
      executeInAllowedThread in class LockableImpl
    • invokeRun

      protected void invokeRun(LockProtectedRunnable task, boolean sameThread, Lock lock)
      Overrides:
      invokeRun in class LockableImpl
    • enterWriteLock

      protected void enterWriteLock()
      Overrides:
      enterWriteLock in class LockableImpl
    • leaveWriteLock

      protected void leaveWriteLock()
      Overrides:
      leaveWriteLock in class LockableImpl
    • prepareCompletion

      protected void prepareCompletion(Transaction t, boolean commit)
      Overrides:
      prepareCompletion in class PersistenceManager
    • transactionApplied

      protected void transactionApplied(Transaction.Data xa, boolean rollback, Transaction t)
      Overrides:
      transactionApplied in class PersistenceManager
    • completeTransaction

      protected void completeTransaction(Transaction t, boolean commit)
      Overrides:
      completeTransaction in class PersistenceManager
    • setProperty

      public void setProperty(String key, Object value)
    • getProperty

      public Object getProperty(String key)
    • removeAllFromExtent

      public void removeAllFromExtent()
      Removes all nodes in graph from extent. Used when automatically generated modules are recompiled. Then instances of the modules must be replaced with new instances of the newly compiled types. Old nodes of the old modules must be removed from the extent so they are no longer referenced.
    • prepareId

      public long prepareId(PersistenceCapable node)
      Specified by:
      prepareId in class PersistenceManager
    • setMakePersistentTransitive

      public void setMakePersistentTransitive(boolean value)
    • makePersistentImpl

      public void makePersistentImpl(PersistenceCapable o, long id, Transaction t)
      Specified by:
      makePersistentImpl in class PersistenceManager
    • getExtent

      public Extent getExtent(Type type)
    • getExtent

      public Extent getExtent(Class type)
    • rebuildExtents

      public void rebuildExtents()
    • makeTransientImpl

      protected void makeTransientImpl(PersistenceCapable o, Transaction t)
      Specified by:
      makeTransientImpl in class PersistenceManager
    • getObject

      public Node getObject(long id)
      Specified by:
      getObject in class PersistenceManager
    • allocateBitMark

      public final int allocateBitMark(boolean resetOnDispose)
      Specified by:
      allocateBitMark in class PersistenceManager
    • disposeBitMark

      public final void disposeBitMark(int handle, boolean resetAll)
      Specified by:
      disposeBitMark in class PersistenceManager
    • disposeBitMark

      public final void disposeBitMark(int handle, boolean resetAll, boolean onlyNodes)
    • allocateObjectMark

      public final int allocateObjectMark(boolean resetOnDispose)
      Specified by:
      allocateObjectMark in class PersistenceManager
    • disposeObjectMark

      public final void disposeObjectMark(int handle, boolean resetAll)
      Specified by:
      disposeObjectMark in class PersistenceManager
    • disposeObjectMark

      public final void disposeObjectMark(int handle, boolean resetAll, boolean onlyNodes)
    • createBooleanMap

      public BooleanMap createBooleanMap()
      Specified by:
      createBooleanMap in interface Graph
    • createObjectMap

      public <V> ObjectMap<V> createObjectMap()
      Specified by:
      createObjectMap in interface Graph
    • writeExtent

      public void writeExtent(PersistenceOutputStream out) throws IOException
      Specified by:
      writeExtent in class PersistenceManager
      Throws:
      IOException
    • writeExtent

      public void writeExtent(GraphOutput out, Node root) throws IOException
      Throws:
      IOException
    • writeExtentWithoutTopology

      public void writeExtentWithoutTopology(GraphOutput out) throws IOException
      Dump the whole graph into out. Nodes are visited without considering their topology
      Parameters:
      out -
      Throws:
      IOException
    • readExtent

      public void readExtent(PersistenceInputStream in) throws IOException
      Specified by:
      readExtent in class PersistenceManager
      Throws:
      IOException
    • addSharedObjectListener

      public void addSharedObjectListener(PropertyChangeListener l)
    • removeSharedObjectListener

      public void removeSharedObjectListener(PropertyChangeListener l)
    • accept

      public final void accept(Object start, Visitor v, ArrayPath placeInPath)
      Specified by:
      accept in interface Graph
    • acceptGraph

      public static void acceptGraph(Node root, Visitor v, ArrayPath pathToUse)
    • createStaticState

      public GraphState createStaticState(ThreadContext tc)
    • getParentAttribute

      public ObjectAttribute getParentAttribute()
      Description copied from interface: Graph
      Defines the derived attribute which has as value the parent object.
      Specified by:
      getParentAttribute in interface Graph
      Returns:
      the parent attribute
      See Also:
    • getTreePattern

      public EdgePattern getTreePattern()
      Description copied from interface: Graph
      Defines the pattern used for the construction of this graph's tree.
      Specified by:
      getTreePattern in interface Graph
      Returns:
      an edge pattern
      See Also:
    • getProviderName

      public String getProviderName()
      Specified by:
      getProviderName in interface SharedObjectProvider
    • readReference

      public ResolvableReference readReference(PersistenceInput in) throws IOException
      Specified by:
      readReference in interface SharedObjectProvider
      Throws:
      IOException
    • writeObject

      public void writeObject(Shareable object, PersistenceOutput out) throws IOException
      Specified by:
      writeObject in interface SharedObjectProvider
      Throws:
      IOException
    • addMetaNode

      public void addMetaNode(Node node, Transaction t)
    • removeMetaNode

      public void removeMetaNode(Node node, Transaction t)
    • getLifeCycleState

      public int getLifeCycleState(Object object, boolean asNode)
      Description copied from interface: Graph
      Returns the life cycle state of the given object as part of this graph.
      Specified by:
      getLifeCycleState in interface Graph
      Parameters:
      object - the object to test
      asNode - true if object is a node, false if object is an edge
      Returns:
      life cycle state, one of Graph.PERSISTENT, Graph.PERSISTENT_DELETED, Graph.TRANSIENT
    • getName

      public String getName(Object object, boolean asNode)
      Description copied from interface: Graph
      Returns a name for the given object. Names are not necessarily unique.
      Specified by:
      getName in interface Graph
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      Returns:
      a name
      See Also:
    • getId

      public long getId(Object node)
      Description copied from interface: Graph
      Returns a unique identifier for the given node.
      Specified by:
      getId in interface Graph
      Parameters:
      node - a node
      Returns:
      the node's unique identifier
      See Also:
    • getNodeForId

      public Object getNodeForId(long id)
      Description copied from interface: Graph
      Returns the node identified by id.
      Specified by:
      getNodeForId in interface Graph
      Parameters:
      id - an identifier
      Returns:
      the corresponding node, or null if id identifies no node
      See Also:
    • getObjectForName

      public Object getObjectForName(boolean node, String name)
      Description copied from interface: Graph
      Returns the object with the given name. If several such objects exist, one of them is chosen in an unspecified manner. If no such object exists, null is returned.
      Specified by:
      getObjectForName in interface Graph
      Parameters:
      node - true if a node of the given name is to be found, false if an edge is to be found
      name - the name of the object
      Returns:
      an object of the given kind (node or edge) with the given name, or null if no such object exists
      See Also:
    • getNodeForName

      public Node getNodeForName(String name)
    • getDescription

      public Object getDescription(Object object, boolean asNode, String type)
      Description copied from interface: Graph
      Returns a description for the given object. The type of the desired description (e.g., text, icon) is specified in the argument type; it is interpreted as in Described.getDescription(String).
      Specified by:
      getDescription in interface Graph
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      type - the type of description
      Returns:
      a description of the given type, or null
    • getSpecialEdgeDescriptors

      public SpecialEdgeDescriptor[] getSpecialEdgeDescriptors(Object node, boolean asSource)
      Specified by:
      getSpecialEdgeDescriptors in interface Graph
    • getSymbol

      public int getSymbol(Object object, boolean asNode)
      Specified by:
      getSymbol in interface Graph
    • getColor

      public int getColor(Object object, boolean asNode)
      Specified by:
      getColor in interface Graph
    • getAttributes

      public Attribute[] getAttributes(Object object, boolean asNode)
      Description copied from interface: Graph
      Returns the set of attributes which are available for the given object.
      Specified by:
      getAttributes in interface Graph
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      Returns:
      the object's attributes
    • getDependent

      public Attribute[] getDependent(Object object, boolean asNode, Attribute a)
      Description copied from interface: Graph
      Returns the set of attributes whose values depend on the given attribute a for the given object.
      Specified by:
      getDependent in interface Graph
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute
      Returns:
      the set of dependent attributes
    • getAccessor

      public AttributeAccessor getAccessor(Object object, boolean asNode, Attribute attribute)
      Description copied from interface: Graph
      Returns an attribute accessor for the given attribute on the given object.
      Specified by:
      getAccessor in interface Graph
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      attribute - the attribute
      Returns:
      an accessor for the object's attribute value
    • getFirstEdge

      public Object getFirstEdge(Object node)
      Description copied from interface: Graph
      Returns the first edge of the linked list of edges of node.
      Specified by:
      getFirstEdge in interface Graph
      Parameters:
      node - the common node of the edges of the linked list
      Returns:
      the first edge of the linked list
      See Also:
    • getInstantiator

      public Instantiator getInstantiator(Object node)
      Specified by:
      getInstantiator in interface Graph
    • getEdgeBits

      public int getEdgeBits(Object edge)
      Description copied from interface: Graph
      Returns the edge bits of an edge.
      Specified by:
      getEdgeBits in interface Graph
      Parameters:
      edge - the edge
      Returns:
      the edge's edge bits
      See Also:
    • getSourceNode

      public Object getSourceNode(Object edge)
      Description copied from interface: Graph
      Returns the source node of edge.
      Specified by:
      getSourceNode in interface Graph
      Parameters:
      edge - an edge
      Returns:
      the source node
      See Also:
    • getTargetNode

      public Object getTargetNode(Object edge)
      Description copied from interface: Graph
      Returns the target node of edge.
      Specified by:
      getTargetNode in interface Graph
      Parameters:
      edge - an edge
      Returns:
      the target node
      See Also:
    • getNextEdge

      public Object getNextEdge(Object edge, Object parentNode)
      Description copied from interface: Graph
      Returns the edge after edge in the linked list of edges of node.
      Specified by:
      getNextEdge in interface Graph
      Parameters:
      edge - the previous edge in the linked list
      parentNode - the common node of the edges of the linked list
      Returns:
      the next edge of the linked list
      See Also:
    • dumpNodeStatistics

      public void dumpNodeStatistics(PrintWriter out)
    • dumpNodeStatistics

      public void dumpNodeStatistics(OutputStream out)
    • toXLString

      public String toXLString(boolean qualified, boolean ids)
      Parses the GraphManager.MAIN_GRAPH and generates a textual representation of it. with classes and id's
      Parameters:
      qualified -
      ids -
      Returns:
    • toXLString

      public String toXLString(boolean qualified)
      Parses the GraphManager.MAIN_GRAPH and generates a textual representation of it. with classes
      Parameters:
      qualified -
      Returns:
    • toXLString

      public String toXLString(boolean qualified, String rootKey, boolean ids)
      Parses the graph from the rootKey and generates a textual representation of it.
      Parameters:
      qualified -
      rootKey - {GraphManager.MAIN_GRAPH, GraphManager.META_GRAPH, GraphManager.COMPONENT_GRAPH}
      Returns:
    • getGraphSize

      public int getGraphSize(String key)
      Number of nodes of the specified graph.
      Parameters:
      key - graph identification key (one of: MAIN_GRAPH, COMPONENT_GRAPH, META_GRAPH)
      Returns:
    • getGraphSize

      public int getGraphSize()
      Number of nodes in the main graph. same as count((* Node *))
      Returns:
    • getMetaGraphSize

      public int getMetaGraphSize()
      Number of nodes in the meta graph.
      Returns:
    • getListOfNodes

      public void getListOfNodes(Node node, Edge edge, boolean branch, HashMap<Node,String> visited, ObjectList<Node> toVisit)
      Parameters:
      node - start node
      edge -
      branch -
      visited - list of visited nodes
      toVisit - list of all nodes
    • contains

      public boolean contains(Node root, String name)
      Check if the graph contains a node with the specified name.
      Parameters:
      root - String name
      name - Node root
      Returns:
      true, if the graph starting with root contains a node with the specified name
    • getNodeForName

      public Node getNodeForName(Node root, String name)
      Check if the graph contains a node with the specified name and possibly returns it.
      Parameters:
      String - name
      Node - root
      Returns:
      node, if the graph starting with root contains a node with the specified name
    • getSRoot

      public Node getSRoot()
      Returns the root of the Structure of scales
      Parameters:
      g - GraphManager (i.e. the graph) instance
      Returns:
      the root of the Structure of scales
    • getScales

      public void getScales(ArrayList<ScaleClass> scales)
    • getScalesInternal

      public void getScalesInternal(Node node, ArrayList<ScaleClass> scales)
    • getTypeRoot

      public Node getTypeRoot()
      Returns the root of the type graph for the graph
      Parameters:
      g - GraphManager (i.e. the graph) instance
      Returns:
      the root of the type graph for the graph
    • getTypeNode

      public Object getTypeNode(Node node)
      Get node in type graph representing the type of the input node
      Parameters:
      node -
      Returns:
      node from type graph representing type of input node
    • getScaleValue

      public int getScaleValue(Node node)
      Get node in type graph representing the type of the input node
      Parameters:
      node -
      Returns:
      node from type graph representing type of input node
    • getVisibleScales

      public boolean[] getVisibleScales()
    • setVisibleScales

      public void setVisibleScales(boolean[] visibleScales)
    • replaceInGraph

      public void replaceInGraph(Node node, Node toBeReplaced, Transaction xa)
      method to replace the node (toBeReplaced) by the node (node) in the graph. I.e. by replacing all edges. Warning: endless loop when replaced happens in visitor. The newly created nodes should be ignored