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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Oct 25 08:36:21 PDT 2016


Author: armin11
Date: 2016-10-25 08:36:21 -0700 (Tue, 25 Oct 2016)
New Revision: 9621

Modified:
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/php/wms.php
   trunk/mapbender/http/plugins/mb_metadata_edit.php
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
Some new functions to bequeath licence and contact information from serv ices to coupled dataset metadata

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2016-10-21 10:37:57 UTC (rev 9620)
+++ trunk/mapbender/http/classes/class_wms.php	2016-10-25 15:36:21 UTC (rev 9621)
@@ -81,8 +81,8 @@
         //dataset metadata handling - defaults to true
 	var $harvestCoupledDatasetMetadata = true;
 	//inheritance of service elements to coupled dataset metadata
-	var $bequeathLicenceInformation = true; //relation wms_termsofuse
-	var $bequeathContactInformation = true; //database attribute fkey_mb_group_id
+	var $wms_bequeath_licence_info = 0; //bequeath relation wms_termsofuse to coupled dataset metadata
+	var $wms_bequeath_contact_info = 0; //bequeath database attribute fkey_mb_group_id to dataset metadata
        
 	var $geoRss;
 	var $geoRssFactory; // = new GeoRssFactory();
@@ -2778,9 +2778,19 @@
 			$mbMetadata->type = $this->objLayer[$i]->layer_metadataurl[$j]->type;
 			$mbMetadata->origin = "capabilities";
 			$mbMetadata->owner = $mdOwner;
+			if ($this->wms_bequeath_licence_info == 1 || $this->wms_bequeath_licence_info == '1') {
+				$bequeathLicence = true;
+			} else {
+				$bequeathLicence = false;
+			}
+			if ($this->wms_bequeath_contact_info == 1 || $this->wms_bequeath_contact_info == '1') {
+				$bequeathContact = true;
+			} else {
+				$bequeathContact = false;
+			}
                         if ($this->harvestCoupledDatasetMetadata == true) {
 				try {
-					$result = $mbMetadata->insertToDB("layer",$this->objLayer[$i]->db_id, $this->bequeathContactInformation, $this->bequeathLicenceInformation );
+					$result = $mbMetadata->insertToDB("layer",$this->objLayer[$i]->db_id, $bequeathContact, $bequeathLicence);
 					if ($result['value'] == false){
 						throw new Exception("Problem while storing metadata url from wms to db");
 					} else {
@@ -2820,6 +2830,8 @@
 			$this->wms_max_imagesize = $row["wms_max_imagesize"];
 			$this->inspire_annual_requests = $row["inspire_annual_requests"];
 			$this->wms_license_source_note = $row["wms_license_source_note"];
+			$this->wms_bequeath_licence_info = $row["wms_bequeath_licence_info"];
+			$this->wms_bequeath_contact_info = $row["wms_bequeath_contact_info"];
 			$this->fkey_mb_group_id = $row["fkey_mb_group_id"];
 		}
 		//if network access is either stored in database nor given thru object, set it too a default value 0
@@ -2855,15 +2867,17 @@
  		$sql .= "wms_username = $18, "; 
  		$sql .= "wms_password = $19, ";
 		$sql .= "inspire_annual_requests = $20, ";
-		$sql .= "wms_license_source_note = $21 ";
+		$sql .= "wms_license_source_note = $21, ";
+		$sql .= "wms_bequeath_licence_info= $22, ";
+		$sql .= "wms_bequeath_contact_info = $23 ";
 		//$sql .= "uuid = $15 ";
 		$sql .= " WHERE wms_id = $15";
 	
 		$v = array($this->wms_version,$this->wms_getcapabilities,
 			$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
 			$admin->char_encode($this->wms_getcapabilities_doc),$this->wms_upload_url,strtotime("now"),
-			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,$this->wms_network_access, $this->fkey_mb_group_id ,$myWMS, $this->wms_max_imagesize, $authType, $username, $password, $this->inspire_annual_requests,$this->wms_license_source_note);
-		$t = array('s','s','s','s','s','s','s','i','s','s','s','s','i','i','i','i','s','s','s','i','s');
+			$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,$this->wms_network_access, $this->fkey_mb_group_id ,$myWMS, $this->wms_max_imagesize, $authType, $username, $password, $this->inspire_annual_requests,$this->wms_license_source_note, $this->wms_bequeath_licence_info, $this->wms_bequeath_contact_info);
+		$t = array('s','s','s','s','s','s','s','i','s','s','s','s','i','i','i','i','s','s','s','i','s','i','i');
 			
 		$res = db_prep_query($sql,$v,$t);
 		if(!$res){
@@ -2891,14 +2905,16 @@
 			$sql .= "wms_max_imagesize = $19, ";
 			$sql .= "wms_license_source_note = $20, ";
 			//$sql .= "inspire_annual_requests = $20, ";
+			$sql .= "wms_bequeath_licence_info = $21, ";
+			$sql .= "wms_bequeath_contact_info = $22, ";
 			$sql .= "fkey_mb_group_id = $17 ";
 			#$sql .= "uuid = $18 ";
 			$sql .= " WHERE wms_id = $18";
 			$v = array($this->wms_title,$this->wms_abstract,$this->fees,$this->accessconstraints,
 				$this->contactperson,$this->contactposition,$this->contactorganization,$this->address,
 				$this->city,$this->stateorprovince,$this->postcode,$this->country,$this->contactvoicetelephone,
-				$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,$this->wms_network_access, $this->fkey_mb_group_id , $myWMS, $this->wms_max_imagesize, $this->wms_license_source_note);
-			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i','i','i','s');
+				$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,$this->wms_network_access, $this->fkey_mb_group_id , $myWMS, $this->wms_max_imagesize, $this->wms_license_source_note, $this->wms_bequeath_licence_info, $this->wms_bequeath_contact_info);
+			$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','i','i','i','i','s','i','i');
 			$res = db_prep_query($sql,$v,$t);
 			if(!$res){
 				db_rollback();	
@@ -3477,7 +3493,8 @@
 				$this->contactelectronicmailaddress = $row2["contactelectronicmailaddress"];
 				$this->wms_max_imagesize = $row2["wms_max_imagesize"];
 				$this->inspire_annual_requests = $row2["inspire_annual_requests"];
-				
+				$this->wms_bequeath_licence_info = $row2["wms_bequeath_licence_information"];
+				$this->wms_bequeath_contact_info = $row2["wms_bequeath_contact_information"];
 				$count_wms++;
 			}
 	
@@ -3704,7 +3721,8 @@
 			$this->uuid = $row2["uuid"];
 			$this->wms_max_imagesize = $row2["wms_max_imagesize"];
 			$this->inspire_annual_requests = $row2["inspire_annual_requests"];
-
+			$this->wms_bequeath_licence_info = $row2["wms_bequeath_licence_info"];
+			$this->wms_bequeath_contact_info = $row2["wms_bequeath_contact_info"];
 			//some default values
 			$this->gui_wms_visible = 1;
 			$this->gui_wms_opacity = 100;

Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php	2016-10-21 10:37:57 UTC (rev 9620)
+++ trunk/mapbender/http/php/wms.php	2016-10-25 15:36:21 UTC (rev 9621)
@@ -106,7 +106,8 @@
 // check if request param is set
 //
 if (!isset($requestType) || $requestType === "" || ($service == "WMS" && $requestType != "GetCapabilities")) {
-	header("Content-type: application/xhtml+xml; charset=UTF-8");
+	//header("Content-type: application/xhtml+xml; charset=UTF-8");
+	header("Content-type: application/vnd.ogc.wms_xml; charset=UTF-8");
 	echo createExceptionXml("", "Parameter REQUEST invalid");
 	die;
 }

Modified: trunk/mapbender/http/plugins/mb_metadata_edit.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.php	2016-10-21 10:37:57 UTC (rev 9620)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.php	2016-10-25 15:36:21 UTC (rev 9621)
@@ -81,6 +81,16 @@
 		<img class="metadata_img" title="<?php echo _mb("INSPIRE Monitoring: Annually requests to View Service");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
 		<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Annually amount of requests to INSPIRE View Service. This value will be used to build the INSPIRE Monitoring information from mapbender registry!");?>'}" src="../img/questionmark.png" alt="" />
 	</p>
+	<p>
+		<label for="wms_bequeath_licence_info"><?php echo _mb("Bequeath licence info from service to coupled dataset metadata (Registry)");?>:</label>
+      		<input name="wms_bequeath_licence_info" id="wms_bequeath_licence_info" type="checkbox"/>
+		<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Bequeath licence information from this service to all coupled dataset metadata. This function activates the dataset metadata proxy and the url of the original metadata will be exchanged with a geoportal proxy url. Check this to have licences of service and dataset in sync. This maybe usefull for a better exchange of geo-metadata with open data catalogues/portals.");?>'}" src="../img/questionmark.png" alt="" />
+	</p>
+	<p>
+		<label for="wms_bequeath_contact_info"><?php echo _mb("Bequeath contact info from service to coupled dataset metadata (Registry)");?>:</label>
+      		<input name="wms_bequeath_contact_info" id="wms_bequeath_contact_info" type="checkbox"/>
+		<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Bequeath contact information from this service to all coupled dataset metadata. This function activates the dataset metadata proxy and the url of the original metadata will be exchanged with a geoportal proxy url. Check this to have the contact information of service and dataset in sync. It will use the contact information of the geoportal organization role system instead of the contact information which originates from the dataset metadata. This maybe usefull for a better exchange of geo-metadata with open data catalogues/portals.");?>'}" src="../img/questionmark.png" alt="" />
+	</p>
 </fieldset>
 <fieldset>
 	<legend><?php echo _mb("WMS Provider Section (OWS)");?></legend>

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2016-10-21 10:37:57 UTC (rev 9620)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2016-10-25 15:36:21 UTC (rev 9621)
@@ -245,7 +245,9 @@
 			"wms_max_imagesize",
 			"fkey_mb_group_id",
 			"inspire_annual_requests",
-			"wms_license_source_note"
+			"wms_license_source_note",
+			"wms_bequeath_licence_info",
+			"wms_bequeath_contact_info"
 		);
 
 		$resultObj = array();
@@ -297,6 +299,8 @@
 			$resultObj["wms_termsofuse"] = null;
 		}
 		$resultObj['wms_network_access'] = $resultObj['wms_network_access'] == 1 ? true : false;
+		$resultObj['wms_bequeath_licence_info'] = $resultObj['wms_bequeath_licence_info'] == 1 ? true : false;
+		$resultObj['wms_bequeath_contact_info'] = $resultObj['wms_bequeath_contact_info'] == 1 ? true : false;
 		if (is_null($resultObj['inspire_annual_requests']) || $resultObj['inspire_annual_requests'] == "") {
 			$resultObj['inspire_annual_requests'] = "0";
 		}
@@ -747,7 +751,9 @@
 					"wms_max_imagesize",
 					"fkey_mb_group_id",
 					"inspire_annual_requests",
-					"wms_license_source_note"
+					"wms_license_source_note",
+					"wms_bequeath_licence_info",
+					"wms_bequeath_contact_info"
 				);
 				foreach ($columns as $c) {
 					if ($c == 'wms_termsofuse' && $data->wms->$c == "0") {
@@ -845,10 +851,14 @@
 						}
 					}
 				}
-				if ($wms->wms_network_access == "on") {
-					$wms->wms_network_access = intval('1');
-				} else {
-					$wms->wms_network_access = intval('0');
+				//array of checkboxes (integer values in database)
+				$checkboxes = array("wms_network_access","wms_bequeath_licence_info","wms_bequeath_contact_info");
+				foreach ($checkboxes as $checkbox) {
+					if ($wms->{$checkbox} == "on") {
+						$wms->{$checkbox} = intval('1');
+					} else {
+						$wms->{$checkbox} = intval('0');
+					}
 				}
 
 				if (defined("TWITTER_NEWS") && TWITTER_NEWS == true && $ajaxResponse->getParameter("twitterNews") == true) {

Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2016-10-21 10:37:57 UTC (rev 9620)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2016-10-25 15:36:21 UTC (rev 9621)
@@ -1251,4 +1251,41 @@
 ALTER TABLE gui_layer ALTER COLUMN gui_layer_style TYPE VARCHAR(100);
 
 ALTER TABLE mb_group ADD COLUMN uuid UUID;
-ALTER TABLE mb_metadata ADD COLUMN fkey_mb_group_id integer;
+ALTER TABLE mb_metadata ADD COLUMN fkey_mb_group_id INTEGER;
+
+-- simple function to exchange some layer information of old layers with new content - maybe usefull if service structure will change sometimes - the layer_id is persistent
+-- Function: f_exchange_layer_info(integer, integer)
+
+-- DROP FUNCTION f_exchange_layer_info(integer, integer);
+
+CREATE OR REPLACE FUNCTION f_exchange_layer_info(integer, integer)
+  RETURNS text AS
+$BODY$DECLARE
+    p_old_layer_id ALIAS FOR $1;
+    p_new_layer_id ALIAS FOR $2;
+    
+BEGIN
+    --attributes: fkey_wms_id, layer_pos, layer_parent, layer_name, layer_title, layer_queryable, layer_minscale, layer_maxscale, layer_dataurl, layer_metadataurl, layer_abstract
+    -- which other technical tables should be adopted:
+    -- layer_dimension, layer_epsg, layer_style
+    UPDATE layer SET fkey_wms_id = l2.fkey_wms_id, layer_title = l2.layer_title, layer_pos = l2.layer_pos, layer_parent = l2.layer_parent, layer_name = l2.layer_name, layer_queryable = l2.layer_queryable, layer_minscale = l2. layer_minscale, layer_maxscale = l2.layer_maxscale, layer_dataurl = l2.layer_dataurl, layer_metadataurl = l2.layer_metadataurl, layer_abstract = l2.layer_abstract 
+    FROM layer AS l2
+    WHERE layer.layer_id = p_old_layer_id and l2.layer_id = p_new_layer_id;
+    DELETE FROM layer_dimension WHERE fkey_layer_id = p_old_layer_id;
+    DELETE FROM layer_epsg WHERE fkey_layer_id = p_old_layer_id;
+    DELETE FROM layer_style WHERE fkey_layer_id = p_old_layer_id;
+    UPDATE layer_dimension SET fkey_layer_id = p_old_layer_id WHERE fkey_layer_id = p_new_layer_id;
+    UPDATE layer_epsg SET fkey_layer_id = p_old_layer_id WHERE fkey_layer_id = p_new_layer_id;
+    UPDATE layer_style SET fkey_layer_id = p_old_layer_id WHERE fkey_layer_id = p_new_layer_id;
+    DELETE FROM layer WHERE layer_id = p_new_layer_id;
+
+    RETURN 'Layer information exchanged!';
+END;
+$BODY$
+  LANGUAGE plpgsql VOLATILE STRICT
+  COST 100;
+ALTER FUNCTION f_exchange_layer_info(integer, integer)
+  OWNER TO postgres;
+ALTER TABLE wms ADD COLUMN wms_bequeath_licence_info INTEGER;
+ALTER TABLE wms ADD COLUMN wms_bequeath_contact_info INTEGER;
+



More information about the Mapbender_commits mailing list