[Mapbender-commits] r9620 - in trunk/mapbender: http/classes http/javascripts http/php resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 21 03:37:57 PDT 2016
Author: armin11
Date: 2016-10-21 03:37:57 -0700 (Fri, 21 Oct 2016)
New Revision: 9620
Modified:
trunk/mapbender/http/classes/class_iso19139.php
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/http/javascripts/initWmcObj.php
trunk/mapbender/http/php/mb_getWmsData.php
trunk/mapbender/http/php/mod_loadCapabilities.php
trunk/mapbender/http/php/mod_loadwms.php
trunk/mapbender/http/php/mod_updateWMS.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
New possibility for dataset metadata to inherit the contact and licence information from the service from which they are delivered
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/classes/class_iso19139.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -51,6 +51,7 @@
var $type;
var $origin;
var $owner;
+ var $fkey_mb_group_id;
var $harvestResult;
var $harvestException;
var $lineage;
@@ -104,6 +105,7 @@
$this->tmpExtentEnd = "1900-01-01";
$this->randomId = new Uuid();
$this->owner = 0; //dummy entry for metadata owner - in case of metadataURL entries the owner of the corresponding service
+ $this->fkey_mb_group_id = null;
$this->href = "";
$this->format = "";
$this->type = "";
@@ -1420,6 +1422,48 @@
return $postGisPolygon;
}
+ public function inheritContactAndLicenceInformation($metadataId,$resourceType,$resourceId,$inheritContactInfo,$inheritLicenceInfo){
+ //$e = new mb_exception("class_iso19139.php: inherit function invoked!");
+ if ($inheritContactInfo == true || $inheritLicenceInfo == true) {
+ //get info from coupled service
+ switch ($resourceType) {
+ case "layer":
+ $sql = "SELECT fkey_mb_group_id, wms.wms_id as service_id, fkey_termsofuse_id FROM wms LEFT JOIN wms_termsofuse ON wms.wms_id = wms_termsofuse.fkey_wms_id WHERE wms_id = (SELECT fkey_wms_id FROM layer WHERE layer_id = $resourceId)";
+ break;
+ case "featuretype":
+ $sql = "SELECT fkey_mb_group_id, wfs.wfs_id as service_id, fkey_termsofuse_id FROM wfs LEFT JOIN wfs_termsofuse ON wfs.wfs_id = wfs_termsofuse.fkey_wfs_id WHERE wfs_id = (SELECT fkey_wfs_id FROM wfs_featuretype WHERE featuretype_id = $resourceId)";
+ break;
+ }
+ $res = db_query($sql);
+ while ($row = db_fetch_array($res)){
+ $fkey_mb_group_id = $row['fkey_mb_group_id'];
+ $service_id = $row['service_id'];
+ $fkey_termsofuse_id = $row['fkey_termsofuse_id'];
+ }
+ //regexpr for strings which represents integer
+ $regExprInt = "/^[0-9]+$/";
+ }
+ if ($inheritContactInfo == true && preg_match($regExprInt,$fkey_mb_group_id)) {
+ $sqlInheritContact = "UPDATE mb_metadata set fkey_mb_group_id = $fkey_mb_group_id WHERE metadata_id = $metadataId";
+ $res = db_query($sqlInheritContact);
+ //$e = new mb_exception("Metadata with id ".$metadataId." inherits contact information from ".$resourceType." with resourceId ".$resourceId);
+ }
+ if ($inheritLicenceInfo == true && preg_match($regExprInt,$fkey_termsofuse_id)) {
+ try {
+ //delete own termsofuse if exists
+ $sqlDeleteTouRelation = "DELETE from md_termsofuse WHERE fkey_metadata_id = $metadataId";
+ $res = db_query($sqlDeleteTouRelation);
+ //insert service termsofuse relation
+ $sqlInsertTouRelation = "INSERT INTO md_termsofuse (fkey_termsofuse_id, fkey_metadata_id) VALUES ($fkey_termsofuse_id,$metadataId)";
+ $res = db_query($sqlInsertTouRelation);
+ //$e = new mb_exception("Metadata with id ".$metadataId." inherits licence information from ".$resourceType." with resourceId ".$resourceId);
+ }
+ catch (Exception $e) {
+ $exception = new mb_exception($e->getMessage());
+ }
+ }
+ }
+
public function insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId){
//first delete old classifications - after that create new ones
//$e = new mb_exception($metadataId." - ".$resourceType." - ".$resourceId);
@@ -1471,7 +1515,7 @@
}
}
$sqlInsert = rtrim($sqlInsert,",");
- $e = new mb_exception("class_Iso19139: insert topic categories: ".$sqlInsert);
+ //$e = new mb_exception("class_Iso19139: insert topic categories: ".$sqlInsert);
$sql = "INSERT INTO mb_metadata_md_topic_category (fkey_metadata_id, fkey_md_topic_category_id) VALUES ".$sqlInsert;
$res = db_query($sql);
if (!$res) {
@@ -1489,7 +1533,7 @@
}
$sqlInsert = rtrim($sqlInsert,",");
$sql = "INSERT INTO mb_metadata_inspire_category (fkey_metadata_id, fkey_inspire_category_id) VALUES ".$sqlInsert;
- $e = new mb_exception("class_Iso19139: insert inspire categories: ".$sqlInsert);
+ //$e = new mb_exception("class_Iso19139: insert inspire categories: ".$sqlInsert);
$res = db_query($sql);
if (!$res) {
$e = new mb_exception("class_Iso19139:"._mb("Cannot insert inspire categories for this metadata!"));
@@ -1506,7 +1550,7 @@
}
$sqlInsert = rtrim($sqlInsert,",");
$sql = "INSERT INTO mb_metadata_custom_category (fkey_metadata_id, fkey_custom_category_id) VALUES ".$sqlInsert;
- $e = new mb_exception("class_Iso19139: insert custom categories: ".$sqlInsert);
+ //$e = new mb_exception("class_Iso19139: insert custom categories: ".$sqlInsert);
$res = db_query($sql);
if (!$res) {
$e = new mb_exception("class_Iso19139:"._mb("Cannot insert custom categories for this metadata!"));
@@ -1810,7 +1854,7 @@
//insert an instance for iso19139 into mapbenders database
$e = new mb_notice("class_iso19139.php: insert metadata with title: ".$this->title);
$sql = <<<SQL
-INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage, inspire_download, bounding_geom, transfer_size, fees, md_license_source_note, constraints, responsible_party_name, responsible_party_email, preview_image) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42)
+INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage, inspire_download, bounding_geom, transfer_size, fees, md_license_source_note, constraints, responsible_party_name, responsible_party_email, preview_image, fkey_mb_group_id) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43)
SQL;
$v = array(
$this->href,
@@ -1854,13 +1898,14 @@
$this->accessConstraints,
$this->resourceResponsibleParty,
$this->resourceContactEmail,
- $this->previewImage
+ $this->previewImage,
+ $this->fkey_mb_group_id
);
//$e = new mb_exception($this->tmpExtentBegin);
//$e = new mb_exception($this->tmpExtentEnd);
//$e = new mb_exception($this->createDate);
//$e = new mb_exception($this->changeDate);
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s','s','s','s');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s','s','s','s','i');
$res = db_prep_query($sql,$v,$t);
return $res;
}
@@ -1919,7 +1964,7 @@
$sql .= "linktype = $4, uuid = $5, title = $6, createdate = $7, changedate = $8, lastchanged = now(), ";
$sql .= "abstract = $9, searchtext = $10, type = $11, tmp_reference_1 = $12, tmp_reference_2 = $13, export2csw = $14, datasetid = $15, ";
$sql .= "datasetid_codespace = $16, randomid = $17, harvestresult = $20, harvestexception = $21, lineage = $22, inspire_top_consistence = $23, ";
- $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34, bounding_geom = $35, transfer_size = $36, fees = $37, md_license_source_note = $38, constraints = $39, responsible_party_name = $40, responsible_party_email = $41 , preview_image = $42 WHERE metadata_id = $19";
+ $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34, bounding_geom = $35, transfer_size = $36, fees = $37, md_license_source_note = $38, constraints = $39, responsible_party_name = $40, responsible_party_email = $41, preview_image = $42, fkey_mb_group_id = $43 WHERE metadata_id = $19";
//$e= new mb_exception("class_iso19139.php: downloadLinks json".$this->jsonEncodeDownloadLinks($this->downloadLinks));
//$e= new mb_exception("class_iso19139.php: downloadLinks[0]".$this->downloadLinks[0]);
$v = array(
@@ -1965,10 +2010,11 @@
$this->accessConstraints,
$this->resourceResponsibleParty,
$this->resourceContactEmail,
- $this->previewImage
+ $this->previewImage,
+ $this->fkey_mb_group_id
);
//$e = new mb_exception("class_iso19139: ".$this->createWktBboxFromArray($this->wgs84Bbox));
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s','s','s','s');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s','s','s','s','i');
$res = db_prep_query($sql,$v,$t);
return $res;
}
@@ -2098,7 +2144,7 @@
return $getMapUrl;
}
- public function insertToDB($resourceType, $resourceId){
+ public function insertToDB($resourceType, $resourceId, $inheritContactInfo = false, $inheritLicenceInfo = false){
$result = array(); //value/message
switch ($this->origin) {
@@ -2205,6 +2251,7 @@
$res = $this->updateMetadataById($metadataId);
$this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
+ $this->inheritContactAndLicenceInformation($metadataId,$resourceType,$resourceId,$inheritContactInfo,$inheritLicenceInfo);
} else {
//check if href already exists
$metadataId = $this->isLinkAlreadyInDB();
@@ -2216,6 +2263,7 @@
//check if the timestamp of an existing metadata element is not newer than the timestamp of the current metadata object!!!!
$res = $this->updateMetadataById($metadataId);
$this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
+ $this->inheritContactAndLicenceInformation($metadataId,$resourceType,$resourceId,$inheritContactInfo,$inheritLicenceInfo);
} else {
//insert new record
$e = new mb_notice("class_Iso19139:"."No existing metadata fileIdentifier found in mapbender metadata table. New record will be inserted with uuid: ".$this->fileIdentifier);
@@ -2254,7 +2302,7 @@
//Propagate information for each new layer to csw if configured*******************
$propagation = new propagateMetadata();
$uuidArray[0] = $this->fileIdentifier;
- $result = $propagation->doPropagation("metadata", false, "push", $uuidArray);
+ $resultPropagation = $propagation->doPropagation("metadata", false, "push", $uuidArray);
//********************************************************************************
//insert relations
$row = db_fetch_assoc($res);
@@ -2298,7 +2346,10 @@
return $result;
} else {
$this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
- //if this was ok, let the resource (layer/featuretype) inherit the classification from the coupled metadata to support better catalogue search
+ //inherit licence info and contact info from coupled service if this is wished so - that will override and/or extent the original metadata!!!
+ $this->inheritContactAndLicenceInformation($metadataId,$resourceType,$resourceId,$inheritContactInfo,$inheritLicenceInfo);
+
+ //TODO: if this was ok, let the resource (layer/featuretype) inherit the classification from the coupled metadata to support better catalogue search
}
}
}
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/classes/class_wms.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -35,7 +35,7 @@
//extended information
var $wms_termsofuse;
var $wms_license_source_note;
-
+
var $fees;
var $accessconstraints;
var $contactperson;
@@ -69,7 +69,6 @@
var $gui_wms_exceptionformat;
var $gui_wms_epsg;
var $gui_wms_sldurl;
-
var $gui_wms_dimension_time;
var $gui_wms_dimension_elevation;
@@ -78,6 +77,13 @@
var $overwriteCategories = false;
var $twitterNews = false;
var $setGeoRss = false;
+
+ //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 $geoRss;
var $geoRssFactory; // = new GeoRssFactory();
const GEORSS = true;
@@ -2479,7 +2485,7 @@
}
//do the things for the parent layers
//get parent layer
- $e = new mb_exception("wms_id: ".$this->wms_id);
+ //$e = new mb_exception("wms_id: ".$this->wms_id);
if (is_int($this->wms_id)) {
$admin = new administration();
$layerIdArray = $admin->getParentLayers($this->wms_id, $this->objLayer[$i]->db_id);
@@ -2772,17 +2778,19 @@
$mbMetadata->type = $this->objLayer[$i]->layer_metadataurl[$j]->type;
$mbMetadata->origin = "capabilities";
$mbMetadata->owner = $mdOwner;
-
- $result = $mbMetadata->insertToDB("layer",$this->objLayer[$i]->db_id);
-
- if ($result['value'] == false){
- $e = new mb_exception("Problem while storing metadata url from wms to db");
- $e = new mb_exception($result['message']);
-
-
- } else {
- $e = new mb_notice("Storing of metadata url from wms to db was successful");
- $e = new mb_notice($result['message']);
+ if ($this->harvestCoupledDatasetMetadata == true) {
+ try {
+ $result = $mbMetadata->insertToDB("layer",$this->objLayer[$i]->db_id, $this->bequeathContactInformation, $this->bequeathLicenceInformation );
+ if ($result['value'] == false){
+ throw new Exception("Problem while storing metadata url from wms to db");
+ } else {
+ $ex = new mb_notice("Storing of metadata url from wms to db was successful");
+ $ex = new mb_notice($result['message']);
+ }
+ }
+ catch(Exception $e) {
+ $exception = new mb_exception($e->getMessage());
+ }
}
}
}
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -460,6 +460,12 @@
$latitudes = array();
$longitudes = array();
foreach($kmls->{$geojsonTitle}->data->features as $feature) {
+ //TODO: ugly fix to read multipolygons - delete if multiobjects are supported somewhen!
+ if ($feature->geometry->type == 'MultiPolygon') {
+ $feature->geometry->type = "Polygon";
+ //read only the first polygon!!
+ $feature->geometry->coordinates = $feature->geometry->coordinates[0];
+ }
switch ($feature->geometry->type) {
case "Polygon":
//$e = new mb_exception("Polygon found!");
Modified: trunk/mapbender/http/php/mb_getWmsData.php
===================================================================
--- trunk/mapbender/http/php/mb_getWmsData.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/php/mb_getWmsData.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -104,6 +104,9 @@
#$changedLayerObj = json_encode($changedLayerArray);
$mywms = new wms();
+ if(empty($_POST['harvest_dataset_metadata'])) {
+ $mywms->harvestCoupledDatasetMetadata = false;
+ }
if ($useAuthentication) {
$result = $mywms->createObjFromXML($url, $auth);
} else {
Modified: trunk/mapbender/http/php/mod_loadCapabilities.php
===================================================================
--- trunk/mapbender/http/php/mod_loadCapabilities.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/php/mod_loadCapabilities.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -177,7 +177,7 @@
echo"Password:<br>";
echo"<input type='text' name='password' size='50' value=''><br>";
}
-
+ echo "<input type='checkbox' name='harvest_dataset_metadata' checked='checked'>"._mb('Harvest coupled dataset metadata from given MetadataURL tags')."<br>";
if (defined("TWITTER_NEWS") && TWITTER_NEWS == true) {
echo"<input type='checkbox' name='twitter_news' checked='checked'>Publish via Twitter<br>";
}
Modified: trunk/mapbender/http/php/mod_loadwms.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwms.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/php/mod_loadwms.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -31,6 +31,9 @@
$auth['auth_type'] = $_REQUEST["auth_type"];
}
$mywms = new wms();
+ if(empty($_POST['harvest_dataset_metadata'])) {
+ $mywms->harvestCoupledDatasetMetadata = false;
+ }
if(empty($_POST['twitter_news'])) {
$mywms->twitterNews = false;
}
Modified: trunk/mapbender/http/php/mod_updateWMS.php
===================================================================
--- trunk/mapbender/http/php/mod_updateWMS.php 2016-10-20 11:41:18 UTC (rev 9619)
+++ trunk/mapbender/http/php/mod_updateWMS.php 2016-10-21 10:37:57 UTC (rev 9620)
@@ -35,10 +35,6 @@
$myURL = $_POST["myURL"];
-
-
-
-
$secParams = SID."&guiID=".$_REQUEST["guiID"]."&elementID=".$_REQUEST["elementID"];
$self = $_SERVER["SCRIPT_NAME"]."?".$secParams;
@@ -53,7 +49,6 @@
return $row ? $row["layer_id"] : null;
}
-
?>
<html>
<head>
@@ -156,8 +151,8 @@
authPassword = $("#imrAuthPassword").val();
authName = $("#imrAuthName").val();
}
- console.log(dbOldNameArray);
- console.log(dbCurrentNameArray);
+ //console.log(dbOldNameArray);
+ //console.log(dbCurrentNameArray);
var updateParams = {
//TODO add auth info!
"command": "updateWMS",
@@ -166,6 +161,7 @@
"authType" : authType,
"authName" : authName,
"authPassword" : authPassword,
+ "harvestDatasetMetadata" : $("#harvest_dataset_metadata").attr("checked"),
"publishRss" : $("#rss_news").attr("checked"),
"publishTwitter" : $("#twitter_news").attr("checked"),
"overwriteCategories" : $("#overwrite_categories").attr("checked"),
@@ -439,6 +435,7 @@
echo "Password : <input type='text' name='imrAuthPassword' id='imrAuthPassword'/><br><br>";
echo "</div>";
echo "Link to new WMS Capabilities URL:<br><input size='100' type='text' name='myURL' id='myURL'><br>";
+ echo"<input type='checkbox' name='harvest_dataset_metadata' id='harvest_dataset_metadata' checked='checked'>"._mb('Harvest/update dataset metadata by following existing MetadataURL tags in the capabilities')."<br>";
if (defined("TWITTER_NEWS") && TWITTER_NEWS == true) {
echo"<input type='checkbox' name='twitter_news' id='twitter_news' checked='checked'>Publish via Twitter<br>";
}
@@ -492,6 +489,9 @@
} else {
$mywms->overwrite=true;
}
+ if(empty($_POST['harvest_dataset_metadata'])) {
+ $mywms->harvestCoupledDatasetMetadata = false;
+ }
//possibility to see update information in georss and/or twitter channel
if(empty($_POST['twitter_news'])) {
$mywms->twitterNews = false;
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-20 11:41:18 UTC (rev 9619)
+++ 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)
@@ -1251,4 +1251,4 @@
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;
More information about the Mapbender_commits
mailing list