[Mapbender-commits] r9413 - in trunk/mapbender/http: classes plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Feb 25 08:26:47 PST 2016
Author: armin11
Date: 2016-02-25 08:26:47 -0800 (Thu, 25 Feb 2016)
New Revision: 9413
Modified:
trunk/mapbender/http/classes/class_iso19139.php
trunk/mapbender/http/plugins/mb_metadata_addon.php
trunk/mapbender/http/plugins/mb_metadata_server.php
trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
Log:
New possibility to handle a relation from a metadata record to a predefined license as it is also possible for wms and wfs
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2016-02-24 12:44:21 UTC (rev 9412)
+++ trunk/mapbender/http/classes/class_iso19139.php 2016-02-25 16:26:47 UTC (rev 9413)
@@ -1023,6 +1023,8 @@
$this->inspireWholeArea = $row['inspire_whole_area'];//"";
$this->inspireActualCoverage = $row['inspire_actual_coverage'];//"";
$this->inspireDownload = $row['inspire_download'];//"";
+ $this->fees = $row['fees'];
+ $this->accessConstraints = $row['constraints'];
//$test = print_r($row['datalinks'],true);
//$e = new mb_exception((string)$test);
$this->downloadLinks = $this->jsonDecodeDownloadLinks($row['datalinks']);
@@ -1557,9 +1559,9 @@
//recreate relation to license
//relation is set via json id
//check for defined license id via editor or s.th. else
-
+ $licenseId = $this->termsOfUseRef;
if ($this->termsOfUseRef == null) {
- //search for given json lincense
+ //search for given json license
if ($this->licenseJson != null) {
$licenseName = json_decode($this->licenseJson)->id;
if ($licenseName != null) {
@@ -1572,9 +1574,11 @@
$res = db_prep_query($sql,$v,$t);
$row = db_fetch_assoc($res);
$licenseId = $row['termsofuse_id'];
+ //if license not found in json string
if ($licenseId == null) {
//if all relevant information is given in json - create a new entry in termsofuse table (id, name, url
$licenseJson = json_decode($this->licenseJson);
+ //check if all fields are there
if ($licenseJson->id != null && $licenseJson->id != "" && $licenseJson->name != null && $licenseJson->name != "" && $licenseJson->url != null && $licenseJson->url != "") {
//insert entry into db - license should be open
$sql = <<<SQL
@@ -1597,17 +1601,13 @@
$licenseId = $row['termsofuse_id'];
}
}
-
}
- } else {
- $licenseId = null;
+
}
- } else {
- $licenseId = $this->termsOfUseRef;
- }
- //do the sql job
+ }
}
- if ($licenseId != null) {
+ $e = new mb_exception("iso19139 license id: ".$this->termsOfUseRef);
+ if ($licenseId !== null) {
$sql = <<<SQL
INSERT INTO md_termsofuse (fkey_termsofuse_id, fkey_metadata_id) VALUES ($1, $2);
SQL;
@@ -1617,6 +1617,8 @@
if (!$res){
$e = new mb_exception("classes/class_Iso19139.php: "._mb("Cannot insert termsofuse relation!"));
}
+ } else {
+ $e = new mb_exception("classes/class_Iso19139.php: license id is null!");
}
}
@@ -1741,7 +1743,7 @@
//insert an instance for iso19139 into mapbenders database
$e = new mb_exception("class_iso19139.php: insert metadata with title: ".$this->title);
$sql = <<<SQL
-INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage, inspire_download, bounding_geom, transfer_size, fees, md_license_source_note) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38)
+INSERT INTO mb_metadata (lastchanged, link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid, datasetid_codespace, randomid, fkey_mb_user_id, harvestresult, harvestexception, lineage, inspire_top_consistence, spatial_res_type, spatial_res_value, update_frequency, format, inspire_charset, ref_system, the_geom, datalinks, inspire_whole_area, inspire_actual_coverage, inspire_download, bounding_geom, transfer_size, fees, md_license_source_note, constraints) VALUES(now(), $1, $18, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39)
SQL;
$v = array(
$this->href,
@@ -1781,13 +1783,14 @@
$this->createWktPolygonFromPointArray($this->polygonalExtentExterior),
$this->transferSize,
$this->fees,
- $this->licenseSourceNote
+ $this->licenseSourceNote,
+ $this->accessConstraints
);
//$e = new mb_exception($this->tmpExtentBegin);
//$e = new mb_exception($this->tmpExtentEnd);
//$e = new mb_exception($this->createDate);
//$e = new mb_exception($this->changeDate);
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s');
$res = db_prep_query($sql,$v,$t);
return $res;
}
@@ -1830,7 +1833,7 @@
$sql .= "linktype = $4, uuid = $5, title = $6, createdate = $7, changedate = $8, lastchanged = now(), ";
$sql .= "abstract = $9, searchtext = $10, type = $11, tmp_reference_1 = $12, tmp_reference_2 = $13, export2csw = $14, datasetid = $15, ";
$sql .= "datasetid_codespace = $16, randomid = $17, harvestresult = $20, harvestexception = $21, lineage = $22, inspire_top_consistence = $23, ";
- $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34, bounding_geom = $35, transfer_size = $36, fees = $37, md_license_source_note = $38 WHERE metadata_id = $19";
+ $sql .= "spatial_res_type = $24, spatial_res_value = $25, update_frequency = $26, format = $27, inspire_charset = $28, ref_system = $29, the_geom = $30, datalinks = $31, inspire_whole_area = $32, inspire_actual_coverage = $33, inspire_download = $34, bounding_geom = $35, transfer_size = $36, fees = $37, md_license_source_note = $38, constraints = $39 WHERE metadata_id = $19";
//$e= new mb_exception("class_iso19139.php: downloadLinks json".$this->jsonEncodeDownloadLinks($this->downloadLinks));
//$e= new mb_exception("class_iso19139.php: downloadLinks[0]".$this->downloadLinks[0]);
$v = array(
@@ -1872,10 +1875,11 @@
$this->createWktPolygonFromPointArray($this->polygonalExtentExterior),
$this->transferSize,
$this->fees,
- $this->licenseSourceNote
+ $this->licenseSourceNote,
+ $this->accessConstraints
);
//$e = new mb_exception("class_iso19139: ".$this->createWktBboxFromArray($this->wgs84Bbox));
- $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s');
+ $t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s','s','s','s','i','i','s','s','b','s','s','s','s','s','s','POLYGON','s','s','s','i','POLYGON','d','s','s','s');
$res = db_prep_query($sql,$v,$t);
return $res;
}
@@ -2096,6 +2100,7 @@
//for uploaded metadata the harvesting was ok otherwise the function returned before
$res = $this->updateMetadataById($metadataId[0]);
+
$this->insertKeywordsAndCategoriesIntoDB($metadataId[0],$resourceType,$resourceId);
} else {
//check if href already exists
@@ -2177,7 +2182,7 @@
$this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
//if this was ok, let the resource (layer/featuretype) inherit the classification from the coupled metadata to support better catalogue search
}
- }
+ }
}
$result['value'] = true;
$result['message'] = "Insert metadata successfully into database!";
Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php 2016-02-24 12:44:21 UTC (rev 9412)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php 2016-02-25 16:26:47 UTC (rev 9413)
@@ -260,6 +260,37 @@
</fieldset>
</div>
<div id="tabs-8">
+ <p>
+ <label for="fees_md"><?php echo _mb("Conditions applying to access and use");?>:</label>
+ <input name="fees_md" id="fees_md"/><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("INSPIRE 8.1: conditions applying to access and use");?>'}" src="../img/questionmark.png" alt="" />
+ </p>
+ <p>
+ <label for="accessconstraints_md"><?php echo _mb("Limitations on public access");?>:</label>
+ <input name="accessconstraints_md" id="accessconstraints_md"/><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("INSPIRE 8.2: limitations on public access");?>'}" src="../img/questionmark.png" alt="" />
+ </p>
+<?php
+ $sql = "SELECT termsofuse_id, name FROM termsofuse";
+ $res = db_query($sql);
+ $termsofuse = array();
+ while ($row = db_fetch_assoc($res)) {
+ $termsofuse[$row["termsofuse_id"]] = $row["name"];
+ }
+?>
+ <p>
+ <label for="md_termsofuse"><?php echo _mb("MD predefined license");?>:</label>
+ <select class="termsofuse_selectbox" name="md_termsofuse" id="md_termsofuse" onChange="var chosenoption=this.options[this.selectedIndex];$('#mb_md_showMetadataAddon').mapbender().fillLicence(chosenoption.value);">
+ <option value='0'>...</option>
+<?php
+ foreach ($termsofuse as $key => $value) {
+ echo "<option value='" . $key . "'>" . htmlentities($value, ENT_QUOTES, CHARSET) . "</option>";
+ }
+?>
+ </select>
+ <img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Selection of predefined licences.");?>'}" src="../img/questionmark.png" alt="" />
+ </p>
+ <p>
+ <img id="licence_symbol_md"> <a id='licence_descriptionlink_md' target='_blank'><a/> <img id="open_symbol_md">
+ </p>
</div>
</div><!--accordion-->
</div><!--demo-->
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2016-02-24 12:44:21 UTC (rev 9412)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2016-02-25 16:26:47 UTC (rev 9413)
@@ -424,7 +424,7 @@
SELECT metadata_id, uuid, link, linktype, md_format, relation.relation_type, origin 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 relation.relation_type IN ('capabilities','external','metador','upload', 'internal')
+mb_metadata.metadata_id = relation.fkey_metadata_id WHERE relation.relation_type IN ('capabilities','external','metador','upload', 'internal') ORDER BY metadata_id DESC
SQL;
$res = db_query($sql);
$resultObj["md_metadata"]->metadata_id = array();
@@ -846,6 +846,13 @@
default:
break;
}
+ //things about licences
+ $resultObj["fees_md"] = $mbMetadata->fees;
+ $resultObj["accessconstraints_md"] = $mbMetadata->accessConstraints;
+ $resultObj["md_termsofuse"] = $mbMetadata->termsOfUseRef;
+ if ($resultObj["md_termsofuse"] == null || !isset($resultObj["md_termsofuse"])) {
+ $resultObj["md_termsofuse"] == '0';
+ }
//categories and keywords
$resultObj["md_md_topic_category_id"] = $mbMetadata->isoCategories;
$resultObj["md_custom_category_id"] = $mbMetadata->customCategories;
@@ -871,8 +878,7 @@
$layerId = $ajaxResponse->getParameter("layerId");
$metadataId = $ajaxResponse->getParameter("metadataId");
$sql = <<<SQL
-SELECT layer_title, layer_abstract, minx as west, miny as south, maxx as east, maxy as north
-FROM layer INNER JOIN layer_epsg ON layer.layer_id = layer_epsg.fkey_layer_id WHERE layer_id = $1 AND epsg = 'EPSG:4326';
+SELECT layerpart.*, wms.accessconstraints, wms.fees FROM (SELECT layer_title, fkey_wms_id, layer_abstract, minx as west, miny as south, maxx as east, maxy as north FROM layer INNER JOIN layer_epsg ON layer.layer_id = layer_epsg.fkey_layer_id WHERE layer_id = $1 AND epsg = 'EPSG:4326') as layerpart INNER JOIN wms ON layerpart.fkey_wms_id = wms.wms_id
SQL;
$v = array($layerId);
$t = array('i');
@@ -886,7 +892,20 @@
$resultObj["south"] = $row["south"]; //double
$resultObj["east"]= $row['east']; //double
$resultObj["north"] = $row["north"]; //double
+ $resultObj["accessconstraints_md"] = $row["accessconstraints"]; //
+ $resultObj["fees_md"] = $row["fees"]; //
}
+ $sql = <<<SQL
+SELECT fkey_termsofuse_id FROM wms_termsofuse WHERE fkey_wms_id = $1;
+SQL;
+ $v = array($row['fkey_wms_id']);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ $row = array();
+ if ($res) {
+ $row = db_fetch_assoc($res);
+ $resultObj["md_termsofuse"]= $row['fkey_termsofuse_id']; //serial
+ }
$ajaxResponse->setResult($resultObj);
$ajaxResponse->setSuccess(true);
break;
@@ -971,6 +990,18 @@
if (isset($data->south)) {
$mbMetadata->wgs84Bbox[1] = $data->south;
}
+ if (isset($data->fees_md)) {
+ $mbMetadata->fees = $data->fees_md;
+ }
+ if (isset($data->accessconstraints_md)) {
+ $mbMetadata->accessConstraints = $data->accessconstraints_md;
+ }
+ $e = new mb_exception($data->md_termsofuse);
+ if (isset($data->md_termsofuse) && $data->md_termsofuse !=='0' && $data->md_termsofuse !== 0) {
+ $mbMetadata->termsOfUseRef = $data->md_termsofuse;
+ } else {
+ $mbMetadata->termsOfUseRef = null;
+ }
//try to update metadata object (only mb_metadata)
$res = $mbMetadata->updateMetadataById($metadataId);
if (!$res) {
@@ -1005,7 +1036,7 @@
from (select wfs_id from wfs where wfs_owner = $1) wfs inner join wfs_featuretype on
wfs.wfs_id = wfs_featuretype.fkey_wfs_id) featuretype inner join ows_relation_metadata on
featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) ows_r_m inner
-join mb_metadata on ows_r_m.fkey_metadata_id = mb_metadata.metadata_id) as foo order by metadata_id
+join mb_metadata on ows_r_m.fkey_metadata_id = mb_metadata.metadata_id) as foo order by metadata_id DESC
SQL;
$v = array($user->id, $layerId);
$t = array('i','i');
@@ -1165,6 +1196,16 @@
} else {
$mbMetadata->inspireDownload = 0;
}
+ if (isset($data->fees_md)) {
+ $mbMetadata->fees = $data->fees_md;
+ }
+ if (isset($data->accessconstraints_md)) {
+ $mbMetadata->accessConstraints = $data->accessconstraints_md;
+ }
+ if (isset($data->md_termsofuse) && $data->md_termsofuse !=='0') {
+ $mbMetadata->termsOfUseRef = $data->md_termsofuse;
+ }
+
//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
@@ -1301,6 +1342,7 @@
} else {
$e = new mb_notice("Metadata with random id ".$randomid." stored to db!");
+
$ajaxResponse->setMessage("Uploaded metadata object inserted into md_metadata table!");
$ajaxResponse->setSuccess(true);
}
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2016-02-24 12:44:21 UTC (rev 9412)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2016-02-25 16:26:47 UTC (rev 9413)
@@ -33,8 +33,10 @@
}
$metadataAddonForm.easyform("reset");
$metadataAddonForm.easyform("fill", obj);
-
-
+ if (obj.md_termsofuse !== "0") {
+ //alert(JSON.stringify(obj));
+ that.fillLicence(obj.md_termsofuse);
+ }
//that.showForm(metadataId, layerId);
/*
//enable link element to edit link!
@@ -90,7 +92,6 @@
req.send();
}
-
this.getAddedMetadata = function(metadataId){
// get metadata from server
var req = new Mapbender.Ajax.Request({
@@ -138,12 +139,52 @@
} else {
$("#delete_existing_polygon").css("display","none");
}
-
+ $(".termsofuse_selectbox").val(obj.md_termsofuse);
+ //show symbol and link for predefined termsofuse
+ if (obj.md_termsofuse !== "0") {
+ //alert(JSON.stringify(obj));
+ that.fillLicence(obj.md_termsofuse);
+ }
}
});
req.send();
- }
+ }
+
+ //Show more information about the licences of the metadata
+ this.fillLicence = function(obj) {
+ // get licence information from server per termsofuse_id
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_metadata_server.php",
+ method: "getLicenceInformation",
+ parameters: {
+ "id": obj
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ return;
+ }
+ if (obj.termsofuse_id) {
+ //alert(JSON.stringify(obj));
+ $('#licence_symbol_md').attr('src', obj.symbollink);
+ $('#licence_descriptionlink_md').text(obj.description);
+ $('#licence_descriptionlink_md').attr('href', obj.descriptionlink);
+ if (obj.isopen == 1) {
+ $('#open_symbol_md').attr('src', '../img/od_80x15_blue.png');
+ } else {
+ $('#open_symbol_md').attr('src', '');
+ }
+ } else {
+ $('#licence_symbol_md').attr('src', '');
+ $('#licence_descriptionlink_md').attr('href', '');
+ $('#licence_descriptionlink_md').text('');
+ $('#open_symbol_md').attr('src', '');
+ }
+ }
+ });
+ req.send();
+ }
+
this.insertAddedMetadata = function(layerId, data){
// push metadata from server
var req = new Mapbender.Ajax.Request({
@@ -380,6 +421,7 @@
}
//c
that.showForm(metadataId, layerId, isNew);
+
$("#uploadImage").click(function () {
initUploadForm(layerId);
});
@@ -389,6 +431,7 @@
$("#delete_existing_polygon").click(function () {
deleteGmlPolygon(metadataId);
});
+
//alert($("#uploadImage").attr('onclick')); //there has been a bigger problem when setting an onclick attribut with jquery :-(
//TODO: make the fields resizable
//$( "#abstract" ).resizable({ minWidth: 75 });
More information about the Mapbender_commits
mailing list