SPT Object Database API

com.sptci.prevayler
Class RelationStorage

java.lang.Object
  extended by com.sptci.prevayler.RelationStorage
All Implemented Interfaces:
Serializable

public class RelationStorage
extends Object
implements Serializable

A store for maintaining the relations between a prevalent object and the other prevalent objects in the prevalent system. This store is consulted for determining the actions to be performed when deleting prevalent objects. This store is mainly responsible for enforcing managed relations between prevalent objects.

© Copyright 2008 Sans Pareil Technologies, Inc.

Version:
$Id: RelationStorage.java 4345 2008-06-30 21:22:03Z rakesh $
Author:
Rakesh Vidyadharan 2008-05-23
See Also:
Serialized Form

Nested Class Summary
private  class RelationStorage.DeleteRule
          A class used to capture the names of the fields in a prevalent object that are related to the prevalent object being managed by this store.
 
Field Summary
private  String className
          The name of the prevalent object whose relations are being mapped.
private  Map<String,RelationStorage.DeleteRule> map
          A map used to store the meta data associated with a prevalent object.
private static long serialVersionUID
           
 
Constructor Summary
RelationStorage(String name)
          Create a new instance of the storage for the specified class name.
 
Method Summary
 void add(PrevalentObject object, String field, ForeignKey.DeleteAction action)
          A a new relationship to the store for the specified prevalent object.
 String getClassName()
          Return the fully qualified class name of the prevalent object for which the reference relations are being stored.
 Map<String,ForeignKey.DeleteAction> getDeleteRules(String name)
          Return a map of field name of delete actions for the specified prevalent class with which the class being managed has relations.
 Collection<String> getRelations()
          Return the names of the classes that hold a reference to the prevalent class that is being managed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

map

private final Map<String,RelationStorage.DeleteRule> map
A map used to store the meta data associated with a prevalent object. The key to the map is the type of prevalent object, while the value is a ForeignKey.DeleteAction object that defines the action to be applied.


className

private final String className
The name of the prevalent object whose relations are being mapped.

Constructor Detail

RelationStorage

public RelationStorage(String name)
Create a new instance of the storage for the specified class name.

Parameters:
name - The className value to use.
Method Detail

add

public void add(PrevalentObject object,
                String field,
                ForeignKey.DeleteAction action)
A a new relationship to the store for the specified prevalent object.

Parameters:
object - The prevalent object that is related to the prevalent object identified by className.
field - The name of the field in object that is an instance of type className.
action - The delete action to use on the fiele when the instance of type className is deleted.

getRelations

public Collection<String> getRelations()
Return the names of the classes that hold a reference to the prevalent class that is being managed.

Returns:
The collection of class names that hold references to instances of the managed class.

getDeleteRules

public Map<String,ForeignKey.DeleteAction> getDeleteRules(String name)
Return a map of field name of delete actions for the specified prevalent class with which the class being managed has relations.

Parameters:
name - The name of prevalent class with which relations are maintained.
Returns:
A map of field-delete rule mappings. Returns an empty map if no rules exist for the specified class.
See Also:
RelationStorage.DeleteRule.getRules()

getClassName

public String getClassName()
Return the fully qualified class name of the prevalent object for which the reference relations are being stored.

Returns:
The className value.

SPT Object Database API