[Mapbender-commits] r9798 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Oct 6 06:08:59 PDT 2017


Author: armin11
Date: 2017-10-06 06:08:59 -0700 (Fri, 06 Oct 2017)
New Revision: 9798

Modified:
   trunk/mapbender/http/classes/class_cswClient.php
   trunk/mapbender/http/classes/class_syncCkan.php
Log:
New option to show html metadata for external CSW based records in ckan export handler

Modified: trunk/mapbender/http/classes/class_cswClient.php
===================================================================
--- trunk/mapbender/http/classes/class_cswClient.php	2017-10-05 13:29:28 UTC (rev 9797)
+++ trunk/mapbender/http/classes/class_cswClient.php	2017-10-06 13:08:59 UTC (rev 9798)
@@ -246,9 +246,16 @@
 		if (strpos($operationNameCsw, "transaction") === false) {
 			//$e = new mb_exception("test: ".$csw->cat_op_values[$operationNameCsw]['post']);
 			$this->operationResult = $this->getResult($csw->cat_op_values[$operationNameCsw]['post'], $postRequest);
+			//Also give back url of operation
+			$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post'];
 		} else {
 			$this->operationResult = $this->getResult($csw->cat_op_values["transaction"]['post'], $postRequest);
+			//$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post'];
 		}
+		//
+		//if (strpos($operationNameCsw, "getrecords") !== false) {
+		//	$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['get'];
+		//}
 		//$e = new mb_exception("testresponse: ".$this->operationResult);
 		//parse response
 		libxml_use_internal_errors(true);

Modified: trunk/mapbender/http/classes/class_syncCkan.php
===================================================================
--- trunk/mapbender/http/classes/class_syncCkan.php	2017-10-05 13:29:28 UTC (rev 9797)
+++ trunk/mapbender/http/classes/class_syncCkan.php	2017-10-06 13:08:59 UTC (rev 9798)
@@ -636,7 +636,7 @@
                                 if ($result->success == true) {
                                     //echo "Creation of package successful!"."<br>";
                                     //recreate views
-                                    //$viewsUpdateProtocol = $this->recreateResourceViews($ckan, $result, $resultCkanRepresentation);
+                                    $viewsUpdateProtocol = $this->recreateResourceViews($ckan, $result, $resultCkanRepresentation);
                                     $numberOfUpdatedPackages++;
                                     //$e = new mb_exception($viewsUpdateProtocol);
                                 } else {
@@ -656,7 +656,7 @@
                                 if ($result->success == true) {
                                     //echo "Creation of package successful!"."<br>";
                                     //recreate views
-                                    //$viewsUpdateProtocol = $this->recreateResourceViews($ckan, $result, $resultCkanRepresentation);
+                                    $viewsUpdateProtocol = $this->recreateResourceViews($ckan, $result, $resultCkanRepresentation);
                                     $numberOfCreatedPackages++;
                                     //$e = new mb_exception($viewsUpdateProtocol);
                                 } else {
@@ -792,6 +792,11 @@
 
     //private function getCkanRepresentationFromCsw($syncList->external_csw[0]->id, uuid) {
     private function getCkanRepresentationFromCsw($cswId, $fileIdentifier, $ckan_orga_ident, $orgaTitle, $orgaEmail, $topicDataThemeCategoryMap, $ckanCategoryFilter) {
+        if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') { 
+	    $mapbenderUrl = MAPBENDER_PATH;
+	} else {
+	    $mapbenderUrl = "http://www.geoportal.rlp.de/mapbender";
+	}
 	//getRecordById
 	$csw = new csw();
 	$csw->createCatObjFromDB($cswId);
@@ -820,7 +825,7 @@
 		$format = (string)$format[0];
 		//$e = new mb_exception($metadataTitle);
 		//$e = new mb_exception($fileIdentifier);
-	
+	        $originalMetadataUrl = $mapbenderUrl."/php/mod_exportIso19139.php?url=".urlencode($cswClient->operationUrl."?REQUEST=GetRecordById&VERSION=2.0.2&SERVICE=CSW&id=".$fileIdentifier);
 		//TODO
 	
         	//write json object
@@ -849,6 +854,7 @@
 				$keywordIndex++;
 			}
             	}
+		//Add resources (name/url/format)
 		$resourcesArray = array();
 		if (isset($resourceName) && $resourceName !=="") {
 			$resourcesArray[0]->name = $resourceName;
@@ -861,13 +867,37 @@
 		} else {
 			$resourcesArray[0]->format = "Unbekannt";
 		}
-		
-		$ckanPackage->resources = array_unique($resourcesArray);
+		//$e = new mb_exception("classes/class_syncCkan.php: Original metadata url: ".$originalMetadataUrl);
+
+		//Add further resource (name/id/description/url/format)
+		$viewArray = array();
+
+		$resourcesArray[1]->name = "Originäre Metadaten";// für ".$row['layer_title'];
+		$resourcesArray[1]->id = $fileIdentifier."_iso19139";
+		$resourcesArray[1]->description = $ckanPackage->title." - Anzeige der originären Metadaten";
+		$resourcesArray[1]->url = $originalMetadataUrl;
+		$resourcesArray[1]->format = "HTML";
+
+		//views to generate
+		$viewArray[0]['view_type'] = "webpage_view";
+		$viewArray[0]['resource_id'] = $fileIdentifier."_iso19139";
+
+		//build whole json structure
+		$viewJson->resource_id = $fileIdentifier."_iso19139";
+		$viewJson->title = "Metadaten HTML";
+		$viewJson->description = "Metadaten HTML";
+		$viewJson->view_type = "webpage_view";
+
+		$viewArray[0]['json'] = json_encode($viewJson);
+
+		//$ckanPackage->resources = array_unique($resourcesArray);
+		$ckanPackage->resources = $resourcesArray;
 	}
+
         $returnArray = array();
         $returnArray['json'] = json_encode($ckanPackage);
-        //$e = new mb_exception("json: ".$returnArray['json']);
-        //$returnArray['views'] = $viewArray;
+	//$e = new mb_exception("classes/class_syncCkan.php: package from csw: ".$returnArray['json']);
+	$returnArray['views'] = $viewArray;
         return $returnArray;
 	/*
         //tags
@@ -950,7 +980,7 @@
 	$indexResourceArray = 0;
 	$indexViewArray = 0;
 	//add html preview for metadata
-	$resourcesArray[$indexResourceArray]->name = "Geo-Metadaten";// für ".$row['layer_title'];
+	$resourcesArray[$indexResourceArray]->name = "Originäre Metadaten";// für ".$row['layer_title'];
 	$resourcesArray[$indexResourceArray]->id = $metadataUuid."_iso19139";
 	$resourcesArray[$indexResourceArray]->description = $ckanPackage->title." - Anzeige der originären Metadaten";
 	$resourcesArray[$indexResourceArray]->url = $mapbenderUrl."/php/mod_exportIso19139.php?url=http%3A%2F%2Fwww.geoportal.rlp.de%2Fmapbender%2Fphp%2Fmod_dataISOMetadata.php%3FoutputFormat%3Diso19139%26id%3D".$metadataUuid;
@@ -962,7 +992,7 @@
 	//build whole json structure
 	$viewJson->resource_id = $metadataUuid."_iso19139";
 	$viewJson->title = "Metadaten HTML";
-	$viewJson->description = "Geo-Metadaten HTML";
+	$viewJson->description = "Metadaten HTML";
 	$viewJson->view_type = "webpage_view";
 	$viewArray[$indexViewArray]['json'] = json_encode($viewJson);
 	$indexViewArray++;



More information about the Mapbender_commits mailing list