|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.prevayler.StorageSystem
com.sptci.prevayler.IndexSystem
com.sptci.prevayler.ConstraintSystem
abstract class ConstraintSystem
System that abstracts all constraint enforcing rules for the prevalent system.
© Copyright 2008 Sans Pareil Technologies, Inc.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sptci.prevayler.StorageSystem |
|---|
StorageSystem.TaskQueue |
| Field Summary | |
|---|---|
private static long |
serialVersionUID
|
| Fields inherited from class com.sptci.prevayler.StorageSystem |
|---|
logger |
| Constructor Summary | |
|---|---|
ConstraintSystem()
|
|
| Method Summary | |
|---|---|
private void |
addReference(PrevalentObject object,
ForeignKey key,
String name)
Maintain the reference relationships between the specified prevalent object and any other prevalent object the object references. |
private void |
cascadeDelete(String className,
String field,
PrevalentObject object,
Date executionTime)
Cascade delete all objects that hold a reference to the specified prevalent object. |
protected void |
checkFields(PrevalentObject object)
Over-ridden to check for ForeignKey
annotation and check for unique constraint violations. |
private void |
checkForeignKey(ForeignKey key,
PrevalentObject object)
Check the ForeignKey annotation
and check for unique constraint violations. |
private void |
checkForeignKeys(PrevalentObject object)
Check the ForeignKeys annotation
for the prevalent class and perform actions as necessary. |
private void |
checkNull(PrevalentObject object)
Check the NotNull annotation on
the prevalent object and its fields and throw exceptions if necessary. |
private void |
checkNull(String member,
PrevalentObject object)
Check the value of the member identified by the name specified in the prevalent object for null value. |
private void |
checkNullFields(PrevalentObject object)
Check all the fields in the prevalent object to see if they have been annotated with the NotNull
annotation. |
protected void |
checkUnique(Field field,
PrevalentObject parent,
PrevalentObject child)
Check the specified child prevalent object to see if a unique constraint is defined on the parent object. |
protected void |
checkUnique(PrevalentObject object)
Over-ridden to process any ForeignKeys
and ForeignKey annotations. |
protected void |
indexClass(PrevalentObject object)
Over-ridden to process the foreign key annotations on the prevalent object and manage the @link StorageSystsem#indexMap} as appropriate. |
protected void |
indexFields(PrevalentObject object)
Over-ridden to process ForeignKey
annotations on the fields of the specified prevalent object and manage
the StorageSystem.indexMap as appropriate. |
private void |
nullReference(String className,
String field,
PrevalentObject object)
Set the field in className that refers to
object to null. |
protected void |
preAdd(PrevalentObject object)
Check the prevalent object specified to ensure that it may be safely added to the prevalent system. |
protected void |
preDelete(PrevalentObject object,
Date executionTime)
Process any delete constraints configured for the specified prevalent object. |
protected void |
preDelete(String className,
PrevalentObject object,
Date executionTime)
Check the foreign key relationship from instances of the specified class to the prevalent object specified and process as necessary. |
private void |
processForeignKey(ForeignKey key,
PrevalentObject object)
Process the foreign key annotation for a field declared at the prevalent class level and manage the StorageSystem.indexMap as appropriate. |
private void |
processForeignKeys(PrevalentObject object)
Process the foreign keys annotation for the prevalent class. |
protected void |
remove(PrevalentObject object)
Over-ridden to remove the references to the prevalent object being removed from the system from the reference storage container. |
| Methods inherited from class com.sptci.prevayler.IndexSystem |
|---|
index |
| Methods inherited from class com.sptci.prevayler.StorageSystem |
|---|
generateOid, getIndexStorage, getIndexStorage, getPrimaryStorage, getPrimaryStorage, getReferenceStorage, getReferenceStorage, getRelationStorage, getRelationStorage, getTaskQueue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sptci.prevayler.DatabaseSystem |
|---|
delete, save |
| Methods inherited from interface com.sptci.prevayler.AbstractDatabase |
|---|
count, fetch, fetch, fetch, fetchIntersection, fetchUnion, search |
| Field Detail |
|---|
private static final long serialVersionUID
| Constructor Detail |
|---|
ConstraintSystem()
| Method Detail |
|---|
protected void preAdd(PrevalentObject object)
throws PrevalentException
object - The prevalent object to check.
PrevalentException - If the checking fails.checkUnique(com.sptci.prevayler.PrevalentObject)
protected void preDelete(PrevalentObject object,
Date executionTime)
throws PrevalentException
object - The prevalent object that is to be deleted from the system.executionTime - The datetime at which the transaction was executed.
PrevalentException - If the object cannot be deleted due to
constraints or other considerations.preDelete( String, PrevalentObject, Date )
protected void preDelete(String className,
PrevalentObject object,
Date executionTime)
throws PrevalentException
ForeignKey.deleteAction() value.
className - The prevalent class that holds references to the
prevalent object to be deleted.object - The prevalent object to be deleted.executionTime - The datetime at which the transaction was executed.
DeleteException - If the object cannot be deleted due to references
to it from other prevalent objects.
PrevalentException - If the prevalent object cannot be deleted.cascadeDelete(java.lang.String, java.lang.String, com.sptci.prevayler.PrevalentObject, java.util.Date),
nullReference(java.lang.String, java.lang.String, com.sptci.prevayler.PrevalentObject)
private void cascadeDelete(String className,
String field,
PrevalentObject object,
Date executionTime)
throws PrevalentException
className - The fully qualified class name of the prevalent object
that holds a reference to the specified prevalent object that is
being deleted.field - The name of the field in className that is
a reference to the prevalent object being deleted.object - The prevalent object that is being deleted from the system.executionTime - The datetime at which the transaction was executed.
PrevalentException - If errors are encountered while deleting the
referencing object.IndexStorage.get(String, Object),
AbstractDatabase.fetch(java.lang.Class, java.lang.Object),
DatabaseSystem.delete(com.sptci.prevayler.PrevalentObject, java.util.Date)
private void nullReference(String className,
String field,
PrevalentObject object)
throws PrevalentException
field in className that refers to
object to null. If the field
is a Collection, then the object is
removed from it.
className - The fully qualified class name of the prevalent object
that holds a reference to the specified prevalent object being deleted.field - The field in className that holds a reference
to the prevalent object being deleted.object - The prevalent object being deleted from the system.
PrevalentException - If errors are encountered while setting
the field to null.
protected void checkUnique(PrevalentObject object)
throws PrevalentException
ForeignKeys
and ForeignKey annotations.
checkUnique in class IndexSystemobject - The prevalent object to check.
ConstraintException - If unique constraints are violated.
PrevalentException - If errors are encountered while processing
the fields of the prevalent object.IndexSystem.checkUnique(com.sptci.prevayler.PrevalentObject),
checkForeignKeys(com.sptci.prevayler.PrevalentObject),
checkForeignKey(com.sptci.prevayler.annotations.ForeignKey, com.sptci.prevayler.PrevalentObject)
private void checkForeignKeys(PrevalentObject object)
throws PrevalentException
ForeignKeys annotation
for the prevalent class and perform actions as necessary.
object - The prevalent object whose annotation is to be used to
check constraints.
ConstraintException - If a unique constraint is violated.
PrevalentException - If exceptions are encountered while processing
the fields of the prevalent object.
private void checkForeignKey(ForeignKey key,
PrevalentObject object)
throws PrevalentException
ForeignKey annotation
and check for unique constraint violations.
key - The annotation to check for unique constraint.object - The prevalent object being checked.
ConstraintException - If a unique constraint is violated.
PrevalentException - If exceptions are encountered while processing
the fields of the prevalent object.addReference(com.sptci.prevayler.PrevalentObject, com.sptci.prevayler.annotations.ForeignKey, java.lang.String)
protected void checkFields(PrevalentObject object)
throws PrevalentException
ForeignKey
annotation and check for unique constraint violations. Super-class
implementation is also applied.
checkFields in class IndexSystemobject - The prevalent object to check.
ConstraintException - If a unique constraint is violated.
PrevalentException - If exceptions are encountered while processing
the fields of the prevalent object.addReference(com.sptci.prevayler.PrevalentObject, com.sptci.prevayler.annotations.ForeignKey, java.lang.String),
IndexSystem.checkFields(com.sptci.prevayler.PrevalentObject)
private void addReference(PrevalentObject object,
ForeignKey key,
String name)
throws PrevalentException
object - The prevalent object whose references are to be processed.key - The foreign key annotation for the field.name - The name of the field that references a prevalent object.
This is necessary since the key may not contain the
name of the field it references if annotated at the field level.
PrevalentException - If errors are encountered while accessing the
field in object.
private void checkNull(PrevalentObject object)
throws PrevalentException
NotNull annotation on
the prevalent object and its fields and throw exceptions if necessary.
object - The prevalent object that is to be verified.
NullException - If the field value is null.
PrevalentException - If errors are encountered while fetching the
field value.checkNull( String, PrevalentObject ),
checkNullFields(com.sptci.prevayler.PrevalentObject)
private void checkNull(String member,
PrevalentObject object)
throws PrevalentException
member - The name of the field that is to be checked.object - The prevalent object to check.
NullException - If the field value is null.
PrevalentException - If errors are encountered while fetching the
field value.
private void checkNullFields(PrevalentObject object)
throws PrevalentException
NotNull
annotation. Annotated fields are checked to ensure that their value is
non-null.
object - The prevalent object whose fields are to be checked.
NullException - If the field value is null.
PrevalentException - If errors are encountered while fetching the
field value.
protected void checkUnique(Field field,
PrevalentObject parent,
PrevalentObject child)
throws ConstraintException
parent object.
field - The field in parent that the child represents.parent - The parent prevalent object.child - The referenced prevalent object in parent
ConstraintException - If a unique constratint violation occurs.
protected void indexFields(PrevalentObject object)
throws PrevalentException
ForeignKey
annotations on the fields of the specified prevalent object and manage
the StorageSystem.indexMap as appropriate. Also processes references from
ReferenceStorage to ensure that foreign keys are indexed.
Super-class impelementation is also invoked.
indexFields in class IndexSystemobject - The prevalent object to index.
PrevalentException - If errors are encountered while processing
the object fields.IndexSystem.indexFields(com.sptci.prevayler.PrevalentObject)
protected void indexClass(PrevalentObject object)
throws PrevalentException
ReferenceStorage is used to fetch the appropriate referenced
prevalent object. The super-class implementation is also invoked.
indexClass in class IndexSystemobject - The prevalent object to process.
PrevalentException - If errors are encountered
while processing the field values of the prevalent object.processForeignKeys(com.sptci.prevayler.PrevalentObject),
processForeignKey(com.sptci.prevayler.annotations.ForeignKey, com.sptci.prevayler.PrevalentObject),
IndexSystem.indexClass(com.sptci.prevayler.PrevalentObject)
private void processForeignKeys(PrevalentObject object)
throws PrevalentException
object - The prevalent object that is to be indexed if necessary.
PrevalentException - If errors are encountered while fetching the
field value.processForeignKey(com.sptci.prevayler.annotations.ForeignKey, PrevalentObject)
private void processForeignKey(ForeignKey key,
PrevalentObject object)
throws PrevalentException
StorageSystem.indexMap as appropriate.
key - The annotation being processed.object - The prevalent object that is to be indexed if necessary.
PrevalentException - If errors are encountered while fetching the
field value.
protected void remove(PrevalentObject object)
throws PrevalentException
remove in class IndexSystemobject - The prevalent object to de-index.
PrevalentException - If errors are encountered while removing the
index for the prevalent object.
|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||