[Cs-webapplibs-commits] SF.net SVN: cs-webapplibs:[157] trunk/0.3
Status: Beta
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-11-09 18:48:36
|
Revision: 157 http://cs-webapplibs.svn.sourceforge.net/cs-webapplibs/?rev=157&view=rev Author: crazedsanity Date: 2009-11-09 18:48:26 +0000 (Mon, 09 Nov 2009) Log Message: ----------- Minor changes. /abstract/cs_gdlPath.abstract.class.php: * create_path(): -- returns the pathIdList if available, otherwise creates the path. * get_text_path_from_id_path() [RENAMED to get_path_from_idlist()] * get_path_from_idlist() [NEW, RENAMED FROM get_text_path_from_id_path()] -- removed call to debug_var_dump(). /setup/schema.pgsql.sql: * make cswal_gdl_path_table.path_id_list UNIQUE. /setup/schema.mysql.sql: * make cswal_gdl_path_table.path_id_list UNIQUE. /tests/testOfCSWebAppLibs.php: * added more tests for get_path_from_idlist(). Modified Paths: -------------- trunk/0.3/abstract/cs_gdlPath.abstract.class.php trunk/0.3/setup/schema.mysql.sql trunk/0.3/setup/schema.pgsql.sql trunk/0.3/tests/testOfCSWebAppLibs.php Modified: trunk/0.3/abstract/cs_gdlPath.abstract.class.php =================================================================== --- trunk/0.3/abstract/cs_gdlPath.abstract.class.php 2009-11-09 17:25:37 UTC (rev 156) +++ trunk/0.3/abstract/cs_gdlPath.abstract.class.php 2009-11-09 18:48:26 UTC (rev 157) @@ -26,14 +26,20 @@ $idList = $this->create_path_objects($path); $pathIdList = $this->create_id_path($idList); - $sql = "INSERT INTO ". self::table ." (path_id_list) VALUES ('". $pathIdList ."')"; - - try { - $insertedId = $this->db->run_insert($sql, self::tableSeq); + if($this->get_path_from_idlist($pathIdList)) { $retval = $pathIdList; } - catch(exception $e) { - throw new exception(__METHOD__ .": unable to create path::: ". $e->getMessage()); + else { + + $sql = "INSERT INTO ". self::table ." (path_id_list) VALUES ('". $pathIdList ."')"; + + try { + $insertedId = $this->db->run_insert($sql, self::tableSeq); + $retval = $pathIdList; + } + catch(exception $e) { + throw new exception(__METHOD__ .": unable to create path::: ". $e->getMessage()); + } } return($retval); @@ -99,12 +105,11 @@ //------------------------------------------------------------------------- - public function get_text_path_from_id_path($idPath) { + public function get_path_from_idlist($idPath) { $idList = explode('::', preg_replace('/^:/', '', preg_replace('/:$/', '', $idPath))); $nameList = $this->build_object_name_list($idList); - $this->gfObj->debug_var_dump($nameList,1); $retval = "/"; foreach($nameList as $id=>$name) { Modified: trunk/0.3/setup/schema.mysql.sql =================================================================== --- trunk/0.3/setup/schema.mysql.sql 2009-11-09 17:25:37 UTC (rev 156) +++ trunk/0.3/setup/schema.mysql.sql 2009-11-09 18:48:26 UTC (rev 157) @@ -178,7 +178,7 @@ CREATE TABLE `cswal_gdl_path_table` ( `path_id` int(11) NOT NULL PRIMARY KEY auto_increment, - `path_id_list` text NOT NULL + `path_id_list` text NOT NULL UNIQUE ) ENGINE=InnoDB; -- Modified: trunk/0.3/setup/schema.pgsql.sql =================================================================== --- trunk/0.3/setup/schema.pgsql.sql 2009-11-09 17:25:37 UTC (rev 156) +++ trunk/0.3/setup/schema.pgsql.sql 2009-11-09 18:48:26 UTC (rev 157) @@ -131,7 +131,7 @@ CREATE TABLE cswal_gdl_path_table ( path_id serial NOT NULL PRIMARY KEY, - path_id_list text NOT NULL + path_id_list text NOT NULL UNIQUE ); -- Modified: trunk/0.3/tests/testOfCSWebAppLibs.php =================================================================== --- trunk/0.3/tests/testOfCSWebAppLibs.php 2009-11-09 17:25:37 UTC (rev 156) +++ trunk/0.3/tests/testOfCSWebAppLibs.php 2009-11-09 18:48:26 UTC (rev 157) @@ -244,6 +244,18 @@ $newPathIdList = $x->create_path('/testing/'. $myPath); $myPathIdList = ':'. $this->gfObj->string_from_array(array_flip($pathBits), null, '::') .':'; $this->assertEqual($newPathIdList, $myPathIdList); + + $this->assertEqual($newPathIdList, $x->create_path('/testing/'. $myPath)); + + $myRearrangedPath = array_reverse($pathBits, true); + $rPathIdList = ':'. $this->gfObj->string_from_array(array_flip($myRearrangedPath), null, '::') .':'; + $rPath = '/'. $this->gfObj->string_from_array($myRearrangedPath, null, '/'); + $this->assertEqual($x->create_path($rPath), $rPathIdList); + + $this->assertEqual($x->get_path_from_idlist($x->create_path($rPath)), $x->get_path_from_idlist($rPathIdList)); + $this->assertEqual($x->get_path_from_idlist($x->create_path($rPath)), $x->get_path_from_idlist($rPathIdList)); + $this->assertEqual($x->get_path_from_idlist($x->create_path($rPath)), $x->get_path_from_idlist($rPathIdList)); + $this->assertEqual($x->get_path_from_idlist($x->create_path($rPath)), $x->get_path_from_idlist($rPathIdList)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |