[Mapbender-commits] r4609 - branches/ur_dev/install
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Sep 10 10:34:46 EDT 2009
Author: uli
Date: 2009-09-10 10:34:46 -0400 (Thu, 10 Sep 2009)
New Revision: 4609
Modified:
branches/ur_dev/install/class_dia.php
branches/ur_dev/install/update.php
Log:
Modified: branches/ur_dev/install/class_dia.php
===================================================================
--- branches/ur_dev/install/class_dia.php 2009-09-10 13:22:07 UTC (rev 4608)
+++ branches/ur_dev/install/class_dia.php 2009-09-10 14:34:46 UTC (rev 4609)
@@ -18,82 +18,121 @@
$this->xp->registerNamespace('dia', 'http://www.lysator.liu.se/~alla/dia/');
return true;
-
-
- $tables = $xp->query("//dia:layer[@name='Background']/dia:object[@type='UML - Class']");
- fwrite(STDOUT, "Found ".$tables->length." composites\n");
- $i = 0;
- foreach ($tables as $table){
- fwrite(STDOUT, "id: ".$table->getAttribute("id")." -- ".$i++."\n");
+ }
+
+ private function getTableNodes(){
+ return $this->xp->query("//dia:layer[@name='Background']/dia:object[@type='UML - Class']");
+ }
+
+ private function getTableNodeById($id){
+ $tables = $this->getTableNodes();
+ foreach($tables as $table){
+ if($table->getAttribute("id") != $id){
+ continue;
+ }
+ return $table;
+ }
+ }
+
+
+ private function getTableIdByName($tablename){
+ $tables = $this->getTableNodes();
+ foreach($tables as $table){
+ $id = $table->getAttribute("id");
$attributes = $table->childNodes;
foreach($attributes as $attribute){
- if($attribute->getAttribute("name") == 'name'){
- fwrite(STDOUT, "TableName: ".$attribute->firstChild->nodeValue." \n");
+ if($attribute->getAttribute("name") != 'name'){
+ continue;
}
- if($attribute->getAttribute("name") == 'attributes'){
-// fwrite(STDOUT, "found attributes \n");
- $composites = $attribute->childNodes;
- foreach($composites as $composite){
-// fwrite(STDOUT, "found composites\n");
- $columns = $composite->childNodes;
- foreach($columns as $column){
-// fwrite(STDOUT, "found columnvalues column=".$column->getAttribute('name')."\n");
- if($column->getAttribute('name') == 'name'){
- fwrite(STDOUT, "found name\n");
- fwrite(STDOUT, "Column: ".$column->firstChild->nodeValue." \n");
- }
- if($column->getAttribute('name') == 'type'){
- fwrite(STDOUT, "found type\n");
- fwrite(STDOUT, "Column: ".$column->firstChild->nodeValue." \n");
- }
- if($column->getAttribute('name') == 'value'){
- fwrite(STDOUT, "found value\n");
- fwrite(STDOUT, "Column: ".$column->firstChild->nodeValue." \n");
- }
- $columnvalues = $column->childNodes;
- }
- }
+ if($this->removeHash($attribute->firstChild->nodeValue) == $tablename){
+ return $id;
}
-
-
}
}
}
- public function getTables(){
+ public function getTableNames(){
$arrayTableNames = array();
- $tables = $this->getTabeleBasicNode();
+
+ $xpString = "//dia:layer[@name='Background']/dia:object[@type='UML - Class']";
+ $xpString .= "/dia:attribute[@name='name']";
+ $tables = $this->xp->query($xpString);
+
foreach($tables as $table){
array_push($arrayTableNames, $this->removeHash($table->firstChild->nodeValue));
}
return $arrayTableNames;
}
- private function removeHash($string){
- //this could be a problem if the columnname contains a #
- return str_replace("#","",$string);
-
- }
- private function getTabeleBasicNode(){
- $xpString = "//dia:layer[@name='Background']/dia:object[@type='UML - Class']";
- $xpString .= "/dia:attribute[@name='name']";
- return $this->xp->query($xpString);
- }
+
+
public function getColumns($tablename){
$arrayTableColumns = array();
- $tables = $this->getTabeleBasicNode();
- foreach($tables as $table){
- if($this->removeHash($table->firstChild->nodeValue) == $tablename){
+ $id = $this->getTableIdByName($tablename);
+ $composites = $this->getCompositeNodesById($id);
+
+ foreach($composites as $composite){
+ $attributes = $composite->childNodes;
+ foreach($attributes as $attribute){
+ if($attribute->getAttribute('name') == 'name'){
+ array_push($arrayTableColumns,$this->removeHash($attribute->firstChild->nodeValue));
+ }
}
- }
+ }
+
return $arrayTableColumns;
}
- public function getColumnType($tablename, $columnname){
+
+ private function getCompositeNodesById($id){
+ $xpString = "//dia:layer[@name='Background']/dia:object[@type='UML - Class' and @id='".$id."']";
+ $xpString .= "/dia:attribute[@name='attributes']/dia:composite";
+ return $this->xp->query($xpString);
+ }
+
+ private function getCompositeByName($tablename,$columnname){
+ $id = $this->getTableIdByName($tablename);
+ $composites = $this->getCompositeNodesById($id);
+ foreach($composites as $composite){
+ $attributes = $composite->childNodes;
+ foreach($attributes as $attribute){
+ if($attribute->getAttribute('name') == 'name' && $this->removeHash($attribute->firstChild->nodeValue) == $columnname){
+ return $composite;
+ }
+ }
+ }
}
+
+ public function getColumnType($tablename, $columnname){
+ $composite = $this->getCompositeByName($tablename,$columnname);
+ $attributes = $composite->childNodes;
+ foreach($attributes as $attribute){
+ if($attribute->getAttribute('name') != 'type'){
+ continue;
+ }
+ return $this->removeHash($attribute->firstChild->nodeValue);
+ }
+ }
+
public function getColumnValue($tablename, $columnname){
+ $composite = $this->getCompositeByName($tablename,$columnname);
+ $attributes = $composite->childNodes;
+ foreach($attributes as $attribute){
+ if($attribute->getAttribute('name') != 'value'){
+ continue;
+ }
+ return $this->removeHash($attribute->firstChild->nodeValue);
+ }
+ }
+
+
+
+
+ private function removeHash($string){
+ //this could be a problem if the columnname contains a #
+ return str_replace("#","",$string);
}
}
Modified: branches/ur_dev/install/update.php
===================================================================
--- branches/ur_dev/install/update.php 2009-09-10 13:22:07 UTC (rev 4608)
+++ branches/ur_dev/install/update.php 2009-09-10 14:34:46 UTC (rev 4609)
@@ -21,9 +21,15 @@
$dia = new Dia();
$dia->load($filename);
//fwrite(STDOUT, "Hello $name");
-$tables = $dia->getTables();
+$tables = $dia->getTableNames();
foreach($tables as $table){
fwrite(STDOUT, "Found Tables: ".$table."\n");
+ $columns = $dia->getColumns($table);
+ foreach($columns as $column){
+ fwrite(STDOUT, " Column: ".$column."\n");
+ fwrite(STDOUT, " Type: ".$dia->getColumnType($table,$column)."\n");
+ fwrite(STDOUT, " Value: ".$dia->getColumnValue($table,$column)."\n");
+ }
}
// Exit correctly
exit(0);
More information about the Mapbender_commits
mailing list