19 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacadeImpl.php");
20 require_once(BASE.
"wcmf/lib/remoting/class.RemotingFacade.php");
46 if (!$session->exist(self::PROXY_OBJECTS_SESSION_VARNAME)) {
48 $session->set(self::PROXY_OBJECTS_SESSION_VARNAME, $proxies);
50 if (!$session->exist(self::REMOTE_OBJECTS_SESSION_VARNAME)) {
52 $session->set(self::REMOTE_OBJECTS_SESSION_VARNAME, $objs);
61 $this->_isResolvingProxies = $isResolvingProxies;
77 $this->_isTranslatingValues = $isTranslatingValues;
90 function &
load($oid, $buildDepth, $buildAttribs=null, $buildTypes=null)
98 $obj = &parent::load($oid, $buildDepth, $buildAttribs, $buildTypes);
111 function &
create($type, $buildDepth, $buildAttribs=null)
113 $obj = &parent::create($type, $buildDepth, $buildAttribs);
125 $result = parent::save($object);
131 function delete($oid, $recursive=
true)
137 $result = parent::delete($oid, $recursive);
143 function getOIDs($type, $criteria=null, $orderby=null, &$pagingInfo)
145 $result = parent::getOIDs($type, $criteria, $orderby, $pagingInfo);
151 function loadObjects($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
153 $tmpResult = parent::loadObjects($type, $buildDepth, $criteria, $orderby, $pagingInfo, $buildAttribs, $buildTypes);
155 foreach($tmpResult as $obj)
157 if ($obj && $this->
isResolvingProxies() && strlen($umi = $obj->getValue(
'umi')) > 0) {
179 Log::debug(
"Get proxy object for: ".$umi, __CLASS__);
183 $umiPrefix = $umiParts[
'prefix'];
186 if (strlen($umiPrefix) == 0) {
198 $oldState = $persistenceFacade->isResolvingProxies();
199 $persistenceFacade->setResolveProxies(
false);
201 $proxy = $persistenceFacade->loadFirstObject($umiParts[
'type'], $buildDepth, array($umiParts[
'type'].
'.umi' => $umi));
202 if ($persistenceFacade instanceof RemoteCapablePersistenceFacadeImpl) {
203 $persistenceFacade->setResolveProxies($oldState);
214 Log::debug(
"Proxy oid: ".$proxy->getOID(), __CLASS__);
225 Log::debug(
"Resolve proxy object for: ".$umi, __CLASS__);
229 $umiPrefix = $umiParts[
'prefix'];
241 array(
'type' => $umiParts[
'type'],
'id' => $umiParts[
'id'])
243 $serverKey = array_pop(split(
':', $umiPrefix));
252 'depth' =>
"".$buildDepth,
253 'omitMetaData' =>
true,
254 'translateValues' => $this->_isTranslatingValues
257 Log::debug(
"Request:\n".$request->toString(), __CLASS__);
261 $response = $facade->doCall($serverKey, $request);
262 $obj = $response->getValue(
'node');
267 while (!$iter->isEnd())
269 $curNode = &$iter->getCurrentObject();
270 $oids = $this->
makeUmis(array($curNode->getOID()), $umiPrefix);
271 $curNode->setOID($oids[0]);
272 $parentOIDs = $this->
makeUmis($curNode->getProperty(
'parentoids'), $umiPrefix);
273 $curNode->setProperty(
'parentoids', $parentOIDs);
274 $childOIDs = $this->
makeUmis($curNode->getProperty(
'childoids'), $umiPrefix);
275 $curNode->setProperty(
'childoids', $childOIDs);
287 $children = $proxy->getChildren();
288 for($i=0, $count=
sizeof($children); $i<$count; $i++) {
289 $obj->addChild($children[$i]);
291 $parents = $proxy->getParents();
292 for($i=0, $count=
sizeof($parents); $i<$count; $i++) {
293 $obj->addParent($parents[$i]);
302 Log::debug(
"Resolved to: ".$obj->toString(), __CLASS__);
305 Log::debug(
"Could not resolve: ".$umi, __CLASS__);
323 $this->
registerObject($umi, $obj, $buildDepth, self::PROXY_OBJECTS_SESSION_VARNAME);
337 $this->
registerObject($umi, $obj, $buildDepth, self::REMOTE_OBJECTS_SESSION_VARNAME);
349 if ($buildDepth == 0) {
354 $objects = &$session->get($varName);
355 if (!isset($objects[$umi])) {
356 $objects[$umi] = array();
358 $objects[$umi][$buildDepth] = &$obj;
359 $session->set($varName, $objects);
363 $classFile = BASE.$objectFactory->getClassfileFromConfig(get_class($obj));
364 $mapperClassFile = BASE.$objectFactory->getClassfileFromConfig(get_class($obj->getMapper()));
365 $session->addClassDefinitions(array($classFile, $mapperClassFile));
376 $proxy = $this->
getRegisteredObject($umi, $buildDepth, self::PROXY_OBJECTS_SESSION_VARNAME);
388 $object = $this->
getRegisteredObject($umi, $buildDepth, self::REMOTE_OBJECTS_SESSION_VARNAME);;
400 if ($buildDepth == 0) {
404 $objects = &$session->get($varName);
405 if (isset($objects[$umi]) && isset($objects[$umi][$buildDepth])) {
406 return $objects[$umi][$buildDepth];
410 $existingDepths = array_keys($objects[$umi]);
411 foreach($existingDepths as $depth) {
413 return $objects[$umi][$depth];
429 foreach ($oids as $oid)
432 if (strlen($oidParts[
'prefix']) == 0)
435 array(
'prefix' => $umiPrefix,
'type' => $oidParts[
'type'],
'id' => $oidParts[
'id'])
const PROXY_OBJECTS_SESSION_VARNAME
registerRemoteObject($umi, &$obj, $buildDepth)
debug($message, $category)
loadRemoteObject($umi, $buildDepth)
NodeIterator is used to iterate over a tree/list build of objects using a Depth-First-Algorithm. Classes used with the NodeIterator must implement the getChildren() and getOID() methods. NodeIterator implements the 'Iterator Pattern'. The base class NodeIterator defines the interface for all specialized Iterator classes.
makeUmis($oids, $umiPrefix)
setResolveProxies($isResolvingProxies)
loadObjects($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
Request holds the request values that are used as input to Controller instances. It is typically inst...
throwEx($message, $file='', $line='')
PersistenceFacadeImpl delegates persistence operations to the type-specific PersistenceMappers.
const BUILDDEPTH_INFINITE
getProxyObject($umi, $buildDepth)
setTranslatingValues($isTranslatingValues)
const REMOTE_OBJECTS_SESSION_VARNAME
decomposeOID($oid, $validate=true)
registerObject($umi, &$obj, $buildDepth=BUILDDEPTH_SINGLE, $varName)
& create($type, $buildDepth, $buildAttribs=null)
RemoteCapablePersistenceFacadeImpl()
registerProxyObject($umi, &$obj, $buildDepth)
isDebugEnabled($category)
getRegisteredRemoteObject($umi, $buildDepth)
getRegisteredObject($umi, $buildDepth=BUILDDEPTH_SINGLE, $varName)
getOIDParameter($oid, $param, $validate=true)
& load($oid, $buildDepth, $buildAttribs=null, $buildTypes=null)
getOIDs($type, $criteria=null, $orderby=null, &$pagingInfo)
getRegisteredProxyObject($umi, $buildDepth)