[Mapbender-commits] r7790 - in trunk/mapbender: conf http/classes http/php http/plugins resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Apr 29 07:54:56 EDT 2011


Author: armin11
Date: 2011-04-29 04:54:56 -0700 (Fri, 29 Apr 2011)
New Revision: 7790

Modified:
   trunk/mapbender/conf/mapbender.conf-dist
   trunk/mapbender/http/classes/class_connector.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/php/mod_deleteWMS.php
   trunk/mapbender/http/php/mod_showMetadata.php
   trunk/mapbender/http/plugins/mb_metadata_layer.js
   trunk/mapbender/http/plugins/mb_metadata_layer.php
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
Log:
Frame for new possibility to store more than one MetadataURL from OWS like this is demanded in the standards (1.1.1/1.3.0). The MetadataURLs are stored in a new table which should be used for also metador. The table will become the central mapbender metadata table for exchanging metadata in a standardized format (iso19139) as it is demanded e.g. for INSPIRE. The concept will integrate the dataset/service coupling which is used for a search over the csw api 1.0 standard which is also used by INSPIRE.

Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/conf/mapbender.conf-dist	2011-04-29 11:54:56 UTC (rev 7790)
@@ -186,6 +186,11 @@
 # --------------------------------------------
 #define("SRS_ARRAY", "4326, 31466, 31467, 31468, 25832");
 
+# --------------------------------------------
+# define a wrapper for index.php/login.php to use e.g. the get api when integrated in external applications like cms
+# --------------------------------------------
+#define("WRAPPER_PATH","/portal/karten.html");
+#define("WRAPPER_PATH","");
 
 ###HACK for GLOBALS
 $DBSERVER=DBSERVER;

Modified: trunk/mapbender/http/classes/class_connector.php
===================================================================
--- trunk/mapbender/http/classes/class_connector.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/classes/class_connector.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -317,8 +317,8 @@
 		}
 		if ($info['http_code'] == '502') {
 			curl_close ($ch);
-			$e = new mb_exception("class_connector.php: Problem with connectiong Gateway - maybe problem with the configuration of the security proxy (mod_proxy?).");
-			return $info['hhtp_code'];
+			$e = new mb_exception("class_connector.php: Problem with connecting Gateway - maybe problem with the configuration of the security proxy (mod_proxy?).");
+			return $info['http_code'];
 			/*fwrite($handle,"HEADER: \n");
 			fwrite($handle,$error_log);
 			fwrite($handle,"502: ".$file."\n");*/

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/classes/class_wms.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -101,7 +101,7 @@
 		#	"$1php/mod_layerMetadata.php?id=", 
 		#	LOGIN
 		#) . $wmsId;
-		return LOGIN."/../../mapbender/php/mod_showMetadata.php?resource=wms&id=".$wmsId;
+		return LOGIN."/../php/mod_showMetadata.php?resource=wms&id=".$wmsId;
 	}
 	public static function getLayerMetadataUrl ($layerId) {
 		#return preg_replace(
@@ -109,7 +109,7 @@
 		#	"$1php/mod_layerMetadata.php?id=", 
 		#	LOGIN
 		#) . $wmsId;
-		return LOGIN."/../../mapbender/php/mod_showMetadata.php?resource=layer&id=".$layerId;
+		return LOGIN."/../php/mod_showMetadata.php?resource=layer&id=".$layerId;
 	}
 	public static function isOwsProxyUrl ($getmap) {
 //		$e = new mb_notice("isOwsProxyUrl? " . $getmap);
@@ -810,6 +810,9 @@
 				$section = "layer";
 				if ($element[type] == "open") {
 					$cnt_epsg = -1;
+					//new for resolving metadataurls and dataurls
+					$cnt_metadataurl = -1;
+					$cnt_dataurl = -1;
 					$cnt_layer++;
 					$parent[$element[level]+1] = $cnt_layer;
 					$myParent[$cnt_layer]= $parent[$element[level]];
@@ -850,7 +853,7 @@
 				if(mb_strtoupper($element[tag]) == "TITLE"){
 					$this->objLayer[$cnt_layer]->layer_style[$cnt_styles]["title"] = ($element[value] ? $element[value] : '');
 				}
-	      		if(mb_strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "open"){
+	      			if(mb_strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "open"){
 					$legendurl = true;
 				}
 				if($legendurl && mb_strtoupper($element[tag]) == "FORMAT"){
@@ -859,7 +862,7 @@
 				if($legendurl && mb_strtoupper($element[tag]) == "ONLINERESOURCE"){
 					$this->objLayer[$cnt_layer]->layer_style[$cnt_styles]["legendurl"] = $element[attributes]["xlink:href"];
 				}
-			    if(mb_strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "close"){
+				if(mb_strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "close"){
 					$legendurl = false;
 				}   
 			}
@@ -877,23 +880,29 @@
 				if(mb_strtoupper($element[tag]) == "KEYWORD"){
 					array_push($this->objLayer[$cnt_layer]->layer_keyword, trim($element[value]));
 				}
-	      		if(mb_strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
+	      			if(mb_strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
 					$dataurl = true;
+					$cnt_dataurl++;
 				}
 				if($dataurl && mb_strtoupper($element[tag]) == "ONLINERESOURCE"){
-					$this->objLayer[$cnt_layer]->layer_dataurl_href = $element[attributes]["xlink:href"];
+					$this->objLayer[$cnt_layer]->layer_dataurl[$cnt_dataurl]->href = $element[attributes]["xlink:href"];
 				}
-			    if(mb_strtoupper($element[tag]) == "DATAURL" && $element[type] == "close"){
+			    	if(mb_strtoupper($element[tag]) == "DATAURL" && $element[type] == "close"){
 					$dataurl = false;
-				}   
+			   	}   
 				
 				if(mb_strtoupper($element[tag]) == "METADATAURL" && $element[type] == "open"){
 					$metadataurl = true;
+					$cnt_metadataurl++;
+					$this->objLayer[$cnt_layer]->layer_metadataurl[$cnt_metadataurl]->type = $element[attributes]["type"];
 				}
+				if($metadataurl && mb_strtoupper($element[tag]) == "FORMAT"){
+					$this->objLayer[$cnt_layer]->layer_metadataurl[$cnt_metadataurl]->format = $element[value];
+				}
 				if($metadataurl && mb_strtoupper($element[tag]) == "ONLINERESOURCE"){
-					$this->objLayer[$cnt_layer]->layer_metadataurl = $element[attributes]["xlink:href"];
+					$this->objLayer[$cnt_layer]->layer_metadataurl[$cnt_metadataurl]->href = $element[attributes]["xlink:href"];
 				}
-			    if(mb_strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
+			    	if(mb_strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
 					$metadataurl = false;
 				}   
 				
@@ -1112,9 +1121,16 @@
 			echo "<hr>";
 			echo "id: <b>".$this->objLayer[$i]->layer_id ."</b> parent: <b>".$this->objLayer[$i]->layer_parent."</b> name: <b>".$this->objLayer[$i]->layer_name;
 			echo "</b> title: <b>".$this->objLayer[$i]->layer_title. "</b> queryable: <b>".$this->objLayer[$i]->layer_queryable."</b> minScale: <b>". $this->objLayer[$i]->layer_minscale."</b> maxScale: <b>".$this->objLayer[$i]->layer_maxscale."</b>";
-			echo "<br>dataurl: <b>".$this->objLayer[$i]->layer_dataurl_href. "</b>";
-			echo "<br>metadataurl: <b>".$this->objLayer[$i]->layer_metadataurl. "</b>";
+			echo "<br>dataurl: <b>".$this->objLayer[$i]->layer_dataurl[0]->href. "</b>";
+			echo "<br>MetadataUrls:<br>";
 			echo "<table border='1'>";
+			echo "<tr><td>link</td><td>type</td><td>format</td></tr>";
+			for($j=0; $j<count($this->objLayer[$i]->layer_metadataurl);$j++){
+				echo "<tr><td>".$this->objLayer[$i]->layer_metadataurl[$j]->href."</td><td>".$this->objLayer[$i]->layer_metadataurl[$j]->type."</td><td>".$this->objLayer[$i]->layer_metadataurl[$j]->format."</td></tr>";
+			}
+			echo "</table>";
+			echo "<br>BBOXes:<br>";
+			echo "<table border='1'>";
 			for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 				echo "<tr><td>".$this->objLayer[$i]->layer_epsg[$j][epsg]."</td><td>".$this->objLayer[$i]->layer_epsg[$j][minx]."</td>";
 				echo "<td>".$this->objLayer[$i]->layer_epsg[$j][miny]."</td><td>".$this->objLayer[$i]->layer_epsg[$j][maxx]."</td>";
@@ -1158,12 +1174,12 @@
 		$newLayer->layer_name = $currentLayer["name"];
 		$newLayer->layer_title = $currentLayer["title"];
 		$newLayer->gui_layer_title = $currentLayer["title"];
-		$newLayer->layer_dataurl_href = $currentLayer["dataurl"];
+		$newLayer->layer_dataurl[0]->href = $currentLayer["dataurl"];
 		$newLayer->layer_pos = $currentLayer["extension"]["LAYER_POS"];
 		$newLayer->layer_queryable = $currentLayer["queryable"];
 		$newLayer->layer_minscale = $currentLayer["extension"]["MINSCALE"];
 		$newLayer->layer_maxscale = $currentLayer["extension"]["MAXSCALE"];
-		$newLayer->layer_metadataurl = $currentLayer["metadataurl"];
+		$newLayer->layer_metadataurl[0]->href = $currentLayer["metadataurl"];
 //		$newLayer->layer_searchable = $currentLayer["searchable"];
 		$newLayer->gui_layer_wms_id = $currentLayer["extension"]["WMS_ID"];
 		$newLayer->gui_layer_status = $currentLayer["extension"]["GUI_STATUS"];
@@ -1311,13 +1327,13 @@
 				$this->objLayer[$i]->layer_uid ."','". 
 				addslashes($this->objLayer[$i]->layer_name) . "','". 
 				addslashes($this->objLayer[$i]->layer_title) ."','". 
-				$this->objLayer[$i]->layer_dataurl_href ."','". 
+				$this->objLayer[$i]->layer_dataurl[0]->href ."','". 
 				$this->objLayer[$i]->layer_pos ."','". 
 				$this->objLayer[$i]->layer_queryable ."','". 
 				$this->objLayer[$i]->layer_minscale . "','". 
 				$this->objLayer[$i]->layer_maxscale ."','". 
-				$this->objLayer[$i]->layer_metadataurl ."','". 
-// will be added later, not needed now
+				$this->objLayer[$i]->layer_metadataurl[0]->href ."','". 
+// will be added later, not needed now TODO check if more than one metadataUrl is usefull here
 //				$this->objLayer[$i]->layer_searchable ."','". 
 				$this->objLayer[$i]->gui_layer_wms_id ."','". 
 				$this->objLayer[$i]->gui_layer_status ."','".
@@ -1433,13 +1449,13 @@
 				$this->objLayer[$i]->layer_uid ."','". 
 				$this->objLayer[$i]->layer_name . "','". 
 				addslashes($this->objLayer[$i]->layer_title) ."','". 
-				$this->objLayer[$i]->layer_dataurl_href ."','". 
+				$this->objLayer[$i]->layer_dataurl[0]->href ."','". 
 				$this->objLayer[$i]->layer_pos ."','". 
 				$this->objLayer[$i]->layer_queryable ."','". 
 				$this->objLayer[$i]->layer_minscale . "','". 
 				$this->objLayer[$i]->layer_maxscale ."','". 
-				$this->objLayer[$i]->layer_metadataurl ."','". 
-// will be added later, not needed now
+				$this->objLayer[$i]->layer_metadataurl[0]->href ."','". 
+// will be added later, not needed now TODO check if more than one metadataUrl is usefull here
 //				$this->objLayer[$i]->layer_searchable ."','". 
 				$this->objLayer[$i]->gui_layer_wms_id ."','". 
 				$this->objLayer[$i]->gui_layer_status ."','".
@@ -1677,8 +1693,8 @@
 		$v = array($myWMS,$tmpPos,$this->objLayer[$i]->layer_parent,$this->objLayer[$i]->layer_name,
 				$this->objLayer[$i]->layer_title,
 				$this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
-				$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
-				$this->objLayer[$i]->layer_metadataurl, $this->objLayer[$i]->layer_searchable,
+				$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl[0]->href,
+				$this->objLayer[$i]->layer_metadataurl[0]->href, $this->objLayer[$i]->layer_searchable,
 				$this->objLayer[$i]->layer_abstract,
 				$uuid);
 		$t = array('i','i','s','s','s','i','i','i','s','s','i','s','s');
@@ -1696,7 +1712,11 @@
 			
 			# insert Keywords
 			$this->insertLayerKeyword($i);	
-		
+	
+			# insert dataurls
+			#$this->insertLayerDataUrls($i);TODO: in the spec 1.3.0 the schema defines a 1:n relation, but in the table there is only one link possible - maybe we need only this one link
+			# insert metadataurls
+			$this->insertLayerMetadataUrls($i);
 		}
 	}
 	function updateLayer($i,$myWMS){
@@ -1738,8 +1758,8 @@
 		$v = array($tmpPos,$this->objLayer[$i]->layer_parent,
 				$this->objLayer[$i]->layer_title,
 				$this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
-				$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
-				$this->objLayer[$i]->layer_metadataurl, $this->objLayer[$i]->layer_searchable,
+				$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl[0]->href,
+				$this->objLayer[$i]->layer_metadataurl[0]->href, $this->objLayer[$i]->layer_searchable,
 				$this->objLayer[$i]->layer_abstract, $l_id		
 			);
 		$t = array('i','s','s','i','i','i','s','s','i', 's','i');
@@ -1764,7 +1784,7 @@
 			# save the id of each layer: set param2 true
 			$this->objLayer[$i]->db_id = $l_id;
 			$this->insertLayerEPSG($i);
-			
+			$this->insertLayerMetadataUrls($i);
 			# TABLE layer_style for each layer
 			$this->insertLayerStyle($i);
 			if($this->overwrite == true){
@@ -2137,6 +2157,141 @@
 			}
 		}
 	}
+	function insertLayerMetadataUrls($i){
+		//first delete the old ones - but only those who have been harvested thru caps before!
+		global $con;
+		$sql = "DELETE FROM mb_metadata WHERE metadata_id IN (SELECT metadata_id FROM mb_metadata INNER JOIN";
+		$sql .= " (SELECT * from ows_relation_metadata WHERE fkey_layer_id = $1) as relation ON ";
+		$sql .= " mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities')";
+		$v = array($this->objLayer[$i]->db_id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		//origin 2 - set by mapbender metadata editor - new record
+		//origin 3 - set by mapbender metadata editor - new linkage
+		//harvest the record if some readable format is given - should this be adoptable?
+		//parse the content if iso19139 is given
+		//TODO: generate temporal uuid for inserting and getting the serial afterwards
+		for($j=0; $j<count($this->objLayer[$i]->layer_metadataurl);$j++){
+
+			//check for returned format?
+			if (($this->objLayer[$i]->layer_metadataurl[$j]->type == 'ISO19115:2003' && $this->objLayer[$i]->layer_metadataurl[$j]->format =='text/xml') || ($this->objLayer[$i]->layer_metadataurl[$j]->type == 'TC211' && $this->objLayer[$i]->layer_metadataurl[$j]->format =='text/xml')) {
+				//load metadata from link
+				$metadataConnector = new connector($this->objLayer[$i]->layer_metadataurl[$j]->href);
+				$metaData = $metadataConnector->file;
+				//parse metadata
+				try {
+					//$iso19139Xml = simplexml_load_string($metaData);
+					$iso19139Xml =  new SimpleXMLElement($metaData);
+					if ($iso19139Xml == false) {
+						throw new Exception('Cannot parse Metadata XML!');
+					}
+				}
+				catch (Exception $e) {
+    					$e = new mb_exception($e->getMessage());
+				}
+				if ($iso19139Xml != false) {
+					//get elements for database from xml by using xpath
+					//uuid
+					$uuid = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
+					//createdate
+					$createdate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+					//changedate
+					$changedate = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:dateStamp/gco:Date');
+					//TODO: check if this is set, maybe DateTime must be searched instead?
+					//title
+					$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+					//abstract
+					$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
+					//searchtext -- use keywords!
+					$keywords = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
+					//type 
+					$type = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
+					//tmp_reference_1
+					$tmp_reference_1 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
+					//tmp_reference_2
+					$tmp_reference_2 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');					//spatial_res_type
+					//spatial_res_value
+					//ref_system
+					//format
+					//inspire_charset
+					//inspire_top_consistence
+					//responsible_party
+					//fees
+					//"constraints"	
+					//fill database with elements:
+					$sql = "INSERT INTO mb_metadata (link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2) ";
+					$sql .= "VALUES($1, 'capabilities', $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)";
+					$v = array($this->objLayer[$i]->layer_metadataurl[$j]->href,
+						$this->objLayer[$i]->layer_metadataurl[$j]->format,
+						$metaData,
+						$this->objLayer[$i]->layer_metadataurl[$j]->type,
+						$uuid[0],
+						$title[0],
+						$createdate[0],
+						$changedate[0],
+						$abstract[0],
+						$keywords[0],
+						$type[0],
+						$tmp_reference_1[0],
+						$tmp_reference_2[0]
+					);
+					$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s');
+					$res = db_prep_query($sql,$v,$t);
+					if(!$res){
+						db_rollback();	
+					}
+					//get last inserted serial_id
+					$mdId = db_insert_id($con, 'mb_metadata','metadata_id');
+					//insert into ows_relation_metadata (fkey_layer_id, fkey_metadata_id) values (20131,3);
+					$sql = "INSERT INTO ows_relation_metadata (fkey_layer_id, fkey_metadata_id) values ($1, $2);";
+					$v = array($this->objLayer[$i]->db_id, $mdId);
+					$t = array('i','i');
+					$res = db_prep_query($sql,$v,$t);
+					if(!$res){
+						db_rollback();	
+					} else {
+						$sql = "UPDATE mb_metadata SET harvestresult = 1 where metadata_id = $1";
+						$v = array($mdId);
+						$t = array('i');
+						$res = db_prep_query($sql,$v,$t);
+					}		
+				}
+			} else {//no readable format given - only store the links!
+				//don't push single elements into database
+				$sql = "INSERT INTO mb_metadata (link, origin, md_format, linktype) ";
+				$sql .= "VALUES($1, 'capabilities', $2, $3)";
+				$v = array($this->objLayer[$i]->layer_metadataurl[$j]->href,
+					$this->objLayer[$i]->layer_metadataurl[$j]->format,
+					$this->objLayer[$i]->layer_metadataurl[$j]->type		
+				);
+				$t = array('s','s','s');
+				$res = db_prep_query($sql,$v,$t);
+				if(!$res){
+					db_rollback();	
+				}
+				//get last inserted serial_id
+				$mdId = db_insert_id($con, 'mb_metadata','metadata_id');
+				//insert into ows_relation_metadata (fkey_layer_id, fkey_metadata_id) values (20131,3);
+				$sql = "INSERT INTO ows_relation_metadata (fkey_layer_id, fkey_metadata_id) values ($1, $2);";
+				$v = array($this->objLayer[$i]->db_id, $mdId);
+				$t = array('i','i');
+				$res = db_prep_query($sql,$v,$t);
+				if(!$res){
+					db_rollback();	
+				} else {
+					//set harvest result to 0 cause this metadata format can not to be parsed
+					$sql = "UPDATE mb_metadata SET harvestresult = 0 where metadata_id = $1";
+					$v = array($mdId);
+					$t = array('i');
+					$res = db_prep_query($sql,$v,$t);
+				}
+			}
+		}
+	}
+	
+
+
+
 	function updateObjInDB($myWMS){
 		if (!isset($this->wms_network_access) || ($this->wms_network_access == '')) {
 			$this->wms_network_access = intval('0');
@@ -2266,9 +2421,28 @@
 		}
 		
 		# delete all layer which are outdated
+		//first delete their metadataUrl entries*****
 		$v = array($myWMS);
 		$t = array('i');
 		$c = 2;
+		$sql = "DELETE FROM mb_metadata WHERE metadata_id IN (SELECT metadata_id FROM mb_metadata INNER JOIN (SELECT * from ows_relation_metadata WHERE fkey_layer_id IN " ;
+		$sql .= "(SELECT layer_id FROM layer WHERE fkey_wms_id = $1 AND NOT layer_name IN (";
+		for($i=0; $i<count($this->objLayer); $i++){
+			if($i>0){$sql .= ',';}
+			$sql .= "$".$c;
+			array_push($v,$this->objLayer[$i]->layer_name);
+			array_push($t,'s');		
+			$c++;
+		}
+		$sql .= ") ) )";
+		$sql .= " as relation ON  mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities')";
+		$res = db_prep_query($sql,$v,$t);		
+		//*******************************************
+		//TODO: is this done for the keywords too? Maybe not, cause they are stored only once! Only the relations have to be deleted!
+		//and then the layer entries
+		$v = array($myWMS);
+		$t = array('i');
+		$c = 2;
 		$sql = "DELETE FROM layer WHERE fkey_wms_id = $1 AND NOT layer_name IN(";
 		for($i=0; $i<count($this->objLayer); $i++){
 			if($i>0){$sql .= ',';}
@@ -2682,8 +2856,22 @@
 				$this->objLayer[$layer_cnt]->layer_uid = $layer_id;
 				$this->objLayer[$layer_cnt]->layer_name = administration::convertIncomingString($row2["layer_name"]);
 				$this->objLayer[$layer_cnt]->layer_title = administration::convertIncomingString($row2["layer_title"]);			
-				$this->objLayer[$layer_cnt]->layer_dataurl_href =$row2["layer_dataurl"];
-				$this->objLayer[$layer_cnt]->layer_metadataurl =$row2["layer_metadataurl"];
+				$this->objLayer[$layer_cnt]->layer_dataurl[0]->href =$row2["layer_dataurl"];
+				//load all metadataUrl elements from mb_metadata
+				$sql = "SELECT metadata_id, link, linktype, md_format FROM mb_metadata INNER JOIN (SELECT * from ows_relation_metadata WHERE fkey_layer_id = $1) as relation ON  mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities'";
+				$v = array($layer_id);
+				$t = array('i');
+				$res_metadataUrl = db_prep_query($sql,$v,$t);
+				$count_metadataUrl = 0;
+				while($row3 = db_fetch_array($res_metadataUrl)){
+					$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->href = $row3["link"];
+					$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->type = $row3["linktype"];
+					$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->format = $row3["md_format"];
+					
+					$count_metadataUrl++;
+				}
+				//old one:
+				//$this->objLayer[$layer_cnt]->layer_metadataurl[0]->href = $row2["layer_metadataurl"];
 				$this->objLayer[$layer_cnt]->layer_searchable =$row2["layer_searchable"];
 				$this->objLayer[$layer_cnt]->layer_pos =$row2["layer_pos"];						
 				$this->objLayer[$layer_cnt]->layer_queryable =$row2["layer_pos"];
@@ -2753,6 +2941,7 @@
 	* creatObjfromDBNoGui
 	*
 	*/ 
+	//TODO Update while editing metadata of wms will update the metadata - delete entries and read new ones - then they will be visible and cannot be set to inactive!
 	  function createObjFromDBNoGui($wms_id, $withProxyUrls = true){
 	   	$sql = "Select * from wms where wms_id = $1 ";
 		$v = array($wms_id);
@@ -2856,8 +3045,25 @@
 			$this->objLayer[$layer_cnt]->layer_title = administration::convertIncomingString($row2["layer_title"]);
 			$this->objLayer[$layer_cnt]->layer_abstract = administration::convertIncomingString($row2["layer_abstract"]);	
 			$this->objLayer[$layer_cnt]->gui_layer_title = $this->objLayer[$layer_cnt]->layer_title;			
-			$this->objLayer[$layer_cnt]->layer_dataurl_href =$row2["layer_dataurl"];
-			$this->objLayer[$layer_cnt]->layer_metadataurl =$row2["layer_metadataurl"];
+			$this->objLayer[$layer_cnt]->layer_dataurl[0]->href =$row2["layer_dataurl"];
+
+
+			//load all metadataUrl elements from mb_metadata
+			$sql = "SELECT metadata_id, link, linktype, md_format FROM mb_metadata INNER JOIN (SELECT * from ows_relation_metadata WHERE fkey_layer_id = $1) as relation ON  mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities'";
+			$v = array($this->objLayer[$layer_cnt]->layer_uid);
+			$t = array('i');
+			$res_metadataUrl = db_prep_query($sql,$v,$t);
+			$count_metadataUrl = 0;
+			while($row4 = db_fetch_array($res_metadataUrl)){
+				$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->href = $row4["link"];
+				$e = new mb_notice("nogui layer_metadataurl: ".$row4["link"]);
+				$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->type = $row4["linktype"];
+				$this->objLayer[$layer_cnt]->layer_metadataurl[$count_metadataUrl]->format = $row4["md_format"];
+					
+				$count_metadataUrl++;
+			}
+			//old one:
+			//$this->objLayer[$layer_cnt]->layer_metadataurl[0]->href = $row2["layer_metadataurl"];
 			$this->objLayer[$layer_cnt]->layer_searchable =$row2["layer_searchable"];
 			$this->objLayer[$layer_cnt]->layer_pos =$row2["layer_pos"];						
 			$this->objLayer[$layer_cnt]->layer_queryable =$row2["layer_queryable"];
@@ -3093,11 +3299,12 @@
 	var $layer_pos;
 	var $layer_queryable;
 	var $layer_minscale;
-	var $layer_maxscale;	
-    var $layer_dataurl_href;
-    var $layer_metadataurl;
+	var $layer_maxscale;
+	var $layer_dataurl;
+    	var $layer_dataurl_href;
+    	var $layer_metadataurl;
 	var $layer_searchable;
-    var $layer_keyword = array();
+    	var $layer_keyword = array();
 	var $layer_epsg = array();
 	var $layer_style = array();
 	var $layer_md_topic_category_id = array();

Modified: trunk/mapbender/http/php/mod_deleteWMS.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWMS.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/php/mod_deleteWMS.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -201,7 +201,19 @@
 			$wms_abstract = $row["wms_abstract"];
 	   }
 		
-
+	//Before the wms will be deleted, the metadataUrls from the Layers must be deleted!
+	//The other things will be done by class_wms!
+	//***
+	$sql = "DELETE FROM mb_metadata WHERE metadata_id IN (SELECT metadata_id FROM mb_metadata INNER JOIN";
+	$sql .= " (SELECT * from ows_relation_metadata WHERE fkey_layer_id IN ";
+	$sql .= " (SELECT layer_id FROM layer WHERE fkey_wms_id = $1) )";
+ 	$sql .= " as relation ON ";
+	$sql .= " mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities')";
+	
+	$v = array($wmsList);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	//***
 	   $sql = "DELETE FROM wms WHERE wms_id = $1";
 	   $v = array($wmsList);
 	   $t = array('i');

Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/php/mod_showMetadata.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -21,7 +21,9 @@
 require_once dirname(__FILE__)."/../classes/class_connector.php";
 require_once dirname(__FILE__) . "/../classes/class_user.php";
 require_once dirname(__FILE__) . "/../classes/class_wms.php";
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
 require_once dirname(__FILE__) . "/../../tools/wms_extent/extent_service.conf";
+require_once dirname(__FILE__) . "/../extensions/phpqrcode/phpqrcode.php";
 
 //GET:
 //resource: wms, layer, wfs, featuretype, wfs-conf, wmc
@@ -164,7 +166,7 @@
 		$translation['crs'] = 'Koordinatenreferenzsysteme (mit BBOX)';
 		$translation['wmccrs'] = 'Eingestelltes Koordinatenreferenzsystem';	
 		$translation['wgs84Bbox'] = 'Eckpunkte in geogr. Koordinaten';
-		$translation['wgs84BboxGraphic'] = 'Kartenübersicht';
+		$translation['wgs84BboxGraphic'] = 'Ausdehnung';
 		$translation['mapbenderCapabilities'] = 'Geoportal Capabilities';
 		$translation['originalCapabilities'] = 'Original Capabilities';
 		$translation['describeFeaturetype'] = 'Link zum Datenschema';
@@ -185,6 +187,7 @@
 		$translation['notMonitored'] = 'Informationen über die Qualität sind nur verfügbar, wenn das Service Monitoring aktiv ist!';
 		$translation['wmcQualityText'] = 'Für Web Map Context Dokumente entfällt die Angabe zur Qualität!';
 		$translation['noTouInformation'] = 'Es sind keine Informationen über Nutzungsbedingungen verfügbar!';
+		$translation['loadWmc'] = 'Link um Anwendung mit WMC zu starten';
 		break;
 	case "en":
 		$translation['overview'] = 'Overview';
@@ -229,7 +232,7 @@
 		$translation['crs'] = 'Coordinate Reference System';
 		$translation['wmccrs'] = 'Used Coordinate Reference System';
 		$translation['wgs84Bbox'] = 'Corner in geographic Coordinates';
-		$translation['wgs84BboxGraphic'] = 'Map View';
+		$translation['wgs84BboxGraphic'] = 'Spatial Extent';
 		$translation['mapbenderCapabilities'] = 'Geoportal Capabilities';
 		$translation['originalCapabilities'] = 'Original Capabilities';
 		$translation['inspireCapabilities'] = 'INSPIRE Capabilities URL';
@@ -250,6 +253,7 @@
 		$translation['notMonitored'] = 'Information about Quality is only available if the service monitoring is activated!';
 		$translation['wmcQualityText'] = 'In case of Web Map Context Documents the Quality part is not applicable!';
 		$translation['noTouInformation'] = 'No informations about terms of use are available!';
+		$translation['loadWmc'] = 'Link to start application with WMC';
 		break;
 	default: #to english
 		$translation['overview'] = 'Overview';
@@ -294,7 +298,7 @@
 		$translation['crs'] = 'Coordinate Reference System';
 		$translation['wmccrs'] = 'Used Coordinate Reference System';
 		$translation['wgs84Bbox'] = 'Corner in geographic Coordinates';
-		$translation['wgs84BboxGraphic'] = 'Map View';
+		$translation['wgs84BboxGraphic'] = 'Spatial Extent';
 		$translation['mapbenderCapabilities'] = 'Geoportal Capabilities';
 		$translation['originalCapabilities'] = 'Original Capabilities';
 		$translation['describeFeaturetype'] = 'Dataschema';
@@ -315,6 +319,7 @@
 		$translation['notMonitored'] = 'Information about Quality is only available if the service monitoring is activated!';
 		$translation['wmcQualityText'] = 'In case of Web Map Context Documents the Quality part is not applicable!';
 		$translation['noTouInformation'] = 'No informations about terms of use are available!';
+		$translation['loadWmc'] = 'Link to start application with WMC';
 }
 
 //Array with infos about the different elements which are shown in the tabs
@@ -989,6 +994,18 @@
 $html .= $tableBegin;
 if ($resource == 'wmc') {
 	$html .= $t_a.$translation['wmc'].$t_b."XML".$t_c;
+	//show qr for link 
+	//create uuid for qr graphic
+	$uuid = new Uuid;
+	$filename = "qr_wmc_".$uuid.".png";
+	//generate qr on the fly in tmp folder
+	//link to invoke wmc per get api if wrapper path isset
+	if (WRAPPER_PATH != "") {
+		$invokeLink = $mapbenderBaseUrl."".WRAPPER_PATH."?WMC=".$resourceMetadata['contentid'];
+		QRcode::png($invokeLink,TMPDIR."/".$filename);
+		$html .= $t_a.$translation['loadWmc'].$t_b."<img src='".TMPDIR."/".$filename."'>".$t_c;
+	}
+	
 }
 if ($resource == 'wfs') {
 }

Modified: trunk/mapbender/http/plugins/mb_metadata_layer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.js	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.js	2011-04-29 11:54:56 UTC (rev 7790)
@@ -87,13 +87,28 @@
 					return;
 				}
 				$metadataForm.easyform("fill", obj);
+				//delete metadataURL entries
+				$('.metadataEntry').remove();
+				//fill MetadataURLs into metadata_selectbox_id
+				that.fillMetadataURLs(obj);
 				that.valid();
 				that.enableResetButton();
 			}
 		});
 		req.send();		
 	};
-	
+	this.fillMetadataURLs = function (obj) {
+		//for size of md_metadata records:
+		for (var i in obj.md_metadata.metadata_id) {
+			if (obj.md_metadata.origin == "capabilities") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><a href='"+obj.md_metadata.link[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td></td><td></td></tr>").appendTo($("#metadataTable"));
+			}
+			if (obj.md_metadata.origin == "mapbender") {
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><a href='"+obj.md_metadata.link[i]+"'>"+obj.md_metadata.uuid[i]+"</a></td><td><input disabled='disabled' class='' type='submit' value='edit'/></td><td><input disabled='disabled' class='' type='submit' value='delete'/></td></tr>").appendTo($("#metadataTable"));
+			}
+		}
+		$("<input disabled='disabled' class='metadataEntry' type='submit' value='new'/>").appendTo($("#metadataTable"));
+	}
 	this.enableResetButton = function () {
 		$("#resetIsoTopicCats").click(function () {
 			$("#layer_md_topic_category_id option").removeAttr("selected");
@@ -122,6 +137,8 @@
 
 	this.init = function (obj) {
 		delete layerId;
+		//delete metadataURL entries
+		$('.metadataEntry').remove();
 		$metadataForm.easyform("reset");
 
 		wmsId = obj;

Modified: trunk/mapbender/http/plugins/mb_metadata_layer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -57,27 +57,18 @@
 		</p>
 		<p>
 		    <div id="buttons">
+			<fieldset>
 		    	<p>
-					<label><?php echo _mb("Add Information about the underlying data");?>:</label>
-					<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Linking the WMS layer with metadata set (coupled resource), which describes the underlying informations of the representation in more detail (eg Actuality / quality). It occurs via a link to an already existing metadta set in a catalog or a simple metadata set will be generatetd using a Mapbender Layer Addon-Editor.");?>'}" src="../img/questionmark.png" alt="" />
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Add new Metadata Record");?>"/>
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Edit Metadata Linkage");?>"/>
-				</p>
-				<p>
-					<input disabled="disabled" class="" type="submit" value="<?php echo _mb("Delete Metadata Linkage");?>"/>
-				</p>
-			</div>
-			<div id="selectbox">
-				<select disabled="disabled" class="metadata_selectbox" size="2" multiple>
-					<option>not</option>
-					<option>yet</option>
-					<option>implemented</option>
-				</select>
-			</div>			
+				<label><?php echo _mb("Add Information about the underlying data");?></label>
+				<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Linking the WMS layer with a metadata set (coupled resource), which describes the underlying information of the representation in more detail (eg actuality / quality). It can be done by linking to an already existing metadata set (e.g. in a catalogue) or by generating a simple metadata file using mapbender.");?>'}" src="../img/questionmark.png" alt="" />
+			</p>
+			<p>
+				<label><?php echo _mb("Table of coupled Metadata");?>:</label>
+				<table id="metadataTable">
+				</table>
+			</p>
+		    </fieldset>
+		    </div>			
 		</p>
 	</fieldset>
 </div>

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2011-04-29 11:54:56 UTC (rev 7790)
@@ -276,7 +276,28 @@
 		while ($row = db_fetch_assoc($res)) {
 			$resultObj["layer_keyword"][]= $row["keyword"];
 		}
-
+		//get MetadataURLs from md_metadata table
+		$sql = <<<SQL
+SELECT metadata_id, uuid, link, linktype, md_format, origin FROM mb_metadata 
+INNER JOIN (SELECT * from ows_relation_metadata 
+WHERE fkey_layer_id = $layerId ) as relation ON 
+mb_metadata.metadata_id = relation.fkey_metadata_id AND mb_metadata.origin = 'capabilities'
+SQL;
+		$res = db_query($sql);
+		$resultObj["md_metadata"]->metadata_id = array();
+		$resultObj["md_metadata"]->uuid = array();
+		$resultObj["md_metadata"]->origin = array();
+		$resultObj["md_metadata"]->linktype = array();
+		$resultObj["md_metadata"]->link = array();
+		$i = 0;
+		while ($row = db_fetch_assoc($res)) {
+			$resultObj["md_metadata"]->metadata_id[$i]= $row["metadata_id"];
+			$resultObj["md_metadata"]->link[$i]= $row["link"];
+			$resultObj["md_metadata"]->uuid[$i]= $row["uuid"];
+			$resultObj["md_metadata"]->origin[$i]= $row["origin"];
+			$resultObj["md_metadata"]->linktype[$i]= $row["linktype"];
+			$i++;
+		}
 		$ajaxResponse->setResult($resultObj);
 		$ajaxResponse->setSuccess(true);
 		break;

Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql	2011-04-29 08:20:32 UTC (rev 7789)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql	2011-04-29 11:54:56 UTC (rev 7790)
@@ -1779,6 +1779,108 @@
 --
 UPDATE gui_element SET e_target = 'pan1' WHERE e_id = 'toggleModule';
 
+-- Table: mb_metadata
 
+DROP TABLE mb_metadata CASCADE;
 
+CREATE TABLE mb_metadata
+(
+  metadata_id serial NOT NULL, --mapbender
+  uuid character varying(100), --mapbender/orig
+  origin character varying(100), --mapbender - capabilities, metador, external
+  includeincaps BOOLEAN DEFAULT TRUE, --mapbender include this metadataUrl in new capabilities
+  "schema" character varying(32), --mapbender/orig/ see geonetwork - maybe iso19139
+  createdate timestamp, --metadata
+  changedate timestamp, --metadata
+  lastchanged timestamp NOT NULL DEFAULT now(), --mapbender
+  data text, --metadata
+  link character varying(250), --link from capabilities/registry/metador
+  linktype character varying(100), -- from ows caps - metadataUrl type attribute
+  md_format character varying(100), -- from ows caps - metadataUrl format tag
+  title character varying(250), --metadata
+  abstract text, --metadata
+  searchtext text, --concatenate search strings
+  status character varying(50), --metadator
+  "type" character varying(50), --from iso19115 - service/dataset/application ...
+  harvestresult integer, --when getting information from caps
+  harvestexception text, --if mimetype from link result is not the expected format
+  tmp_reference_1 timestamp, --metadata
+  tmp_reference_2 timestamp, --metadata
+  spatial_res_type integer, --metadata
+  spatial_res_value character varying(20), --metadata
+  ref_system character varying(20), --metadata
+  format character varying(100), --metadata
+  inspire_charset character varying(10), --metadata
+  inspire_top_consistence boolean, --metadata
+  fkey_mb_user_id integer NOT NULL DEFAULT 1, -- from metador
+  responsible_party integer, --what is this? --fkey_mb_group_id will be better
+  individual_name integer, --what is this?
+  visibility character varying(12), --from metador
+  locked boolean DEFAULT false, --from metador
+  copyof character varying(100),--from metador
+ -- fkey_metadata_id integer,
+ -- fkey_layer_id integer,
+ -- fkey_featuretype_id integer,
+ -- mb_user_mb_group integer,
+ -- mb_user_mb_group_type integer,
+  "constraints" text, --metadata/metador?
+  fees character varying(2500), --metadata/metador?
+  classification character varying(100), --metadata/metador?
+  browse_graphic character varying(255), --metadata/metador?
+  inspire_conformance boolean, --metadata/metador?
+  preview_image text, --metadata/metador?
+  the_geom geometry, --metador
+  CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
+  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL),
+  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 4326),
+  CONSTRAINT metadata_pkey PRIMARY KEY (metadata_id)
+--  CONSTRAINT metadata_uuid_key UNIQUE (uuid) -- not used cause this could happen!
+)
+WITH (
+  OIDS=TRUE
+);
+ALTER TABLE mb_metadata OWNER TO postgres;
 
+
+-- Table: ows_relation_metadata
+
+DROP TABLE ows_relation_metadata CASCADE;
+
+CREATE TABLE ows_relation_metadata
+(
+  fkey_metadata_id integer NOT NULL,
+  fkey_layer_id integer,
+  fkey_featuretype_id integer,
+  CONSTRAINT ows_relation_metadata_fkey_featuretype_id_fkey FOREIGN KEY (fkey_featuretype_id)
+      REFERENCES wfs_featuretype (featuretype_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT ows_relation_metadata_fkey_layer_id_fkey FOREIGN KEY (fkey_layer_id)
+      REFERENCES layer (layer_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE,
+  CONSTRAINT ows_relation_metadata_fkey_metadata_id_fkey FOREIGN KEY (fkey_metadata_id)
+      REFERENCES mb_metadata (metadata_id) MATCH SIMPLE
+      ON UPDATE CASCADE ON DELETE CASCADE
+)
+WITH (
+  OIDS=FALSE
+);
+ALTER TABLE ows_relation_metadata OWNER TO postgres;
+
+
+
+CREATE OR REPLACE FUNCTION update_lastchanged_column()
+RETURNS TRIGGER AS $$
+BEGIN
+   NEW.lastchanged = now(); 
+   RETURN NEW;
+END;
+$$ language 'plpgsql';
+
+CREATE TRIGGER update_mb_metadata_lastchanged BEFORE UPDATE
+    ON mb_metadata FOR EACH ROW EXECUTE PROCEDURE 
+    update_lastchanged_column();
+
+
+
+
+



More information about the Mapbender_commits mailing list