fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6708] Added code to update bim objects and tests


From: Petur Bjorn Thorsteinsson
Subject: [Fmsystem-commits] [6708] Added code to update bim objects and tests
Date: Mon, 27 Dec 2010 13:15:39 +0000

Revision: 6708
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6708
Author:   peturbjorn
Date:     2010-12-27 13:15:39 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
Added code to update bim objects and tests

Modified Paths:
--------------
    branches/dev-bim2/property/inc/class.sobim.inc.php
    branches/dev-bim2/property/tests/BIM/PropertyBimTestSuite.php
    branches/dev-bim2/property/tests/BIM/TestSObim.php

Modified: branches/dev-bim2/property/inc/class.sobim.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.sobim.inc.php  2010-12-27 12:29:55 UTC 
(rev 6707)
+++ branches/dev-bim2/property/inc/class.sobim.inc.php  2010-12-27 13:15:39 UTC 
(rev 6708)
@@ -20,6 +20,7 @@
        public function addBimItem($bimItem);
        public function deleteBimItem($guid);
        public function checkIfBimItemExists($guid);
+       public function updateBimItem($bimItem);
 }
 class sobim_impl implements sobim
 {
@@ -65,9 +66,10 @@
        
        public function addBimItem($bimItem) {
                /* @var $bimItem BimItem */
+               
                $sql = "INSERT INTO ".self::bimItemTable." (type, guid, 
xml_representation) values (";
-               $sql = $sql."(select id from ".self::bimTypeTable." where name 
= '$bimItem->getType()'),";
-               $sql = $sql."'$bimItem->getGuid()', '$bimItem->getXml()')";
+               $sql = $sql."(select id from ".self::bimTypeTable." where name 
= '".$bimItem->getType()."'),";
+               $sql = $sql."'".$bimItem->getGuid()."', 
'".$bimItem->getXml()."')";
                if(is_null($this->db->query($sql,__LINE__,__FILE__))) {
                        throw new Exception('Query to add item was 
unsuccessful');
                } else {
@@ -98,6 +100,18 @@
                        return $this->db->num_rows();
                }
        }
+       
+       public function updateBimItem($bimItem) {
+               if(!$this->checkIfBimItemExists($bimItem->getGuid())) {
+                       throw new Exception("Item does not exist!");
+               }
+               $sql = "Update ".self::bimItemTable." set 
xml_representation='$bimItem->getXml()' where guid='".$bimItem->getGuid()."'";
+        if(is_null($this->db->query($sql,__LINE__,__FILE__) )){
+                       throw new Exception("Error updating xml of bim item!");
+               } else {
+                       return (bool)$this->db->num_rows();
+               }
+       }
 
 
 
@@ -181,7 +195,9 @@
        function getXml() {
                return $this->xml;
        }
-       
+       function setXml($xml) {
+               $this->xml = $xml;
+       }
         
 }
 

Modified: branches/dev-bim2/property/tests/BIM/PropertyBimTestSuite.php
===================================================================
--- branches/dev-bim2/property/tests/BIM/PropertyBimTestSuite.php       
2010-12-27 12:29:55 UTC (rev 6707)
+++ branches/dev-bim2/property/tests/BIM/PropertyBimTestSuite.php       
2010-12-27 13:15:39 UTC (rev 6708)
@@ -64,7 +64,8 @@
                
         //$suite->addTestFiles(self::$suite_tests);
         
-        $suite_tests = array(dirname(__FILE__).'\TestSObim.php', 
dirname(__FILE__).'\TestSObimtype.php');
+               $suite_tests = array(dirname(__FILE__).'\TestSObim.php', 
dirname(__FILE__).'\TestSObimtype.php');
+        
                $suite->addTestFiles($suite_tests);
         return $suite;
     }

Modified: branches/dev-bim2/property/tests/BIM/TestSObim.php
===================================================================
--- branches/dev-bim2/property/tests/BIM/TestSObim.php  2010-12-27 12:29:55 UTC 
(rev 6707)
+++ branches/dev-bim2/property/tests/BIM/TestSObim.php  2010-12-27 13:15:39 UTC 
(rev 6708)
@@ -116,6 +116,7 @@
                $sobim = new sobim_impl($this->db);
                /* @var $bimItem BimItem */
                $bimItem = $sobim->getBimItem($this->projectGuid);
+               var_dump($bimItem);
                $this->assertNotNull($bimItem);
                $bimItem->setDatabaseId(0);
                $localBimItem = new BimItem(0, $this->projectGuid, 
$this->projectType, $this->projectXml->asXML());
@@ -135,8 +136,17 @@
        public function testAddBimItem() {
                $sobim = new sobim_impl($this->db);
                $itemToBeAdded = new BimItem(null, $this->projectGuid, 
$this->projectType, $this->projectXml->asXML());
-               var_dump($itemToBeAdded);
                $this->assertEquals(1, $sobim->addBimItem($itemToBeAdded));
        }
        
+       public function testUpdateBimItem() {
+               $sobim = new sobim_impl($this->db);
+               $bimItem = $sobim->getBimItem($this->projectGuid);
+               $xml = new SimpleXMLElement($bimItem->getXml());
+               $xml->attributes->name = "new name";
+               $bimItem->setXml($xml->asXML());
+               
+               $this->assertTrue($sobim->updateBimItem($bimItem));
+       }
+       
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]