[Mapbender-commits] r9846 - in trunk/mapbender: http/classes http/plugins resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jan 16 11:55:45 PST 2018


Author: armin11
Date: 2018-01-16 11:55:45 -0800 (Tue, 16 Jan 2018)
New Revision: 9846

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/plugins/mb_metadata_addon.php
   trunk/mapbender/http/plugins/mb_metadata_manager_select.js
   trunk/mapbender/http/plugins/mb_metadata_manager_server.php
   trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
   trunk/mapbender/http/plugins/mb_metadata_xml_import.js
   trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
New possibility to create dataset metadata without having a service yet ;-)

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/classes/class_iso19139.php	2018-01-16 19:55:45 UTC (rev 9846)
@@ -1491,17 +1491,21 @@
 	}*/
 
 	public function checkMetadataRelation($resourceType, $resourceId, $metadataId, $origin){
-		//check if one relation already exists - if so no new one should be generated!!!
-		$sql = "SELECT count(fkey_metadata_id) FROM ows_relation_metadata WHERE fkey_".$resourceType."_id = $1 AND fkey_metadata_id = $2 AND relation_type = $3";
-		$v = array($resourceId, $metadataId, $origin);
-		$t = array('i','i','s');
-		$res = db_prep_query($sql,$v,$t);
-		while ($row = db_fetch_array($res)){
-			$numberOfRelations = $row['count'];	
-		}
-		if ($numberOfRelations > 0) {
-			return true;
-		} else {	
+		if ($resourceType !== 'metadata') {
+			//check if one relation already exists - if so no new one should be generated!!!
+			$sql = "SELECT count(fkey_metadata_id) FROM ows_relation_metadata WHERE fkey_".$resourceType."_id = $1 AND fkey_metadata_id = $2 AND relation_type = $3";
+			$v = array($resourceId, $metadataId, $origin);
+			$t = array('i','i','s');
+			$res = db_prep_query($sql,$v,$t);
+			while ($row = db_fetch_array($res)){
+				$numberOfRelations = $row['count'];	
+			}
+			if ($numberOfRelations > 0) {
+				return true;
+			} else {	
+				return false;
+			}
+		} else {
 			return false;
 		}
 	}
@@ -1777,7 +1781,7 @@
 		//map category name to id before insert them into db!
 		//read maptable from db
 		//iso - code in xml
-		if ($resourceType == "wms" || $resourceType == "wfs" || $resourceType == "inspire_dls_atom" || $resourceType == "inspire_dls_atom_dataset") {
+		if ($resourceType == "wms" || $resourceType == "wfs" || $resourceType == "inspire_dls_atom" || $resourceType == "inspire_dls_atom_dataset" || $resourceType == "metadata") {
 			return false;
 		}
 		switch ($resourceType) {
@@ -2032,7 +2036,7 @@
 	}
 
 	public function deleteCategoriesFromCoupledResource($metadataId,$resourceType,$resourceId) {
-		if ($resourceType == 'inspire_dls_atom' || $resourceType == 'inspire_dls_atom_dataset') {
+		if ($resourceType == 'inspire_dls_atom' || $resourceType == 'inspire_dls_atom_dataset' || $resourceType == 'metadata') {
 			return false;
 		}
 		//delete inherited categories from coupled resources: layer/featuretype
@@ -2388,11 +2392,15 @@
 				//insert relation
 				$row = db_fetch_assoc($res);
 				$metadataId = $row['metadata_id'];
-				//insert relation to layer/featuretype
-				$sql = "INSERT INTO ows_relation_metadata (fkey_".$resourceType."_id, fkey_metadata_id, relation_type) values ($1, $2, $3);";	
-				$v = array($resourceId, $metadataId, $this->origin);
-				$t = array('i','i', 's');
-				$res = db_prep_query($sql,$v,$t);
+				if ($resourceType !== 'metadata') {
+					//insert relation to layer/featuretype
+					$sql = "INSERT INTO ows_relation_metadata (fkey_".$resourceType."_id, fkey_metadata_id, relation_type) values ($1, $2, $3);";	
+					$v = array($resourceId, $metadataId, $this->origin);
+					$t = array('i','i', 's');
+					$res = db_prep_query($sql,$v,$t);
+				} else {
+					$res = false;
+				}
 				if(!$res){
 					db_rollback();
 					$e = new mb_exception("class_Iso19139:"._mb("Cannot insert metadata relation!"));
@@ -2612,18 +2620,23 @@
 				//insert relations
 				$row = db_fetch_assoc($res);
 				$metadataId = $row['metadata_id'];
-				//check if current relation already exists in case of upload
-				if ($this->checkMetadataRelation($resourceType, $resourceId, $metadataId,$this->origin)) {
-					$e = new mb_notice("class_Iso19139:"._mb("Relation already exists - it will not be generated twice!"));
-					$result['value'] = true;
-					$result['message'] = "Relation already exists - it will not be generated twice!";
-					return $result;
+				if ($resourceType !== 'metadata') {
+					/*************************************/
+					//check if current relation already exists in case of upload
+					if ($this->checkMetadataRelation($resourceType, $resourceId, $metadataId,$this->origin)) {
+						$e = new mb_notice("class_Iso19139:"._mb("Relation already exists - it will not be generated twice!"));
+						$result['value'] = true;
+						$result['message'] = "Relation already exists - it will not be generated twice!";
+						return $result;
+					}
+					//insert relation to layer/featuretype
+					$sql = "INSERT INTO ows_relation_metadata (fkey_".$resourceType."_id, fkey_metadata_id, relation_type) values ($1, $2, $3);";
+					$v = array($resourceId, $metadataId, $this->origin);
+					$t = array('i','i','s');
+					$res = db_prep_query($sql,$v,$t);
+ 				} else {
+					$res = true;
 				}
-				//insert relation to layer/featuretype
-				$sql = "INSERT INTO ows_relation_metadata (fkey_".$resourceType."_id, fkey_metadata_id, relation_type) values ($1, $2, $3);";
-				$v = array($resourceId, $metadataId, $this->origin);
-				$t = array('i','i','s');
-				$res = db_prep_query($sql,$v,$t);
 				if(!$res){
 					db_rollback();
 					$e = new mb_exception("class_Iso19139:"._mb("Cannot insert metadata relation!"));

Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php	2018-01-16 19:55:45 UTC (rev 9846)
@@ -32,7 +32,7 @@
 			<table><tr><td><img class='clickable' src='../img/osgeo_graphics/geosilk/link_mae.png' title='linkage' onclick='$("#addonChooser").css("display","none");$("#link_editor").css("display","block");$("#kindOfMetadataAddOn").attr("value","link");' /></td><td><?php echo _mb("Add URL to existing Metadataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Here someone can add a url to an existing metadata record, which is available over www. The record can either be harvested and pushed to the own catalogue service or it is only used as a link. This links are pushed into the service metadata record and the new capabilities document.");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
 			<tr><td><img  class='clickable' src='../img/gnome/edit-select-all.png' title='metadata'  onclick='$("#addonChooser").css("display","none");$("#simple_metadata_editor").css("display","block");$("#kindOfMetadataAddOn").attr("value","metadataset");' /></td><td><?php echo _mb("Add a simple metadata record which is mostly generated from given layer information");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("With this option someone can generate a very simple metadata record for the data which is distributed thru the wms layer. The record fulfills only the INSPIRE Metadata Regulation! Most of the needed data is pulled from the service, layer and group information of the owner of the service. The metadate will be created on the fly. It is not stored in the database!");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
 			<tr><td><img  class='clickable' onclick='initUploadForm();' src='../img/button_blue_red/up_mae.png' id='uploadImage' title='upload'  /></td><td><?php echo _mb("Add a simple metadata record from a local file");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("With this option someone can upload an existing metadata record and couple it to the layer. The uploaded data is pushed to the catalogue and will be available for searching. The uploaded data is not fully controlled and validated. It cannot be edited but must be replaced with a new record if needed!");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
-			<tr><td><img  class='clickable' src='../img/osgeo_graphics/geosilk/link_mae.png' title='linkage' onclick='getOwnedMetadata();$("#addonChooser").css("display","none");$("#internal_link").css("display","block");$("#kindOfMetadataAddOn").attr("value","internallink");' /></td><td><?php echo _mb("Linkage to existing internal Metadataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Here someone can add a linkage to an existing internal metadata record, which is also available over www. This link is also pushed into the service metadata record and the new capabilities document.");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
+			<tr id="internalLinkage"><td><img  class='clickable' src='../img/osgeo_graphics/geosilk/link_mae.png' title='linkage' onclick='getOwnedMetadata();$("#addonChooser").css("display","none");$("#internal_link").css("display","block");$("#kindOfMetadataAddOn").attr("value","internallink");' /></td><td><?php echo _mb("Linkage to existing internal Metadataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Here someone can add a linkage to an existing internal metadata record, which is also available over www. This link is also pushed into the service metadata record and the new capabilities document.");?>'}" src="../img/questionmark.png" alt="" /></td></tr>
 			</table>
 		</p>
 	</fieldset>

Modified: trunk/mapbender/http/plugins/mb_metadata_manager_select.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_manager_select.js	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/plugins/mb_metadata_manager_select.js	2018-01-16 19:55:45 UTC (rev 9846)
@@ -152,7 +152,10 @@
 		tableHeaderContainer = $(document.createElement('thead'));
 		tableHeaderRowContainer = $(document.createElement('tr'));
 		tableContainer.attr({'id':'metadataTable'});
+		//add button to add new entry to metadata table
+		$("<img class='metadataEntry clickable' title='new' src='../img/add.png' onclick='initMetadataAddon(null, null, \"metadata\", true);return false;'/>").appendTo($("#mb_metadata_manager_select"));
 		mainDivContainer.append(tableContainer);
+		//alert("created");
 		//call translations
 		var req = new Mapbender.Ajax.Request({
 			url: "../plugins/mb_metadata_manager_server.php",
@@ -242,6 +245,8 @@
 					that.toggleSearchability(id);
 					return false;
 				});
+
+
 				// add option to open metadata windows in a modal dialog
 				$(".modalDialog").click(function (e) {
 					var iframe = $('<iframe width="100%" height="100%" frameborder="0" scrolling="yes" style="min-width: 95%;height:100%;"></iframe>');

Modified: trunk/mapbender/http/plugins/mb_metadata_manager_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_manager_server.php	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/plugins/mb_metadata_manager_server.php	2018-01-16 19:55:45 UTC (rev 9846)
@@ -92,8 +92,13 @@
 	}
 	//add column for deleting metadata
 	$row[] = "<img style='cursor:pointer;' class='deleteImg' title='"._mb("Delete")."' src='../img/cross.png' />";
+	if ($row[7] == 'metador' || $row[7] == 'upload' || $row[7] == 'external') {
+		$row[] = "<img class='clickable' title='edit' src='../img/pencil.png' onclick='initMetadataAddon(".$row[0].",null,\"metadata\",false);return false;'/>";
+	} else {
+		$row[] = "";
+	}
 	if ($withOutFirstColumn == true) {
-		$newRow = array($row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10]);
+		$newRow = array($row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11]);
 		$row = $newRow;
 	}
 	return $row;
@@ -277,7 +282,8 @@
 			_mb("Origin"),
 			_mb("Searchability"),
 			_mb("Catalogue export"),
-			_mb("Delete")
+			_mb("Delete"),
+			_mb("Edit")
 		);
 		$translation = array(
 			"confirmSearchabilityMessage" => _mb('Do you really want to change the searchability?'),

Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2018-01-16 19:55:45 UTC (rev 9846)
@@ -199,8 +199,12 @@
 				$("<div></div>").text(message).dialog({
 					modal: true
 				});
-				//update resource form to show edited data
-				that.fillResourceForm(resourceId, resourceType);
+				if (resourceType !== 'metadata') {
+					//update resource form to show edited data
+					that.fillResourceForm(resourceId, resourceType);
+				} else {
+					Mapbender.modules.mb_metadata_manager_select.initTable();
+				}
 			}
 		});
 		req.send();	
@@ -224,8 +228,12 @@
 				$("<div></div>").text(message).dialog({
 					modal: true
 				});
-				//update resource form to show edited data
-				that.fillResourceForm(resourceId, resourceType);
+				if (resourceType !== 'metadata') {
+					//update resource form to show edited data
+					that.fillResourceForm(resourceId, resourceType);
+				} else {
+					Mapbender.modules.mb_metadata_manager_select.initTable();
+				}
 			}
 		});
 		req.send();	
@@ -439,6 +447,10 @@
 				that.getInitialResourceMetadata(metadataId, resourceId, resourceType);
 			}
 			that.showForm(metadataId, resourceId, resourceType, isNew);
+			//if add only dataset metadata, the reference to other datasets is not possible!
+			if (resourceType == 'metadata') {
+				$("#internalLinkage").css("display","none")
+			} 
 			$("#uploadImage").click(function () {
 				initUploadForm(resourceId, resourceType);
 				//initUploadForm(layerId);

Modified: trunk/mapbender/http/plugins/mb_metadata_xml_import.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_xml_import.js	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/http/plugins/mb_metadata_xml_import.js	2018-01-16 19:55:45 UTC (rev 9846)
@@ -36,8 +36,13 @@
 				}
 				alert(message);
 				$xmlImport.dialog("close");
-				//invoke external script from mb_metadata_showMetadataAddon.js
-				Mapbender.modules.mb_md_showMetadataAddon.fillResourceForm(resourceId, resourceType);
+				if (resourceType !== 'metadata') {
+					//invoke external script from mb_metadata_showMetadataAddon.js
+					Mapbender.modules.mb_md_showMetadataAddon.fillResourceForm(resourceId, resourceType);
+				} else {
+					Mapbender.modules.mb_metadata_manager_select.initTable();
+				}
+			
 				if ($.isFunction(callback)) {
 					callback(obj.id);
 				}

Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2018-01-15 08:33:04 UTC (rev 9845)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql	2018-01-16 19:55:45 UTC (rev 9846)
@@ -2032,3 +2032,50 @@
 
 ALTER TABLE mb_group ADD COLUMN mb_group_registry_url character varying(1024);
 
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','jq_metadata',1,1,'Metadata plugin','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','','../extensions/jquery.metadata.2.1/jquery.metadata.min.js','','','http://plugins.jquery.com/project/metadata');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','jq_ui_datepicker',5,1,'Datepicker from jQuery UI framework','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','../plugins/jq_ui_datepicker.js','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/jquery.ui.datepicker.js','','jq_ui','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','jq_ui_tabs',5,1,'horizontal tabs from the jQuery UI framework','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','','../extensions/jquery-ui-1.8.16.custom/development-bundle/ui/minified/jquery.ui.tabs.min.js','','jq_ui,jq_ui_widget','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','jq_upload',1,1,'Allows to upload files into Mapbender''s temporary files folder','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','','../plugins/jq_upload.js','','','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','jq_validate',1,1,'The jQuery validation plugin','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','../javascripts/jq_validate.js','../extensions/jquery-validate/jquery.validate.min.js','','','http://docs.jquery.com/Plugins/Validation');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('admin_metadata', 'jq_validate', 'css', 'label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }', '' ,'text/css');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','mb_geodata_import',1,0,'Allows to upload files into Mapbender''s temporary files folder','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','../plugins/mb_metadata_import.js','','','','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','mb_md_showMetadataAddon',2,1,'Show addon editor for metadata','Metadata Addon Editor','div','','',NULL ,NULL ,NULL ,NULL ,NULL ,'display:none;','','div','../plugins/mb_metadata_showMetadataAddon.js','','','jq_ui_dialog','');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('admin_metadata', 'mb_md_showMetadataAddon', 'differentFromOriginalCss', '.differentFromOriginal{
+background-color:#FFFACD;
+}', 'css for class differentFromOriginal' ,'text/css');
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) VALUES('admin_metadata', 'mb_md_showMetadataAddon', 'inputs', '[
+    {
+        "method": "init",
+        "title": "initialize",
+        "linkedTo": [
+            {
+                "id": "mb_md_edit",
+                "event": "showOriginalMetadata",
+                "attr": "data" 
+            } 
+        ] 
+    },
+    {
+        "method": "initLayer",
+        "title": "initialize",
+        "linkedTo": [
+            {
+                "id": "mb_md_layer",
+                "event": "showOriginalLayerMetadata",
+                "attr": "data" 
+            } 
+        ] 
+    }
+]', '' ,'var');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','mb_metadata_gml_import',1,1,'','','div','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','div','../plugins/mb_metadata_gml_import.js','','','','');
+
+INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_metadata','mb_metadata_xml_import',1,1,'','','div','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','div','../plugins/mb_metadata_xml_import.js','','','','');
+
+



More information about the Mapbender_commits mailing list