fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6915] Improved error handling


From: Petur Thorsteinsson
Subject: [Fmsystem-commits] [6915] Improved error handling
Date: Thu, 03 Feb 2011 19:20:03 +0000

Revision: 6915
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6915
Author:   peturbjorn
Date:     2011-02-03 19:20:02 +0000 (Thu, 03 Feb 2011)
Log Message:
-----------
Improved error handling

Modified Paths:
--------------
    branches/dev-bim2/property/inc/class.bobimmodel.inc.php

Modified: branches/dev-bim2/property/inc/class.bobimmodel.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.bobimmodel.inc.php     2011-02-03 
19:19:19 UTC (rev 6914)
+++ branches/dev-bim2/property/inc/class.bobimmodel.inc.php     2011-02-03 
19:20:02 UTC (rev 6915)
@@ -14,6 +14,7 @@
        public function setSobimmodel(sobimmodel $sobimmodel);
        public function checkBimModelExists();
        public function checkBimModelExistsByModelId();
+       public function checkBimModelIsUsed();
        public function removeIfcModel();
        public function removeIfcModelByModelId();
        public function setModelName($name);
@@ -85,31 +86,17 @@
                        
                        foreach($BimModelArray as $BimModel) {
                                //var_dump($BimModel);
-                               array_push($outputArray, 
$this->transformObjectToArray($BimModel));
+                               /* @var $BimModel BimModel */
+                               //array_push($outputArray, 
$this->transformObjectToArray($BimModel));
+                               array_push($outputArray, 
$BimModel->transformObjectToArray());
                        }
                        return $outputArray;
                }
                
        }
+       
+       
        /*
-        * Takes an object, gets the varibles from the public getter function 
and returns
-        * an associative array
-        */
-       private function transformObjectToArray($object) {
-               $reflection = new ReflectionObject($object);
-               $publicMethods = 
$reflection->getMethods(ReflectionProperty::IS_PUBLIC);
-               $result = array();
-               foreach($publicMethods as $method) {
-                       /* @var $method ReflectionMethod */
-                       if(preg_match("/^get(.+)/", $method->getName(), 
$matches)) {
-                               $memberVarible = lcfirst($matches[1]);
-                               $value = $method->invoke($object);
-                               $result[$memberVarible] = $value;
-                       }
-               }
-               return $result;
-       }
-       /*
         * This function requires:
         * An SOvfs object with the filename and the submodule set
         * An sobimmodel object with the modelname and the vfs_database_id
@@ -130,7 +117,7 @@
                
        }
        public function getIfcFileNameWithRealPath() {
-               $this->checkIdArguments();
+               $this->checkIdVfsArguments();
                /* @var $bimModel BimModel */
                $bimModel = 
$this->sobimmodel->retrieveBimModelInformationById();
                $this->sovfs->setFilename($bimModel->getFileName());
@@ -145,9 +132,15 @@
                $bimModel = 
$this->sobimmodel->retrieveBimModelInformationById();
                return ($bimModel != null);
        }
+       public function checkBimModelIsUsed() {
+               $this->checkIdArguments();
+               /* @var $bimModel BimModel */
+               $bimModel = 
$this->sobimmodel->retrieveBimModelInformationById();
+               return ($bimModel->getUsedItemCount() > 0);
+       }
        
        private function displayArguments() {
-               $string = "Argument list:\n".
+               $string = "(bobimmodel)Argument list:\n".
                                "Model name:\t $this->modelName \n".
                                "Model id:\t 
".$this->sobimmodel->getModelId()." \n".
                                "SOvfs:\t ".gettype($this->sovfs)."\n".
@@ -176,7 +169,7 @@
         */
        public function removeIfcModelByModelId() {
                try {
-                       $this->checkIdArguments();
+                       $this->checkIdVfsArguments();
                } catch (InvalidArgumentException $e) {
                        throw $e;
                }
@@ -194,11 +187,16 @@
                
        }
        
-       private function checkIdArguments() {
+       private function checkIdVfsArguments() {
                if(!$this->sobimmodel || !$this->sovfs || 
!$this->sobimmodel->getModelId() || !$this->sovfs->getSubModule()) {
                        throw new 
InvalidArgumentException($this->displayArguments());
                }
        }
+       private function checkIdArguments() {
+               if(!$this->sobimmodel || !$this->sobimmodel->getModelId() || 
!$this->sovfs->getSubModule()) {
+                       throw new 
InvalidArgumentException($this->displayArguments());
+               }
+       }
        /*
         * expects item from the $_FILES object in the form:
         * @param $uploadedFileArray  Array (   [name] => <name> 




reply via email to

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