[Mapbender-commits] r10326 - trunk/mapbender/tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Nov 11 08:47:53 PST 2019


Author: armin11
Date: 2019-11-11 08:47:52 -0800 (Mon, 11 Nov 2019)
New Revision: 10326

Modified:
   trunk/mapbender/tools/mod_exportISOMetadata.php
Log:
Export application metadata and metadata for OGC API Features REST interfaces.

Modified: trunk/mapbender/tools/mod_exportISOMetadata.php
===================================================================
--- trunk/mapbender/tools/mod_exportISOMetadata.php	2019-11-11 16:21:39 UTC (rev 10325)
+++ trunk/mapbender/tools/mod_exportISOMetadata.php	2019-11-11 16:47:52 UTC (rev 10326)
@@ -35,8 +35,8 @@
 db_select_db(DB,$con);
 
 //define the view or table where to read out the layer ids for which metadatafiles should be generated
-$wmsView = "search_wms_view";
-//$wmsView = "wms_search_table";
+//$wmsView = "search_wms_view";
+$wmsView = "wms_search_table";
 
 if (isset($configObject->metadataGenerationUri) && $configObject->metadataGenerationUri != "") {
     $baseUri = $configObject->metadataGenerationUri;
@@ -72,6 +72,9 @@
 $countLayer = 0;
 $countMetadataURL = 0;
 $countDls = 0;
+$countApplications = 0;
+$countRestInterfaces = 0;
+
 logMessages(date('Y-m-d - H:i:s', time()));
 //remove files from $metadataDir!
 if ($handle = opendir($metadataDir)) {
@@ -194,12 +197,12 @@
 
 					SELECT wfs_version, fkey_wfs_id, featuretype_id FROM (SELECT fkey_wfs_id, featuretype_id FROM wfs_featuretype WHERE featuretype_id 
 					IN (select fkey_featuretype_id from mb_metadata LEFT JOIN ows_relation_metadata ON metadata_id = fkey_metadata_id where 
-					 fkey_featuretype_id IS NOT NULL)) ft LEFT JOIN wfs ON 
-					ft.fkey_wfs_id = wfs_id WHERE wfs_version = '2.0.0' OR wfs_version = '2.0.2' ;
+					 fkey_featuretype_id IS NOT NULL AND metadata_id = $1)) ft LEFT JOIN wfs ON 
+					ft.fkey_wfs_id = wfs_id WHERE (wfs_version = '2.0.0' OR wfs_version = '2.0.2');
 
 SQL;
-					$v = array();
-					$t = array();
+					$v = array($row_metadata["metadata_id"]);
+					$t = array('i');
 					$res_wfs2 = db_prep_query($sqlWfs2,$v,$t);
 					while ($row_wfs2 = db_fetch_array($res_wfs2)) {
 						$generatorDlsUrlWfs2 = $generatorBaseUrlDlsWfs2."SERVICE=WFS&outputFormat=iso19139&Id=".$row_wfs2['featuretype_id'];
@@ -221,9 +224,60 @@
 	}
 	$countLayer++;
 }
+//export application metadata
+$sql_app = "select uuid, export2csw from mb_metadata where type = 'application' and searchable = true;";
+$v = array();
+$t = array();
+$res_app = db_prep_query($sql_app, $v, $t);
+while ($row_app = db_fetch_array($res_app)) {
+    $generatorUrlMetadata = $generatorBaseUrlMetadata."outputFormat=iso19139&id=".$row_app['uuid'];
+    logMessages("URL for app requested: ".$generatorUrlMetadata);
+    $generatorInterfaceObject = new connector($generatorUrlMetadata);
+    $ISOFile = $generatorInterfaceObject->file;
+    logMessages("Metadata uuid: ".$row_app['uuid']);
+    //generate temporary files under tmp
+    if($h = fopen($metadataDir."/mapbenderApplicationMetadata_".$row_app['uuid']."_iso19139.xml","w")){
+        if(!fwrite($h,$ISOFile)){
+            logMessages("mod_exportISOMetadata.php: cannot write to file: ".$metadataDir."/metadata/mapbenderMetadata_".$row_app['uuid']."_iso19139.xml");
+	}
+	logMessages("Application metadata file with metadata uuid ".$row_app['uuid']." written to ".$metadataDir);
+	fclose($h);
+	$countApplications++;
+    }
+}
+//export rest interfaces for wfs2.0.0+ based wfs featuretypes which are searchable and opendata classified
+
+$sql_rest = "select wfs_featuretype.featuretype_id from wfs_featuretype where fkey_wfs_id in (select wfs_id from wfs where wfs_id in (select fkey_wfs_id from wfs_termsofuse inner join termsofuse on fkey_termsofuse_id = termsofuse_id where termsofuse.isopen = 1) and wfs_version = '2.0.0') and featuretype_searchable = 1";
+
+$v = array();
+$t = array();
+$res_rest = db_prep_query($sql_rest, $v, $t);
+while ($row_rest = db_fetch_array($res_rest)) {
+    //$generatorUrlMetadata = $generatorBaseUrlMetadata."outputFormat=iso19139&id=".$row_app['uuid'];
+    $generatorDlsUrlRest = $generatorBaseUrlDlsWfs2."SERVICETYPE=ogcapifeatures&outputFormat=iso19139&Id=".$row_rest['featuretype_id'];
+    //logMessages("URL for app requested: ".$generatorUrlMetadata);
+    $generatorInterfaceObject = new connector($generatorDlsUrlRest);
+    $ISOFile = $generatorInterfaceObject->file;
+    logMessages("Featuretype id: ".$row_rest['featuretype_id']);
+    //generate temporary files under tmp
+    if($h = fopen($metadataDir."/mapbenderRestMetadata_".$row_rest['featuretype_id']."_iso19139.xml","w")){
+        if(!fwrite($h,$ISOFile)){
+            logMessages("mod_exportISOMetadata.php: cannot write to file: ".$metadataDir."/metadata/mapbenderRestMetadata_".$row_rest['featuretype_id']."_iso19139.xml");
+	}
+	logMessages("REST metadata file with featuretype_id ".$row_rest['featuretype_id']." written to ".$metadataDir);
+	fclose($h);
+	$countRestInterfaces++;
+    }
+}
+
+
+ 
 logMessages("Number of generated View Service Metadata Records (one for each layer): ".$countLayer);
 logMessages("Number of generated Data Metadata Records (multiple for each layer): ".$countMetadataURL);
 logMessages("Number of generated Download Service Metadata Records (multiple for each metadataset): ".$countDls);
+logMessages("Number of generated Application Metadata Records: ".$countApplications);
+logMessages("Number of generated REST Service Metadata Records: ".$countRestInterfaces);
+
 logMessages(date('Y-m-d - H:i:s', time()));
 
 



More information about the Mapbender_commits mailing list