[Mapbender-commits] r8341 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 3 11:35:37 EDT 2012
Author: armin11
Date: 2012-05-03 08:35:37 -0700 (Thu, 03 May 2012)
New Revision: 8341
Modified:
trunk/mapbender/http/plugins/mb_metadata_layer.js
trunk/mapbender/http/plugins/mb_metadata_server.php
trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
Log:
More work on the wms metadata editor for inspire. Now entries from mb_metadata can also be used to be linked to layer.
Modified: trunk/mapbender/http/plugins/mb_metadata_layer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.js 2012-05-03 14:54:48 UTC (rev 8340)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.js 2012-05-03 15:35:37 UTC (rev 8341)
@@ -105,18 +105,34 @@
layerId = obj.layer_id;
//for size of md_metadata records:
for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
- if (obj.md_metadata.origin[i] == "capabilities") {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
- }
- if (obj.md_metadata.origin[i] == "external") {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- }
- if (obj.md_metadata.origin[i] == "upload") {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- }
- if (obj.md_metadata.origin[i] == "metador") {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- }
+ if (obj.md_metadata.origin[i] == "capabilities") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/server_map-ilink.png' title='link to metadata from capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "external") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/link-ilink.png' title='link to external linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "upload") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/up-ilink.png' title='link to external uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "metador") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/edit-select-all-ilink.png' title='link to external edited metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
}
$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));
}
@@ -150,6 +166,10 @@
return wmsId;
}
+ this.getLayerId = function() {
+ return layerId;
+ }
+
this.init = function (obj) {
delete layerId;
//delete metadataURL entries
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2012-05-03 14:54:48 UTC (rev 8340)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2012-05-03 15:35:37 UTC (rev 8341)
@@ -279,7 +279,7 @@
}
//get MetadataURLs from md_metadata table
$sql = <<<SQL
-SELECT metadata_id, uuid, link, linktype, md_format, origin FROM mb_metadata
+SELECT metadata_id, uuid, link, linktype, md_format, origin, relation.internal FROM mb_metadata
INNER JOIN (SELECT * from ows_relation_metadata
WHERE fkey_layer_id = $layerId ) as relation ON
mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.origin IN ('capabilities','external','metador','upload')
@@ -290,6 +290,7 @@
$resultObj["md_metadata"]->origin = array();
$resultObj["md_metadata"]->linktype = array();
$resultObj["md_metadata"]->link = array();
+ $resultObj["md_metadata"]->internal = array();
$i = 0;
while ($row = db_fetch_assoc($res)) {
$resultObj["md_metadata"]->metadata_id[$i]= $row["metadata_id"];
@@ -297,6 +298,7 @@
$resultObj["md_metadata"]->uuid[$i]= $row["uuid"];
$resultObj["md_metadata"]->origin[$i]= $row["origin"];
$resultObj["md_metadata"]->linktype[$i]= $row["linktype"];
+ $resultObj["md_metadata"]->internal[$i]= $row["internal"];
$i++;
}
$ajaxResponse->setResult($resultObj);
@@ -538,6 +540,9 @@
$ajaxResponse->setSuccess(true);
break;
+
+
+
case "getContactMetadata" :
$mbGroupId = $ajaxResponse->getParameter("id");
$sql = <<<SQL
@@ -692,6 +697,33 @@
$ajaxResponse->setMessage("Metadata updated!");
$ajaxResponse->setSuccess(true);
break;
+
+ case "getOwnedMetadata" :
+ $featuretypeId = $ajaxResponse->getParameter("layerId");
+
+ $user = new User(Mapbender::session()->get("mb_user_id"));
+ //$e = new mb_exception("plugins/mb_metadata_wfs_server.php: user_id: ".$user->id);
+ $sql = <<<SQL
+
+SELECT metadata_id, title, fkey_layer_id FROM mb_metadata INNER JOIN ows_relation_metadata ON ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id WHERE fkey_mb_user_id = $1 AND fkey_layer_id IS DISTINCT FROM $2 ORDER BY metadata_id ASC
+
+SQL;
+ $v = array($user->id, $layerId);
+ $t = array('i','i');
+ $res = db_prep_query($sql,$v,$t);
+ $row = array();
+ $resultObj = array();
+ $i = 0;
+ while ($row = db_fetch_assoc($res)) {
+ $resultObj[$i]->metadataId = $row['metadata_id']; //integer
+ $resultObj[$i]->metadataTitle = $row["title"]; //char
+ $i++;
+ }
+
+ $ajaxResponse->setResult($resultObj);
+ $ajaxResponse->setSuccess(true);
+ break;
+
case "insertLayerMetadataAddon" :
$layerId = $ajaxResponse->getParameter("layerId");
$data = $ajaxResponse->getParameter("data");
@@ -700,6 +732,25 @@
//use this to distinguish between the to different inserts!
//this insert should also push one entry in the ows_relation_metadata table! - after the insert into md_metadata
//origin
+ if ($data->kindOfMetadataAddOn == 'internallink') {
+ //insert a simple relation to an internal metadata entry - but how can this be distinguished?
+ //we need a new column with type of relation - maybe called internal
+
+ $sql = <<<SQL
+
+INSERT INTO ows_relation_metadata (fkey_metadata_id, fkey_layer_id, internal) VALUES ( $1, $2, $3)
+
+SQL;
+ $v = array($data->internal_relation,$layerId, 1);
+ $t = array('i','i','i');
+ $res = db_prep_query($sql,$v,$t);
+ if (!$res){
+ abort(_mb("Could not insert internal metadatalink into database!"));
+ }
+ $ajaxResponse->setMessage("Metadatalink inserted!");
+ $ajaxResponse->setSuccess(true);
+ break;
+ }
if ($data->kindOfMetadataAddOn == 'link') {
//generate metador entry
$origin = 'external';
@@ -965,6 +1016,32 @@
$ajaxResponse->setSuccess(true);
}
break;
+
+ case "deleteInternalMetadataLinkage" :
+ $metadataId = $ajaxResponse->getParameter("metadataId");
+ $layerId = $ajaxResponse->getParameter("layerId");
+ $sql = <<<SQL
+
+DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_layer_id = $2 and internal = 1
+
+SQL;
+ $v = array($metadataId, $layerId);
+ $t = array('i','i');
+ //$e = new mb_exception("metadataid:".$metadataId." - layerid: ".$layerId);
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("Could not delete internal metadata linkage from database!"));
+ $ajaxResponse->send();
+ die;
+ }
+ $ajaxResponse->setMessage("Internal metadata linkage deleted!");
+ $ajaxResponse->setSuccess(true);
+
+ break;
+
case "deleteLayerMetadataAddon" :
$metadataId = $ajaxResponse->getParameter("metadataId");
$sql = <<<SQL
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2012-05-03 14:54:48 UTC (rev 8340)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2012-05-03 15:35:37 UTC (rev 8341)
@@ -61,6 +61,36 @@
});
req.send();
}
+
+ getOwnedMetadata = function (){
+ // get metadata from server
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_metadata_server.php",
+ method: "getOwnedMetadata",
+ parameters: {
+ "layerId": Mapbender.modules.mb_md_layer.getLayerId()
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ return;
+ }
+ //fill options for of internal linkages
+ $("#internal_relation").empty();
+ var emptyOption = '<option value="">---</option>';
+ $("#internal_relation").append(emptyOption);
+ for ( var i=0 ; i<obj.length ; i++ ) {
+ var optionVal = obj[i].metadataId;
+ var optionName = obj[i].metadataId + " : " + obj[i].metadataTitle;
+ var optionHtml = "<option value='" + optionVal + "'>" + optionName + "</option>";
+ $("#internal_relation").append(optionHtml);
+ }
+
+ }
+ });
+ req.send();
+ }
+
+
this.getAddedMetadata = function(metadataId, layerId){
// get metadata from server
var req = new Mapbender.Ajax.Request({
@@ -204,6 +234,35 @@
}
+ deleteInternalMetadataLinkage = function(metadataId, layerId){
+ // push metadata from server
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_metadata_server.php",
+ method: "deleteInternalMetadataLinkage",
+ parameters: {
+ "metadataId": metadataId,
+ "layerId": layerId
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ return;
+ }
+ //delete metadataURL entries
+ $('.metadataEntry').remove();
+ //fill MetadataURLs into metadata_selectbox_id
+ //update layer form to show edited data
+ that.fillLayerForm(layerId);
+ //alert(wmsId);
+ $("<div></div>").text(message).dialog({
+ modal: true
+ });
+ }
+ });
+ req.send();
+
+
+ }
+
this.showForm = function (metadataId, layerId, isNew) {
$metadataAddonPopup.append($metadataAddonForm);
$metadataAddonPopup.dialog({
More information about the Mapbender_commits
mailing list