org.deduced.controller.implementation
Class AbstractPropertyCollectionController

java.lang.Object
  extended by org.deduced.AbstractPropertyCollection<K,V>
      extended by org.deduced.FixedPropertyInstanceCollection<java.lang.Object,java.lang.Object>
          extended by org.deduced.controller.implementation.PropertyCollectionControllerModelImplementation
              extended by org.deduced.controller.implementation.AbstractPropertyCollectionController
All Implemented Interfaces:
java.lang.Cloneable, PropertyCollectionController, PropertyCollectionControllerModel, NamedPropertyCollection, PropertyCollection<java.lang.Object,java.lang.Object>
Direct Known Subclasses:
DirectPropertyCollectionController, FlyWheelPropertyCollectionController, SimplePropertyCollectionController

public abstract class AbstractPropertyCollectionController
extends PropertyCollectionControllerModelImplementation
implements PropertyCollectionController

Title: AbstractPropertyCollectionController

Description: AbstractPropertyCollectionController implements the base methods required by a property collection controller.

Author:
Steve McDuff

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deduced.AbstractPropertyCollection
AbstractPropertyCollection.CollectionToDeleteMonitor
 
Field Summary
private  DeducedControllerLayerExtension controlLayer
          control layer
private static long serialVersionUID
          the actual iterator used to browse the list
 
Fields inherited from class org.deduced.controller.implementation.PropertyCollectionControllerModelImplementation
KEY_SET
 
Fields inherited from class org.deduced.AbstractPropertyCollection
CHECK_DELETE_MODE_AUTOMATIC, CHECK_DELETE_MODE_MANUAL, COLLECTION_TO_DELETE
 
Fields inherited from interface org.deduced.controller.PropertyCollectionControllerModel
CHILD_COLLECTION_CONTROLLER_LIST_INSTANCE, CHILD_PROPERTY_CONTROLLER_LIST_INSTANCE, CONTROLLED_COLLECTION_INSTANCE, IS_ADD_AVAILABLE_INSTANCE, IS_DELETE_AVAILABLE_INSTANCE, PROPERTY_COLLECTION_CONTROLLER_MODEL_TYPE
 
Fields inherited from interface org.deduced.NamedPropertyCollection
NAME_INSTANCE, NAMED_PROPERTY_COLLECTION_TYPE
 
Fields inherited from interface org.deduced.PropertyCollection
PROPERTY_COLLECTION_TYPE
 
Constructor Summary
AbstractPropertyCollectionController(DeducedControllerLayerExtension setControlLayer)
          AbstractPropertyCollectionController Constructor
 
Method Summary
 Task addPropertyToControlledCollection(java.lang.Object propertyKey, PropertyCollection<?,?> instance, java.lang.Object propertyValue)
          (non-Javadoc)
static Task baseAddPropertyToControlledCollection(java.lang.Object propertyKey, PropertyCollection<?,?> instance, java.lang.Object propertyValue, PropertyCollectionController controller, DeducedControllerLayerExtension controlLayer)
          base Add Property To Controlled Collection
static Task baseCreateAndAddProperty(PropertyCollection<?,?> createType, PropertyCollection<?,?> instance, java.lang.Object key, PropertyCollectionController controller)
          base method to create and add a property
static Task baseDeleteControlledCollection(PropertyCollectionController controller)
          base Delete Controlled Collection
static boolean baseIsAddValueValid(PropertyCollection<?,?> instance, PropertyCollection<?,?> value, ModelFactory modelFactory, PropertyCollectionController controller, boolean validateParent)
          base method to verify if a value to add is valid or not
 Task createAndAddProperty(java.lang.Object key, PropertyCollection<?,?> instance, PropertyCollection<?,?> createType)
          (non-Javadoc)
 Task deleteControlledCollection()
          (non-Javadoc)
 DeducedControllerLayerExtension getControlLayer()
          get Control Layer
private static PropertyCollection<?,?> getInstanceForAdditionThrowIfInvalid(PropertyCollection<?,?> addInstance, PropertyCollection<?,?> controlledCollection)
          get Instance For Addition and Throw an exception if the instance is invalid
static ModelFactory getModelFactoryFromCollection(PropertyCollection<?,?> collection)
          the model factory associated with the specified collection
static Task handleException(Task currentTask, java.lang.Exception e)
          handle Exception by registering them on the task
protected static
<K,V> K
internalAddPropertyToControlledCollection(K propertyKey, PropertyCollection<?,?> instance, V propertyValue, PropertyCollectionController controller, DeducedControllerLayerExtension controlLayer)
          internalAddPropertyToControlledCollection
 boolean isAddValueValid(PropertyCollection<?,?> instance, PropertyCollection<?,?> value, boolean validateParent)
          (non-Javadoc)
 void setControlLayer(DeducedControllerLayerExtension setControlLayer)
          set Control Layer
static void validateAddToCollection(java.lang.Object propertyValue, PropertyCollection<?,?> addInstance, ModelFactory modelFactory, PropertyCollection<?,?> controlledCollection, boolean validateParent)
          validate if a value is valid to be added to a collection
 
Methods inherited from class org.deduced.controller.implementation.PropertyCollectionControllerModelImplementation
asKeySet, clone, createInstancesAndTypes, createKeyList, equals, fillInstancesAndTypes, fillInstancesAndTypesFromSchema, fillTypeLists, getChildCollectionControllerList, getChildCollectionControllerList, getChildPropertyControllerList, getChildPropertyControllerList, getControlledCollection, getControlledCollection, getName, getName, getPropertyValue, isAddAvailable, isAddAvailable, isDeleteAvailable, isDeleteAvailable, resetListFixedInstances, setChildCollectionControllerList, setChildCollectionControllerList, setChildPropertyControllerList, setChildPropertyControllerList, setControlledCollection, setControlledCollection, setIsAddAvailable, setIsAddAvailable, setIsDeleteAvailable, setIsDeleteAvailable, setName, setName, setProperty, type
 
Methods inherited from class org.deduced.FixedPropertyInstanceCollection
addProperty, areKeysAssignedAutomatically, containsKey, getProperty, iterator, iteratorByValue, removeProperty, removePropertyInstance, removePropertyValue, size
 
Methods inherited from class org.deduced.AbstractPropertyCollection
activate, addListener, asPropertyList, asPropertyMap, asValueList, asValueMap, callObjectClone, classLogger, cleanNewlyClonedValue, clear, clearCollectionMonitoredForDelete, cloneCollection, containsInstance, containsValue, createUniqueID, delete, deleteClearAllProperties, deleteClearListenerList, deleteFireDeleteEvent, deleteProcessCompletedValidation, deleteRemoveLocalObjectFromParent, deleteValidateEmptyListenerList, deleteValidateNoPendingReferences, firePropertyChangeEvent, flushCollectionsWithNewParent, flushCollectionsWithNewParent, getActionInvoker, getCheckDeleteMode, getCheckDeleteRunner, getFixedInstance, getInstanceIdentityKey, hashCode, id, instanceKey, internalFirePropertyChangeEvent, invokeAction, isActivated, isDeleteCheckedOnClearParent, isEmpty, isListenerRegistered, isParentOrKeyNull, keyOnParent, parent, removeListener, requiresChangeEvent, setActionInvoker, setCheckDeleteMode, setCheckDeleteRunner, setDeleteCheckedOnClearParent, setFixedInstance, setParent, toString, updateReference, updateReferenceWithReferenceFlag, validateAllPropertyInstances, validateNoListener, validateNoParentRecursion, validateParentIsNull, validateParentIsNull, valueKey
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.deduced.controller.PropertyCollectionControllerModel
getChildCollectionControllerList, getChildPropertyControllerList, getControlledCollection, isAddAvailable, isDeleteAvailable, setChildCollectionControllerList, setChildPropertyControllerList, setControlledCollection, setIsAddAvailable, setIsDeleteAvailable
 
Methods inherited from interface org.deduced.NamedPropertyCollection
getName, setName
 
Methods inherited from interface org.deduced.PropertyCollection
activate, addListener, addProperty, areKeysAssignedAutomatically, asKeySet, asPropertyList, asPropertyMap, asValueList, asValueMap, clear, clone, containsInstance, containsKey, containsValue, delete, getFixedInstance, getProperty, getPropertyValue, id, instanceKey, invokeAction, isActivated, isEmpty, isListenerRegistered, iterator, iteratorByValue, keyOnParent, parent, removeListener, removeProperty, removePropertyInstance, removePropertyValue, setFixedInstance, setParent, setProperty, size, type, valueKey
 

Field Detail

serialVersionUID

private static final long serialVersionUID
the actual iterator used to browse the list

See Also:
Constant Field Values

controlLayer

private DeducedControllerLayerExtension controlLayer
control layer

Constructor Detail

AbstractPropertyCollectionController

public AbstractPropertyCollectionController(DeducedControllerLayerExtension setControlLayer)
AbstractPropertyCollectionController Constructor

Parameters:
setControlLayer - the control layer to use.
Method Detail

getControlLayer

public DeducedControllerLayerExtension getControlLayer()
get Control Layer

Returns:
the control layer

setControlLayer

public void setControlLayer(DeducedControllerLayerExtension setControlLayer)
set Control Layer

Parameters:
setControlLayer - the control layer to use

createAndAddProperty

public Task createAndAddProperty(java.lang.Object key,
                                 PropertyCollection<?,?> instance,
                                 PropertyCollection<?,?> createType)
(non-Javadoc)

Specified by:
createAndAddProperty in interface PropertyCollectionController
Parameters:
key - the key of the created type
instance - the instance of the created type
createType - the type of object to create
Returns:
a task used to monitor the creation process. If the task is successful, the added property key will be set as the result of the task.
See Also:
PropertyCollectionController.createAndAddProperty(java.lang.Object, org.deduced.PropertyCollection, org.deduced.PropertyCollection)

baseCreateAndAddProperty

public static Task baseCreateAndAddProperty(PropertyCollection<?,?> createType,
                                            PropertyCollection<?,?> instance,
                                            java.lang.Object key,
                                            PropertyCollectionController controller)
base method to create and add a property

Parameters:
createType - the type to create
instance - the instance of the created property
key - the property key
controller - the property collection controller
Returns:
a task of the creation process

getModelFactoryFromCollection

public static ModelFactory getModelFactoryFromCollection(PropertyCollection<?,?> collection)
the model factory associated with the specified collection

Parameters:
collection - the collection to use
Returns:
the model factory associated with the specified collection

handleException

public static Task handleException(Task currentTask,
                                   java.lang.Exception e)
handle Exception by registering them on the task

Parameters:
currentTask - the current task
e - the exception to handle
Returns:
a task that is linked to the exception. This will return the same value as the current task parameter unless no task is passed, then a new task will be created.

addPropertyToControlledCollection

public Task addPropertyToControlledCollection(java.lang.Object propertyKey,
                                              PropertyCollection<?,?> instance,
                                              java.lang.Object propertyValue)
(non-Javadoc)

Specified by:
addPropertyToControlledCollection in interface PropertyCollectionController
Parameters:
propertyKey - the property key
instance - the property instance
propertyValue - the property value
Returns:
a task used to monitor the creation process. If the task is successful, the added property key will be set as the result of the task.
See Also:
PropertyCollectionController.addPropertyToControlledCollection(java.lang.Object, org.deduced.PropertyCollection, java.lang.Object)

baseAddPropertyToControlledCollection

public static Task baseAddPropertyToControlledCollection(java.lang.Object propertyKey,
                                                         PropertyCollection<?,?> instance,
                                                         java.lang.Object propertyValue,
                                                         PropertyCollectionController controller,
                                                         DeducedControllerLayerExtension controlLayer)
base Add Property To Controlled Collection

Parameters:
propertyKey - the key to use while adding
instance - the instance to use while adding
propertyValue - the new property value
controller - the controller to use while adding
controlLayer - the control layer used by the controller
Returns:
a task to monitor the add operation

internalAddPropertyToControlledCollection

protected static <K,V> K internalAddPropertyToControlledCollection(K propertyKey,
                                                                   PropertyCollection<?,?> instance,
                                                                   V propertyValue,
                                                                   PropertyCollectionController controller,
                                                                   DeducedControllerLayerExtension controlLayer)
internalAddPropertyToControlledCollection

Type Parameters:
K - the type of key to add
V - the type of value to add
Parameters:
propertyKey - the key to use while adding
instance - the instance to use while adding
propertyValue - the new property value
controller - the controller to use while adding
controlLayer - the control layer used by the controller
Returns:
the key of the newly added property

validateAddToCollection

public static void validateAddToCollection(java.lang.Object propertyValue,
                                           PropertyCollection<?,?> addInstance,
                                           ModelFactory modelFactory,
                                           PropertyCollection<?,?> controlledCollection,
                                           boolean validateParent)
validate if a value is valid to be added to a collection

Parameters:
propertyValue - the value to add
addInstance - the instance specified during addition. If null, the collection fixed instance is used.
modelFactory - the model factory used to generate a validation model
controlledCollection - the controlled collection to receive the add operation.
validateParent - option to validate the parent while adding the collection
Throws:
java.lang.IllegalArgumentException - when the value isn't valid.

getInstanceForAdditionThrowIfInvalid

private static PropertyCollection<?,?> getInstanceForAdditionThrowIfInvalid(PropertyCollection<?,?> addInstance,
                                                                            PropertyCollection<?,?> controlledCollection)
get Instance For Addition and Throw an exception if the instance is invalid

Parameters:
addInstance - the instance to add. If null, then the fixed instance of the collection will be used.
controlledCollection - the controlled collection
Returns:
the instance to use while adding

deleteControlledCollection

public Task deleteControlledCollection()
(non-Javadoc)

Specified by:
deleteControlledCollection in interface PropertyCollectionController
Returns:
the task monitoring the delete operation
See Also:
PropertyCollectionController.deleteControlledCollection()

baseDeleteControlledCollection

public static Task baseDeleteControlledCollection(PropertyCollectionController controller)
base Delete Controlled Collection

Parameters:
controller - the controller on which to delete the controlled collection
Returns:
a task monitoring the delete operation

isAddValueValid

public boolean isAddValueValid(PropertyCollection<?,?> instance,
                               PropertyCollection<?,?> value,
                               boolean validateParent)
(non-Javadoc)

Specified by:
isAddValueValid in interface PropertyCollectionController
Parameters:
instance - the property instance to use while adding. If null, the fixed instance on the collection will be used.
value - the value to add to the collection
validateParent - option to validate the parent of the value as well. If true, then the parent must be null for all properties by value to be valid. If false, then the parent isn't validated.
Returns:
true if add is valid
See Also:
PropertyCollectionController.isAddValueValid(org.deduced.PropertyCollection, org.deduced.PropertyCollection, boolean)

baseIsAddValueValid

public static boolean baseIsAddValueValid(PropertyCollection<?,?> instance,
                                          PropertyCollection<?,?> value,
                                          ModelFactory modelFactory,
                                          PropertyCollectionController controller,
                                          boolean validateParent)
base method to verify if a value to add is valid or not

Parameters:
instance - the instance to use while adding. If null, the collection fixed instance will be used.
value - the value to add
modelFactory - the model factory to use to create validation models
controller - the controller where the add will be performed
validateParent - option to validate the parent of the added value or not. If set to true, then the added value must have a null parent.
Returns:
true if the addition is valid, false otherwise.