Author: dr
Date: Tue Jul 31 10:42:17 2007
New Revision: 5769
Log:
- Removed the ezcTreeBackend interface and added those method as abstract
methods to the ezcTree abstract class. The backends now just have to inherit
from that one.
- Added a test for rollback that pointed me to this issue.
Removed:
trunk/Tree/src/interfaces/backend.php
trunk/Tree/src/interfaces/backend.xml
Modified:
trunk/Tree/design/class_diagram.png
trunk/Tree/src/backends/db.php
trunk/Tree/src/backends/memory.php
trunk/Tree/src/backends/xml.php
trunk/Tree/src/tree.php
trunk/Tree/src/tree_autoload.php
trunk/Tree/tests/tree.php
Modified: trunk/Tree/design/class_diagram.png
==============================================================================
Binary files - no diff available.
Modified: trunk/Tree/src/backends/db.php
==============================================================================
--- trunk/Tree/src/backends/db.php [iso-8859-1] (original)
+++ trunk/Tree/src/backends/db.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -17,7 +17,7 @@
* @version //autogentag//
* @mainclass
*/
-abstract class ezcTreeDb extends ezcTree implements ezcTreeBackend
+abstract class ezcTreeDb extends ezcTree
{
protected $dbh;
Modified: trunk/Tree/src/backends/memory.php
==============================================================================
--- trunk/Tree/src/backends/memory.php [iso-8859-1] (original)
+++ trunk/Tree/src/backends/memory.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -17,7 +17,7 @@
* @version //autogentag//
* @mainclass
*/
-class ezcTreeMemory extends ezcTree implements ezcTreeBackend
+class ezcTreeMemory extends ezcTree
{
/**
* Contains a list of all nodes, indexed by node ID that link directly to
the create node so that they can be looked up quickly.
Modified: trunk/Tree/src/backends/xml.php
==============================================================================
--- trunk/Tree/src/backends/xml.php [iso-8859-1] (original)
+++ trunk/Tree/src/backends/xml.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -17,7 +17,7 @@
* @version //autogentag//
* @mainclass
*/
-class ezcTreeXml extends ezcTree implements ezcTreeBackend
+class ezcTreeXml extends ezcTree
{
const relaxNG = '<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:etd="http://components.ez.no/Tree/data"
ns="http://components.ez.no/Tree" xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
Modified: trunk/Tree/src/tree.php
==============================================================================
--- trunk/Tree/src/tree.php [iso-8859-1] (original)
+++ trunk/Tree/src/tree.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -131,6 +131,161 @@
}
/**
+ * Returns all the children of the node with ID $id.
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchChildren( $id );
+
+ /**
+ * Returns all the nodes in the path from the root node to the node with ID
+ * $id, including those two nodes.
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchPath( $id );
+
+ /**
+ * Alias for fetchSubtreeDepthFirst().
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchSubtree( $id );
+
+ /**
+ * Returns the node with ID $id and all its children, sorted accoring to
+ * the `Breadth-first sorting`_ algorithm.
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchSubtreeBreadthFirst( $id );
+
+ /**
+ * Returns the node with ID $id and all its children, sorted accoring to
+ * the `Depth-first sorting`_ algorithm.
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchSubtreeDepthFirst( $id );
+
+ /**
+ * Returns the node with ID $id and all its children, sorted accoring to
+ * the `Topological sorting`_ algorithm.
+ *
+ * @param string $id
+ * @return ezcTreeNodeList
+ */
+ abstract public function fetchSubtreeTopological( $id );
+
+
+ /**
+ * Returns the number of direct children of the node with ID $id
+ *
+ * @param string $id
+ * @return int
+ */
+ abstract public function getChildCount( $id );
+
+ /**
+ * Returns the number of children of the node with ID $id, recursively
+ *
+ * @param string $id
+ * @return int
+ */
+ abstract public function getChildCountRecursive( $id );
+
+ /**
+ * Returns the distance from the root node to the node with ID $id
+ *
+ * @param string $id
+ * @return int
+ */
+ abstract public function getPathLength( $id );
+
+
+ /**
+ * Returns whether the node with ID $id has children
+ *
+ * @param string $id
+ * @return bool
+ */
+ abstract public function hasChildNodes( $id );
+
+
+ /**
+ * Returns whether the node with ID $childId is a direct child of the node
+ * with ID $parentId
+ *
+ * @param string $childId
+ * @param string $parentId
+ * @return bool
+ */
+ abstract public function isChildOf( $childId, $parentId );
+
+ /**
+ * Returns whether the node with ID $childId is a direct or indirect child
+ * of the node with ID $parentId
+ *
+ * @param string $childId
+ * @param string $parentId
+ * @return bool
+ */
+ abstract public function isDecendantOf( $childId, $parentId );
+
+ /**
+ * Returns whether the nodes with IDs $child1Id and $child2Id are siblings
+ * (ie, the share the same parent)
+ *
+ * @param string $child1Id
+ * @param string $child2Id
+ * @return bool
+ */
+ abstract public function isSiblingOf( $child1Id, $child2Id );
+
+
+ /**
+ * Returns whether the node with ID $id exists
+ *
+ * @param string $id
+ * @return bool
+ */
+ abstract public function nodeExists( $id );
+
+ /**
+ * Sets a new node as root node, this wipes also out the whole tree
+ *
+ * @param ezcTreeNode $node
+ */
+ abstract public function setRootNode( ezcTreeNode $node );
+
+ /**
+ * Adds the node $childNode as child of the node with ID $parentId
+ *
+ * @param string $parentId
+ * @paran ezcTreeNode $childNode
+ */
+ abstract public function addChild( $parentId, ezcTreeNode $childNode );
+
+ /**
+ * Deletes the node with ID $id from the tree, including all its children
+ *
+ * @param string $id
+ */
+ abstract public function delete( $id );
+
+ /**
+ * Moves the node with ID $id as child to the node with ID $targetParentId
+ *
+ * @param string $id
+ * @param string $targetParentId
+ */
+ abstract public function move( $id, $targetParentId );
+ /**
* Starts an transaction in which all tree modifications are queued until
* the transaction is committed with the commit() method.
*/
@@ -178,7 +333,7 @@
*
* @param ezcTreeTransactionItem $item
*/
- public function addTransactionItem( ezcTreeTransactionItem $item )
+ protected function addTransactionItem( ezcTreeTransactionItem $item )
{
if ( !$this->inTransaction )
{
Modified: trunk/Tree/src/tree_autoload.php
==============================================================================
--- trunk/Tree/src/tree_autoload.php [iso-8859-1] (original)
+++ trunk/Tree/src/tree_autoload.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -15,7 +15,6 @@
'ezcTreeInvalidClassException' => 'Tree/exceptions/invalid_class.php',
'ezcTreeInvalidIdException' => 'Tree/exceptions/invalid_id.php',
'ezcTree' => 'Tree/tree.php',
- 'ezcTreeBackend' => 'Tree/interfaces/backend.php',
'ezcTreeDataStore' => 'Tree/interfaces/data_store.php',
'ezcTreeDb' => 'Tree/backends/db.php',
'ezcTreeDbDataStore' => 'Tree/stores/db.php',
Modified: trunk/Tree/tests/tree.php
==============================================================================
--- trunk/Tree/tests/tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/tree.php [iso-8859-1] Tue Jul 31 10:42:17 2007
@@ -531,6 +531,31 @@
self::assertSame( 2, $tree->getChildCount( '1' ) );
}
+ public function testTreeDeleteNodeWithTransactionRollback()
+ {
+ $tree = $this->setUpTestTree();
+
+ self::assertSame( true, $tree->nodeExists( 5 ) );
+
+ $tree->beginTransaction();
+ $tree->delete( '5' );
+ $tree->delete( '4' );
+
+ self::assertSame( true, $tree->nodeExists( '4' ) );
+ self::assertSame( true, $tree->nodeExists( '6' ) );
+ self::assertSame( true, $tree->nodeExists( '8' ) );
+ self::assertSame( 4, $tree->getChildCount( '1' ) );
+
+ $tree->rollback();
+
+ self::assertSame( true, $tree->nodeExists( '4' ) );
+ self::assertSame( true, $tree->nodeExists( '5' ) );
+ self::assertSame( true, $tree->nodeExists( '6' ) );
+ self::assertSame( true, $tree->nodeExists( '7' ) );
+ self::assertSame( true, $tree->nodeExists( '8' ) );
+ self::assertSame( 8, $tree->getChildCountRecursive( '1' ) );
+ }
+
public function testTreeNodeListIterator()
{
$tree = $this->setUpTestTree();
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components