[Mapbender-commits] r4719 - branches/ur_dev/install

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sat Sep 26 11:18:07 EDT 2009


Author: uli
Date: 2009-09-26 11:18:06 -0400 (Sat, 26 Sep 2009)
New Revision: 4719

Added:
   branches/ur_dev/install/class_database.php
   branches/ur_dev/install/class_table.php
Modified:
   branches/ur_dev/install/class_dia.php
   branches/ur_dev/install/update.php
Log:


Added: branches/ur_dev/install/class_database.php
===================================================================
--- branches/ur_dev/install/class_database.php	                        (rev 0)
+++ branches/ur_dev/install/class_database.php	2009-09-26 15:18:06 UTC (rev 4719)
@@ -0,0 +1,8 @@
+<?php
+class database{
+	public function __construct(){
+		
+	}
+	
+}
+?>

Modified: branches/ur_dev/install/class_dia.php
===================================================================
--- branches/ur_dev/install/class_dia.php	2009-09-26 15:13:43 UTC (rev 4718)
+++ branches/ur_dev/install/class_dia.php	2009-09-26 15:18:06 UTC (rev 4719)
@@ -29,16 +29,59 @@
 		$arrayIds = array();
 		$query = "//dia:layer[@name='Background']/dia:object[@type='UML - Association']";
 		$objects = $this->xp->query($query);
-		fwrite(STDOUT, serialize($objects));
 		foreach($objects as $object){
 			array_push($arrayIds,$object->getAttribute('id'));
 		}
 		return $arrayIds;
 	}
 	
+	private function getConstraintKeys($id){
+		
+		for($i=1; $i<=2; $i++){
+			$query = "//dia:layer[@name='Background']";
+			$query .= "/dia:object[@type='UML - Association' and @id='".$id."']";
+			$query .= "/dia:attribute[@name='ends']/dia:composite[".$i."]";
+			$query .= "/dia:attribute[@name='role']";
+			
+			$keys = $this->xp->query($query);
+			
+			$key = $keys->item(0);
+			if ($i === 1) {
+				$left = $this->removeHash($key->firstChild->nodeValue);
+				$leftConnection = $key->parentNode->parentNode->nextSibling->firstChild->getAttribute("connection");
+				
+			}
+			else {
+				$right = $this->removeHash($key->firstChild->nodeValue);
+				$text = $this->removeHash($key->nextSibling->firstChild->nodeValue);
+				$rightConnection = $key->parentNode->parentNode->nextSibling->firstChild->nextSibling->getAttribute("connection");
+			}
+			
+
+		}	
+			
+//		return $this->removeHash($currentKey[0]);
+		return array(
+			"left" => $left,
+			"right" => $right,
+			"text" => $text,
+			"leftConnection" => $leftConnection,
+			"rightConnection" => $rightConnection
+		);
+	}
+	
+	
+	
+	
 	public function getConstraints(){
+		$constraints = array();
+		
 		$constraintIds = $this->getConstraintIds();
-		
+		foreach($constraintIds as $constraintId){
+			$constraints[] = $this->getConstraintKeys($constraintId);
+		}
+		print_r($constraints);
+		return serialize($constraints);
 	}
 	
 	private function getTableNodeById($id){
@@ -94,9 +137,29 @@
 			$attributes = $composite->childNodes;
 			foreach($attributes as $attribute){
 				if($attribute->getAttribute('name') == 'name'){
-					array_push($arrayTableColumns,$this->removeHash($attribute->firstChild->nodeValue));								
+					$name = $this->removeHash($attribute->firstChild->nodeValue);								
 				}
+				if($attribute->getAttribute('name') == 'visibility'){
+					$primaryKey = ($this->removeHash($attribute->firstChild->getAttribute("val")) === "2") ? true : false;								
+				}
+				if($attribute->getAttribute('name') == 'type'){
+					$type = $this->removeHash($attribute->firstChild->nodeValue);								
+				}
+				if($attribute->getAttribute('name') == 'value'){
+					$value = $this->removeHash($attribute->firstChild->nodeValue);								
+				}
 			}
+			
+			$arrayTableColumns[] = array(
+				"name" => $name,
+				"type" => $type,
+				"value" => $value,
+				"primaryKey" => $primaryKey
+			);
+			unset($name);
+			unset($type);
+			unset($value);
+			unset($primaryKey);
 		}		
 		
 		return $arrayTableColumns;
@@ -122,31 +185,50 @@
 		}		
 	}
 	
-	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 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;
+//	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);
+//		}
+//	}
+	
+	
+	public function getSequences(){
+		
+		$pre = array();
+		$post = array();
+		
+		$xpString = "//dia:layer[@name='Background']/dia:object[@type='UML - SmallPackage']";
+		$xpString .= "/dia:attribute[@name='stereotype']";
+		
+		$sequences =  $this->xp->query($xpString);
+		foreach($sequences as $sequence){
+			$type = $this->removeHash($sequence->firstChild->nodeValue);
+			if($type == "postgres:pre"){
+				$pre[] =  $this->removeHash($sequence->nextSibling->firstChild->firstChild->firstChild->nodeValue);
 			}
-			return $this->removeHash($attribute->firstChild->nodeValue);
+			else if ($type == "postgres:post"){
+				$post[] =  $this->removeHash($sequence->nextSibling->firstChild->firstChild->firstChild->nodeValue);
+			}
 		}
+		return array_merge_recursive ($pre,$post);		
 	}
 	
-	
-	
-	
 	private function removeHash($string){
 		//this could be a problem if the columnname contains a '#'
 		return str_replace("#","",$string);

Added: branches/ur_dev/install/class_table.php
===================================================================
--- branches/ur_dev/install/class_table.php	                        (rev 0)
+++ branches/ur_dev/install/class_table.php	2009-09-26 15:18:06 UTC (rev 4719)
@@ -0,0 +1,7 @@
+<?php
+class table{
+	public function __construct(){
+		
+	}
+}
+?>

Modified: branches/ur_dev/install/update.php
===================================================================
--- branches/ur_dev/install/update.php	2009-09-26 15:13:43 UTC (rev 4718)
+++ branches/ur_dev/install/update.php	2009-09-26 15:18:06 UTC (rev 4719)
@@ -20,17 +20,29 @@
 
 $dia = new Dia();
 $dia->load($filename);
+
 //fwrite(STDOUT, "Hello $name");
+
 $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");
-	}
+	#print_r($columns);
 }
+
+$constraints = $dia->getConstraints();
+
+# fwrite(STDOUT, "	constraint: ".$constraint."\n");
+
+// von den rightConnection noch alle pk löschen (auf 0)
+
+
+//foreach($constraints as $constraint){
+//	fwrite(STDOUT, "	key: ".$constraint."\n");
+//}
+
+var_dump($dia->getSequences());
+
 // Exit correctly
 exit(0);
 



More information about the Mapbender_commits mailing list