org.caleigo.core
Class AbstractEntityDescriptor

java.lang.Object
  extended byorg.caleigo.core.AbstractEntityDescriptor
All Implemented Interfaces:
IEntityDescriptor, java.io.Serializable
Direct Known Subclasses:
AbstractMetaEntityDescriptor, CompositeEntityDescriptor, CustomEntityDescriptor

public abstract class AbstractEntityDescriptor
extends java.lang.Object
implements IEntityDescriptor

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
static class AbstractEntityDescriptor.DeleteEntityAction
          The default delete action used by the AbstsractEntityDescriptor class.
protected static class AbstractEntityDescriptor.Dezerializer
           
static class AbstractEntityDescriptor.StoreEntityAction
          The default store action used by the AbstsractEntityDescriptor class.
 
Field Summary
static int CACHEABLE
           
static int CREATABLE
           
static int DELETABLE
           
static int EDITABLE
           
static int LISTABLE
           
static int SCANABLE
           
static int SELECTABLE
           
 
Fields inherited from interface org.caleigo.core.IEntityDescriptor
CUSTOM_ENTITY, DELETE_ACTION, LINK_ENTITY, MASTER_ENTITY, NO_TIME_LIMIT, SLAVE_ENTITY, STATIC_ENTITY, STORE_ACTION
 
Constructor Summary
protected AbstractEntityDescriptor(java.lang.String codeName, java.lang.String sourceName, java.lang.String displayName, java.lang.String entityClassName, java.lang.String dataSourceClassName, int entityType, IFieldDescriptor[] fields, IEntityRelation[] relations)
          Note that the constructor for this class is protected.
 
Method Summary
protected  void addEntityAction(IEntityAction entityAction)
          Registers an new IEntityAction object as part of the entity descriptor.
 boolean contains(IFieldDescriptor fieldDescriptor)
          Reurns true if the provided field descriptor is a part the called entity descriptor.
protected  ICalculatedFieldDescriptor[] createCalculatedFieldDescriptors()
          This should be overridden if one want to add ICalculatedFieldDescriptor's to an EntityDescriptor.
protected  IEntityAction createDeleteAction()
          Creates and returns the delete action for entity objects of the type described by the called entity descriptor.
 IEntity createEntity()
          Creates an entity with of the type described by this descriptor and loads it with default data.
 IEntity createEntity(IDataProvider propertySource)
          Creates an entity with of the type described by this descriptor and loads it with data from the provided property source.
protected static IEntityRelation createEntityRelation(IFieldRelation[] fieldRelation, java.lang.String codeName, java.lang.String forwardName, java.lang.String reverseName)
          This help method makes possible for sub classes in other packages to easily create entity relations.
protected static IEntityRelation createEntityRelation(IFieldRelation fieldRelation, java.lang.String codeName, java.lang.String forwardName, java.lang.String reverseName)
          This help method makes possible for sub classes in other packages to easily create entity relations.
protected static IEntityRelation createEntityRelation(java.lang.String sourceEntityDescriptorClassName, java.lang.String sourceFieldDescriptorCodeName, java.lang.String targetEntityDescriptorClassName, java.lang.String targetFieldDescriptorCodeName, java.lang.String codeName, java.lang.String forwardName, java.lang.String reverseName)
          This help method makes possible for sub classes in other packages to easily create field relations.
protected static IFieldDescriptor createFieldDescriptor(java.lang.String codeName, java.lang.String sourceName, java.lang.String displayName, java.lang.String entityDescriptorName, DataType dataType, int length, int flags, java.lang.Object defValue)
          This help method makes possible for sub classes in other packages to create field descriptor.
protected static IFieldRelation createFieldRelation(java.lang.String sourceEntityDescriptorClassName, java.lang.String sourceFieldDescriptorCodeName, java.lang.String targetEntityDescriptorClassName, java.lang.String targetFieldDescriptorCodeName)
          This help method makes possible for sub classes in other packages to easily create field relations.
protected  IEntityAction createStoreAction()
          Creates and returns the store action for entity objects of the type described by the called entity descriptor.
protected  void defineEntityActions()
          Called by the constructor.
 IEntityAction getAction(int index)
          Returns the indexed IEntityAction.
 IEntityAction getAction(java.lang.String codeName)
          Returns the IEntityAction with the provided code name.
 int getActionCount()
          Access method that returns the number of IEntityAction objects that are available for access from the called IEntityDescriptor.
 java.util.Iterator getActions()
          Returns an iterator with all contained IEntityAction objects that are available for access from the called IEntityDescriptor.
 int getCacheTime()
          Returns the acceptable time in seconds to cache entities described by the descriptor.
 java.lang.String getCodeName()
          Returns an identifying name that can be used to address the field in client software if the field descriptor for some reason is not available.
 int getDataFieldCount()
          Returns the number of field descriptors that have persistent data or in other words are not descendants to ICalculatedFieldDescriptor's that this entity descriptor contains.
 IDataSourceDescriptor getDataSourceDescriptor()
          Returns the DataSource descriptor that this entity is a part of.
 java.lang.String getDisplayName()
          Returns the class for the entities described by the entity descriptor.
 java.lang.Class getEntityClass()
          Returns the class for the entities described by the entity descriptor.
 IEntityRelation getEntityRelation(int index)
          Access method that returns the indexed IEntityRelation.
 int getEntityRelationCount()
          Access method that returns the number of IEntityRelation:s that has the called entity descriptor as source or target.
 int getEntityRelationIndex(java.lang.String codeName)
          Returns the index of the IEntityRelation with the specified code name, or -1 if no relation is found.
 java.util.Iterator getEntityRelations()
          Access method that returns an editable copy of the IEntityRelation list with all relation objects that the descriptor is part of.
 int getEntityType()
          Returns the entity type signified by the constants...
 int getFieldCount()
          Returns the number of field descriptors that this entity descriptor contains.
 IFieldDescriptor getFieldDescriptor(int index)
          Returns a specific field descriptor from the entity descriptor addressed by its ordial index.
 IFieldDescriptor getFieldDescriptor(java.lang.String codeName)
          Returns a specific field descriptor from the entity descriptor addressed by its code name.
 java.util.Iterator getFieldDescriptors()
          Returns all field descriptors as an iterator.
 int getFieldIndex(IFieldDescriptor fieldDescriptor)
          Returns the index of the provided field descriptor or a negative value if the field is not a part of the entity descriptor.
 int getFieldIndex(java.lang.String codeName)
          Returns the index of the field descriptor with the provided code name or a negative value if the field is not a part of the entity descriptor.
 java.lang.Class getHomeClass()
          Temporary solution!!!
 java.lang.String getJNDIName()
          Temporary solution!!!
 EntityCollator getNaturalOrder()
          Returns en entity collator defining the natural order for the called entity descriptors entities.
 java.lang.Class getRemoteClass()
          Temporary solution!!!
 java.lang.String getSourceName()
          Returns an identifying name used in communication with the data service layer.
 boolean isCacheable()
          This routine should return true if it "pays" for the system to cache the entire table when accessing a single entity.
 boolean isCreatable()
          Returns true if entities described by the called descriptor may be created.
 boolean isDeletable()
          Returns true if entities described by the called descriptor may be deleted.
 boolean isEditable()
          Returns true if entities described by the called descriptor may be updated.
 boolean isListable()
          This routine should return true if it is meaningfull to display ALL existing entities for a user at the same time.
 boolean isScanable()
          This routine should return true if it is acceptable for the system to for any reason scan all existing entities of this type.
 boolean isSelectable()
          This routine should return true if it possible to view and select between ALL existing entities.
 IEntity loadEntity(Qualifier identityQualifier)
          The load method returnes a single entity object intentified by the provided indentity qualifier that must be able to uniquely identify a single entity instance.
 ISelection loadSelection(Qualifier qualifier)
          Loads a selection of entities of the called descriptors type using the provided entity descriptor.
protected  void setCacheTime(int seconds)
          Sets a optional cache time for the entity.
protected  void setFlags(int cacheFlags)
          Sets the flags for the entity descriptor.
 java.lang.String toString()
           
protected  java.lang.Object writeReplace()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECTABLE

public static final int SELECTABLE
See Also:
Constant Field Values

LISTABLE

public static final int LISTABLE
See Also:
Constant Field Values

CACHEABLE

public static final int CACHEABLE
See Also:
Constant Field Values

SCANABLE

public static final int SCANABLE
See Also:
Constant Field Values

CREATABLE

public static final int CREATABLE
See Also:
Constant Field Values

EDITABLE

public static final int EDITABLE
See Also:
Constant Field Values

DELETABLE

public static final int DELETABLE
See Also:
Constant Field Values
Constructor Detail

AbstractEntityDescriptor

protected AbstractEntityDescriptor(java.lang.String codeName,
                                   java.lang.String sourceName,
                                   java.lang.String displayName,
                                   java.lang.String entityClassName,
                                   java.lang.String dataSourceClassName,
                                   int entityType,
                                   IFieldDescriptor[] fields,
                                   IEntityRelation[] relations)
Note that the constructor for this class is protected.

Method Detail

toString

public java.lang.String toString()

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

createEntity

public IEntity createEntity()
Creates an entity with of the type described by this descriptor and loads it with default data.

Specified by:
createEntity in interface IEntityDescriptor

createEntity

public IEntity createEntity(IDataProvider propertySource)
Creates an entity with of the type described by this descriptor and loads it with data from the provided property source.

Specified by:
createEntity in interface IEntityDescriptor

loadSelection

public ISelection loadSelection(Qualifier qualifier)
Loads a selection of entities of the called descriptors type using the provided entity descriptor. The method uses the default data source for the entity type.

Specified by:
loadSelection in interface IEntityDescriptor

loadEntity

public IEntity loadEntity(Qualifier identityQualifier)
The load method returnes a single entity object intentified by the provided indentity qualifier that must be able to uniquely identify a single entity instance.

Specified by:
loadEntity in interface IEntityDescriptor

getCodeName

public java.lang.String getCodeName()
Returns an identifying name that can be used to address the field in client software if the field descriptor for some reason is not available.

Specified by:
getCodeName in interface IEntityDescriptor

getSourceName

public java.lang.String getSourceName()
Returns an identifying name used in communication with the data service layer. Should normally never be used by the client developer.

Specified by:
getSourceName in interface IEntityDescriptor

getDisplayName

public java.lang.String getDisplayName()
Returns the class for the entities described by the entity descriptor.

Specified by:
getDisplayName in interface IEntityDescriptor

getEntityClass

public java.lang.Class getEntityClass()
Returns the class for the entities described by the entity descriptor.

Specified by:
getEntityClass in interface IEntityDescriptor

getEntityType

public int getEntityType()
Returns the entity type signified by the constants...

MASTER_ENTITY = Signifies that these enitities are handled as seperate units that can be viewed and handled as isolated units.
SLAVE_ENTITY = These entities are generally never viewed or handled as an isolated seperate unit. They are genneraly always viewed and manipulated as slaves or children to another entity type that generaly is a master entity.
LINK_ENTITY = Signifies that the purpose of this entity is only to link other entity types together in N to N relationships.
STATIC_ENTITY = Used for tables storing system constants that rarely or never changes. These entities are generally cacheable with no time limit.
CUSTOM_ENTITY = Used for entities that are composites of other entities and therefore can not specify another entity type.

Specified by:
getEntityType in interface IEntityDescriptor

isCreatable

public boolean isCreatable()
Returns true if entities described by the called descriptor may be created. If a store operation is called on a non-persistent entity of the described type an exception should be thrown.

Specified by:
isCreatable in interface IEntityDescriptor

isEditable

public boolean isEditable()
Returns true if entities described by the called descriptor may be updated. If a store operation is called on a persistent entity of the described type an exception should be thrown.

Specified by:
isEditable in interface IEntityDescriptor

isDeletable

public boolean isDeletable()
Returns true if entities described by the called descriptor may be deleted. If a store operation is called on a persistent entity of the described type an exception should be thrown.

Specified by:
isDeletable in interface IEntityDescriptor

getCacheTime

public int getCacheTime()
Returns the acceptable time in seconds to cache entities described by the descriptor. Zero means no caching is accepable and the constant NO_TIME_LIMIT sinifies that there are no time limit when cacheing.

Specified by:
getCacheTime in interface IEntityDescriptor

isSelectable

public boolean isSelectable()
This routine should return true if it possible to view and select between ALL existing entities. In other words if it possible to use for instance a combo box to select between the entities. This is generally true when the entity count is less then 20.

Specified by:
isSelectable in interface IEntityDescriptor

isListable

public boolean isListable()
This routine should return true if it is meaningfull to display ALL existing entities for a user at the same time. This is generally true when the entity count is less then 200.

Specified by:
isListable in interface IEntityDescriptor

isCacheable

public boolean isCacheable()
This routine should return true if it "pays" for the system to cache the entire table when accessing a single entity. This depends on many factors, the size of the entities, the bandwith and the frequence of entity access. If the amount of entities exceds 2000 they generaly not considered cachable.

Specified by:
isCacheable in interface IEntityDescriptor

isScanable

public boolean isScanable()
This routine should return true if it is acceptable for the system to for any reason scan all existing entities of this type. In other words if a tablescan is acceptable or should be avoide. If the amount of entities excedes a million this is generally not true.

Specified by:
isScanable in interface IEntityDescriptor

getFieldCount

public int getFieldCount()
Returns the number of field descriptors that this entity descriptor contains. This includes both data and calculated field descriptors.

Specified by:
getFieldCount in interface IEntityDescriptor

getDataFieldCount

public int getDataFieldCount()
Returns the number of field descriptors that have persistent data or in other words are not descendants to ICalculatedFieldDescriptor's that this entity descriptor contains.

Specified by:
getDataFieldCount in interface IEntityDescriptor

getFieldDescriptor

public IFieldDescriptor getFieldDescriptor(int index)
Returns a specific field descriptor from the entity descriptor addressed by its ordial index. May cast OutOfBoundException.

Specified by:
getFieldDescriptor in interface IEntityDescriptor

getFieldDescriptor

public IFieldDescriptor getFieldDescriptor(java.lang.String codeName)
Returns a specific field descriptor from the entity descriptor addressed by its code name. May return null if the codeName was not identified.

Specified by:
getFieldDescriptor in interface IEntityDescriptor

getFieldDescriptors

public java.util.Iterator getFieldDescriptors()
Returns all field descriptors as an iterator.

Specified by:
getFieldDescriptors in interface IEntityDescriptor

getDataSourceDescriptor

public IDataSourceDescriptor getDataSourceDescriptor()
Returns the DataSource descriptor that this entity is a part of.

Specified by:
getDataSourceDescriptor in interface IEntityDescriptor

contains

public boolean contains(IFieldDescriptor fieldDescriptor)
Reurns true if the provided field descriptor is a part the called entity descriptor.

Specified by:
contains in interface IEntityDescriptor

getFieldIndex

public int getFieldIndex(IFieldDescriptor fieldDescriptor)
Returns the index of the provided field descriptor or a negative value if the field is not a part of the entity descriptor.

Specified by:
getFieldIndex in interface IEntityDescriptor

getFieldIndex

public int getFieldIndex(java.lang.String codeName)
Returns the index of the field descriptor with the provided code name or a negative value if the field is not a part of the entity descriptor.

Specified by:
getFieldIndex in interface IEntityDescriptor

getEntityRelationCount

public int getEntityRelationCount()
Access method that returns the number of IEntityRelation:s that has the called entity descriptor as source or target.

Specified by:
getEntityRelationCount in interface IEntityDescriptor

getEntityRelation

public IEntityRelation getEntityRelation(int index)
Access method that returns the indexed IEntityRelation.

Specified by:
getEntityRelation in interface IEntityDescriptor

getEntityRelationIndex

public int getEntityRelationIndex(java.lang.String codeName)
Returns the index of the IEntityRelation with the specified code name, or -1 if no relation is found.

Specified by:
getEntityRelationIndex in interface IEntityDescriptor

getEntityRelations

public java.util.Iterator getEntityRelations()
Access method that returns an editable copy of the IEntityRelation list with all relation objects that the descriptor is part of.

Specified by:
getEntityRelations in interface IEntityDescriptor

getActionCount

public int getActionCount()
Access method that returns the number of IEntityAction objects that are available for access from the called IEntityDescriptor.

Specified by:
getActionCount in interface IEntityDescriptor

getAction

public IEntityAction getAction(int index)
Returns the indexed IEntityAction.

Specified by:
getAction in interface IEntityDescriptor

getAction

public IEntityAction getAction(java.lang.String codeName)
Returns the IEntityAction with the provided code name. Returns null if the code name could not be identified.

Specified by:
getAction in interface IEntityDescriptor

getActions

public java.util.Iterator getActions()
Returns an iterator with all contained IEntityAction objects that are available for access from the called IEntityDescriptor.

Specified by:
getActions in interface IEntityDescriptor

getNaturalOrder

public EntityCollator getNaturalOrder()
Returns en entity collator defining the natural order for the called entity descriptors entities.

Specified by:
getNaturalOrder in interface IEntityDescriptor

setCacheTime

protected void setCacheTime(int seconds)
Sets a optional cache time for the entity. A negative value means that entities can be cached forever.


setFlags

protected void setFlags(int cacheFlags)
Sets the flags for the entity descriptor. Valid values are SELECTABLE, LISTABLE, CACHEABLE, SCANABLE, CREATABLE, EDITABLE, DELETABLE or a combination of these.


addEntityAction

protected void addEntityAction(IEntityAction entityAction)
Registers an new IEntityAction object as part of the entity descriptor. These actions can then be accessed and be reflected using the entity descriptor. By declaring the propper flags it will be automatically integrated in the applications user interface.

Parameters:
entityAction - The IEntityAction to be added.

createStoreAction

protected IEntityAction createStoreAction()
Creates and returns the store action for entity objects of the type described by the called entity descriptor. The method can be used to return an modified store action that for example could be used to store additional auditing information or modify the data to be stored.

Returns:
The IEntityAction object that should be used to store entity objects for the called entity. By default the nested StoreEntityAction class will be returned.

createDeleteAction

protected IEntityAction createDeleteAction()
Creates and returns the delete action for entity objects of the type described by the called entity descriptor. The method can be used to return an modified delete action that for example could be used to backup the deleted data to another format.

Returns:
The IEntityAction object that should be used to delete entity objects for the called entity. By default the nested DeleteEntityAction class will be returned.

defineEntityActions

protected void defineEntityActions()
Called by the constructor. The method is expected to add all the descriptors entity action objects.


createFieldDescriptor

protected static IFieldDescriptor createFieldDescriptor(java.lang.String codeName,
                                                        java.lang.String sourceName,
                                                        java.lang.String displayName,
                                                        java.lang.String entityDescriptorName,
                                                        DataType dataType,
                                                        int length,
                                                        int flags,
                                                        java.lang.Object defValue)
This help method makes possible for sub classes in other packages to create field descriptor. Note that this is the only way to make instances if you dont wont sub class the field descriptor.


createCalculatedFieldDescriptors

protected ICalculatedFieldDescriptor[] createCalculatedFieldDescriptors()
This should be overridden if one want to add ICalculatedFieldDescriptor's to an EntityDescriptor. Returns null by default witch means that no calcultaed fields are added.


createFieldRelation

protected static IFieldRelation createFieldRelation(java.lang.String sourceEntityDescriptorClassName,
                                                    java.lang.String sourceFieldDescriptorCodeName,
                                                    java.lang.String targetEntityDescriptorClassName,
                                                    java.lang.String targetFieldDescriptorCodeName)
This help method makes possible for sub classes in other packages to easily create field relations.


createEntityRelation

protected static IEntityRelation createEntityRelation(java.lang.String sourceEntityDescriptorClassName,
                                                      java.lang.String sourceFieldDescriptorCodeName,
                                                      java.lang.String targetEntityDescriptorClassName,
                                                      java.lang.String targetFieldDescriptorCodeName,
                                                      java.lang.String codeName,
                                                      java.lang.String forwardName,
                                                      java.lang.String reverseName)
This help method makes possible for sub classes in other packages to easily create field relations.


createEntityRelation

protected static IEntityRelation createEntityRelation(IFieldRelation fieldRelation,
                                                      java.lang.String codeName,
                                                      java.lang.String forwardName,
                                                      java.lang.String reverseName)
This help method makes possible for sub classes in other packages to easily create entity relations.


createEntityRelation

protected static IEntityRelation createEntityRelation(IFieldRelation[] fieldRelation,
                                                      java.lang.String codeName,
                                                      java.lang.String forwardName,
                                                      java.lang.String reverseName)
This help method makes possible for sub classes in other packages to easily create entity relations.


getJNDIName

public java.lang.String getJNDIName()
Description copied from interface: IEntityDescriptor
Temporary solution!!! Should be moved!

Specified by:
getJNDIName in interface IEntityDescriptor

getRemoteClass

public java.lang.Class getRemoteClass()
Description copied from interface: IEntityDescriptor
Temporary solution!!! Should be moved!

Specified by:
getRemoteClass in interface IEntityDescriptor

getHomeClass

public java.lang.Class getHomeClass()
Description copied from interface: IEntityDescriptor
Temporary solution!!! Should be moved!

Specified by:
getHomeClass in interface IEntityDescriptor


Copyright © 2005 Caleigo. All Rights Reserved.