wcmf logo wemove logo

PersistenceFacade Class Reference
[Persistence]

PersistenceFacade delegates persistence operations to the type-specific PersistenceMappers. More...

Inheritance diagram for PersistenceFacade:

Inheritance graph
[legend]

Public Member Functions

getInstance ()
 getKnownTypes ()
 isKnownType ($type)
load ($oid, $buildDepth, $buildAttribs=null, $buildTypes=null)
create ($type, $buildDepth, $buildAttribs=null)
 save (&$object)
 delete ($oid, $recursive=true)
 getCreatedOIDs ($type)
 getLastCreatedOID ($type)
 getOIDs ($type, $criteria=null, $orderby=null, &$pagingInfo)
 getOIDsEx ($type, $where=null, $orderby=null, &$pagingInfo)
 getFirstOID ($type, $criteria=null, $orderby=null, &$pagingInfo)
 getFirstOIDEx ($type, $where=null, $orderby=null, &$pagingInfo)
 loadObjects ($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
loadFirstObject ($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
 createObjectQuery ($type)
 createStringQuery ()
 startTransaction ()
 commitTransaction ()
 rollbackTransaction ()
getMapper ($type)
 storeConnection ($className, &$connection)
 getClassFile ($parser, $className)
 setReadOnly ($isReadOnly)
 enableLogging ($logStrategy)
 disableLogging ()
 isLogging ()
 setCaching ($isCaching)
 clearCache ()
 getCacheKey ($oid, $buildDepth, $buildAttribs, $buildTypes)
 composeOID ($params)
 decomposeOID ($oid)
 getOIDParameter ($oid, $param)
 setOIDParameter ($oid, $param, $value)
 isValidOID ($oid)
 getNumberOfPKs ($type)
 getDummyId ()
 isDummyId ($id)
 getId ()
 valueChanged (&$object, $name, $type, $oldValue, $newValue)
 propertyChanged (&$object, $name, $oldValue, $newValue)
 stateChanged (&$object, $oldValue, $newValue)

Data Fields

 $_mapperObjects = array()
 $_createdOIDs = array()
 $_dbConnections = array()
 $_cache = array()
 $_logging = false
 $_logStrategy = null
 $_isReadOnly = false
 $_isCaching = false
 $_inTransaction = false

Detailed Description

PersistenceFacade delegates persistence operations to the type-specific PersistenceMappers.

Note:
The OID parameter must provide enough information to select the appropriate mapper. This may be achived by different strategies, e.g. coding the object type into the OID or having a global registry which maps OIDs to objects. wCMF uses the first method. The OID is a string in order to make it easier to serialize it in HTML forms. The following notation is used: type:id1:id2:... where type is the object type and id1, id2, .. are the values of the primary key columns (in case of simple keys only one). PersistenceFacade provides methods to handle OIDs (composeOID(), decomposeOID(), ...)
Author:
ingo herwig <ingo@wemove.com>

Definition at line 53 of file class.PersistenceFacade.php.


Member Function Documentation

& getInstance (  ) 

Returns an instance of the class.

Returns:
A reference to the only instance of the Singleton object

Definition at line 69 of file class.PersistenceFacade.php.

Referenced by XMLUtil::_GetNodePath(), XMLUtil::_GetOID(), XMLUtil::_InsertNode(), UserRDBBase::addChild(), RoleRDBBase::addChild(), NodeUtil::addLanguageChildren(), NodeUtil::addMandatoryChildren(), RDBMapper::appendChildData(), TableRDBMapper::applyDataOnLoad(), NodeUtil::completeNode(), RDBMapper::connect(), NodeToSingleTableMapper::create(), RDBMapper::createImpl(), NodeXMLDBMapper::createImpl(), UserManagerRDB::createRoleImpl(), UserManagerRDB::createUserImpl(), NodeToSingleTableMapper::delete(), RDBMapper::deleteImpl(), NodeXMLDBMapper::deleteImpl(), NodeSerializer::deserializeNode(), StringQuery::execute(), UserController::executeKernel(), SortController::executeKernel(), SearchController::executeKernel(), SaveController::executeKernel(), ResourceListController::executeKernel(), PagingController::executeKernel(), InsertController::executeKernel(), DisplayController::executeKernel(), DeleteController::executeKernel(), CopyController::executeKernel(), ChildrenListController::executeKernel(), AsyncPagingController::executeKernel(), AssociateController::executeKernel(), PrincipalController::executeKernel(), ConfigController::executeKernel(), AdminController::executeKernel(), ObjectQuery::executeString(), g_getObjects(), g_getOIDArray(), g_getOIDs(), g_getTypes(), TreeViewController::getChildren(), UserRDBBase::getChildrenEx(), RoleRDBBase::getChildrenEx(), ObjectQuery::getConnection(), NodeUtil::getConnectionToAncestor(), NodeUtil::getConnectionToDescendant(), NodeUtil::getDisplayNameFromType(), NodeUtil::getDisplayValues(), NodeUnifiedRDBMapper::getInsertSQL(), getKnownTypes(), FormUtil::getListMap(), getMapper(), AbstractFormat::getNode(), getNumberOfPKs(), SearchController::getObjects(), ObjectQuery::getObjectTemplate(), NodeToSingleTableMapper::getOIDs(), SimplePagingController::getOIDs(), NodeListController::getOIDs(), ChildrenListController::getOIDs(), ObjectQuery::getOrderby(), NodeToSingleTableMapper::getParentOID(), NodeUtil::getParentQuery(), NodeUtil::getPath(), RDBMapper::getPKNamesForType(), NodeUtil::getPossibleChildren(), NodeUtil::getPossibleParents(), NodeToSingleTableMapper::getPropertyMap(), User::getRoleByName(), TreeViewController::getRootOIDs(), NodeUtil::getSelfQuery(), NodeUnifiedRDBMapper::getUpdateSQL(), User::getUser(), XMLExportController::initExport(), UserManagerRDB::initialize(), BatchController::initialize(), isKnownType(), NodeToSingleTableMapper::load(), Node::loadChildren(), UserRDBBase::loadChildren(), RoleRDBBase::loadChildren(), RDBMapper::loadImpl(), NodeXMLDBMapper::loadImpl(), Node::loadParents(), AuthUser::login(), StringQuery::mapToDatabase(), ChildrenListController::modifyModel(), AsyncPagingController::modifyModel(), ObjectQuery::ObjectQuery(), PersistentObject::PersistentObject(), PersistentIterator::proceed(), MultipleActionController::replaceVariablesString(), NodeToSingleTableMapper::save(), RDBMapper::saveImpl(), NodeXMLDBMapper::saveImpl(), smarty_function_linktext(), SortController::sortAll(), storeConnection(), Table::Table(), XMLExportController::writeNode(), and LogOutputStrategy::writeObject().

getKnownTypes (  ) 

Get a list of types defined in the application.

Returns:
The list of types

Definition at line 82 of file class.PersistenceFacade.php.

References getInstance().

Referenced by g_getTypes().

Here is the call graph for this function:

isKnownType ( type  ) 

& load ( oid,
buildDepth,
buildAttribs = null,
buildTypes = null 
)

Load an object from the database.

Parameters:
oid OID of the object to construct
buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
buildAttribs An assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypes An array listing the (sub-)types to include
Returns:
A reference to the object, null if oid does not exist or a given condition prevents loading.

Definition at line 115 of file class.PersistenceFacade.php.

References decomposeOID(), getCacheKey(), getMapper(), and WCMFException::throwEx().

Here is the call graph for this function:

& create ( type,
buildDepth,
buildAttribs = null 
)

Construct the template of an Object of a given type.

Parameters:
type The type of object to build
buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
buildAttribs An assoziative array listing the attributes to create (default: null creates all attributes) (keys: the types, values: an array of attributes of the type to create) Use this to create only a subset of attributes
Returns:
A reference to the object.

Definition at line 165 of file class.PersistenceFacade.php.

References getMapper(), and WCMFException::throwEx().

Here is the call graph for this function:

save ( &$  object  ) 

Save an object to the database (inserted if it is new).

Parameters:
object A reference to the object to save
Returns:
True/False depending on success of operation

Definition at line 187 of file class.PersistenceFacade.php.

delete ( oid,
recursive = true 
)

Delete an object from the database (together with all of its children).

Parameters:
oid The object id of the object to delete
recursive True/False whether to physically delete it's children too [default: true]
Returns:
True/False depending on success of operation

Definition at line 201 of file class.PersistenceFacade.php.

References decomposeOID(), and getMapper().

Here is the call graph for this function:

getCreatedOIDs ( type  ) 

Get the object ids of newly created objects of a given type.

Parameters:
type The type of the object
Returns:
An array containing the objects ids

Definition at line 218 of file class.PersistenceFacade.php.

getLastCreatedOID ( type  ) 

Get the object id of the last created object of a given type.

Parameters:
type The type of the object
Returns:
The object id or null

Definition at line 229 of file class.PersistenceFacade.php.

getOIDs ( type,
criteria = null,
orderby = null,
&$  pagingInfo 
)

Get the object ids of objects matching a given criteria. If a PagingInfo instance is passed it will be used and updated.

Parameters:
type The type of the object
criteria An assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderby An array holding names of attributes to order by (maybe null). [default: null]
pagingInfo A reference PagingInfo instance (optional, default null does not work in PHP4).
Returns:
An array containing the objects ids

Definition at line 244 of file class.PersistenceFacade.php.

References getMapper().

Referenced by getFirstOID().

Here is the call graph for this function:

getOIDsEx ( type,
where = null,
orderby = null,
&$  pagingInfo 
)

Deprecated:
use getOIDs() instead

Definition at line 255 of file class.PersistenceFacade.php.

References Log::error(), and WCMFException::getStackTrace().

Here is the call graph for this function:

getFirstOID ( type,
criteria = null,
orderby = null,
&$  pagingInfo 
)

Get the first object id of objects matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters:
type The type of the object
criteria An assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderby An array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfo A reference PagingInfo instance (optional, default null does not work in PHP4).
Returns:
An object id or null

Definition at line 268 of file class.PersistenceFacade.php.

References getOIDs().

Here is the call graph for this function:

getFirstOIDEx ( type,
where = null,
orderby = null,
&$  pagingInfo 
)

Deprecated:
use getFirstOID() instead

Definition at line 279 of file class.PersistenceFacade.php.

References Log::error(), and WCMFException::getStackTrace().

Here is the call graph for this function:

loadObjects ( type,
buildDepth,
criteria = null,
orderby = null,
&$  pagingInfo,
buildAttribs = null,
buildTypes = null 
)

Load the objects matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters:
type The type of the object
buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
criteria An assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderby An array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfo A reference PagingInfo instance (optional, default null does not work in PHP4).
buildAttribs An assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypes An array listing the (sub-)types to include
Returns:
An array containing the objects

Definition at line 297 of file class.PersistenceFacade.php.

References getMapper().

Referenced by loadFirstObject().

Here is the call graph for this function:

& loadFirstObject ( type,
buildDepth,
criteria = null,
orderby = null,
&$  pagingInfo,
buildAttribs = null,
buildTypes = null 
)

Load the first object matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters:
type The type of the object
buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
criteria An assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderby An array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfo A reference PagingInfo instance (optional, default null does not work in PHP4).
buildAttribs An assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypes An array listing the (sub-)types to include
Returns:
A reference to the object or null

Definition at line 319 of file class.PersistenceFacade.php.

References loadObjects().

Here is the call graph for this function:

createObjectQuery ( type  ) 

Create an object query.

Parameters:
type The object type to search for
Returns:
An ObjectQuery instance

Definition at line 332 of file class.PersistenceFacade.php.

Referenced by g_getObjects(), NodeUtil::getChildQuery(), NodeUtil::getNodeQuery(), SearchController::getObjects(), NodeUtil::getParentQuery(), NodeUtil::getSelfQuery(), and SOAPController::soapSearch().

createStringQuery (  ) 

Create a string query.

Returns:
An StringQuery instance

Definition at line 340 of file class.PersistenceFacade.php.

Referenced by g_getOIDs(), and SOAPController::soapAdvancedSearch().

startTransaction (  ) 

Start a transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the startTransaction() method of every used PersistenceMapper will be called - until commitTransaction() is called.

Note:
There is only ONE transaction active at a time. Repeated calls of this method will leave the initial transaction active until commitTransaction() ore rollbackTransaction() is called.

Definition at line 351 of file class.PersistenceFacade.php.

References Log::debug(), and isLogging().

Here is the call graph for this function:

commitTransaction (  ) 

Commit the started transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the commitTransaction() method of every used PersistenceMapper will be called.

Note:
There is only ONE transaction active at a time. Repeated calls of this method will do nothing until a new transaction was started by calling startTransaction().

Definition at line 373 of file class.PersistenceFacade.php.

References Log::debug(), and isLogging().

Here is the call graph for this function:

rollbackTransaction (  ) 

Rollback the started transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the rollbackTransaction() method of every used PersistenceMapper will be called.

Note:
There is only ONE transaction active at a time. Repeated calls of this method will do nothing until a new transaction was started by calling startTransaction(). Rollbacks have to be supported by the data storage.

Definition at line 395 of file class.PersistenceFacade.php.

References Log::debug(), and isLogging().

Here is the call graph for this function:

& getMapper ( type  ) 

Get the PersistenceMapper for a given type. If no mapper for this type is defined the mapper for type '*' will be returned

Parameters:
type The type of the object to get the PersistenceMapper for
Returns:
A reference to the PersistenceMapper, null on error

Definition at line 415 of file class.PersistenceFacade.php.

References getClassFile(), getInstance(), isLogging(), and WCMFException::throwEx().

Referenced by create(), delete(), getOIDs(), load(), and loadObjects().

Here is the call graph for this function:

storeConnection ( className,
&$  connection 
)

Store a connection for reuse

Parameters:
className The name of the class for which the connection is defined (PersistenceFacade retrieves the initParams section from this)
connection A reference to the connection to save

Definition at line 525 of file class.PersistenceFacade.php.

References getInstance().

Here is the call graph for this function:

getClassFile ( parser,
className 
)

Get the class file name from the classmapping section of ini file

Parameters:
parser The ini file parser
className The class name
Returns:
The class file name

Definition at line 540 of file class.PersistenceFacade.php.

References WCMFException::throwEx().

Referenced by getMapper().

Here is the call graph for this function:

setReadOnly ( isReadOnly  ) 

Set state to readonly. If set to true, PersistenceFacade will return only immutable objects and save/delete methods are disabled.

Parameters:
isReadOnly True/False whether objects should be readonly or not

Definition at line 554 of file class.PersistenceFacade.php.

enableLogging ( logStrategy  ) 

Enable logging using a given OutputStrategy to log insert/update/delete actions to a file.

Parameters:
logStrategy The OutputStrategy to use.

Definition at line 562 of file class.PersistenceFacade.php.

disableLogging (  ) 

Disable logging.

Definition at line 570 of file class.PersistenceFacade.php.

isLogging (  ) 

Check if the PersistenceMapper is logging.

Returns:
True/False whether the PersistenceMapper is logging.

Definition at line 578 of file class.PersistenceFacade.php.

Referenced by commitTransaction(), getMapper(), rollbackTransaction(), and startTransaction().

setCaching ( isCaching  ) 

Set state to caching. If set to true, PersistenceFacade will cache all loaded objects and returns cached instances when calling the PersistenceFacade::load method.

Parameters:
isCaching True/False whether objects should be chached or not

Definition at line 587 of file class.PersistenceFacade.php.

clearCache (  ) 

Clear the object cache

Definition at line 594 of file class.PersistenceFacade.php.

getCacheKey ( oid,
buildDepth,
buildAttribs,
buildTypes 
)

Get cache key from the given parameters

Parameters:
oid OID of the object
buildDepth One of the BUILDDEPTH constants
buildAttribs An assoziative array (
See also:
PersistenceFacade::load)
Parameters:
buildTypes An array (
See also:
PersistenceFacade::load)
Returns:
The cache key string

Definition at line 606 of file class.PersistenceFacade.php.

Referenced by load().

composeOID ( params  ) 

Compose an OID from several parameters.

Parameters:
params An assoziative array with the keys 'type' and 'id' where the value of id maybe a single value or an array (for compound primary keys). If id is an array, the order of the values must match the order of the primary key names given by PersistenceMapper::getPkNames(). If only type is given in params, the primary key columns will be set with initial values.
Returns:
An OID

Definition at line 622 of file class.PersistenceFacade.php.

References getDummyId(), getNumberOfPKs(), and WCMFException::throwEx().

Referenced by NodeRDBMapper::applyDataOnCreate(), NodeRDBMapper::applyDataOnLoad(), RDBMapper::constructOID(), UserRDBBase::deleteChild(), RoleRDBBase::deleteChild(), UserController::executeKernel(), g_getOIDs(), FormUtil::getListMap(), NullNode::getOID(), NMUserRoleBase::getRoleRDBOID(), XMLUtil::getRootOID(), NMUserRoleBase::getUserRDBOID(), LocktableBase::getUserRDBOID(), PersistentObject::PersistentObject(), PersistentObject::setDBID(), setOIDParameter(), and PersistentObject::updateOID().

Here is the call graph for this function:

decomposeOID ( oid  ) 

getOIDParameter ( oid,
param 
)

setOIDParameter ( oid,
param,
value 
)

Set a part of an object id (e.g. the 'type' parameter).

Parameters:
oid The OID of the object.
param The name of the parameter.
value The value of the parameter.
Returns:
The modified object id.

Definition at line 691 of file class.PersistenceFacade.php.

References composeOID(), and decomposeOID().

Here is the call graph for this function:

isValidOID ( oid  ) 

getNumberOfPKs ( type  ) 

Get the number of primary keys a type has.

Parameters:
type The type to check.
Returns:
The number of primary keys (default: 1)

Definition at line 725 of file class.PersistenceFacade.php.

References getInstance(), and isKnownType().

Referenced by composeOID(), and isValidOID().

Here is the call graph for this function:

getDummyId (  ) 

Get a dummy id ("wcmf" + unique 32 character string).

Returns:
A dummy id

Definition at line 740 of file class.PersistenceFacade.php.

Referenced by NodeRDBMapper::applyDataOnCreate(), and composeOID().

isDummyId ( id  ) 

Check if a given id is a dummy id.

Parameters:
id The id to check
Returns:
True/False

Definition at line 749 of file class.PersistenceFacade.php.

Referenced by NodeUnifiedRDBMapper::prepareInsert(), and ObjectQuery::registerObjectTemplate().

getId (  ) 

ChangeListener interface implementation

See also:
ChangeListener::getId()

Reimplemented from ChangeListener.

Definition at line 761 of file class.PersistenceFacade.php.

valueChanged ( &$  object,
name,
type,
oldValue,
newValue 
)

See also:
ChangeListener::valueChanged()

Reimplemented from ChangeListener.

Definition at line 768 of file class.PersistenceFacade.php.

propertyChanged ( &$  object,
name,
oldValue,
newValue 
)

See also:
ChangeListener::propertyChanged()

Reimplemented from ChangeListener.

Definition at line 772 of file class.PersistenceFacade.php.

stateChanged ( &$  object,
oldValue,
newValue 
)

See also:
ChangeListener::stateChanged()

Reimplemented from ChangeListener.

Definition at line 776 of file class.PersistenceFacade.php.


Field Documentation

$_mapperObjects = array()

Definition at line 55 of file class.PersistenceFacade.php.

$_createdOIDs = array()

Definition at line 56 of file class.PersistenceFacade.php.

$_dbConnections = array()

Definition at line 57 of file class.PersistenceFacade.php.

$_cache = array()

Definition at line 58 of file class.PersistenceFacade.php.

$_logging = false

Definition at line 59 of file class.PersistenceFacade.php.

$_logStrategy = null

Definition at line 60 of file class.PersistenceFacade.php.

$_isReadOnly = false

Definition at line 61 of file class.PersistenceFacade.php.

$_isCaching = false

Definition at line 62 of file class.PersistenceFacade.php.

$_inTransaction = false

Definition at line 63 of file class.PersistenceFacade.php.


The documentation for this class was generated from the following file:

This page generated via doxygen 1.5.8 Mon Mar 30 01:58:45 2009.
Copyright © 2009 wemove digital solutions GmbH.
sourceforge logo