com.metamatrix.console.models
Class ConfigurationPropertiedObjectEditor

java.lang.Object
  extended by com.metamatrix.console.models.ConfigurationPropertiedObjectEditor
All Implemented Interfaces:
PropertiedObjectEditor, PropertyAccessPolicy, UserTransaction, UserTransactionFactory, StringUtil.Constants
Direct Known Subclasses:
ResourcePropertiedObjectEditor

public class ConfigurationPropertiedObjectEditor
extends java.lang.Object
implements PropertiedObjectEditor, StringUtil.Constants, UserTransaction

This class serves as both a PropertiedObjectEditor and a UserTransaction for the editing of ComponentObjects and the PropertyDefinitions associated to them through their ComponentType.

This class fronts a ConfigurationObjectEditor, and a ConfigurationAdminAPIFacade. It can be used in one of two ways (corresponding to the two contstructors).

The first way is to use the no-arg constructor. This implementation will then support transactions through the UserTransaction API, which this object also implements, and which PropertiedObjectPanel uses automatically.

The second way to use this implementation is to use the second constructor which takes a ModificationActionQueue parameter. This allows a client to control the transactional nature of this implementation - the client can manually manage the list of Action objects in the ModificationActionQueue, and execute them as a transaction whenever the client deems it appropriate. Automatic transactional support will be disabled in this implementation; the methods implementing the UserTransaction interface will be disabled.


Field Summary
 
Fields inherited from interface com.metamatrix.common.object.PropertiedObjectEditor
NO_VALUE
 
Fields inherited from interface com.metamatrix.common.object.PropertyAccessPolicy
DEFAULT_READ_ONLY_PRIVILEGE
 
Fields inherited from interface com.metamatrix.core.util.StringUtil.Constants
CARRIAGE_RETURN, CARRIAGE_RETURN_CHAR, DBL_SPACE, DOT, DOT_CHAR, EMPTY_STRING, EMPTY_STRING_ARRAY, LINE_FEED, LINE_FEED_CHAR, NEW_LINE, NEW_LINE_CHAR, PATTERN_BACK_SLASH, PATTERN_QUESTION, PATTERN_STAR, SPACE, SPACE_CHAR, TAB, TAB_CHAR
 
Method Summary
protected  ComponentObject assertComponentObject(PropertiedObject obj)
           
 void begin()
          Create a new transaction and associate it with this object.
 void commit()
          Complete the transaction associated with this object.
 UserTransaction createReadTransaction()
          Create a new instance of a UserTransaction that may be used to read information.
 UserTransaction createWriteTransaction()
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 UserTransaction createWriteTransaction(java.lang.Object source)
          Create a new instance of a UserTransaction that may be used to write and/or update information.
 java.util.List getAllowedValues(PropertiedObject obj, PropertyDefinition def)
          Get the allowed values for the property on the specified object.
protected  ConfigurationAdminAPI getConfigurationAPI()
           
protected  ConfigurationManager getConfigurationManager()
           
protected  ConfigurationObjectEditor getEditor()
           
 PropertyAccessPolicy getPolicy()
           
 java.util.List getPropertyDefinitions(PropertiedObject obj)
          Obtain the list of PropertyDefinitions that apply to the specified object's type.
 java.lang.Object getSource()
          Return the (optional) reference to the object that is considered the source of the transaction represented by this object.
 int getStatus()
          Obtain the status of the transaction represented by this object.
 java.lang.Object getValue(PropertiedObject obj, PropertyDefinition def)
          Obtain from the specified PropertiedObject the property value that corresponds to the specified PropertyDefinition.
protected  boolean isAutomaticTransaction()
           
 boolean isReadOnly(PropertiedObject obj)
          Return whether this editor may be used to set property values on the specified PropertiedObject.
 boolean isReadOnly(PropertiedObject obj, PropertyDefinition def)
           
 boolean isValidValue(PropertiedObject obj, PropertyDefinition def, java.lang.Object value)
          Return whether the specified value is considered valid.
 void reset(PropertiedObject obj)
           
 void rollback()
          Roll back the transaction associated with this object.
protected  java.util.List setIsModifiable(java.util.Collection componentTypeDefns, ConfigurationID id)
          This method will resolve whether or not the PropertyDefinitions in the list of passed in ComponentTypeDefinitions should be modifiable or not.
 void setPolicy(PropertyAccessPolicy policy)
           
 void setReadOnly(PropertiedObject obj, boolean readOnly)
           
 void setReadOnly(PropertiedObject obj, PropertyDefinition def, boolean readOnly)
           
 void setRollbackOnly()
          Modify the transaction associated with this object such that the only possible outcome of the transaction is to roll back the transaction.
 void setTransactionTimeout(int seconds)
          Modify the value of the timeout value that is associated with the transactions represented by this object.
 void setValue(PropertiedObject obj, PropertyDefinition def, java.lang.Object value)
          Set on the specified PropertiedObject the value defined by the specified PropertyDefinition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPropertyDefinitions

public java.util.List getPropertyDefinitions(PropertiedObject obj)
Obtain the list of PropertyDefinitions that apply to the specified object's type.

Specified by:
getPropertyDefinitions in interface PropertiedObjectEditor
Parameters:
obj - the propertied object for which the PropertyDefinitions are to be obtained; may not be null
Returns:
an unmodifiable list of the PropertyDefinition objects that define the properties for the object; never null but possibly empty
Throws:
java.lang.AssertionError - if obj is null

getAllowedValues

public java.util.List getAllowedValues(PropertiedObject obj,
                                       PropertyDefinition def)
Get the allowed values for the property on the specified object. By default, this implementation simply returns the allowed values in the supplied PropertyDefinition instance.

Specified by:
getAllowedValues in interface PropertiedObjectEditor
Parameters:
obj - the propertied object whose property value is to be obtained; may not be null
def - the reference to the PropertyDefinition describing the property whose value is to be returned; may not be null
Returns:
the unmodifiable list of allowed values for this property, or an empty set if the values do not have to conform to a fixed set.
See Also:
#hasAllowedValues

isReadOnly

public boolean isReadOnly(PropertiedObject obj)
Return whether this editor may be used to set property values on the specified PropertiedObject.

Specified by:
isReadOnly in interface PropertiedObjectEditor
Specified by:
isReadOnly in interface PropertyAccessPolicy
Parameters:
obj - the propertied object; may not be null
Returns:
true if the object may not be modified, or false otherwise.
Throws:
java.lang.AssertionError - if obj is null

getValue

public java.lang.Object getValue(PropertiedObject obj,
                                 PropertyDefinition def)
Obtain from the specified PropertiedObject the property value that corresponds to the specified PropertyDefinition. The return type and cardinality (including whether the value may be null) depend upon the PropertyDefinition.

Specified by:
getValue in interface PropertiedObjectEditor
Parameters:
obj - the propertied object whose property value is to be obtained; may not be null
def - the reference to the PropertyDefinition describing the property whose value is to be returned; may not be null
Returns:
the value for the property, which may be an empty collection if the property is multi-valued, or may be null if the multiplicity includes "0", or the NO_VALUE reference if the specified object does not contain the specified PropertyDefinition
Throws:
java.lang.AssertionError - if either of obj or def is null

isValidValue

public boolean isValidValue(PropertiedObject obj,
                            PropertyDefinition def,
                            java.lang.Object value)
Return whether the specified value is considered valid. The value is not valid if the propertied object does not have the specified property definition, or if it does but the value is inconsistent with the requirements of the property definition.

Specified by:
isValidValue in interface PropertiedObjectEditor
Parameters:
obj - the propertied object whose property value is to be validated; may not be null
def - the reference to the PropertyDefinition describing the property whose value is to be validated; may not be null
value - the proposed value for the property, which may be a collection if the property is multi-valued, or may be null if the multiplicity includes "0"
Returns:
true if the value is considered valid, or false otherwise.
Throws:
java.lang.AssertionError - if either of obj or def is null

setValue

public void setValue(PropertiedObject obj,
                     PropertyDefinition def,
                     java.lang.Object value)
Set on the specified PropertiedObject the value defined by the specified PropertyDefinition. If null is passed in as the value parameter, this implementation will take that to mean that the value is reverting to its default value. In this case, the default value will be stored as the value; the value entry in the config database will NOT be deleted, but will be assigned the default value.

Specified by:
setValue in interface PropertiedObjectEditor
Parameters:
obj - the propertied object whose property value is to be set; may not be null
def - the reference to the PropertyDefinition describing the property whose value is to be changed; may not be null
value - the new value for the property; the cardinality and type must conform PropertyDefinition. If null, this will be interpreted as reverting to the default value.
Throws:
java.lang.IllegalArgumentException - if the value does not correspond to the PropertyDefinition requirements.
java.lang.AssertionError - if either of obj or def is null

getPolicy

public PropertyAccessPolicy getPolicy()
Specified by:
getPolicy in interface PropertiedObjectEditor

setPolicy

public void setPolicy(PropertyAccessPolicy policy)
Specified by:
setPolicy in interface PropertiedObjectEditor

isReadOnly

public boolean isReadOnly(PropertiedObject obj,
                          PropertyDefinition def)
Specified by:
isReadOnly in interface PropertyAccessPolicy

setReadOnly

public void setReadOnly(PropertiedObject obj,
                        PropertyDefinition def,
                        boolean readOnly)
Specified by:
setReadOnly in interface PropertyAccessPolicy

setReadOnly

public void setReadOnly(PropertiedObject obj,
                        boolean readOnly)
Specified by:
setReadOnly in interface PropertyAccessPolicy

reset

public void reset(PropertiedObject obj)
Specified by:
reset in interface PropertyAccessPolicy

createReadTransaction

public UserTransaction createReadTransaction()
Create a new instance of a UserTransaction that may be used to read information. Read transactions do not have a source object associated with them (since they never directly modify data).

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createReadTransaction in interface UserTransactionFactory
Returns:
the new transaction object

createWriteTransaction

public UserTransaction createWriteTransaction()
Create a new instance of a UserTransaction that may be used to write and/or update information. The transaction will not have a source object associated with it.

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Returns:
the new transaction object

createWriteTransaction

public UserTransaction createWriteTransaction(java.lang.Object source)
Create a new instance of a UserTransaction that may be used to write and/or update information. The source object will be used for all events that are fired as a result of or as a product of this transaction.

The returned transaction object will not be bound to an underlying system transaction until begin() is called on the returned object.

Specified by:
createWriteTransaction in interface UserTransactionFactory
Parameters:
source - the object that is considered to be the source of the transaction; may be null
Returns:
the new transaction object

getStatus

public int getStatus()
              throws TransactionException
Obtain the status of the transaction represented by this object. Note: this class does not currently support status, and will return either TransactionStatus.STATUS_UNKNOWN for automatic transaction mode (indicating there might be a transaction), or TransactionStatus.STATUS_NO_TRANSACTION if this object is not in automatic transaction mode.

Specified by:
getStatus in interface UserTransaction
Returns:
The transaction status.
Throws:
TransactionException

begin

public void begin()
           throws TransactionException
Create a new transaction and associate it with this object.

Specified by:
begin in interface UserTransaction
Throws:
TransactionNotSupportedException - if the current thread is already associated with a transaction and the manager does not support nested system transactions.
TransactionException

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws TransactionException
Modify the value of the timeout value that is associated with the transactions represented by this object. Note: this implementation has no timeout, and does not support timeout.

Specified by:
setTransactionTimeout in interface UserTransaction
Parameters:
seconds - The value of the timeout in seconds. If the value is zero, the transaction service restores the default value.
Throws:
java.lang.IllegalStateException - Thrown if this object is not associated with a transaction
TransactionException

setRollbackOnly

public void setRollbackOnly()
                     throws TransactionException
Modify the transaction associated with this object such that the only possible outcome of the transaction is to roll back the transaction. Note: this implementation does not support this method, and the method will do nothing

Specified by:
setRollbackOnly in interface UserTransaction
Throws:
java.lang.IllegalStateException - Thrown if this object is not associated with a transaction.
TransactionException

commit

public void commit()
            throws TransactionException
Complete the transaction associated with this object. When this method completes, the thread becomes associated with no transaction.

Specified by:
commit in interface UserTransaction
Throws:
java.lang.IllegalStateException - Thrown if this object is not associated with a transaction.
TransactionException

rollback

public void rollback()
              throws TransactionException
Roll back the transaction associated with this object. When this method completes, the thread becomes associated with no transaction.

Specified by:
rollback in interface UserTransaction
Throws:
java.lang.IllegalStateException - Thrown if this object is not associated with a transaction.
TransactionException

getSource

public java.lang.Object getSource()
                           throws TransactionException
Return the (optional) reference to the object that is considered the source of the transaction represented by this object. This is used, for example, to set the source of all events occuring within this transaction.

Specified by:
getSource in interface UserTransaction
Returns:
the source object, which may be null
Throws:
TransactionException

isAutomaticTransaction

protected boolean isAutomaticTransaction()

assertComponentObject

protected ComponentObject assertComponentObject(PropertiedObject obj)

getEditor

protected ConfigurationObjectEditor getEditor()

setIsModifiable

protected java.util.List setIsModifiable(java.util.Collection componentTypeDefns,
                                         ConfigurationID id)
This method will resolve whether or not the PropertyDefinitions in the list of passed in ComponentTypeDefinitions should be modifiable or not. In order to determine this it uses the effectiveImmediately parameter, the isModifiable() state of the PropertyDefinition itself, and the Configuration that the currently edited ComponentDefn belongs to.

Parameters:
componentTypeDefns - list of ComponentTypeDefns to be interrogated
id - the ConfigurationID of the object being edited by this editor.
Returns:
a list of PropertyDefinition objects with their isModifiable attribute set correctly.

getConfigurationAPI

protected ConfigurationAdminAPI getConfigurationAPI()

getConfigurationManager

protected ConfigurationManager getConfigurationManager()


Copyright © 2009. All Rights Reserved.