Commit c74c9c6e authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #254 in ZP/z-push from...

Merge pull request #254 in ZP/z-push from bugfix/ZP-940-implement-set-getmovestates-in-combined to develop

* commit '40020a48':
  ZP-940 Fixed comments.
  ZP-940 Make combined backend movestate compatible.
parents 3651a8e1 40020a48
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
class ExportChangesCombined implements IExportChanges { class ExportChangesCombined implements IExportChanges {
private $backend; private $backend;
private $syncstates; private $syncstates;
private $movestateSrc;
private $movestateDst;
private $exporters; private $exporters;
private $importer; private $importer;
private $importwraps; private $importwraps;
...@@ -56,6 +58,8 @@ class ExportChangesCombined implements IExportChanges { ...@@ -56,6 +58,8 @@ class ExportChangesCombined implements IExportChanges {
public function ExportChangesCombined(&$backend) { public function ExportChangesCombined(&$backend) {
$this->backend =& $backend; $this->backend =& $backend;
$this->exporters = array(); $this->exporters = array();
$this->movestateSrc = false;
$this->movestateDst = false;
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined constructed"); ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined constructed");
} }
...@@ -180,4 +184,46 @@ class ExportChangesCombined implements IExportChanges { ...@@ -180,4 +184,46 @@ class ExportChangesCombined implements IExportChanges {
} }
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->InitializeExporter(...) success"); ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->InitializeExporter(...) success");
} }
/**
* Sets the states from move operations.
* When src and dst state are set, a MOVE operation is being executed.
*
* @param mixed $srcState
* @param mixed (opt) $dstState, default: null
*
* @access public
* @return boolean
*/
public function SetMoveStates($srcState, $dstState = null) {
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->SetMoveStates()");
// Set the move states equally to every sub exporter.
// By default they are false or null, we know that they've changed, if the exporter will return a different value.
foreach($this->exporters as $i => $e){
$e->SetMoveStates($srcState, $dstState);
}
// let's remember what we sent down
$this->movestateSrc = $srcState;
$this->movestateDst = $dstState;
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->SetMoveStates() success");
}
/**
* Gets the states of special move operations.
*
* @access public
* @return array(0 => $srcState, 1 => $dstState)
*/
public function GetMoveStates() {
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->GetMoveStates()");
foreach($this->exporters as $i => $e){
list($srcState, $dstState) = $this->exporters[$i]->GetMoveStates();
if ($srcState != $this->movestateSrc || $dstState != $this->movestateDst) {
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->GetMoveStates() success (returned states from exporter $i)");
return array($srcState, $dstState);
}
}
ZLog::Write(LOGLEVEL_DEBUG, "ExportChangesCombined->GetMoveStates() success (no movestate)");
return false;
}
} }
...@@ -290,6 +290,40 @@ class ImportChangesCombined implements IImportChanges { ...@@ -290,6 +290,40 @@ class ImportChangesCombined implements IImportChanges {
} }
return $this->icc->GetState(); return $this->icc->GetState();
} }
/**
* Sets the states from move operations.
* When src and dst state are set, a MOVE operation is being executed.
*
* @param mixed $srcState
* @param mixed (opt) $dstState, default: null
*
* @access public
* @return boolean
*/
public function SetMoveStates($srcState, $dstState = null) {
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesCombined->SetMoveStates()");
if (!$this->icc) {
ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->SetMoveStates() icc not configured");
return false;
}
$this->icc->SetMoveStates($srcState, $dstState);
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesCombined->SetMoveStates() success");
}
/**
* Gets the states of special move operations.
*
* @access public
* @return array(0 => $srcState, 1 => $dstState)
*/
public function GetMoveStates() {
if (!$this->icc) {
ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->GetMoveStates() icc not configured");
return false;
}
return $this->icc->GetMoveStates();
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment