[Mapbender-commits] r8629 - in trunk/mapbender/http: classes plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun May 26 05:18:54 PDT 2013


Author: armin11
Date: 2013-05-26 05:18:54 -0700 (Sun, 26 May 2013)
New Revision: 8629

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/plugins/mb_metadata_server.php
Log:
Some further enhancements for service content metadata editor and code cleaning.

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2013-05-26 08:43:56 UTC (rev 8628)
+++ trunk/mapbender/http/classes/class_iso19139.php	2013-05-26 12:18:54 UTC (rev 8629)
@@ -627,8 +627,119 @@
 		}
 	}
 
-	public function createFromDB($fileIdentifier){
-		return $this;
+	public function createFromDBInternalId($metadataId){
+		$sql = "SELECT * from mb_metadata WHERE metadata_id = $1";
+		$v = array($metadataId);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		if ($res) {
+			$row = db_fetch_assoc($res);
+			//fill object with information from mb_metadata table
+			//initialize empty iso19139 object
+			$this->fileIdentifier = $row['uuid'];
+			$this->title = $row['title'];
+			$this->abstract = $row['abstract'];
+			$this->createDate =  $row['createdate'];//"1900-01-01";
+			$this->changeDate = $row['changedate'];//"1900-01-01";
+			$this->metadata = $row['data'];
+			//some possibilities:
+			$this->datasetId = $row['datasetid'];
+			$this->datasetIdCodeSpace = $row['datasetid_codespace'];
+
+			//fill keywords and categories later cause they are stored in relations!
+			/*$this->keywords = array();
+			$this->keywordsThesaurusName = array();
+			$this->isoCategoryKeys = array();
+			//following information is specific to mapbender information model - they are identified by id!
+			$this->isoCategories = array();
+			$this->inspireCategories = array();
+			$this->customCategories = array();
+			//*/
+
+			$this->hierachyLevel = $row['type'];
+			$this->tmpExtentBegin = $row['tmp_reference_1'];//"1900-01-01";
+			$this->tmpExtentEnd = $row['tmp_reference_2'];//"1900-01-01";
+			$this->randomId =  $row['randomid'];
+			$this->owner = $row['fkey_mb_user_id']; //dummy entry for metadata owner - in case of metadataURL entries the owner of the corresponding service
+			$this->href = $row['link'];// "";
+			$this->format = $row['md_format'];//"";
+			$this->type = $row['linktype'];//"";
+			$this->origin = $row['origin'];//"";
+			$this->refSystem = $row['ref_system'];//"";
+			$this->harvestResult = $row['harvestresult'];//;0;
+			$this->harvestException = $row['harvestexception'];//"";
+			$this->lineage = $row['lineage'];//"";
+			$this->inspireTopConsistence = $row['inspire_top_consistance'];//"f";
+			$this->spatialResType = $row['spatial_res_type'];//"";
+			$this->spatialResValue = $row['spatial_res_value'];//"";
+			$this->export2Csw = $row['export2csw'];//"t";
+			$this->updateFrequency = $row['update_frequency'];//"";
+			$this->dataFormat = $row['format'];//"";
+			$this->inspireCharset = $row['inspire_charset'];//"";
+			//
+			//$this->linkAlreadyInDB = false;
+			//$this->fileIdentifierAlreadyInDB = false;
+			//get relations from other tables:
+			//get categories and keywords
+			//get isoCategories
+			$sql = <<<SQL
+SELECT md_topic_category_id, md_topic_category_code_en FROM mb_metadata_md_topic_category INNER JOIN md_topic_category ON mb_metadata_md_topic_category.fkey_md_topic_category_id = md_topic_category.md_topic_category_id WHERE mb_metadata_md_topic_category.fkey_metadata_id = $1
+SQL;
+			$v = array($metadataId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while ($row = db_fetch_assoc($res)) {
+				$this->isoCategories[]  = (string)$row['md_topic_category_id'];
+				$this->isoCategoriesKeys[] = $row['md_topic_category_code_en'];
+			}
+
+			//get custom categories
+			$sql = <<<SQL
+SELECT custom_category_id FROM mb_metadata_custom_category INNER JOIN custom_category ON mb_metadata_custom_category.fkey_custom_category_id = custom_category.custom_category_id WHERE mb_metadata_custom_category.fkey_metadata_id = $1
+SQL;
+			$v = array($metadataId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while ($row = db_fetch_assoc($res)) {
+				$this->customCategories[]  = (string)$row['custom_category_id'];
+				//generate one keyword entry with special thesaurus 
+				$this->keywords[] = $row['fkey_custom_category_id'];
+				if (defined("METADATA_DEFAULT_CODESPACE") && METADATA_DEFAULT_CODESPACE != '') {
+					$this->keywordsThesaurusName[] = METADATA_DEFAULT_CODESPACE;
+				} else {
+					$this->keywordsThesaurusName[] = "http://www.mapbender.org";
+				}
+			}
+			//get inspire categories
+			$sql = <<<SQL
+SELECT inspire_category_id, inspire_category_key FROM mb_metadata_inspire_category INNER JOIN inspire_category ON mb_metadata_inspire_category.fkey_inspire_category_id = inspire_category.inspire_category_id WHERE mb_metadata_inspire_category.fkey_metadata_id = $1
+SQL;
+			$v = array($metadataId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while ($row = db_fetch_assoc($res)) {
+				$this->inspireCategories[]  = (string)$row['inspire_category_id'];
+				$this->keywords[] = $row['inspire_category_key'];
+				$this->keywordsThesaurusName[] = "GEMET - INSPIRE themes, version 1.0";
+			}
+			//get other keywords from keyword table - only fill in, if not already in keywords!
+			$sql = <<<SQL
+SELECT keyword FROM mb_metadata_keyword INNER JOIN keyword ON mb_metadata_keyword.fkey_keyword_id = keyword.keyword_id WHERE  mb_metadata_keyword.fkey_metadata_id = $1
+SQL;
+			$v = array($metadataId);
+			$t = array('i');
+			$res = db_prep_query($sql,$v,$t);
+			while ($row = db_fetch_assoc($res)) {
+				if (!in_array($row['keyword'],$this->keywords)) {
+					$this->keywords[] = $row['keyword'];
+					$this->keywordsThesaurusName[] = "";
+				}
+			}
+		} else {
+			$e = new mb_exception("Could not get metadata with id ".$metadataId." from DB!");
+		return false;
+		}
+		return true;
 	}
 
 	//the following functions are only for the simple metadata editor
@@ -893,6 +1004,7 @@
 			$countExistingKeywords = 0;
 			while ($row = db_fetch_assoc($res)) {
 				$existingKeywords[$countExistingKeywords]['keyword'] = $row['keyword'];
+				$e = new mb_exception("existing keyword: ".$row['keyword']);
 				$existingKeywords[$countExistingKeywords]['id'] = $row['keyword_id'];
 				$existingKeywordsArray[$countExistingKeywords] = $row['keyword'];
 				$countExistingKeywords++;
@@ -912,10 +1024,12 @@
 			}	
 			$sqlInsert = rtrim($sqlInsert,",");
 			$sql = "INSERT INTO mb_metadata_keyword (fkey_metadata_id, fkey_keyword_id) VALUES ".$sqlInsert;
-			$e = new mb_notice("class_Iso19139.php: sql for keywords: ".$sql);
+			$e = new mb_exception("class_Iso19139.php: sql for keywords: ".$sql);
 			$res = db_query($sql);
 			if (!$res) {
 				$e = new mb_exception("class_Iso19139:"._mb("Cannot insert keyword relations for this metadata!"));
+			} else {
+				$e = new mb_exception("class_Iso19139:"._mb("Inserted keyword relations for existing keywords!"));
 			}
 		}
 		//insert those keywords, that are not already in the keyword table
@@ -929,9 +1043,20 @@
 			)
 		*/
 		$sqlInsert = "";
-		$otherKeywords = array_diff($this->keywords,$existingKeywordsArray);
+		//test if $existingKeywordsArray is array!
+		if (is_array($existingKeywordsArray)) {
+			$otherKeywords = array_values(array_diff($this->keywords,$existingKeywordsArray));
+		} else {
+			$otherKeywords = $this->keywords;
+		} 
+		//debug
+		foreach ($otherKeywords as $test) {
+			$e = new mb_exception("otherKeywords: ".$test);
+		}
+		$e = new mb_exception("otherKeywords: ".$otherKeywords);
 		if (count($otherKeywords) > 0) {
 			if (count($otherKeywords) == 1) {
+				$e = new mb_exception("Only one new keyword found: ".$otherKeywords[0]);
 				//keyword table
 				$sqlInsert .= "('".$otherKeywords[0]."')";
 			} else {
@@ -941,7 +1066,7 @@
 			}	
 			$sqlInsert = rtrim($sqlInsert,",");
 			$sql = "INSERT INTO keyword (keyword) VALUES ".$sqlInsert." RETURNING keyword_id" ;
-			$e = new mb_notice("class_Iso19139.php: sql for keywords: ".$sql);
+			$e = new mb_exception("class_Iso19139.php: sql for keywords: ".$sql);
 			$res = db_query($sql);
 			if (!$res) {
 				$e = new mb_exception("class_Iso19139:"._mb("Cannot insert new keywords into keyword table!"));
@@ -954,7 +1079,7 @@
 				}
 				if (count($insertedKeywordIds) == 1) {
 					//keyword relation table
-					$sqlInsert .= "(".$insertedKeywordIds[0].")";
+					$sqlInsert .= "(".(integer)$metadataId.",".$insertedKeywordIds[0].")";
 				} else {
 					foreach ($insertedKeywordIds as $insertedKeywordId) {
 						$sqlInsert .= "(".(integer)$metadataId.",".(integer)$insertedKeywordId."),";
@@ -1053,7 +1178,7 @@
 	}
 
 
-	private function updateMetadataById($metadataId) {
+	public function updateMetadataById($metadataId) {
 		//check if the timestamp of an existing metadata element is not newer than the timestamp of the current metadata object!!!!
 		//TODO
 		//problem: <<<SQL have a limited number of chars!

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2013-05-26 08:43:56 UTC (rev 8628)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2013-05-26 12:18:54 UTC (rev 8629)
@@ -656,13 +656,10 @@
 			$ajaxResponse->setSuccess(false);
 		}
 		break;
-
 	case "getWmsIdByLayerId" :
 		$layerId = $ajaxResponse->getParameter("layerId");
 		$sql = <<<SQL
-
 SELECT fkey_wms_id from layer where layer_id = $1
-
 SQL;
 		$v = array($layerId);
 		$t = array('i');
@@ -676,37 +673,29 @@
 		$ajaxResponse->setSuccess(true);
 		break;
 	case "getLayerMetadataAddon" :
-		$layerId = $ajaxResponse->getParameter("layerId");
+		//$layerId = $ajaxResponse->getParameter("layerId");
 		$metadataId = $ajaxResponse->getParameter("metadataId");
-
-		$sql = <<<SQL
-
-SELECT * from mb_metadata where metadata_id = $1
-
-SQL;
-		$v = array($metadataId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$row = array();
-		if ($res) {
-			$row = db_fetch_assoc($res);
-			$resultObj["metadata_id"]= $row['metadata_id']; //serial
-			$resultObj["uuid"] = $row["uuid"]; //char
-			$resultObj["origin"] = $row["origin"]; //char
-			$resultObj["link"] = $row["link"]; //char
-			$resultObj["linktype"] = $row["linktype"]; //char
-			$resultObj["title"] = $row["title"]; //char -- prefill from layer
-			$resultObj["abstract"] = $row["abstract"]; //char - prefill from layer
-			$resultObj["format"] = $row["format"]; //char
-			$resultObj["ref_system"] = $row["ref_system"]; //char
-			$resultObj["spatial_res_type"] = $row["spatial_res_type"]; //integer
-			$resultObj["spatial_res_value"] = $row["spatial_res_value"]; //char
-			$resultObj["inspire_charset"] = $row["inspire_charset"]; //char
-			$resultObj["lineage"] = $row["lineage"]; //text
-			$resultObj["tmp_reference_1"] = $row["tmp_reference_1"]; //text
-			$resultObj["tmp_reference_2"] = $row["tmp_reference_2"]; //text
-			$export2csw = $row["export2csw"]; //boolean
-			$resultObj["update_frequency"] = $row["update_frequency"]; //text
+		$mbMetadata = new Iso19139();
+		$result = $mbMetadata->createFromDBInternalId($metadataId);
+		if ($result) {
+			//map metadata object to json return object
+			$resultObj["metadata_id"]= $metadataId; //is not part of the object TODO!
+			$resultObj["uuid"] = $mbMetadata->fileIdentifier; //char
+			$resultObj["origin"] = $mbMetadata->origin; //char
+			$resultObj["link"] = $mbMetadata->href; //char
+			$resultObj["linktype"] = $mbMetadata->type; //char
+			$resultObj["title"] = $mbMetadata->title; //char -- prefill from layer
+			$resultObj["abstract"] = $mbMetadata->abstract; //char - prefill from layer
+			$resultObj["format"] = $mbMetadata->dataFormat; //char
+			$resultObj["ref_system"] = $mbMetadata->refSystem; //char
+			$resultObj["spatial_res_type"] = $mbMetadata->spatialResType; //integer
+			$resultObj["spatial_res_value"] = $mbMetadata->spatialResValue; //char
+			$resultObj["inspire_charset"] = $mbMetadata->inspireCharset; //char
+			$resultObj["lineage"] = $mbMetadata->lineage; //text
+			$resultObj["tmp_reference_1"] = $mbMetadata->tmpExtentBegin; //text
+			$resultObj["tmp_reference_2"] = $mbMetadata->tmpExtentEnd; //text
+			$export2csw = $mbMetadata->export2Csw; //boolean
+			$resultObj["update_frequency"] = $mbMetadata->updateFrequency; //text
 			switch ($export2csw) {
 				case "t" :
 					$resultObj["export2csw"] = true;
@@ -717,7 +706,7 @@
 				default:
 				break;	
 			}
-			$inspire_top_consistence = $row["inspire_top_consistence"]; //boolean
+			$inspire_top_consistence = $mbMetadata->inspireTopConsistence; //boolean
 			switch ($inspire_top_consistence) {
 				case "t" :
 					$resultObj["inspire_top_consistence"] = true;
@@ -727,50 +716,33 @@
 					break;
 				default:
 				break;	
-			}					
-			
+			}
+			//categories and keywords
+			$resultObj["md_md_topic_category_id"] = $mbMetadata->isoCategories;
+			$resultObj["md_custom_category_id"] = $mbMetadata->customCategories;
+			$resultObj["md_inspire_category_id"] = $mbMetadata->inspireCategories;
+			//only pull keywords without a thesaurus name!!
+			for ($i = 0; $i < count($mbMetadata->keywords); $i++) {
+				if ($mbMetadata->keywordsThesaurusName[$i] == "" or $mbMetadata->keywordsThesaurusName[$i] == "none") {
+					$resultObj["keywords"][] = $mbMetadata->keywords[$i];	
+				}
+			}
+			$resultObj["keywords"] = implode(",",$resultObj["keywords"]);
+			//give back result:
+			$ajaxResponse->setResult($resultObj);
+			$ajaxResponse->setSuccess(true);
+			break;
+		} else {
+			//could not read metadata from db
+			$ajaxResponse->setMessage(_mb("Could not get metadata object from database!"));
+			$ajaxResponse->setSuccess(false);
+			break;
 		}
-		//get categories and keywords
-		//get isoCategories
-		$sql = <<<SQL
-SELECT fkey_md_topic_category_id FROM mb_metadata_md_topic_category where fkey_metadata_id = $1
-SQL;
-		$v = array($metadataId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		while ($row = db_fetch_assoc($res)) {
-			$resultObj["md_md_topic_category_id"][]= $row["fkey_md_topic_category_id"];
-		}
-		//get custom categories
-		$sql = <<<SQL
-SELECT fkey_custom_category_id FROM mb_metadata_custom_category where fkey_metadata_id = $1
-SQL;
-		$v = array($metadataId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		while ($row = db_fetch_assoc($res)) {
-			$resultObj["md_custom_category_id"][]= $row["fkey_custom_category_id"];
-		}
-		//get inspire categories
-		$sql = <<<SQL
-SELECT fkey_inspire_category_id FROM mb_metadata_inspire_category where fkey_metadata_id = $1
-SQL;
-		$v = array($metadataId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		while ($row = db_fetch_assoc($res)) {
-			$resultObj["md_inspire_category_id"][]= $row["fkey_inspire_category_id"];
-		}
-		$ajaxResponse->setResult($resultObj);
-		$ajaxResponse->setSuccess(true);
-		break;
 	case "getInitialLayerMetadata" :
 		$layerId = $ajaxResponse->getParameter("layerId");
 		$metadataId = $ajaxResponse->getParameter("metadataId");
 		$sql = <<<SQL
-
 SELECT layer_title, layer_abstract from layer where layer_id = $1
-
 SQL;
 		$v = array($layerId);
 		$t = array('i');
@@ -785,92 +757,73 @@
 		$ajaxResponse->setSuccess(true);
 		break;
 	case "updateLayerMetadataAddon" :
-		$layerId = $ajaxResponse->getParameter("layerId");
+		//$layerId = $ajaxResponse->getParameter("layerId");
 		$metadataId = $ajaxResponse->getParameter("metadataId");
+		//get json data from ajax call
 		$data = $ajaxResponse->getParameter("data");
-		if ($data->export2csw) {
-			$data->export2csw = 't';
-		} else {
-			$data->export2csw = 'f';
-		}
-		if ($data->inspire_top_consistence) {
-			$data->inspire_top_consistence = 't';
-		} else {
-			$data->inspire_top_consistence = 'f';
-		}
-		//new for keywords and classifications:
-		/*if (isset($data->keywords) && $data->keywords != "") {
-			$mbMetadata->keywords = explode(',',$data->keywords);
-			//for all those keywords don't set a special thesaurus name
-			foreach ($mbMetadata->keywords as $keyword) {
-				$mbMetadata->keywordsThesaurusName[] = "none";
+		//initialize actual metadata object from db!
+		$mbMetadata = new Iso19139();
+		$result = $mbMetadata->createFromDBInternalId($metadataId);
+		if ($result) {
+			if ($data->export2csw) {
+				$mbMetadata->export2Csw = 't';
+			} else {
+				$mbMetadata->export2Csw = 'f';
 			}
-		}
-		
-		if (isset($data->md_md_topic_category_id)) {
-			$mbMetadata->isoCategories = $data->md_md_topic_category_id;
-		}
-		if (isset($data->md_inspire_category_id)) {
-			$inspireCategories = $data->md_inspire_category_id;
-			$e = new mb_exception($inspireCategories);
-			if (count($inspireCategories) > 1 ) {
-				//for all those keywords set a special thesaurus name
-				foreach ($inspireCategories as $keyword) {
-					$mbMetadata->keywords[] = $keyword;
-					$mbMetadata->keywordsThesaurusName[] = "GEMET - INSPIRE themes, version 1.0";
-				}
+			if ($data->inspire_top_consistence) {
+				$mbMetadata->inspireTopConsistence = 't';
 			} else {
-				$mbMetadata->keywords[] = $inspireCategories;
-				$mbMetadata->keywordsThesaurusName[] = "GEMET - INSPIRE themes, version 1.0";
-			
+				$mbMetadata->inspireTopConsistence = 'f';
 			}
-		}
-		if (isset($data->md_custom_category_id)) {
-			$customCategories = $data->md_custom_category_id;
-			if (count($customCategories) > 1 ) {
+			//$mbMetadata->fileIdentifier = $metadataId;
+			$mbMetadata->href = $data->link;
+			$mbMetadata->title = $data->title;
+			$mbMetadata->abstract = $data->abstract;
+			$mbMetadata->dataFormat = $data->format;
+			$mbMetadata->refSystem = $data->ref_system;
+			$mbMetadata->tmpExtentBegin = $data->tmp_reference_1;
+			$mbMetadata->tmpExtentEnd = $data->tmp_reference_2;
+			$mbMetadata->lineage = $data->lineage;
+			$mbMetadata->spatialResType = $data->spatial_res_type;
+			$mbMetadata->spatialResValue = $data->spatial_res_value;
+			$mbMetadata->inspireCharset = $data->inspire_charset;
+			$mbMetadata->updateFrequency = $data->update_frequency;
+			//categories ...
+			//new for keywords and classifications:
+			if (isset($data->keywords) && $data->keywords != "") {
+				$mbMetadata->keywords = array_map('trim',explode(',',$data->keywords));
 				//for all those keywords don't set a special thesaurus name
-				foreach ($customCategories as $keyword) {
-					$mbMetadata->keywords[] = $keyword;
-					if (defined("METADATA_DEFAULT_CODESPACE") && METADATA_DEFAULT_CODESPACE != '') {
-						$mbMetadata->keywordsThesaurusName[] = METADATA_DEFAULT_CODESPACE;
-					} else {
-						$mbMetadata->keywordsThesaurusName[] = "http://www.mapbender.org";
-					}
+				foreach ($mbMetadata->keywords as $keyword) {
+					$mbMetadata->keywordsThesaurusName[] = "none";
 				}
+			}
+			if (isset($data->md_md_topic_category_id)) {
+				$mbMetadata->isoCategories = $data->md_md_topic_category_id;
+			}
+			if (isset($data->md_inspire_category_id)) {
+				$mbMetadata->inspireCategories = $data->md_inspire_category_id;
+			}
+			if (isset($data->md_custom_category_id)) {
+				$mbMetadata->customCategories = $data->md_custom_category_id;
+			}
+			//try to update metadata object (only mb_metadata)
+			$res = $mbMetadata->updateMetadataById($metadataId);
+			if (!$res) {
+				//could not update metadata in db
+				$ajaxResponse->setMessage(_mb("Could not update metadata object in database!"));
+				$ajaxResponse->setSuccess(false);
 			} else {
-				$mbMetadata->keywords[] = $customCategories;
-				if (defined("METADATA_DEFAULT_CODESPACE") && METADATA_DEFAULT_CODESPACE != '') {
-					$mbMetadata->keywordsThesaurusName[] = METADATA_DEFAULT_CODESPACE;
-				} else {
-					$mbMetadata->keywordsThesaurusName[] = "http://www.mapbender.org";
-				}
+				//update relations for keywords and categories
+				$mbMetadata->insertKeywordsAndCategoriesIntoDB($metadataId);
+				$ajaxResponse->setMessage(_mb("Edited metadata was updated in the mapbender database!"));
+				$ajaxResponse->setSuccess(true);
 			}
-		}*/ //no mbMetadata instantiated till now
-		
-		$sql = <<<SQL
 
-UPDATE mb_metadata SET link = $2, title = $3, abstract = $4, format = $5, ref_system = $6, export2csw = $7, inspire_top_consistence = $8, tmp_reference_1 = $9, tmp_reference_2 = $10, lineage = $11, spatial_res_type = $12, spatial_res_value = $13, inspire_charset = $14, changedate = now(), update_frequency = $15 WHERE metadata_id = $1
-
-SQL;
-		$v = array($metadataId, $data->link, $data->title, $data->abstract, $data->format, $data->ref_system, $data->export2csw, $data->inspire_top_consistence, $data->tmp_reference_1, $data->tmp_reference_2, $data->lineage, $data->spatial_res_type, $data->spatial_res_value, $data->inspire_charset, $data->update_frequency);
-		$t = array('i','s','s','s','s','s','b','b','s','s','s','s','s','s','s');
-		try {
-			$res = db_prep_query($sql,$v,$t);
-		}
-		catch (Exception $e){
+		} else {
+			//could not read metadata from db
+			$ajaxResponse->setMessage(_mb("Could not get metadata object from database!"));
 			$ajaxResponse->setSuccess(false);
-			$ajaxResponse->setMessage(_mb("Could not update metadata object in database!"));
-			$ajaxResponse->send();
-			die;	
 		}
-		//delete all categories
-		//TODO!!!
-
-		//newly create them
-		
-
-		$ajaxResponse->setMessage("Metadata updated!");
-		$ajaxResponse->setSuccess(true);
 		break;
 
 	case "getOwnedMetadata" :
@@ -1023,7 +976,6 @@
 		if (isset($data->md_custom_category_id)) {
 			$mbMetadata->customCategories = $data->md_custom_category_id;
 		}
-
 		//Check if origin is external and export2csw is activated!
 		if ($origin == 'external' ) {
 			//harvest link from location, parse the content for datasetid and push xml into data column
@@ -1033,9 +985,7 @@
 			$mbMetadata->type = "ISO19115:2003";
 			$mbMetadata->origin = "external";
 			$mbMetadata->owner = $mdOwner;
-
 			$result = $mbMetadata->insertToDB("layer",$layerId);
-
 			if ($result['value'] == false){
 				$e = new mb_exception("Problem while storing metadata to mb_metadata table!");
 				$e = new mb_exception($result['message']);
@@ -1089,7 +1039,6 @@
 		//$ajaxResponse->send();
 		//die();
 		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");
@@ -1112,9 +1061,7 @@
 		$mbMetadata->type = "ISO19115:2003";
 		$mbMetadata->origin = "upload";
 		$mbMetadata->owner = $mdOwner;
-
 		$result = $mbMetadata->insertToDB("layer",$layerId);
-
 		if ($result['value'] == false){
 			$e = new mb_exception("Problem while storing uploaded metadata xml to mb_metadata table!");
 			$e = new mb_exception($result['message']);
@@ -1126,12 +1073,10 @@
 			$ajaxResponse->setSuccess(true);
 		}
 		break;		
-
 	default: 
 		$ajaxResponse->setSuccess(false);
 		$ajaxResponse->setMessage(_mb("An unknown error occured."));
 		break;
 }
-
 $ajaxResponse->send();
 ?>



More information about the Mapbender_commits mailing list