[Mapbender-commits] r8619 - in trunk/mapbender: http/classes http/plugins resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sun May 12 08:45:56 PDT 2013
Author: armin11
Date: 2013-05-12 08:45:56 -0700 (Sun, 12 May 2013)
New Revision: 8619
Modified:
trunk/mapbender/http/classes/class_iso19139.php
trunk/mapbender/http/plugins/mb_metadata_server.php
trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
Log:
Some bugfixes for wms and wfs metadata editor. Metadatasets which have been uploaded or linked are not deleted directly any more. Only if they have no other linkages and if they are not made with the internal metadata editor (metador or simple editor).
New tables for relations of metadatasets to categories and keywords. They are needed to allow a metadata search thru mapbenders searchInterface as it is possible for layers, featuretypes and wmc. They are also needed to allow a better apriori INSPIRE dataset-service coupling. For the mapbender3 datamodell it will be better to implement this somewhat easier.
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/http/classes/class_iso19139.php 2013-05-12 15:45:56 UTC (rev 8619)
@@ -29,6 +29,8 @@
var $datasetId;
var $datasetIdCodeSpace;
var $keywords = array();
+ var $keywordsThesaurusName = array();
+ var $isoCategories = array();
var $hierachyLevel;
var $tmpExtentBegin;
var $tmpExtentEnd;
@@ -64,7 +66,9 @@
$this->metadata = "";
$this->datasetId = "";
$this->datasetIdCodeSpace = "";
- $this->keywords[0] = "";
+ $this->keywords[0] = "";
+ $this->keywordsThesaurusName[0] = "";
+ $this->isoCategories[0] = "";
$this->hierachyLevel = "dataset";
$this->tmpExtentBegin = "1900-01-01";
$this->tmpExtentEnd = "1900-01-01";
@@ -77,7 +81,6 @@
$this->refSystem = "";
$this->harvestResult = 0;
$this->harvestException = "";
-
$this->lineage = "";
$this->inspireTopConsistence = "f";
$this->spatialResType = "";
@@ -155,6 +158,17 @@
$this->abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
$this->abstract = $this->abstract[0];
$this->keywords = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/gco:CharacterString');
+ //get thesaurus name only for found keywords!
+ $iKeyword = 0;
+ foreach ($this->keywords as $keyword) {
+
+ $thesaurusName = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords[gmd:MD_Keywords/gmd:keyword/gco:CharacterString="'.$keyword.'"]/gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString');
+ $this->keywordsThesaurusName[$iKeyword] = $thesaurusName[0];
+ unset($thesaurusName);
+ $iKeyword++;
+ }
+ $iKeyword = 0;
+ $this->isoCategories = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode');
$this->hierachyLevel = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
$this->hierachyLevel = $this->hierachyLevel[0];
$this->tmpExtentBegin = $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');
@@ -170,6 +184,13 @@
//get last part of string separated by the colon symbol
$this->refSystem = explode(':',$this->refSystem);
$this->refSystem = "EPSG:".$this->refSystem[count($this->refSystem)-1];
+ //debug output of keywords:
+ $iKeyword = 0;
+ foreach($this->keywords as $keyword) {
+ $e = new mb_exception("Keyword: ".$keyword." - Thesaurus: ".$this->keywordsThesaurusName[$iKeyword]);
+ $iKeyword++;
+ }
+ $iKeyword = 0;
//format
//inspire_charset
//inspire_top_consistence
@@ -787,7 +808,7 @@
if ($metadata == false) {
//xml could not be parsed
$result['value'] = false;
- $result['message'] = "Metadata bbject could not be created!";
+ $result['message'] = "Metadata object could not be created!";
return $result;
}
//else save it into database
@@ -1009,6 +1030,12 @@
}
}
}
+ //insert keywords into keyword table
+ //check if keyword already exists - if not create new one
+ //insert relations into database
+ //insert relations for categories for topic, inspire, custom
+ //1. delete old relations
+ //2. create new ones
$result['value'] = true;
$result['message'] = "Insert metadata successfully into database!";
return $result;
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2013-05-12 15:45:56 UTC (rev 8619)
@@ -987,11 +987,10 @@
case "deleteLayerMetadataAddon" :
$metadataId = $ajaxResponse->getParameter("metadataId");
- $sql = <<<SQL
+ //TODO delete the entry only, if the metadataset has no other relation!!!!!
+ //get count of relations for the relevant metadata set
+ $sql = "SELECT count(*) as count FROM ows_relation_metadata WHERE fkey_metadata_id = $1";
-DELETE FROM mb_metadata WHERE metadata_id = $1
-
-SQL;
$v = array($metadataId);
$t = array('i');
try {
@@ -999,14 +998,66 @@
}
catch (Exception $e){
$ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Could not delete metadata from database!"));
+ $ajaxResponse->setMessage(_mb("Could not determine a count of metadata relations!"));
$ajaxResponse->send();
die;
}
- $ajaxResponse->setMessage("Metadata deleted!");
- $ajaxResponse->setSuccess(true);
- break;
+ while ($row = db_fetch_assoc($res)) {
+ $countMetadataLinkage = (integer)$row['count']; //integer
+ }
+ if ($countMetadataLinkage == 1) {
+ $e = new mb_exception("Metadata has only one reference and will be deleted from database if it was created by upload or link!");
+ //delete the metadata itself cause it has no other reference - really - not right for metador files !!!
+ $sql = <<<SQL
+DELETE FROM mb_metadata WHERE metadata_id = $1 and origin NOT IN ('metador')
+
+SQL;
+ $v = array($metadataId);
+ $t = array('i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $e){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not delete metadata from database!"));
+ $ajaxResponse->send();
+ die;
+ }
+ $ajaxResponse->setMessage("Metadata was deleted from database!");
+ $ajaxResponse->setSuccess(true);
+ break;
+
+
+
+ } else {
+ $e = new mb_exception("Number of related OWS resources: ".$countMetadataLinkage);
+ //only delete the relation
+ $metadataId = $ajaxResponse->getParameter("metadataId");
+ $layerId = $ajaxResponse->getParameter("layerId");
+ $sql = <<<SQL
+
+DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_layer_id = $2
+
+SQL;
+ $v = array($metadataId, $layerId);
+ $t = array('i','i');
+ //$e = new mb_exception("metadataid:".$metadataId." - layerid: ".$layerId);
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not delete metadata linkage from database!"));
+ $ajaxResponse->send();
+ die;
+ }
+ $ajaxResponse->setMessage("Metadata linkage deleted!");
+ $ajaxResponse->setSuccess(true);
+ }
+
+ break;
+
case "importLayerXmlAddon" :
//this case is similar to insert the metadata from external link, but came from internal file from tmp folder which has been uploaded before
$layerId = $ajaxResponse->getParameter("layerId");
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2013-05-12 15:45:56 UTC (rev 8619)
@@ -212,7 +212,8 @@
url: "../plugins/mb_metadata_server.php",
method: "deleteLayerMetadataAddon",
parameters: {
- "metadataId": metadataId
+ "metadataId": metadataId,
+ "layerId": layerId
},
callback: function (obj, result, message) {
if (!result) {
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js 2013-05-12 15:45:56 UTC (rev 8619)
@@ -211,7 +211,8 @@
url: "../plugins/mb_metadata_wfs_server.php",
method: "deleteFeaturetypeMetadataAddon",
parameters: {
- "metadataId": metadataId
+ "metadataId": metadataId,
+ "featuretypeId": featuretypeId
},
callback: function (obj, result, message) {
if (!result) {
Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-05-12 15:45:56 UTC (rev 8619)
@@ -693,9 +693,78 @@
$ajaxResponse->setSuccess(true);
break;
-
case "deleteFeaturetypeMetadataAddon" :
$metadataId = $ajaxResponse->getParameter("metadataId");
+ //TODO delete the entry only, if the metadataset has no other relation!!!!!
+ //get count of relations for the relevant metadata set
+ $sql = "SELECT count(*) as count FROM ows_relation_metadata WHERE fkey_metadata_id = $1";
+
+ $v = array($metadataId);
+ $t = array('i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $e){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not determine a count of metadata relations!"));
+ $ajaxResponse->send();
+ die;
+ }
+ while ($row = db_fetch_assoc($res)) {
+ $countMetadataLinkage = (integer)$row['count']; //integer
+ }
+ if ($countMetadataLinkage == 1) {
+ $e = new mb_exception("Metadata has only one reference and will be deleted from database if it was created by upload or link!");
+ //delete the metadata itself cause it has no other reference - really - not right for metador files !!!
+ $sql = <<<SQL
+
+DELETE FROM mb_metadata WHERE metadata_id = $1 and origin NOT IN ('metador')
+
+SQL;
+ $v = array($metadataId);
+ $t = array('i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $e){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not delete metadata from database!"));
+ $ajaxResponse->send();
+ die;
+ }
+ $ajaxResponse->setMessage("Metadata was deleted from database!");
+ $ajaxResponse->setSuccess(true);
+ break;
+
+
+
+ } else {
+ //only delete the relation
+ $metadataId = $ajaxResponse->getParameter("metadataId");
+ $featuretypeId = $ajaxResponse->getParameter("featuretypeId");
+ $sql = <<<SQL
+
+DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_featuretype_id = $2
+
+SQL;
+ $v = array($metadataId, $featuretypeId);
+ $t = array('i','i');
+ //$e = new mb_exception("metadataid:".$metadataId." - layerid: ".$layerId);
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not delete metadata linkage from database!"));
+ $ajaxResponse->send();
+ die;
+ }
+ $ajaxResponse->setMessage("Metadata linkage deleted!");
+ $ajaxResponse->setSuccess(true);
+ }
+ break;
+ /*case "deleteFeaturetypeMetadataAddon" :
+ $metadataId = $ajaxResponse->getParameter("metadataId");
$sql = <<<SQL
DELETE FROM mb_metadata WHERE metadata_id = $1
@@ -714,7 +783,7 @@
}
$ajaxResponse->setMessage("Metadata deleted!");
$ajaxResponse->setSuccess(true);
- break;
+ break;*/
case "importFeaturetypeXmlAddon" :
//this case is similar to insert the metadata from external link, but came from internal file from tmp folder which has been uploaded before
$featuretypeId = $ajaxResponse->getParameter("featuretypeId");
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-05-08 14:58:54 UTC (rev 8618)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-05-12 15:45:56 UTC (rev 8619)
@@ -90,3 +90,99 @@
ALTER TABLE mb_group ADD COLUMN mb_group_admin_code character varying(255);
ALTER TABLE mb_group ALTER COLUMN mb_group_admin_code SET DEFAULT ''::character varying;
+
+--tables for categories and keywords of metadata sets - relational mapping
+
+
+
+-- Table: mb_metadata_inspire_category
+
+-- DROP TABLE mb_metadata_inspire_category;
+
+CREATE TABLE mb_metadata_inspire_category
+(
+ fkey_metadata_id integer NOT NULL,
+ fkey_inspire_category_id integer NOT NULL,
+ CONSTRAINT mb_metadata_inspire_category_fkey_inspire_category_id_fkey FOREIGN KEY (fkey_inspire_category_id)
+ REFERENCES inspire_category (inspire_category_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT mb_metadata_inspire_category_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 mb_metadata_inspire_category
+ OWNER TO postgres;
+
+-- Table: md_md_topic_category
+
+-- DROP TABLE md_md_topic_category;
+
+CREATE TABLE mb_metadata_md_topic_category
+(
+ fkey_metadata_id integer NOT NULL,
+ fkey_md_topic_category_id integer NOT NULL,
+ CONSTRAINT mb_metadata_md_topic_category_fkey_md_topic_category_id_fkey FOREIGN KEY (fkey_md_topic_category_id)
+ REFERENCES md_topic_category (md_topic_category_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT mb_metadata_md_topic_category_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 mb_metadata_md_topic_category
+ OWNER TO postgres;
+
+-- Table: mb_metadata_custom_category
+
+-- DROP TABLE mb_metadata_custom_category;
+
+CREATE TABLE mb_metadata_custom_category
+(
+ fkey_metadata_id integer NOT NULL,
+ fkey_custom_category_id integer NOT NULL,
+ CONSTRAINT mb_metadata_custom_category_fkey_custom_category_id_fkey FOREIGN KEY (fkey_custom_category_id)
+ REFERENCES custom_category (custom_category_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT mb_metadata_custom_category_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 mb_metadata_custom_category
+ OWNER TO postgres;
+
+--other keywords
+-- Table: mb_metadata_keyword
+
+-- DROP TABLE mb_metadata_keyword;
+
+CREATE TABLE mb_metadata_keyword
+(
+ fkey_metadata_id integer NOT NULL,
+ fkey_keyword_id integer NOT NULL,
+ CONSTRAINT pk_mb_metadata_keyword PRIMARY KEY (fkey_metadata_id , fkey_keyword_id ),
+ CONSTRAINT fkey_keyword_id_fkey_metadata_id FOREIGN KEY (fkey_keyword_id)
+ REFERENCES keyword (keyword_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE,
+ CONSTRAINT fkey_metadata_id_fkey_keyword_id FOREIGN KEY (fkey_metadata_id)
+ REFERENCES mb_metadata (metadata_id) MATCH SIMPLE
+ ON UPDATE CASCADE ON DELETE CASCADE
+)
+WITH (
+ OIDS=FALSE
+);
+ALTER TABLE mb_metadata_keyword
+ OWNER TO postgres;
+
+
+
+
+
+
More information about the Mapbender_commits
mailing list