Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/alfresco/Service/Node.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * Copyright (C) 2005 Alfresco, Inc.
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019  * As a special exception to the terms and conditions of version 2.0 of 
00020  * the GPL, you may redistribute this Program in connection with Free/Libre 
00021  * and Open Source Software ("FLOSS") applications as described in Alfresco's 
00022  * FLOSS exception.  You should have recieved a copy of the text describing 
00023  * the FLOSS exception, and it is also available here: 
00024  * http://www.alfresco.com/legal/licensing"
00025  */
00026 
00027 require_once 'Store.php';
00028 require_once 'ChildAssociation.php';
00029 require_once 'Association.php';
00030 require_once 'NamespaceMap.php';
00031 require_once 'ContentData.php';
00032 require_once 'VersionHistory.php';
00033 require_once 'Version.php';
00034 
00035 class Node extends BaseObject 
00036 {
00037         private $_session;
00038         private $_store;
00039         private $_id;
00040         private $_type;
00041         private $_aspects;
00042         private $_properties;
00043         private $_children;
00044         private $_parents;
00045         private $_primaryParent;
00046         private $_isNewNode;
00047         private $_associations;
00048         private $_versionHistory;       
00049         private $origionalProperties;
00050         private $addedAspects;
00051         private $removedAspects;
00052         private $addedChildren;
00053         private $addedParents;
00054         private $addedAssociations;
00055         private $removedAssociations;
00056 
00060         public function __construct($session, $store, $id) 
00061         {
00062                 $this->_session = $session;
00063                 $this->_store = $store;
00064                 $this->_id = $id;       
00065                 $this->_isNewNode = false;
00066                 $this->addedChildren = array();
00067                 $this->addedParents = array();
00068                 $this->addedAssociations = array();
00069         }
00070 
00074         public static function createFromWebServiceData($session, $webServiceNode) 
00075         {
00076                 $scheme = $webServiceNode->reference->store->scheme;
00077                 $address = $webServiceNode->reference->store->address;
00078                 $id = $webServiceNode->reference->uuid;
00079 
00080                 $store = $session->getStore($address, $scheme);
00081                 $node = $session->getNode($store, $id);
00082         $node->populateFromWebServiceNode($webServiceNode);
00083         
00084                 return $node;
00085         }
00086         
00087         public function setPropertyValues($properties)
00088         {
00089                 // Check that the properties of the node have been populated
00090                 $this->populateProperties();
00091                 
00092                 // Set the property values
00093                 foreach ($properties as $name=>$value)
00094                 {
00095                         $name = $this->_session->namespaceMap->getFullName($name);
00096                         $this->_properties[$name] = $value;
00097                 }               
00098         }
00099         
00100         public function updateContent($property, $mimetype, $encoding="UTF-8", $content=null)
00101         {
00102                 list($property) = $this->_session->namespaceMap->getFullNames(array($property));
00103                 $contentData = new ContentData($this, $property, $mimetype, $encoding);
00104                 if ($content != null)
00105                 {
00106                         $contentData->content = $content;
00107                 }
00108                 $this->_properties[$property] = $contentData;
00109                 
00110                 return $contentData;
00111         }
00112         
00113         public function hasAspect($aspect)
00114         {
00115                 list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));
00116                 $this->populateProperties();
00117                 return in_array($aspect, $this->_aspects);
00118         }
00119         
00120         public function addAspect($aspect, $properties = null)
00121         {
00122                 list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));            
00123                 $this->populateProperties();
00124                 
00125                 if (in_array($aspect, $this->_aspects) == false)
00126                 {
00127                         $this->_aspects[] = $aspect;
00128                         if ($properties != null)
00129                         {
00130                                 foreach ($properties as $name=>$value)
00131                                 {
00132                                         $name = $this->_session->namespaceMap->getFullName($name);
00133                                         $this->_properties[$name] = $value;
00134                                 }
00135                         }
00136                         
00137                         $this->remove_array_value($aspect, $this->removedAspects);
00138                         $this->addedAspects[] = $aspect;        
00139                 }                       
00140         }
00141         
00142         public function removeAspect($aspect)
00143         {
00144                 list($aspect) = $this->_session->namespaceMap->getFullNames(array($aspect));
00145                 $this->populateProperties();    
00146                 
00147                 if (in_array($aspect, $this->_aspects) == true)
00148                 {               
00149                         $this->remove_array_value($aspect, $this->_aspects);
00150                         $this->remove_array_value($aspect, $this->addedAspects);        
00151                         $this->removedAspects[] = $aspect;
00152                 }
00153         }
00154         
00155         public function createChild($type, $associationType, $associationName)
00156         {               
00157                 list($type, $associationType, $associationName) = $this->_session->namespaceMap->getFullNames(array($type, $associationType, $associationName));
00158                 
00159                 $id = $this->_session->nextSessionId();
00160                 $newNode = new Node($this->_session, $this->_store, $id);       
00161                 $childAssociation = new ChildAssociation($this, $newNode, $associationType, $associationName, true);
00162                 
00163                 $newNode->_isNewNode = true;
00164                 
00165                 $newNode->_properties = array();
00166                 $newNode->_aspects = array();
00167                 $newNode->_properties = array();
00168                 $newNode->_children = array();
00169                 $newNode->origionalProperties = array();
00170                 $newNode->addedAspects = array();
00171                 $newNode->removedAspects = array();
00172                 
00173                 $newNode->_type = $type;
00174                 $newNode->_parents = array(); 
00175                 $newNode->addedParents = array($this->__toString() => $childAssociation);
00176                 $newNode->_primaryParent = $this;
00177                 
00178                 $this->addedChildren[$newNode->__toString()] = $childAssociation;               
00179                 
00180                 $this->_session->addNode($newNode);
00181                 
00182                 return $newNode;                                        
00183         }
00184         
00185         public function addChild($node, $associationType, $associationName)
00186         {
00187                 list($associationType, $associationName) = $this->_session->namespaceMap->getFullNames(array($associationType, $associationName));
00188                 
00189                 $childAssociation = new ChildAssociation($this, $node, $associationType, $associationName, false);
00190                 $this->addedChildren[$node->__toString()] = $childAssociation;
00191                 $node->addedParents[$this->__toString()] = $childAssociation;
00192         }
00193         
00194         public function removeChild($childAssociation)
00195         {
00196                 
00197         }
00198         
00199         public function addAssociation($to, $associationType)
00200         {
00201                 list($associationType) = $this->_session->namespaceMap->getFullNames(array($associationType));
00202                 
00203                 $association = new Association($this, $to, $associationType);
00204                 $this->addedAssociations[$to->__toString()] = $association;             
00205         }
00206         
00207         public function removeAssociation($association)
00208         {
00209                 
00210         }
00211         
00212         public function createVersion($description=null, $major=false)
00213         {
00214                 // We can only create a version if there are no outstanding changes for this node
00215                 if ($this->isDirty() == true)
00216                 {
00217                         throw new Exception("You must save any outstanding modifications before a new version can be created.");
00218                 }
00219                 
00220                 // TODO implement major flag ...
00221                 
00222                 $client = WebServiceFactory::getAuthoringService($this->_session->repository->connectionUrl, $this->_session->ticket);
00223                 $result = $client->createVersion(
00224                         array("items" => array("nodes" => $this->__toArray()),
00225                               "comments" => array("name" => "description", "value" => $description),
00226                               "versionChildren" => false));                     
00227                               
00228                 // Clear the properties and aspects
00229                 $this->_properties = null;
00230                 $this->_aspects = null;                                                               
00231                               
00232                 // Get the version details 
00233                 // TODO get some of the other details too ...
00234                 $versionId = $result->createVersionReturn->versions->id->uuid;
00235                 $versionStoreScheme = $result->createVersionReturn->versions->id->store->scheme;
00236                 $versionStoreAddress = $result->createVersionReturn->versions->id->store->address;              
00237                 
00238                 // Create the version object to return        
00239                 return new Version($this->_session, new Store($this->_session, $versionStoreAddress, $versionStoreScheme), $versionId);                                       
00240         }
00241         
00242         private function isDirty()
00243         {
00244                 $result = true;
00245                 if ($this->_isNewNode == false &&
00246                         count($this->getModifiedProperties()) == 0 &&
00247                         ($this->addedAspects == null || count($this->addedAspects) == 0) &&
00248                         ($this->removedAssociations == null || count($this->removedAssociations) == 0) &&
00249                         ($this->addedChildren == null || count($this->addedChildren) == 0) &&
00250                         ($this->addedAssociations == null || count($this->addedAssociations) == 0))
00251                 {
00252                         $result = false;
00253                 }
00254                 return $result;
00255         }
00256         
00257         public function __get($name)
00258         {
00259                 $fullName = $this->_session->namespaceMap->getFullName($name);
00260                 if ($fullName != $name)
00261                 {
00262                         $this->populateProperties();    
00263                         if (array_key_exists($fullName, $this->_properties) == true)
00264                         {
00265                                 return $this->_properties[$fullName];
00266                         }       
00267                         else
00268                         {       
00269                                 return null;    
00270                         }       
00271                 }       
00272                 else
00273                 {
00274                         return parent::__get($name);
00275                 }
00276         }
00277         
00278         public function __set($name, $value)
00279         {
00280                 $fullName = $this->_session->namespaceMap->getFullName($name);
00281                 if ($fullName != $name)
00282                 {
00283                         $this->populateProperties();
00284                         $this->_properties[$fullName] = $value;
00285                         
00286                         // Ensure that the node and property details are stored on the contentData object
00287                         if ($value instanceof ContentData)
00288                         {
00289                                 $value->setPropertyDetails($this, $fullName);   
00290                         }
00291                 }
00292                 else
00293                 {
00294                         parent::__set($name, $value);
00295                 }
00296         }
00297 
00301         public function __toString() 
00302         {
00303                 return Node::__toNodeRef($this->_store, $this->id);
00304         }
00305         
00306         public static function __toNodeRef($store, $id)
00307         {
00308                 return $store->scheme . "://" . $store->address . "/" . $id;    
00309         }
00310         
00311         public function __toArray()
00312         {
00313                 return array("store" => $this->_store->__toArray(),
00314                                          "uuid" => $this->_id);
00315         }
00316   
00317     public function getSession()
00318     {
00319         return $this->_session;
00320     }
00321   
00322         public function getStore() 
00323         {
00324                 return $this->_store;
00325         }
00326 
00327         public function getId() 
00328         {
00329                 return $this->_id;
00330         }
00331         
00332         public function getIsNewNode()
00333         {
00334                 return $this->_isNewNode;
00335         }
00336 
00337         public function getType() 
00338         {
00339                 $this->populateProperties();    
00340                 return $this->_type;
00341         }
00342 
00343         public function getAspects() 
00344         {
00345                 $this->populateProperties();
00346                 return $this->_aspects;
00347         }
00348         
00349         public function getProperties()
00350         {
00351                 $this->populateProperties();
00352                 return $this->_properties;
00353         }
00354         
00355         public function setProperties($properties)
00356         {
00357                 $this->populateProperties();
00358                 $this->_properties = $properties;       
00359         }
00360         
00366         public function getVersionHistory()
00367         {
00368                 if ($this->_versionHistory == null)
00369                 {
00370                         $this->_versionHistory = new VersionHistory($this);
00371                 }
00372                 return $this->_versionHistory;
00373         }
00374         
00375         public function getChildren()
00376         {
00377                 if ($this->_children == null)
00378                 {
00379                         $this->populateChildren();
00380                 }
00381                 return $this->_children + $this->addedChildren;
00382         }
00383         
00384         public function getParents()
00385         {
00386                 if ($this->_parents == null)
00387                 {
00388                         $this->populateParents();
00389                 }
00390                 return $this->_parents + $this->addedParents;
00391         }
00392         
00393         public function getPrimaryParent()
00394         {
00395                 if ($this->_primaryParent == null)
00396                 {
00397                         $this->populateParents();
00398                 }
00399                 return $this->_primaryParent;   
00400         }
00401         
00402         public function getAssociations()
00403         {
00404                 if ($this->_associations == null)
00405                 {
00406                         $this->populateAssociations();
00407                 }
00408                 return $this->_associations + $this->addedAssociations;
00409         }
00410         
00413         private function populateProperties()
00414         {
00415                 if ($this->_isNewNode == false && $this->_properties == null)
00416                 {
00417                         $result = $this->_session->repositoryService->get(array (
00418                                         "where" => array (
00419                                                 "nodes" => array(
00420                                                         "store" => $this->_store->__toArray(),
00421                                                         "uuid" => $this->_id))));       
00422                                                         
00423                         $this->populateFromWebServiceNode($result->getReturn);
00424                 }       
00425         }
00426         
00427         private function populateFromWebServiceNode($webServiceNode)
00428         {
00429                 $this->_type = $webServiceNode->type;
00430 
00431                 // Get the aspects
00432                 $this->_aspects = array();
00433                 $aspects = $webServiceNode->aspects;
00434                 if (is_array($aspects) == true)
00435                 {
00436                         foreach ($aspects as $aspect)
00437                         {
00438                                 $this->_aspects[] = $aspect;
00439                         }
00440                 }
00441                 else
00442                 {
00443                         $this->_aspects[] = $aspects;   
00444                 }               
00445 
00446                 // Set the property values
00447                 // NOTE: do we need to be concerned with identifying whether this is an array or not when there is
00448                 //       only one property on a node
00449                 $this->_properties = array();
00450                 foreach ($webServiceNode->properties as $propertyDetails) 
00451                 {
00452                         $name = $propertyDetails->name;
00453                         $isMultiValue = $propertyDetails->isMultiValue;
00454                         $value = null;
00455                         if ($isMultiValue == false)
00456                         {
00457                                 $value = $propertyDetails->value;
00458                                 if ($this->isContentData($value) == true)
00459                                 {
00460                                         $value = new ContentData($this, $name);
00461                                 }
00462                         }
00463                         else
00464                         {
00465                                 $value = $propertyDetails->values;                              
00466                         }
00467                         $this->_properties[$name] = $value;
00468                                                 
00469                 }       
00470                 
00471                 $this->origionalProperties = $this->_properties;        
00472                 $this->addedAspects = array();
00473                 $this->removedAspects = array();
00474                 
00475         }       
00476         
00477         private function populateChildren()
00478         {
00479                 // TODO should do some sort of limited pull here        
00480                 $result = $this->_session->repositoryService->queryChildren(array("node" => $this->__toArray()));               
00481                 $resultSet = $result->queryReturn->resultSet;
00482                 
00483                 $children = array();
00484                 $map = $this->resultSetToMap($resultSet);
00485                 foreach($map as $value)
00486                 {
00487                         $id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
00488                         $store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
00489                         $store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
00490                         $assoc_type = $value["associationType"];
00491                         $assoc_name = $value["associationName"];
00492                         $isPrimary = $value["isPrimary"];
00493                         $nthSibling = $value["nthSibling"];
00494                         
00495                         $child = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
00496                         $children[$child->__toString()] = new ChildAssociation($this, $child, $assoc_type, $assoc_name, $isPrimary, $nthSibling);
00497                 }
00498                 
00499                 $this->_children = $children;   
00500         }
00501         
00502         private function populateAssociations()
00503         {
00504                 // TODO should do some sort of limited pull here
00505                 $result = $this->_session->repositoryService->queryAssociated(array("node" => $this->__toArray(),
00506                                                                                                                                                         "association" => array("associationType" => null,
00507                                                                                                                                                                                                    "direction" => null)));
00508                 $resultSet = $result->queryReturn->resultSet;
00509                 
00510                 $associations = array();
00511                 $map = $this->resultSetToMap($resultSet);
00512                 foreach($map as $value)
00513                 {
00514                         $id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
00515                         $store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
00516                         $store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
00517                         $assoc_type = $value["associationType"];
00518                         
00519                         $to = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
00520                         $associations[$to->__toString()] = new Association($this, $to, $assoc_type);
00521                 }
00522                 
00523                 $this->_associations = $associations;   
00524         }
00525         
00526         private function populateParents()
00527         {               
00528                 // TODO should do some sort of limited pull here
00529                 $result = $this->_session->repositoryService->queryParents(array("node" => $this->__toArray()));                
00530                 $resultSet = $result->queryReturn->resultSet;
00531                 
00532                 $parents = array();
00533                 $map = $this->resultSetToMap($resultSet);
00534                 foreach($map as $value)
00535                 {
00536                         $id = $value["{http://www.alfresco.org/model/system/1.0}node-uuid"];
00537                         $store_scheme = $value["{http://www.alfresco.org/model/system/1.0}store-protocol"];
00538                         $store_address = $value["{http://www.alfresco.org/model/system/1.0}store-identifier"];
00539                         $assoc_type = $value["associationType"];
00540                         $assoc_name = $value["associationName"];
00541                         $isPrimary = $value["isPrimary"];
00542                         $nthSibling = $value["nthSibling"];
00543                         
00544                         $parent = $this->_session->getNode(new Store($this->_session, $store_address, $store_scheme), $id);
00545                         if ($isPrimary == "true" or $isPrimary == true)
00546                         {
00547                                 $this->_primaryParent = $parent;
00548                         }
00549                         $parents[$parent->__toString()] = new ChildAssociation($parent, $this, $assoc_type, $assoc_name, $isPrimary, $nthSibling);
00550                 }
00551                 
00552                 $this->_parents = $parents;
00553         }
00554         
00555         public function onBeforeSave(&$statements)
00556         {
00557                 if ($this->_isNewNode == true)
00558                 {
00559                         $childAssociation = $this->addedParents[$this->_primaryParent->__toString()];           
00560                         
00561                         $parentArray = array();
00562                         $parent = $this->_primaryParent;
00563                         if ($parent->_isNewNode == true)
00564                         {
00565                                 $parentArray["parent_id"] = $parent->id;
00566                                 $parentArray["associationType"] = $childAssociation->type;
00567                                 $parentArray["childName"] = $childAssociation->name;
00568                     }
00569                     else
00570                     {
00571                         $parentArray["parent"] = array(
00572                                                                                         "store" => $this->_store->__toArray(),
00573                                                                                         "uuid" => $this->_primaryParent->_id,
00574                                                                                         "associationType" => $childAssociation->type,
00575                                                                                         "childName" => $childAssociation->name);
00576                     }
00577                                 
00578                         $this->addStatement($statements, "create",
00579                                                                 array("id" => $this->_id) +
00580                                                                 $parentArray +
00581                                                                 array(  
00582                                                                         "type" => $this->_type,
00583                                                                         "property" => $this->getPropertyArray($this->_properties)));    
00584                 }
00585                 else
00586                 {
00587                         // Add the update statement for the modified properties
00588                         $modifiedProperties = $this->getModifiedProperties();           
00589                         if (count($modifiedProperties) != 0)
00590                         {                                       
00591                                 $this->addStatement($statements, "update", array("property" => $this->getPropertyArray($modifiedProperties)) + $this->getWhereArray());
00592                         }
00593                         
00594                         // TODO deal with any deleted properties
00595                 }
00596                 
00597                 // Update any modified content properties
00598                 if ($this->_properties != null)
00599                 {
00600                         foreach($this->_properties as $name=>$value)
00601                         {
00602                                 if (($value instanceof ContentData) && $value->isDirty == true)
00603                                 {
00604                                         $value->onBeforeSave($statements, $this->getWhereArray());
00605                                 }
00606                         }
00607                 }               
00608                 
00609                 // Add the addAspect statements
00610                 if ($this->addedAspects != null)
00611                 {
00612                         foreach($this->addedAspects as $aspect)
00613                         {
00614                                 $this->addStatement($statements, "addAspect", array("aspect" => $aspect) + $this->getWhereArray());
00615                         }
00616                 }
00617                 
00618                 // Add the removeAspect
00619                 if ($this->removedAspects != null)
00620                 {
00621                         foreach($this->removedAspects as $aspect)
00622                         {
00623                                 $this->addStatement($statements, "removeAspect", array("aspect" => $aspect) + $this->getWhereArray());
00624                         }
00625                 }
00626                 
00627                 // Add non primary children
00628                 foreach($this->addedChildren as $childAssociation)
00629                 {
00630                         if ($childAssociation->isPrimary == false)
00631                         {
00632                                 
00633                                 $assocDetails = array("associationType" => $childAssociation->type, "childName" => $childAssociation->name);
00634                                 
00635                                 $temp = array();
00636                                 if ($childAssociation->child->_isNewNode == true)
00637                                 {
00638                                         $temp["to_id"] = $childAssociation->child->_id;
00639                                         $temp = $temp + $assocDetails;
00640                                 }       
00641                                 else
00642                                 {
00643                                         $temp["to"] = array(
00644                                                                         "store" => $this->_store->__toArray(),
00645                                                                         "uuid" => $childAssociation->child->_id) + 
00646                                                                         $assocDetails;  
00647                                 }
00648                                 $temp = $temp + $this->getWhereArray();
00649                                 $this->addStatement($statements, "addChild", $temp);
00650                         }
00651                 }
00652                 
00653                 // Add associations
00654                 foreach($this->addedAssociations as $association)
00655                 {
00656                         $temp = array("association" => $association->type);
00657                         $temp = $temp + $this->getPredicateArray("from", $this) + $this->getPredicateArray("to", $association->to);
00658                         $this->addStatement($statements, "createAssociation", $temp);
00659                 }
00660         }
00661         
00662         private function addStatement(&$statements, $statement, $body)
00663         {               
00664                 $result = array();      
00665                 if (array_key_exists($statement, $statements) == true)  
00666                 {
00667                         $result = $statements[$statement];
00668                 }
00669                 $result[] = $body;
00670                 $statements[$statement] = $result;
00671         }
00672         
00673         private function getWhereArray()
00674         {
00675                 return $this->getPredicateArray("where", $this);
00676         }
00677         
00678         private function getPredicateArray($label, $node)
00679         {
00680                 if ($node->_isNewNode == true)
00681                 {
00682                         return array($label."_id" => $node->_id);       
00683                 }
00684                 else
00685                 {
00686                         return array(
00687                                         $label => array(
00688                                                  "nodes" => $node->__toArray()
00689                                                  ));                                             
00690                 }       
00691         }
00692         
00693         private function getPropertyArray($properties)
00694         {
00695                 $result = array();
00696                 foreach ($properties as $name=>$value)
00697                 {       
00698                         // Ignore content properties
00699                         if (($value instanceof ContentData) == false)
00700                         {
00701                                 // TODO need to support multi values
00702                                 $result[] = array(
00703                                                                 "name" => $name,
00704                                                                 "isMultiValue" => false,
00705                                                                 "value" => $value);
00706                         }
00707                 }
00708                 return $result;
00709         }
00710         
00711         private function getModifiedProperties()
00712         {
00713                 $modified = $this->_properties;
00714                 $origional = $this->origionalProperties;
00715                 $result = array();
00716                 if ($modified != null)
00717                 {
00718                         foreach ($modified as $key=>$value)
00719                         {
00720                                 // Ignore content properties
00721                                 if (($value instanceof ContentData) == false)
00722                                 {
00723                                         if (array_key_exists($key, $origional) == true)
00724                                         {
00725                                                 // Check to see if the value have been modified
00726                                                 if ($value != $origional[$key])
00727                                                 {
00728                                                         $result[$key] = $value;
00729                                                 }
00730                                         }       
00731                                         else
00732                                         {                       
00733                                                 $result[$key] = $value;
00734                                         }
00735                                 }
00736                         }
00737                 }
00738                 return $result;
00739         }
00740         
00741         public function onAfterSave($idMap)
00742         {
00743                 if (array_key_exists($this->_id, $idMap ) == true)
00744                 {
00745                         $uuid = $idMap[$this->_id];
00746                         if ($uuid != null)
00747                         {
00748                                 $this->_id = $uuid;
00749                         }
00750                 }
00751                 
00752                 if ($this->_isNewNode == true)
00753                 {
00754                         $this->_isNewNode = false;
00755                         
00756                         // Clear the properties and aspect 
00757                         $this->_properties = null;
00758                         $this->_aspects = null;
00759                 }
00760                 
00761                 // Update any modified content properties
00762                 if ($this->_properties != null)
00763                 {
00764                         foreach($this->_properties as $name=>$value)
00765                         {
00766                                 if (($value instanceof ContentData) && $value->isDirty == true)
00767                                 {
00768                                         $value->onAfterSave();
00769                                 }
00770                         }
00771                 }
00772                 
00773                 $this->origionalProperties = $this->_properties;
00774                 
00775                 if ($this->_aspects != null)
00776                 {
00777                         // Calculate the updated aspect list
00778                         if ($this->addedAspects != null)
00779                         {                       
00780                                 $this->_aspects = $this->_aspects + $this->addedAspects;
00781                         }
00782                         if ($this->removedAspects != null)
00783                         {
00784                                 foreach ($this->_aspects as $aspect)
00785                                 {
00786                                         if (in_array($aspect, $this->removedAspects) == true)
00787                                         {                                       
00788                                                 $this->remove_array_value($aspect, $this->_aspects);
00789                                         }
00790                                 }
00791                         }
00792                 } 
00793                 $this->addedAspects = array();
00794                 $this->removedAspects = array();
00795                 
00796                 if ($this->_parents != null)
00797                 {
00798                         $this->_parents = $this->_parents + $this->addedParents;
00799                 }
00800                 $this->addedParents = array();
00801                 
00802                 if ($this->_children != null)
00803                 {
00804                         $this->_children = $this->_children + $this->addedChildren;
00805                 }
00806                 $this->addedChildren = array();         
00807                 
00808                 if ($this->_associations != null)
00809                 {
00810                         $this->_associations = $this->_associations + $this->addedAssociations;
00811                 }
00812                 $this->addedAssociations = array();
00813         }
00814 }
00815 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations