[Mapbender-commits] r8627 - in trunk/mapbender/http: classes plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 23 08:25:13 PDT 2013
Author: armin11
Date: 2013-05-23 08:25:13 -0700 (Thu, 23 May 2013)
New Revision: 8627
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
trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
Log:
Initial commit to extent metadata editor for categories, keywords, own geometries and some other inspire relevant things. Some code cleaning. Some things to be done next week.
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/classes/class_iso19139.php 2013-05-23 15:25:13 UTC (rev 8627)
@@ -30,7 +30,12 @@
var $datasetIdCodeSpace;
var $keywords = array();
var $keywordsThesaurusName = array();
+ var $isoCategoryKeys = array();
+
var $isoCategories = array();
+ var $inspireCategories = array();
+ var $customCategories = array();
+
var $hierachyLevel;
var $tmpExtentBegin;
var $tmpExtentEnd;
@@ -66,9 +71,14 @@
$this->metadata = "";
$this->datasetId = "";
$this->datasetIdCodeSpace = "";
- $this->keywords[0] = "";
- $this->keywordsThesaurusName[0] = "";
- $this->isoCategories[0] = "";
+ $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 = "dataset";
$this->tmpExtentBegin = "1900-01-01";
$this->tmpExtentEnd = "1900-01-01";
@@ -123,6 +133,31 @@
}
//if parsing was successful
if ($iso19139Xml !== false) {
+ //built hashes for category mapping
+ $topicCatHash = array();
+ $sql = "SELECT md_topic_category_id, md_topic_category_code_en FROM md_topic_category";
+ $res = db_query($sql);
+ while ($row = db_fetch_array($res)){
+ $topicCatHash[$row['md_topic_category_code_en']] = (integer)$row['md_topic_category_id'];
+ //$e = new mb_exception("topicCatHash: ".$row['md_topic_category_code_en'] ." : ". $topicCatHash[$row['md_topic_category_code_en']] );
+ }
+ //inspire
+ $inspireCatHash = array();
+ $sql = "SELECT inspire_category_id, inspire_category_code_en FROM inspire_category";
+ $res = db_query($sql);
+ while ($row = db_fetch_array($res)){
+ $inspireCatHash[$row['inspire_category_code_en']] = (integer)$row['inspire_category_id'];
+ //$e = new mb_exception("inspireCatHash: ".$row['inspire_category_code_en'] ." : ". $row['inspire_category_id'] );
+ }
+ //custom
+ //keywords - as text i custom category - special keywords of geoportal instance defined as keys!
+ $customCatHash = array();
+ $sql = "SELECT custom_category_id, custom_category_key FROM custom_category";
+ $res = db_query($sql);
+ while ($row = db_fetch_array($res)){
+ $customCatHash[$row['custom_category_key']] = (integer)$row['custom_category_id'];
+ //$e = new mb_exception("customCatHash: ".$row['custom_category_key'] ." : ". $row['custom_category_id'] );
+ }
//add namespaces to xml if not given - how? - it is to late now - maybe they were given in the csw tag!
$e = new mb_exception("Parsing of xml metadata file was successfull");
$this->fileIdentifier = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:fileIdentifier/gco:CharacterString');
@@ -161,14 +196,42 @@
//get thesaurus name only for found keywords!
$iKeyword = 0;
foreach ($this->keywords as $keyword) {
-
$thesaurusName = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords[gmd:MD_Keywords/gmd:keyword/gco:CharacterString="'.$keyword.'"]/gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString');
$this->keywordsThesaurusName[$iKeyword] = $thesaurusName[0];
+ //check if keyword is inspire thematic key and add it into mapbenders inspire category
+ if (is_int($inspireCatHash[trim($keyword)])) {
+ $this->inspireCategories[] = $inspireCatHash[trim($keyword)];
+ }
+ //check if keyword is a key in mapbenders custom keywords and add it to mapbenders custom categories
+ if (is_int($customCatHash[trim($keyword)])) {
+ $this->customCategories[] = $customCatHash[trim($keyword)];
+ }
unset($thesaurusName);
$iKeyword++;
}
$iKeyword = 0;
- $this->isoCategories = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode');
+ $this->isoCategoryKeys = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory/gmd:MD_TopicCategoryCode');
+ //create mapbenders internal category objects
+ //first for topic categories
+ foreach ($this->isoCategoryKeys as $isoKey) {
+ $e = new mb_exception("class_iso19139.php: look for iso key: ".$isoKey);
+ //test if key is found in hash
+ $e = new mb_exception("class_iso19139.php: found: ".$topicCatHash[trim($isoKey)]);
+ if (is_int($topicCatHash[trim($isoKey)])) {
+ $e = new mb_exception("class_iso19139.php: isoCategories entry added: ".$topicCatHash[trim($isoKey)]);
+ $this->isoCategories[] = $topicCatHash[trim($isoKey)];
+ }
+ }
+ //debug output:
+ foreach ($this->isoCategories as $category) {
+ $e = new mb_exception("class_iso19139.php: isocat: ".$category);
+ }
+ foreach ($this->inspireCategories as $category) {
+ $e = new mb_exception("class_iso19139.php: inspirecat: ".$category);
+ }
+ foreach ($this->customCategories as $category) {
+ $e = new mb_exception("class_iso19139.php: customcat: ".$category);
+ }
$this->hierachyLevel = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
$this->hierachyLevel = $this->hierachyLevel[0];
$this->tmpExtentBegin = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
@@ -185,12 +248,12 @@
$this->refSystem = explode(':',$this->refSystem);
$this->refSystem = "EPSG:".$this->refSystem[count($this->refSystem)-1];
//debug output of keywords:
- $iKeyword = 0;
+ /*$iKeyword = 0;
foreach($this->keywords as $keyword) {
$e = new mb_exception("Keyword: ".$keyword." - Thesaurus: ".$this->keywordsThesaurusName[$iKeyword]);
$iKeyword++;
}
- $iKeyword = 0;
+ $iKeyword = 0;*/
//format
//inspire_charset
//inspire_top_consistence
@@ -567,7 +630,17 @@
public function createFromDB($fileIdentifier){
return $this;
}
- //TODO: following 2 classes are not used til now - check plugins mb_metadata_server scripts to exchange handling
+
+ //the following functions are only for the simple metadata editor
+ public function createMetadataAddonFromDB() {
+
+ }
+
+ public function updateMetadataAddonInDB() {
+
+ }
+
+ //TODO: following 2 functions are not used til now - check plugins mb_metadata_server scripts to exchange handling
public function deleteMetadataRelation($resourceType, $resourceId, $relationType){
//delete all relations which are defined from capabilities - this don't delete the metadata entries themself!
//all other relations stay alive
@@ -614,6 +687,92 @@
}
}
+ public function deleteInternalMetadataLinkage($resourceType, $resourceId, $metadataId){
+ $returnObject = array();
+ $sql = "DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_".$resourceType."_id = $2 and relation_type = 'internal'";
+ $v = array($metadataId, $resourceId);
+ $t = array('i','i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $returnObject['success'] = false;
+ $returnObject['message'] = _mb("Could not delete internal metadata linkage from database!");
+ return $returnObject;
+ }
+ $returnObject['success'] = true;
+ $returnObject['message'] = _mb("Internal metadata linkage deleted!");
+ return $returnObject;
+ }
+
+ public function deleteMetadataAddon($resourceType, $resourceId, $metadataId){
+ $returnObject = array();
+ $sql = "SELECT count(*) as count FROM ows_relation_metadata WHERE fkey_metadata_id = $1";
+ $v = array($metadataId);
+ $t = array('i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $e){
+ $returnObject['success'] = false;
+ $returnObject['message'] = _mb("Could not determine a count of metadata relations!");
+ return $returnObject;
+ }
+ while ($row = db_fetch_assoc($res)) {
+ $countMetadataLinkage = (integer)$row['count']; //integer
+ }
+ if ($countMetadataLinkage == 1) {
+ $e = new mb_exception("Metadata has only one reference and will be deleted from database if it was created by upload or link!");
+ //delete the metadata itself cause it has no other reference - really - not right for metador files !!!
+ $sql = <<<SQL
+
+DELETE FROM mb_metadata WHERE metadata_id = $1 and origin NOT IN ('metador')
+
+SQL;
+ $v = array($metadataId);
+ $t = array('i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $e){
+ $returnObject['success'] = false;
+ $returnObject['message'] = _mb("Could not delete metadata from database!");
+ return $returnObject;
+ }
+ //delete link if metadata was not deleted cause it has been created by editor!
+ $sql = "DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_".$resourceType."_id = $2";
+ $v = array($metadataId, $resourceId);
+ $t = array('i','i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $returnObject['success'] = false;
+ $returnObject['message'] = _mb("Could not delete internal metadata linkage from database!");
+ return $returnObject;
+ }
+ $returnObject['success'] = true;
+ $returnObject['message'] = _mb("Metadata and/or linkage was deleted from database!");
+ return $returnObject;
+ } else {
+ //delete only linkage
+ $sql = "DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_".$resourceType."_id = $2";
+ $v = array($metadataId, $resourceId);
+ $t = array('i','i');
+ try {
+ $res = db_prep_query($sql,$v,$t);
+ }
+ catch (Exception $E){
+ $returnObject['success'] = false;
+ $returnObject['message'] = _mb("Could not delete metadata linkage from database!");
+ return $returnObject;
+ }
+ $returnObject['success'] = true;
+ $returnObject['message'] = _mb("Metadata linkage deleted!");
+ return $returnObject;
+ }
+ }
+
public function isLinkAlreadyInDB(){
$sql = <<<SQL
SELECT metadata_id FROM mb_metadata WHERE link = $1 AND link <> '' ORDER BY lastchanged DESC
@@ -657,6 +816,292 @@
}
}
+ public function insertKeywordsAndCategoriesIntoDB($metadataId){
+ //first delete old classifications - after that create new ones
+ $this->deleteKeywordsAndCategoriesFromDB($metadataId);
+ //insert keywords and categories into tables!
+ //parse keywords and isoCategories
+ //INSERT INTO films (code, title, did, date_prod, kind) VALUES
+ //('B6717', 'Tampopo', 110, '1985-02-10', 'Comedy'),
+ //('HG120', 'The Dinner Game', 140, DEFAULT, 'Comedy');
+ //use category name instead of id's!
+ //map category name to id before insert them into db!
+ //read maptable from db
+ //iso - code in xml
+
+ //map keys into relevant ids
+ $sqlInsert = "";
+ if (count($this->isoCategories) > 0) {
+ if (count($this->isoCategories) == 1) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$this->isoCategories.")";
+ } else {
+ foreach ($this->isoCategories as $isoCategory) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$isoCategory."),";
+ }
+ }
+ $sqlInsert = rtrim($sqlInsert,",");
+ $sql = "INSERT INTO mb_metadata_md_topic_category (fkey_metadata_id, fkey_md_topic_category_id) VALUES ".$sqlInsert;
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot insert iso categories for this metadata!"));
+ }
+ }
+ $sqlInsert = "";
+ if (count($this->inspireCategories) > 0) {
+ if (count($this->inspireCategories) == 1) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$this->inspireCategories.")";
+ } else {
+ foreach ($this->inspireCategories as $inspireCategory) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$inspireCategory."),";
+ }
+ }
+ $sqlInsert = rtrim($sqlInsert,",");
+ $sql = "INSERT INTO mb_metadata_inspire_category (fkey_metadata_id, fkey_inspire_category_id) VALUES ".$sqlInsert;
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot insert inspire categories for this metadata!"));
+ }
+ }
+ $sqlInsert = "";
+ if (count($this->customCategories) > 0) {
+ if (count($this->customCategories) == 1) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$this->customCategories.")";
+ } else {
+ foreach ($this->customCategories as $customCategory) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$customCategory."),";
+ }
+ }
+ $sqlInsert = rtrim($sqlInsert,",");
+ $sql = "INSERT INTO mb_metadata_custom_category (fkey_metadata_id, fkey_custom_category_id) VALUES ".$sqlInsert;
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot insert custom categories for this metadata!"));
+ }
+ }
+ $sqlInsert = "";
+ //insert keywords into keyword table
+ //foreach keyword look for an id or create it newly - made for postgres > 8.2 with returning option for insert statement
+ $keyword = "'";
+ $keyword .= implode('\',\'',$this->keywords);
+ $keyword .= "'";
+ $existingKeywords = array();
+ $sql = "SELECT keyword, keyword_id from keyword WHERE keyword in ($keyword);";
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139.php: cannot get keywords from database!");
+ } else {
+ $countExistingKeywords = 0;
+ while ($row = db_fetch_assoc($res)) {
+ $existingKeywords[$countExistingKeywords]['keyword'] = $row['keyword'];
+ $existingKeywords[$countExistingKeywords]['id'] = $row['keyword_id'];
+ $existingKeywordsArray[$countExistingKeywords] = $row['keyword'];
+ $countExistingKeywords++;
+ }
+ }
+ /*foreach ($existingKeywords as $test) {
+ $e = new mb_exception("exists: ".$test['keyword']);
+ }*/
+ //for each existing keyword add a new relation into relation table
+ if ($countExistingKeywords > 0) {
+ if ($countexistingKeywords == 1) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$existingKeywords[0]['id'].")";
+ } else {
+ foreach ($existingKeywords as $existingKeyword) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$existingKeyword['id']."),";
+ }
+ }
+ $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);
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot insert keyword relations for this metadata!"));
+ }
+ }
+ //insert those keywords, that are not already in the keyword table
+ //$this->keywords
+ /*$array1 = array("a" => "grün", "rot", "blau", "rot");
+ $array2 = array("b" => "grün", "gelb", "rot");
+ $result = array_diff($array1, $array2);
+ Array
+ (
+ [1] => blau
+ )
+ */
+ $sqlInsert = "";
+ $otherKeywords = array_diff($this->keywords,$existingKeywordsArray);
+ if (count($otherKeywords) > 0) {
+ if (count($otherKeywords) == 1) {
+ //keyword table
+ $sqlInsert .= "('".$otherKeywords[0]."')";
+ } else {
+ foreach ($otherKeywords as $otherKeyword) {
+ $sqlInsert .= "('".$otherKeyword."'),";
+ }
+ }
+ $sqlInsert = rtrim($sqlInsert,",");
+ $sql = "INSERT INTO keyword (keyword) VALUES ".$sqlInsert." RETURNING keyword_id" ;
+ $e = new mb_notice("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!"));
+ } else {
+ //insert relations for keywords
+ $sqlInsert = "";
+ $insertedKeywords = array();
+ while ($row = db_fetch_assoc($res)) {
+ $insertedKeywordIds[] = $row['keyword_id'];
+ }
+ if (count($insertedKeywordIds) == 1) {
+ //keyword relation table
+ $sqlInsert .= "(".$insertedKeywordIds[0].")";
+ } else {
+ foreach ($insertedKeywordIds as $insertedKeywordId) {
+ $sqlInsert .= "(".(integer)$metadataId.",".(integer)$insertedKeywordId."),";
+ }
+ }
+ $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 keyword relation: ".$sql);
+ $res = db_query($sql);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot insert metadata keyword relations into db!"));
+ }
+ }
+ }
+ }
+
+ public function deleteKeywordsAndCategoriesFromDB($metadataId) {
+ $sql = "DELETE FROM mb_metadata_md_topic_category where fkey_metadata_id = $1 ";
+ $v = array($metadataId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot delete topic category relations for metadata with id ".$metadataId));
+ } else {
+ $e = new mb_exception("class_Iso19139: topic category relations deleted from database!");
+ }
+ $sql = "DELETE FROM mb_metadata_inspire_category where fkey_metadata_id = $1 ";
+ $v = array($metadataId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot delete inspire category relations for metadata with id ".$metadataId));
+ } else {
+ $e = new mb_exception("class_Iso19139: inspire category relations deleted from database!");
+ }
+ $sql = "DELETE FROM mb_metadata_custom_category where fkey_metadata_id = $1 ";
+ $v = array($metadataId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot delete custom category relations for metadata with id ".$metadataId));
+ } else {
+ $e = new mb_exception("class_Iso19139: custom category relations deleted from database!");
+ }
+ //delete keyword relations - problem, that keywords are referenced from more than one table. We can only delete the relations but there may be orphaned keywords, which have to be deleted by cronjob - maybe - TODO
+ $sql = "DELETE FROM mb_metadata_keyword where fkey_metadata_id = $1 ";
+ $v = array($metadataId);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ if (!$res) {
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot delete keyword relations for metadata with id ".$metadataId));
+ } else {
+ $e = new mb_exception("class_Iso19139: keyword relations deleted from database!");
+ }
+ }
+
+ public function insertMetadataIntoDB() {
+ //insert an instance for iso19139 into mapbenders database
+ $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) 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)
+SQL;
+ $v = array(
+ $this->href,
+ $this->format,
+ $this->metadata,
+ $this->type,
+ $this->fileIdentifier,
+ $this->title,
+ $this->createDate,
+ $this->changeDate,
+ $this->abstract,
+ $this->keywords[0],
+ $this->hierachyLevel,
+ $this->tmpExtentBegin,
+ $this->tmpExtentEnd,
+ $this->export2Csw,
+ $this->datasetId,
+ $this->datasetIdCodeSpace,
+ $this->randomId,
+ $this->origin,
+ $this->owner,
+ $this->harvestResult,
+ $this->harvestException,
+ $this->lineage,
+ $this->inspireTopConsistence,
+ $this->spatialResType,
+ $this->spatialResValue,
+ $this->updateFrequency,
+ $this->dataFormat,
+ $this->inspireCharset,
+ $this->refSystem
+ );
+ $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');
+ $res = db_prep_query($sql,$v,$t);
+ return $res;
+ }
+
+
+ private 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!
+ $sql = "UPDATE mb_metadata SET link = $1, origin = $18, md_format = $2, data = $3, ";
+ $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 WHERE metadata_id = $19";
+
+ $v = array(
+ $this->href,
+ $this->format,
+ $this->metadata,
+ $this->type,
+ $this->fileIdentifier, // is the old one! or not?
+ $this->title,
+ $this->createDate,
+ $this->changeDate,
+ $this->abstract,
+ $this->keywords[0],
+ $this->hierachyLevel,
+ $this->tmpExtentBegin,
+ $this->tmpExtentEnd,
+ $this->export2Csw,
+ $this->datasetId,
+ $this->datasetIdCodeSpace,
+ $this->randomId,
+ $this->origin,
+ //$this->owner, //owner is the old one - maybe here we have something TODO!
+ $metadataId, //The first metadataId which was found will be selected!
+ $this->harvestResult,
+ $this->harvestException,
+ $this->lineage,
+ $this->inspireTopConsistence,
+ $this->spatialResType,
+ $this->spatialResValue,
+ $this->updateFrequency,
+ $this->dataFormat,
+ $this->inspireCharset,
+ $this->refSystem
+ );
+ $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');
+ $res = db_prep_query($sql,$v,$t);
+ return $res;
+ }
+
+
+
public function insertMetadataUrlToDB($resourceType, $resourceId){
//check if metadata record already exists, if not create a new one else insert relation only!
$metadataId = $this->isLinkAlreadyInDB();
@@ -831,142 +1276,21 @@
//update the metadata - new random id set therefor there is no problem when setting the relation afterwards
$e = new mb_exception("existing metadata fileIdentifier found at metadata with id: ".$metadataId[0]." - update will be performed");
//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!
- $sql = "UPDATE mb_metadata SET link = $1, origin = $18, md_format = $2, data = $3, ";
- $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 WHERE metadata_id = $19";
-
- $v = array(
- $this->href,
- $this->format,
- $this->metadata,
- $this->type,
- $this->fileIdentifier,
- $this->title,
- $this->createDate,
- $this->changeDate,
- $this->abstract,
- $this->keywords[0],
- $this->hierachyLevel,
- $this->tmpExtentBegin,
- $this->tmpExtentEnd,
- $this->export2Csw,
- $this->datasetId,
- $this->datasetIdCodeSpace,
- $this->randomId,
- $this->origin,
- //$this->owner, //owner is the old one - maybe here we have something TODO!
- $metadataId[0], //The first metadataId which was found will be selected!
- $this->harvestResult,
- $this->harvestException,
- $this->lineage,
- $this->inspireTopConsistence,
- $this->spatialResType,
- $this->spatialResValue,
- $this->updateFrequency,
- $this->dataFormat,
- $this->inspireCharset,
- $this->refSystem
- );
- $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');
- $res = db_prep_query($sql,$v,$t);
-
+ $res = $this->updateMetadataById($metadataId[0]);
} else {
//check if href already exists
$metadataId = $this->isLinkAlreadyInDB();
- //if so, the metadataset will be the same - (same url same metadataset) - update this one
+ //if so, the metadataset will be the same - (same url same metadataset) - update this as before
if ($metadataId != false) {
//the link to an existing metadataset already exists - don't store it again or insert anything
$e = new mb_exception("existing metadata linkage found at metadata with id: ".$metadataId[0]." - update will be performed");
//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!
- $sql = "UPDATE mb_metadata SET link = $1, origin = $18, md_format = $2, data = $3, ";
- $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 WHERE metadata_id = $19";
-
- $v = array(
- $this->href,
- $this->format,
- $this->metadata,
- $this->type,
- $this->fileIdentifier,
- $this->title,
- $this->createDate,
- $this->changeDate,
- $this->abstract,
- $this->keywords[0],
- $this->hierachyLevel,
- $this->tmpExtentBegin,
- $this->tmpExtentEnd,
- $this->export2Csw,
- $this->datasetId,
- $this->datasetIdCodeSpace,
- $this->randomId,
- $this->origin,
- //$this->owner, //owner is the old one - maybe here we have something TODO!
- $metadataId[0], //The first metadataId which was found will be selected!
- $this->harvestResult,
- $this->harvestException,
- $this->lineage,
- $this->inspireTopConsistence,
- $this->spatialResType,
- $this->spatialResValue,
- $this->updateFrequency,
- $this->dataFormat,
- $this->inspireCharset,
- $this->refSystem
- );
- $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');
- $res = db_prep_query($sql,$v,$t);
+ $res = $this->updateMetadataById($metadataId[0]);
} else {
//insert new record
$e = new mb_exception("class_Iso19139:"."No existing metadata fileIdentifier found in mapbender metadata table. New record will be inserted with uuid: ".$this->fileIdentifier);
-
- $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) 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)
-SQL;
- $v = array(
- $this->href,
- $this->format,
- $this->metadata,
- $this->type,
- $this->fileIdentifier,
- $this->title,
- $this->createDate,
- $this->changeDate,
- $this->abstract,
- $this->keywords[0],
- $this->hierachyLevel,
- $this->tmpExtentBegin,
- $this->tmpExtentEnd,
- $this->export2Csw,
- $this->datasetId,
- $this->datasetIdCodeSpace,
- $this->randomId,
- $this->origin,
- $this->owner,
- $this->harvestResult,
- $this->harvestException,
- $this->lineage,
- $this->inspireTopConsistence,
- $this->spatialResType,
- $this->spatialResValue,
- $this->updateFrequency,
- $this->dataFormat,
- $this->inspireCharset,
- $this->refSystem
-
- );
- $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');
- $res = db_prep_query($sql,$v,$t);
+ $res = $this->insertMetadataIntoDB();
}
-
}
if(!$res){
db_rollback();
@@ -976,7 +1300,7 @@
return $result;
} else {
//insert relation into db
- //get inserted metadata_id
+ //get inserted metadata_id by use the
$sql = <<<SQL
SELECT metadata_id FROM mb_metadata WHERE randomid = $1
SQL;
@@ -986,11 +1310,11 @@
$res = db_prep_query($sql,$v,$t);
}
catch (Exception $e){
- $e = new mb_exception("class_Iso19139:"._mb("Cannot get metadata record with following uuid from database: ".$uuid));
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot get metadata record with following uuid from database: ".$this->randomId));
}
if (!$res) {
//do nothing
- $e = new mb_exception("class_Iso19139:"._mb("Cannot get metadata record with following uuid from database: ".$uuid));
+ $e = new mb_exception("class_Iso19139:"._mb("Cannot get metadata record with following uuid from database: ".$this->randomId));
$result['value'] = false;
$result['message'] = "Cannot get metadata record with following uuid from database: ".$uuid;
return $result;
@@ -1027,15 +1351,11 @@
$result['value'] = false;
$result['message'] = "Cannot update mb_metadata table to fill in harvest result!";
return $result;
+ } else {
+ $this->insertKeywordsAndCategoriesIntoDB($metadataId);
}
}
}
- //insert keywords into keyword table
- //check if keyword already exists - if not create new one
- //insert relations into database
- //insert relations for categories for topic, inspire, custom
- //1. delete old relations
- //2. create new ones
$result['value'] = true;
$result['message'] = "Insert metadata successfully into database!";
return $result;
Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php 2013-05-23 15:25:13 UTC (rev 8627)
@@ -1,6 +1,30 @@
<?php
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+
+
+ function displayCategories ($sql) {
+ if (Mapbender::session()->get("mb_lang") === "de") {
+ $sql = str_replace("category_code_en", "category_code_de", $sql);
+ }
+
+ $str = "";
+ $res = db_query($sql);
+ while ($row = db_fetch_assoc($res)) {
+ $str .= "<option value='" . $row["id"] . "'>" .
+ htmlentities($row["name"], ENT_QUOTES, CHARSET) .
+ "</option>";
+ }
+ return $str;
+ }
?>
+
+<script type="text/javascript">
+$(function() {
+ $("#tabs").tabs({ active: 1 })
+});
+</script>
+<div class="demo">
+
<fieldset class="ui-widget" id="metadataUrlEditor" name="metadataUrlEditor" type="hidden" style="display: none">
<input name="kindOfMetadataAddOn" id="kindOfMetadataAddOn" type="hidden" value="" />
<fieldset id="addonChooser" name="addonChooser" style="display: none">
@@ -36,7 +60,16 @@
</fieldset>
<!--fieldset for metadata form-->
<fieldset id="simple_metadata_editor" name="simple_metadata_editor" type="hidden" style="display: none">
- <legend><?php echo _mb("Simple metadata editor");?></legend>
+ <div id="tabs">
+ <ul>
+ <li><a href="#tabs-1"><?php echo _mb("Identification");?></a></li>
+ <li><a href="#tabs-2"><?php echo _mb("Classification");?></a></li>
+ <li><a href="#tabs-3"><?php echo _mb("Temporal extent");?></a></li>
+ <li><a href="#tabs-4"><?php echo _mb("Quality");?></a></li>
+ <li><a href="#tabs-5"><?php echo _mb("Spatial Extent");?></a></li>
+ </ul>
+ <!--<legend><?php echo _mb("Simple metadata editor");?></legend>-->
+ <div id="tabs-1">
<fieldset>
<legend><?php echo _mb("Resource title");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This a characteristic, and often unique, name by which the resource is known.");?>'}" src="../img/questionmark.png" alt="" /></legend>
<input class="required" name="title" id="title"/>
@@ -45,18 +78,90 @@
<legend><?php echo _mb("Resource abstract");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This is a brief narrative summary of the content of the resource.");?>'}" src="../img/questionmark.png" alt="" /></legend>
<input class="required" name="abstract" id="abstract"/>
</fieldset>
+ <fieldset id="data_format">
+ <legend><?php echo _mb("Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the computer language construct(s) specifying the representation of data objects in a record, file, message, storage device or transmission channel.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <select class="required format_selectbox" id='format' name='format'>
+ <option value="database"><?php echo _mb("Database");?></option>
+ <option value="shapefile"><?php echo _mb("Esri Shape");?></option>
+ <option value="tab"><?php echo _mb("MapInfo Tab file");?></option>
+ <option value="csv"><?php echo _mb("CSV");?></option>
+ <option value="gml"><?php echo _mb("GML");?></option>
+ <option value="geotiff"><?php echo _mb("GeoTIFF");?></option>
+ </select>
+ </fieldset>
+ <fieldset id="charset">
+ <legend><?php echo _mb("Character Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The character encoding used in the data set. This element is mandatory only if an encoding is used that is not based on UTF-8.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <select class="required charset_selectbox" id='inspire_charset' name='inspire_charset'>
+ <option value="utf8"><?php echo _mb("utf8");?></option>
+ <option value="latin1"><?php echo _mb("latin1");?></option>
+ </select>
+ </fieldset>
+ <fieldset id="referencesystem">
+ <legend><?php echo _mb("Coordinate Reference System");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the coordinate reference system(s) used in the data set.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+<?php
+ if (defined('SRS_ARRAY')) {
+ $srs_array = explode(",", SRS_ARRAY);
+ echo '<select class="required ref_system_selectbox" name="ref_system" id="ref_system">';
+ foreach ($srs_array as $epsg) {
+ echo "<option value='" . "EPSG:" .$epsg . "'>" . _mb("EPSG:".$epsg) . "</option>";
+ }
+ echo "</select>";
+
+ } else {
+ echo '<input name="ref_system" id="ref_system"/>';
+ }
+?>
+ </fieldset>
+ </div>
+ <div id="tabs-2">
+ <fieldset id="md_classification">
+ <legend><?php echo _mb("Classification");?></legend>
<fieldset>
- <legend><?php echo _mb("Lineage");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This is a statement on process history and/or overall quality of the spatial data set. Where appropriate it may include a statement whether the data set has been validated or quality assured, whether it is the official version (if multiple versions exist), and whether it has legal validity. The value domain of this metadata element is free text.");?>'}" src="../img/questionmark.png" alt="" /></legend>
- <input class="required" name="lineage" id="lineage"/>
+ <legend><?php echo _mb("Keywords");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Define a list of comma separated keywords which helps to classify the dataset.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <input class="" name="keywords" id="keywords"/>
</fieldset>
+ <p>
+ <label for="md_md_topic_category_id" class="label_classification"><?php echo _mb("ISO Topic Category");?>:</label>
+ <img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+ <select class="metadata_selectbox" id="md_md_topic_category_id" name="md_md_topic_category_id" size="2" multiple="multiple">
+<?php
+ $sql = "SELECT md_topic_category_id AS id, md_topic_category_code_en AS name FROM md_topic_category";
+ echo displayCategories($sql);
+?>
+ </select>
+ <img id="resetIsoTopicCats" title="<?php echo _mb("Reset selection");?>" src="../img/cross.png" style="cursor:pointer;"/>
+ </p>
+ <p>
+ <label for="md_inspire_category_id" class="label_classification"><?php echo _mb("INSPIRE Category");?>:</label>
+ <img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png" alt="" />
+ <select class="metadata_selectbox" id="md_inspire_category_id" name="md_inspire_category_id" size="2" multiple="multiple">
+<?php
+ $sql = "SELECT inspire_category_id AS id, inspire_category_code_en AS name FROM inspire_category";
+ echo displayCategories($sql);
+?>
+ </select>
+ <img id="resetInspireCats" title="<?php echo _mb("Reset selection");?>" src="../img/cross.png" style="cursor:pointer;"/>
+ </p>
+ <p>
+ <label for="md_custom_category_id" class="label_classification"><?php echo _mb("Custom Category");?>:</label>
+ <span class="metadata_span"></span>
+ <select class="metadata_selectbox" id="md_custom_category_id" name="md_custom_category_id" size="2" multiple="multiple">
+<?php
+ $sql = "SELECT custom_category_id AS id, custom_category_code_en AS name FROM custom_category";
+ echo displayCategories($sql);
+?>
+ </select>
+ <img id="resetCustomCats" title="<?php echo _mb("Reset selection");?>" src="../img/cross.png" style="cursor:pointer;"/>
+ </p>
+ </fieldset>
+ </div>
+ <div id="tabs-3">
<fieldset id="tempref" name="tempref">
<legend><?php echo _mb("TEMPORAL REFERENCE");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This metadata element addresses the requirement to have information on the temporal dimension of the data as referred to in Article 8(2)(d) of Directive 2007/2/EC. At least one of the metadata elements referred to in points 5.1 to 5.4 shall be provided. The value domain of the metadata elements referred to in points 5.1 to 5.4 is a set of dates. Each date shall refer to a temporal reference system and shall be expressed in a form compatible with that system. The default reference system shall be the Gregorian calendar, with dates expressed in accordance with ISO 8601.");?>'}" src="../img/questionmark.png" alt="" /></legend>
<fieldset id="timespan" name="timespan">
<legend><?php echo _mb("Temporal extent");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The temporal extent defines the time period covered by the content of the resource. This time period may be expressed as any of the following: - an individual date, - an interval of dates expressed through the starting date and end date of the interval, - a mix of individual dates and intervals of dates.");?>'}" src="../img/questionmark.png" alt="" /></legend>
- <label for=""><?php echo _mb("from");?>:</label>
- <input class="required hasdatepicker" name="tmp_reference_1" id="tmp_reference_1"/>
- <label for=""><?php echo _mb("to");?>:</label>
- <input class="required hasdatepicker" name="tmp_reference_2" id="tmp_reference_2"/>
+ <p><?php echo _mb("from");?>:</p><input class="required hasdatepicker" name="tmp_reference_1" id="tmp_reference_1"/><br>
+ <p><?php echo _mb("to");?>:</p><input class="required hasdatepicker" name="tmp_reference_2" id="tmp_reference_2"/>
</fieldset>
<fieldset id="cyclicupdate" name="cyclicupdate">
<legend><?php echo _mb("Maintenance and update frequency");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Frequency with which changes and additions are made to the resource after the initial resource is completed. Notice: This value may change the value of the end date of temporal extent. The end date will be computed automatically from the current timestamp if a cyclic update is defined!");?>'}" src="../img/questionmark.png" alt="" /></legend>
@@ -78,7 +183,13 @@
</select>
</fieldset>
</fieldset>
- <fieldset id="spatialres">
+ </div>
+ <div id="tabs-4">
+ <fieldset>
+ <legend><?php echo _mb("Lineage");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("This is a statement on process history and/or overall quality of the spatial data set. Where appropriate it may include a statement whether the data set has been validated or quality assured, whether it is the official version (if multiple versions exist), and whether it has legal validity. The value domain of this metadata element is free text.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+ <input class="required" name="lineage" id="lineage"/>
+ </fieldset>
+ <fieldset id="spatialres">
<legend><?php echo _mb("Spatial resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Spatial resolution refers to the level of detail of the data set. It shall be expressed as a set of zero to many resolution distances (typically for gridded data and imagery-derived products) or equivalent scales (typically for maps or map-derived products). An equivalent scale is generally expressed as an integer value expressing the scale denominator. A resolution distance shall be expressed as a numerical value associated with a unit of length.");?>'}" src="../img/questionmark.png" alt="" /></legend>
<label for="groundDistance">
<input class="required radioRes" name="spatial_res_type" id="groundDistance" type="radio"/ value="groundDistance" checked="checked">
@@ -92,45 +203,21 @@
</label>
<label><?php echo _mb("Value of resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Value of spatial resolution in [m] or scale denominator");?>'}" src="../img/questionmark.png" alt="" /></label>
<input class="required" name="spatial_res_value" id="spatial_res_value"/>
- </fieldset>
- <!-- Dropdown List of CRS which are defined in mapbender.conf. For those CRS the layer extents will be computed by mapbender - this is relevant for INSPIRE.-->
- <fieldset id="referencesystem">
- <legend><?php echo _mb("Coordinate Reference System");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the coordinate reference system(s) used in the data set.");?>'}" src="../img/questionmark.png" alt="" /></legend>
-<?php
- if (defined('SRS_ARRAY')) {
- $srs_array = explode(",", SRS_ARRAY);
- echo '<select class="required ref_system_selectbox" name="ref_system" id="ref_system">';
- foreach ($srs_array as $epsg) {
- echo "<option value='" . "EPSG:" .$epsg . "'>" . _mb("EPSG:".$epsg) . "</option>";
- }
- echo "</select>";
+ </fieldset>
+ <!-- Dropdown List of CRS which are defined in mapbender.conf. For those CRS the layer extents will be computed by mapbender - this is relevant for INSPIRE.-->
- } else {
- echo '<input name="ref_system" id="ref_system"/>';
- }
-?>
- </fieldset>
- <fieldset id="data_format">
- <legend><?php echo _mb("Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Description of the computer language construct(s) specifying the representation of data objects in a record, file, message, storage device or transmission channel.");?>'}" src="../img/questionmark.png" alt="" /></legend>
- <select class="required format_selectbox" id='format' name='format'>
- <option value="database"><?php echo _mb("Database");?></option>
- <option value="shapefile"><?php echo _mb("Esri Shape");?></option>
- <option value="tab"><?php echo _mb("MapInfo Tab file");?></option>
- <option value="csv"><?php echo _mb("CSV");?></option>
- <option value="gml"><?php echo _mb("GML");?></option>
- <option value="geotiff"><?php echo _mb("GeoTIFF");?></option>
- </select>
- </fieldset>
- <fieldset id="charset">
- <legend><?php echo _mb("Character Encoding");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("The character encoding used in the data set. This element is mandatory only if an encoding is used that is not based on UTF-8.");?>'}" src="../img/questionmark.png" alt="" /></legend>
- <select class="required charset_selectbox" id='inspire_charset' name='inspire_charset'>
- <option value="utf8"><?php echo _mb("utf8");?></option>
- <option value="latin1"><?php echo _mb("latin1");?></option>
- </select>
- </fieldset>
- <fieldset id="consistance">
+ <fieldset id="consistance">
<legend><?php echo _mb("Topological Consistency");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Correctness of the explicitly encoded topological characteristics of the data set as described by the scope. This element is mandatory only if the data set includes types from the Generic Network Model and does not assure centreline topology (connectivity of centrelines) for the network.");?>'}" src="../img/questionmark.png" alt="" /></legend>
<input name="inspire_top_consistence" id="inspire_top_consistence" type="checkbox" checked="checked"/>
+ </fieldset>
+
+ </div>
+ <div id="tabs-5">
+ undefined
+ </div>
+ </div><!--accordion-->
+ </div><!--demo-->
</fieldset>
- </fieldset>
+
</fieldset>
+
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2013-05-23 15:25:13 UTC (rev 8627)
@@ -1,7 +1,7 @@
<?php
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
require_once dirname(__FILE__) . "/../classes/class_user.php";
-require_once dirname(__FILE__) . "/../classes/class_wms.php";
+require_once dirname(__FILE__) . "/../classes/class_wms.php";//already includes iso19139!
require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
$ajaxResponse = new AjaxResponse($_POST);
@@ -678,6 +678,7 @@
case "getLayerMetadataAddon" :
$layerId = $ajaxResponse->getParameter("layerId");
$metadataId = $ajaxResponse->getParameter("metadataId");
+
$sql = <<<SQL
SELECT * from mb_metadata where metadata_id = $1
@@ -729,6 +730,37 @@
}
}
+ //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;
@@ -766,6 +798,55 @@
} 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";
+ }
+ }
+
+ 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";
+ }
+ } else {
+ $mbMetadata->keywords[] = $inspireCategories;
+ $mbMetadata->keywordsThesaurusName[] = "GEMET - INSPIRE themes, version 1.0";
+
+ }
+ }
+ if (isset($data->md_custom_category_id)) {
+ $customCategories = $data->md_custom_category_id;
+ if (count($customCategories) > 1 ) {
+ //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";
+ }
+ }
+ } else {
+ $mbMetadata->keywords[] = $customCategories;
+ if (defined("METADATA_DEFAULT_CODESPACE") && METADATA_DEFAULT_CODESPACE != '') {
+ $mbMetadata->keywordsThesaurusName[] = METADATA_DEFAULT_CODESPACE;
+ } else {
+ $mbMetadata->keywordsThesaurusName[] = "http://www.mapbender.org";
+ }
+ }
+ }*/ //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
@@ -782,6 +863,12 @@
$ajaxResponse->send();
die;
}
+ //delete all categories
+ //TODO!!!
+
+ //newly create them
+
+
$ajaxResponse->setMessage("Metadata updated!");
$ajaxResponse->setSuccess(true);
break;
@@ -919,6 +1006,23 @@
if (isset($data->update_frequency)) {
$mbMetadata->updateFrequency = $data->update_frequency;
}
+ //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 ($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;
+ }
//Check if origin is external and export2csw is activated!
if ($origin == 'external' ) {
@@ -947,7 +1051,7 @@
$mbMetadata->randomId = $randomid;
$result = $mbMetadata->insertToDB("layer",$layerId);
-
+ $e = new mb_exception("test to metadata insert/update via metador!");
if ($result['value'] == false) {
$e = new mb_exception("Problem while storing metadata from editor to mb_metadata table!");
$e = new mb_exception($result['message']);
@@ -963,101 +1067,29 @@
case "deleteInternalMetadataLinkage" :
$metadataId = $ajaxResponse->getParameter("metadataId");
$layerId = $ajaxResponse->getParameter("layerId");
- $sql = <<<SQL
+ $resourceId = $layerId;
+ $resourceType = "layer";
+ $mbMetadata = new Iso19139();
+ $result = $mbMetadata->deleteInternalMetadataLinkage($resourceType, $resourceId, $metadataId);
+ $ajaxResponse->setSuccess($result['success']);
+ $ajaxResponse->setMessage($result['message']);
+ //$ajaxResponse->send();
+ //die();
+ break;
-DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_layer_id = $2 and relation_type = 'internal'
-
-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");
- //TODO delete the entry only, if the metadataset has no other relation!!!!!
- //get count of relations for the relevant metadata set
- $sql = "SELECT count(*) as count FROM ows_relation_metadata WHERE fkey_metadata_id = $1";
+ $layerId = $ajaxResponse->getParameter("layerId");
+ $resourceId = $layerId;
+ $resourceType = "layer";
+ $mbMetadata = new Iso19139();
+ $result = $mbMetadata->deleteMetadataAddon($resourceType, $resourceId, $metadataId); //$contentType = "layer" or "featuretype" or ...
+ $ajaxResponse->setSuccess($result['success']);
+ $ajaxResponse->setMessage($result['message']);
+ //$ajaxResponse->send();
+ //die();
+ break;
- $v = array($metadataId);
- $t = array('i');
- try {
- $res = db_prep_query($sql,$v,$t);
- }
- catch (Exception $e){
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Could not determine a count of metadata relations!"));
- $ajaxResponse->send();
- die;
- }
- while ($row = db_fetch_assoc($res)) {
- $countMetadataLinkage = (integer)$row['count']; //integer
- }
- if ($countMetadataLinkage == 1) {
- $e = new mb_exception("Metadata has only one reference and will be deleted from database if it was created by upload or link!");
- //delete the metadata itself cause it has no other reference - really - not right for metador files !!!
- $sql = <<<SQL
-
-DELETE FROM mb_metadata WHERE metadata_id = $1 and origin NOT IN ('metador')
-
-SQL;
- $v = array($metadataId);
- $t = array('i');
- try {
- $res = db_prep_query($sql,$v,$t);
- }
- catch (Exception $e){
- $ajaxResponse->setSuccess(false);
- $ajaxResponse->setMessage(_mb("Could not delete metadata from database!"));
- $ajaxResponse->send();
- die;
- }
- $ajaxResponse->setMessage("Metadata was deleted from database!");
- $ajaxResponse->setSuccess(true);
- break;
-
-
-
- } else {
- $e = new mb_exception("Number of related OWS resources: ".$countMetadataLinkage);
- //only delete the relation
- $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
-
-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 metadata linkage from database!"));
- $ajaxResponse->send();
- die;
- }
- $ajaxResponse->setMessage("Metadata linkage deleted!");
- $ajaxResponse->setSuccess(true);
- }
-
- 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");
@@ -1093,7 +1125,6 @@
$ajaxResponse->setMessage("Uploaded metadata object inserted into md_metadata table!");
$ajaxResponse->setSuccess(true);
}
-
break;
default:
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js 2013-05-23 15:25:13 UTC (rev 8627)
@@ -271,7 +271,7 @@
autoOpen : false,
draggable : true,
modal : true,
- width : 600,
+ width : 700,
position : [600, 75],
buttons: {
"close": function() {
Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddonWfs.js 2013-05-23 15:25:13 UTC (rev 8627)
@@ -270,7 +270,7 @@
autoOpen : false,
draggable : true,
modal : true,
- width : 600,
+ width : 700,
position : [600, 75],
buttons: {
"close": function() {
Modified: trunk/mapbender/http/plugins/mb_metadata_wfs_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-05-22 14:44:51 UTC (rev 8626)
+++ trunk/mapbender/http/plugins/mb_metadata_wfs_server.php 2013-05-23 15:25:13 UTC (rev 8627)
@@ -695,6 +695,7 @@
break;
case "deleteFeaturetypeMetadataAddon" :
$metadataId = $ajaxResponse->getParameter("metadataId");
+ $featuretypeId = $ajaxResponse->getParameter("featuretypeId");
//TODO delete the entry only, if the metadataset has no other relation!!!!!
//get count of relations for the relevant metadata set
$sql = "SELECT count(*) as count FROM ows_relation_metadata WHERE fkey_metadata_id = $1";
@@ -732,7 +733,25 @@
$ajaxResponse->send();
die;
}
- $ajaxResponse->setMessage("Metadata was deleted from database!");
+ //delete link if metadata was not deleted cause it has been created by editor!
+ $sql = <<<SQL
+
+DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_featuretype_id = $2
+
+SQL;
+ $v = array($metadataId, $featuretypeId);
+ $t = array('i','i');
+
+ 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("Metadata and/or linkage was deleted from database!");
$ajaxResponse->setSuccess(true);
break;
@@ -740,8 +759,6 @@
} else {
//only delete the relation
- $metadataId = $ajaxResponse->getParameter("metadataId");
- $featuretypeId = $ajaxResponse->getParameter("featuretypeId");
$sql = <<<SQL
DELETE FROM ows_relation_metadata WHERE fkey_metadata_id = $1 and fkey_featuretype_id = $2
More information about the Mapbender_commits
mailing list