UpdateDatabase.php
authorAlan Knowles <alan@roojs.com>
Fri, 15 Nov 2013 06:11:10 +0000 (14:11 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 15 Nov 2013 06:11:10 +0000 (14:11 +0800)
UpdateDatabase.php

index f61561a..b5ad03b 100644 (file)
@@ -97,7 +97,7 @@ class Pman_Xtuple_UpdateDatabase extends Pman
         
         
     }
-    function loadFromFile($db, $file)
+    function importFromArray($db, $file)
     {
         
 
@@ -121,79 +121,12 @@ class Pman_Xtuple_UpdateDatabase extends Pman
                 continue;
             }
             $type = str_replace('_', '-', substr($o,6));
-            $this->loadFromFile($type, $v);
+            $this->importFromArray($type, $v);
         }
         
+         
         
-        if($k == 'accnt'){
-            if(empty($opt['source'])){
-                die("Missing Source directory for account json files! Try -f [JSON file path] \n");
-            }
-            
-            if (!file_exists($opt['source'])) {
-                die("can not found account json file : {$opt['source']} \n");
-            }
-
-            $accounts = json_decode(file_get_contents($opt['source']),true);
-            
-            DB_DataObject::factory('accnt')->importFromArray($this, $accounts);
-            
-            die("DONE! \n");
-        }
-        
-        if($k == 'curr_symbol'){
-            if(!empty($opt['base'])){
-                DB_DataObject::factory('curr_symbol')->setBase($this, $opt['base']);
-                die("DONE! \n");
-            }
-            
-            if(!empty($opt['source'])){
-                
-                if (!file_exists($opt['source'])) {
-                    die("can not found currency json file : {$opt['source']} \n");
-                }
-                
-                $currencies = json_decode(file_get_contents($opt['source']),true);
-                
-                DB_DataObject::factory('curr_symbol')->importFromArray($this, $currencies);
-                die("DONE! \n");
-            }
-            
-            die("Missing Base Currency or Source directory for Currency json files! Try -b [base currency] or -f [JSON file path]\n");
-        }
-        
-        if($k == 'location'){
-            if(empty($opt['source'])){
-                die("Missing Source directory for location json file! Try -f [JSON file path] \n");
-            }
-            
-            if (!file_exists($opt['source'])) {
-                die("can not found location json file : {$opt['source']} \n");
-            }
-            
-            $locations = json_decode(file_get_contents($opt['source']),true);
-            
-            DB_DataObject::factory('location')->importFromArray($this, $locations);
-            
-            die("DONE! \n");
-        }
-        
-        if($k == 'terms'){
-            if(empty($opt['source'])){
-                die("Missing Source directory for terms json file! Try -f [JSON file path] \n");
-            }
-            
-            if (!file_exists($opt['source'])) {
-                die("can not found terms json file : {$opt['source']} \n");
-            }
-            
-            $terms = json_decode(file_get_contents($opt['source']),true);
-            
-            DB_DataObject::factory('terms')->importFromArray($this, $terms);
-            
-            die("DONE! \n");
-        }
-        
+          
         
         $this->updateData($k);