Example #1
0
 /**
  * Save changes made to objects.
  *
  * Objects stay dirties after save. You have to destroy/reload them to get them up-to-date (id, version, ...)
  *
  * @param type $comment
  * @return bool true if has saved something, false if nothing to save.
  * @throws OSM_Exception if not authenticated
  */
 public function saveChanges($comment)
 {
     OSM_ZLog::notice(__METHOD__, 'comment = "', $comment, '"');
     if ($this->_authProvider == null) {
         throw new OSM_Exception('Must be authenticated');
     }
     if ($this->_options['simulation']) {
         OSM_ZLog::notice(__METHOD__, 'Simulation Mode, not saving' . ($this->_options['outputFolder'] != null ? ' but look inside folder ' . $this->_options['outputFolder'] : ''));
     }
     $dirtyObjects = $this->getDirtyObjects();
     $dirtyObjectsCount = count($dirtyObjects);
     if ($dirtyObjectsCount == 0) {
         OSM_ZLog::notice(__METHOD__, 'No dirty object, abort save');
         return false;
     }
     OSM_ZLog::notice(__METHOD__, 'Has dirty ', $dirtyObjectsCount, ' objects');
     $changeSet = $this->_createChangeSet($comment);
     $changeSetId = $changeSet->getId();
     foreach ($dirtyObjects as $obj) {
         //OSM_ZLog::debug(__METHOD__,print_r($obj,true));
         if ($obj->isDeleted()) {
             $changeSet->deleteObject($obj);
         } else {
             $changeSet->addObject($obj);
         }
     }
     $this->_uploadChangeSet($changeSet);
     $this->_closeChangeSet($changeSet);
     return true;
 }