[Mapbender-commits] r9989 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Nov 5 07:03:10 PST 2018


Author: armin11
Date: 2018-11-05 07:03:10 -0800 (Mon, 05 Nov 2018)
New Revision: 9989

Modified:
   trunk/mapbender/http/php/mod_dataISOMetadata.php
Log:
Fix for export of edited metadata - bequeauth the categories from layers and featuretypes to metadata which was edited by metadator

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-11-05 15:02:57 UTC (rev 9988)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-11-05 15:03:10 UTC (rev 9989)
@@ -1013,9 +1013,29 @@
 	//pull special keywords from custom categories:
 	//$e = new mb_notice("layer: ".$layerId);	
 
-	$sql = "SELECT DISTINCT custom_category.custom_category_key FROM custom_category, mb_metadata_custom_category WHERE mb_metadata_custom_category.fkey_metadata_id = $1 AND mb_metadata_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
-	$v = array((integer)$mb_metadata['metadata_id']);
-	$t = array('i');
+	//$sql = "SELECT DISTINCT custom_category.custom_category_key FROM custom_category, mb_metadata_custom_category WHERE mb_metadata_custom_category.fkey_metadata_id = $1 AND mb_metadata_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
+
+	$sql = <<<SQL
+
+SELECT custom_category.custom_category_key FROM custom_category WHERE custom_category_id IN (
+
+SELECT DISTINCT fkey_custom_category_id FROM (
+
+SELECT mb_metadata_custom_category.fkey_custom_category_id from mb_metadata_custom_category WHERE mb_metadata_custom_category.fkey_metadata_id = $1
+
+UNION 
+
+SELECT layer_custom_category.fkey_custom_category_id from layer_custom_category WHERE fkey_layer_id IN (SELECT fkey_layer_id FROM ows_relation_metadata WHERE fkey_metadata_id = $2)
+
+UNION
+
+SELECT wfs_featuretype_custom_category.fkey_custom_category_id from wfs_featuretype_custom_category WHERE fkey_featuretype_id IN (SELECT fkey_featuretype_id FROM ows_relation_metadata WHERE fkey_metadata_id = $3)) as custom_category
+
+) AND custom_category_hidden = 0
+
+SQL;
+	$v = array((integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id']);
+	$t = array('i','i','i');
 	$res = db_prep_query($sql,$v,$t);
 	$e = new mb_notice("look for custom categories: ");
 	$countCustom = 0;
@@ -1039,9 +1059,30 @@
 /* example
 <gmd:keyword><gco:CharacterString>Geographical names</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>BasisDLM</gco:CharacterString></gmd:keyword>	
 */
-	$sql = "SELECT DISTINCT inspire_category.inspire_category_code_en FROM inspire_category, mb_metadata_inspire_category WHERE mb_metadata_inspire_category.fkey_metadata_id=$1 AND mb_metadata_inspire_category.fkey_inspire_category_id=inspire_category.inspire_category_id";
-	$v = array((integer)$mb_metadata['metadata_id']);
-	$t = array('i');
+	//$sql = "SELECT DISTINCT inspire_category.inspire_category_code_en FROM inspire_category, mb_metadata_inspire_category WHERE mb_metadata_inspire_category.fkey_metadata_id=$1 AND mb_metadata_inspire_category.fkey_inspire_category_id=inspire_category.inspire_category_id";
+
+	$sql = <<<SQL
+
+SELECT inspire_category.inspire_category_code_en FROM inspire_category WHERE inspire_category_id IN (
+
+SELECT DISTINCT fkey_inspire_category_id FROM (
+
+SELECT mb_metadata_inspire_category.fkey_inspire_category_id from mb_metadata_inspire_category WHERE mb_metadata_inspire_category.fkey_metadata_id = $1
+
+UNION 
+
+SELECT layer_inspire_category.fkey_inspire_category_id from layer_inspire_category WHERE  fkey_layer_id IN (SELECT fkey_layer_id FROM ows_relation_metadata WHERE fkey_metadata_id = $2)
+
+UNION
+
+SELECT wfs_featuretype_inspire_category.fkey_inspire_category_id from wfs_featuretype_inspire_category WHERE fkey_featuretype_id IN (SELECT fkey_featuretype_id FROM ows_relation_metadata WHERE fkey_metadata_id = $3)) as inspire_category
+
+)
+
+SQL;
+
+	$v = array((integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id']);
+	$t = array('i','i','i');
 	$res = db_prep_query($sql,$v,$t);
 	while ($row = db_fetch_array($res)) {
 		
@@ -1316,14 +1357,40 @@
 	//Topic Category B 2.1 - not needed for services
 
 	//read topic categories for resource out of the database:
-	$sql = "SELECT DISTINCT md_topic_category.md_topic_category_code_en FROM md_topic_category INNER JOIN mb_metadata_md_topic_category ON md_topic_category.md_topic_category_id = mb_metadata_md_topic_category.fkey_md_topic_category_id WHERE mb_metadata_md_topic_category.fkey_metadata_id = $1";
-	$v = array((integer)$mb_metadata['metadata_id']);
-	$t = array('i');
+	//$sql = "SELECT DISTINCT md_topic_category.md_topic_category_code_en FROM md_topic_category INNER JOIN mb_metadata_md_topic_category ON md_topic_category.md_topic_category_id = mb_metadata_md_topic_category.fkey_md_topic_category_id WHERE mb_metadata_md_topic_category.fkey_metadata_id = $1";
+
+	$sql = <<<SQL
+
+SELECT md_topic_category.md_topic_category_code_en FROM md_topic_category WHERE md_topic_category_id IN (
+
+SELECT DISTINCT fkey_md_topic_category_id FROM (
+
+SELECT mb_metadata_md_topic_category.fkey_md_topic_category_id from mb_metadata_md_topic_category WHERE mb_metadata_md_topic_category.fkey_metadata_id = $1
+
+UNION 
+
+SELECT layer_md_topic_category.fkey_md_topic_category_id from layer_md_topic_category WHERE fkey_layer_id IN (SELECT fkey_layer_id FROM ows_relation_metadata WHERE fkey_metadata_id = $2)
+
+UNION
+
+SELECT wfs_featuretype_md_topic_category.fkey_md_topic_category_id from wfs_featuretype_md_topic_category WHERE fkey_featuretype_id IN (SELECT fkey_featuretype_id FROM ows_relation_metadata WHERE fkey_metadata_id = $3)) as md_topic_category
+)
+
+SQL;
+
+	$v = array((integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id'],(integer)$mb_metadata['metadata_id']);
+	$t = array('i','i','i');
 	$res = db_prep_query($sql,$v,$t);
 	$e = new mb_notice("look for topic: ");
+
+
+
+
+
+
 	$countTopic = 0;
 	while ($row = db_fetch_array($res)) {
-		$e = new mb_notice("topic cat found!");
+		$e = new mb_notice("topic cat found: ".$row['md_topic_category_code_en']);
 		$topicCategory=$iso19139->createElement("gmd:topicCategory");
 		$MD_TopicCategoryCode=$iso19139->createElement("gmd:MD_TopicCategoryCode");
 		$MD_TopicCategoryText=$iso19139->createTextNode($row['md_topic_category_code_en']);



More information about the Mapbender_commits mailing list