[Mapbender-commits] r9540 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Jul 13 08:10:59 PDT 2016
Author: armin11
Date: 2016-07-13 08:10:58 -0700 (Wed, 13 Jul 2016)
New Revision: 9540
Modified:
trunk/mapbender/http/classes/class_iso19139.php
Log:
Bugfixes
Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php 2016-07-13 13:20:26 UTC (rev 9539)
+++ trunk/mapbender/http/classes/class_iso19139.php 2016-07-13 15:10:58 UTC (rev 9540)
@@ -17,6 +17,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_Uuid.php");
require_once dirname(__FILE__) . "/../../tools/wms_extent/extent_service.conf";
class Iso19139 {
//values for handling apriori ows metadataurls
@@ -100,7 +101,7 @@
$this->hierachyLevel = "dataset";
$this->tmpExtentBegin = "1900-01-01";
$this->tmpExtentEnd = "1900-01-01";
- $this->randomId = "";
+ $this->randomId = new Uuid();
$this->owner = 0; //dummy entry for metadata owner - in case of metadataURL entries the owner of the corresponding service
$this->href = "";
$this->format = "";
@@ -489,6 +490,9 @@
}
$metadataConnector = new connector($url);
$metadataConnector->set("timeOut", "5");
+ if ($metadataConnector->timedOut == true) {
+ return false;
+ }
$xml = $metadataConnector->file;
$mbMetadata = $this->createMapbenderMetadataFromXML($xml);
return $mbMetadata;
@@ -1305,7 +1309,7 @@
public function isLinkAlreadyInDB(){
$sql = <<<SQL
-SELECT metadata_id FROM mb_metadata WHERE link = $1 AND link <> '' ORDER BY lastchanged DESC
+SELECT metadata_id FROM mb_metadata WHERE link = $1 AND link <> '' AND link IS NOT NULL ORDER BY lastchanged DESC
SQL;
$v = array(
$this->href
@@ -1315,8 +1319,8 @@
while ($row = db_fetch_array($res)){
$metadataId[] = $row['metadata_id'];
}
- if (count($metadataId) > 0) {
- return $metadataId;
+ if (count($metadataId) > 0 && count($metadataId) < 2) {
+ return $metadataId[0];
} else {
return false;
}
@@ -1324,7 +1328,7 @@
public function isFileIdentifierAlreadyInDB(){
$sql = <<<SQL
-SELECT metadata_id, createdate FROM mb_metadata WHERE uuid = $1 AND uuid <> '' ORDER BY lastchanged DESC
+SELECT metadata_id, createdate FROM mb_metadata WHERE uuid = $1 AND uuid <> '' AND uuid IS NOT NULL ORDER BY lastchanged DESC LIMIT 1
SQL;
if (!isset($this->fileIdentifier) || $this->fileIdentifier == '') {
$e = new mb_exception("class_Iso19139:"."Empty or no fileIdentifier found in the metadata! No metadataset will be updated");
@@ -1339,8 +1343,8 @@
while ($row = db_fetch_array($res)){
$metadataId[] = $row['metadata_id'];
}
- if (count($metadataId) > 0) {
- return $metadataId;
+ if (count($metadataId) > 0 && count($metadataId) < 2) {
+ return $metadataId[0];
} else {
return false;
}
@@ -1403,6 +1407,9 @@
//map category name to id before insert them into db!
//read maptable from db
//iso - code in xml
+ if ($resourceType == "wms" || $resourceType == "wfs" || $resourceType == "inspire_dls_atom" || $resourceType == "inspire_dls_atom_dataset") {
+ return false;
+ }
switch ($resourceType) {
case "featuretype":
$tablePrefix = 'wfs_featuretype';
@@ -1655,6 +1662,9 @@
}
public function deleteCategoriesFromCoupledResource($metadataId,$resourceType,$resourceId) {
+ if ($resourceType == 'inspire_dls_atom' || $resourceType == 'inspire_dls_atom_dataset') {
+ return false;
+ }
//delete inherited categories from coupled resources: layer/featuretype
switch ($resourceType) {
case "featuretype":
@@ -1772,7 +1782,7 @@
public function insertMetadataIntoDB() {
//insert an instance for iso19139 into mapbenders database
- $e = new mb_exception("class_iso19139.php: insert metadata with title: ".$this->title);
+ $e = new mb_notice("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, constraints, responsible_party_name, responsible_party_email, preview_image) 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, $40, $41, $42)
SQL;
@@ -1875,6 +1885,7 @@
}
public function updateMetadataById($metadataId) {
+ $e = new mb_exception("update metadata id: ".$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!
@@ -1943,7 +1954,7 @@
$metadataId = $this->isLinkAlreadyInDB();
if ($metadataId != false) {
//update the metadataURL entry
- $e = new mb_notice("class_Iso19139:"."existing metadata link(s) found: ".$metadataId[0]." - update will be performed");
+ $e = new mb_notice("class_Iso19139:"."existing metadata link(s) found: ".$metadataId." - update will be performed");
$sql = "UPDATE mb_metadata SET link = $1, origin = $2, md_format = $3, linktype = $4, changedate = now(), export2csw = $5, randomid = $6, harvestresult = $8, harvestexception = $9 WHERE metadata_id = $7";
$v = array(
$this->href,
@@ -1952,7 +1963,7 @@
$this->type,
'f',
$this->randomId,
- $metadataId[0],
+ $metadataId,
$this->harvestResult,
$this->harvestException
);
@@ -2157,26 +2168,28 @@
//check if metadata record already exists, if not create a new one, else insert relation only and update the metadata itself!
$metadataId = $this->isFileIdentifierAlreadyInDB();
-
+ $e = new mb_exception("found metadata_id: ".$metadataId);
+
if ($metadataId != false) {
//update the metadata - new random id set therefor there is no problem when setting the relation afterwards
- $e = new mb_notice("existing metadata fileIdentifier found at metadata with id: ".$metadataId[0]." - update will be performed");
+ $e = new mb_notice("existing metadata fileIdentifier found at metadata with id: ".$metadataId." - update will be performed");
//TODO: Check if the timestamp of an existing metadata element is not newer than the timestamp of the current metadata object!!!!
//for uploaded metadata the harvesting was ok otherwise the function returned before
- $res = $this->updateMetadataById($metadataId[0]);
+ $res = $this->updateMetadataById($metadataId);
- $this->insertKeywordsAndCategoriesIntoDB($metadataId[0],$resourceType,$resourceId);
+ $this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
} else {
//check if href already exists
$metadataId = $this->isLinkAlreadyInDB();
+ $e = new mb_exception("found metadata_id by link : ".$metadataId);
//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_notice("existing metadata linkage found at metadata with id: ".$metadataId[0]." - update will be performed");
+ $e = new mb_notice("existing metadata linkage found at metadata with id: ".$metadataId." - update will be performed");
//check if the timestamp of an existing metadata element is not newer than the timestamp of the current metadata object!!!!
- $res = $this->updateMetadataById($metadataId[0]);
- $this->insertKeywordsAndCategoriesIntoDB($metadataId[0],$resourceType,$resourceId);
+ $res = $this->updateMetadataById($metadataId);
+ $this->insertKeywordsAndCategoriesIntoDB($metadataId,$resourceType,$resourceId);
} else {
//insert new record
$e = new mb_notice("class_Iso19139:"."No existing metadata fileIdentifier found in mapbender metadata table. New record will be inserted with uuid: ".$this->fileIdentifier);
@@ -2192,7 +2205,7 @@
return $result;
} else {
//insert relation into db
- //get inserted metadata_id by use the
+ //get inserted or updated metadata_id by use the randomid
$sql = <<<SQL
SELECT metadata_id FROM mb_metadata WHERE randomid = $1
SQL;
More information about the Mapbender_commits
mailing list