Author: sevein
Date: Wed Jul 11 11:47:10 2012
New Revision: 11908

Log:
Add isInTree, isRoot and isDescendantOf checks in moveToNextSiblingOf and 
moveToPrevSiblingOf

Modified:
   trunk/lib/model/om/BaseActor.php
   trunk/lib/model/om/BaseDigitalObject.php
   trunk/lib/model/om/BaseInformationObject.php
   trunk/lib/model/om/BaseMenu.php
   trunk/lib/model/om/BasePhysicalObject.php
   trunk/lib/model/om/BaseTaxonomy.php
   trunk/lib/model/om/BaseTerm.php
   trunk/lib/propel/builder/QubitObjectBuilder.php
   trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php

Modified: trunk/lib/model/om/BaseActor.php
==============================================================================
--- trunk/lib/model/om/BaseActor.php    Wed Jul 11 11:42:23 2012        (r11907)
+++ trunk/lib/model/om/BaseActor.php    Wed Jul 11 11:47:10 2012        (r11908)
@@ -811,9 +811,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -823,9 +833,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BaseDigitalObject.php
==============================================================================
--- trunk/lib/model/om/BaseDigitalObject.php    Wed Jul 11 11:42:23 2012        
(r11907)
+++ trunk/lib/model/om/BaseDigitalObject.php    Wed Jul 11 11:47:10 2012        
(r11908)
@@ -538,9 +538,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -550,9 +560,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BaseInformationObject.php
==============================================================================
--- trunk/lib/model/om/BaseInformationObject.php        Wed Jul 11 11:42:23 
2012        (r11907)
+++ trunk/lib/model/om/BaseInformationObject.php        Wed Jul 11 11:47:10 
2012        (r11908)
@@ -789,9 +789,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -801,9 +811,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BaseMenu.php
==============================================================================
--- trunk/lib/model/om/BaseMenu.php     Wed Jul 11 11:42:23 2012        (r11907)
+++ trunk/lib/model/om/BaseMenu.php     Wed Jul 11 11:47:10 2012        (r11908)
@@ -978,9 +978,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -990,9 +1000,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BasePhysicalObject.php
==============================================================================
--- trunk/lib/model/om/BasePhysicalObject.php   Wed Jul 11 11:42:23 2012        
(r11907)
+++ trunk/lib/model/om/BasePhysicalObject.php   Wed Jul 11 11:47:10 2012        
(r11908)
@@ -661,9 +661,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -673,9 +683,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BaseTaxonomy.php
==============================================================================
--- trunk/lib/model/om/BaseTaxonomy.php Wed Jul 11 11:42:23 2012        (r11907)
+++ trunk/lib/model/om/BaseTaxonomy.php Wed Jul 11 11:47:10 2012        (r11908)
@@ -696,9 +696,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -708,9 +718,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/model/om/BaseTerm.php
==============================================================================
--- trunk/lib/model/om/BaseTerm.php     Wed Jul 11 11:42:23 2012        (r11907)
+++ trunk/lib/model/om/BaseTerm.php     Wed Jul 11 11:47:10 2012        (r11908)
@@ -1923,9 +1923,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -1935,9 +1945,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

Modified: trunk/lib/propel/builder/QubitObjectBuilder.php
==============================================================================
--- trunk/lib/propel/builder/QubitObjectBuilder.php     Wed Jul 11 11:42:23 
2012        (r11907)
+++ trunk/lib/propel/builder/QubitObjectBuilder.php     Wed Jul 11 11:47:10 
2012        (r11908)
@@ -2129,9 +2129,19 @@
 
   public function moveToPrevSiblingOf(\$sibling, PropelPDO \$con = null)
   {
-    if (\$this->parentId != \$sibling->parentId)
+    if (!\$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if (\$sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if (\$sibling->isDescendantOf(\$this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     \$this->moveSubtreeTo(\$sibling->lft, \$con);
@@ -2148,9 +2158,19 @@
 
   public function moveToNextSiblingOf(\$sibling, PropelPDO \$con = null)
   {
-    if (\$this->parentId != \$sibling->parentId)
+    if (!\$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if (\$sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if (\$sibling->isDescendantOf(\$this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     \$this->moveSubtreeTo(\$sibling->rgt + 1, \$con);

Modified: trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php     Wed Jul 11 
11:42:23 2012        (r11907)
+++ trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php     Wed Jul 11 
11:47:10 2012        (r11908)
@@ -1058,9 +1058,19 @@
 
   public function moveToPrevSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
+    {
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->lft, $con);
@@ -1070,9 +1080,19 @@
 
   public function moveToNextSiblingOf($sibling, PropelPDO $con = null)
   {
-    if ($this->parentId != $sibling->parentId)
+    if (!$this->isInTree())
+    {
+      throw new PropelException('This object must be already in the tree to be 
moved. Use the insertAsPrevSiblingOf() instead.');
+    }
+
+    if ($sibling->isRoot())
+    {
+      throw new PropelException('Cannot move to previous sibling of a root 
node.');
+    }
+
+    if ($sibling->isDescendantOf($this))
     {
-      throw new PropelException('This functionality is limited to objects 
within the same level.');
+      throw new PropelException('Cannot move a node as sibling of one of its 
subtree nodes.');
     }
 
     $this->moveSubtreeTo($sibling->rgt + 1, $con);

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to