[Mapbender-commits] r7444 - in trunk/mapbender: http/classes
resources/db/pgsql/UTF-8/update tools
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jan 17 12:51:57 EST 2011
Author: armin11
Date: 2011-01-17 09:51:56 -0800 (Mon, 17 Jan 2011)
New Revision: 7444
Added:
trunk/mapbender/tools/mod_updateDatabaseUuid.php
Modified:
trunk/mapbender/http/classes/class_wfsToDb.php
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
Log:
Extent the mapbender wms/layer/wfs/featuretype resources with a column uuid. With this it is easier to generate consistent geo - metadata. The uuid is only generated when insert the data for the first time!
Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php 2011-01-17 16:15:05 UTC (rev 7443)
+++ trunk/mapbender/http/classes/class_wfsToDb.php 2011-01-17 17:51:56 UTC (rev 7444)
@@ -21,6 +21,7 @@
require_once(dirname(__FILE__)."/class_connector.php");
require_once(dirname(__FILE__)."/class_administration.php");
require_once(dirname(__FILE__)."/class_wfs.php");
+require_once dirname(__FILE__) . "//class_Uuid.php";
class WfsToDb {
@@ -45,12 +46,12 @@
*/
public static function insert ($aWfs) {
db_begin();
-
+ $uuid = new Uuid();
$sql = "INSERT INTO wfs (wfs_version, wfs_name, wfs_title, wfs_abstract, ";
$sql .= "wfs_getcapabilities, wfs_getcapabilities_doc, wfs_upload_url, ";
$sql .= "wfs_describefeaturetype, wfs_getfeature, wfs_transaction, fees, ";
- $sql .= "accessconstraints, wfs_owner, wfs_timestamp) ";
- $sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)";
+ $sql .= "accessconstraints, wfs_owner, wfs_timestamp, uuid) ";
+ $sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14,$15)";
$v = array(
$aWfs->getVersion(),
@@ -66,10 +67,11 @@
$aWfs->fees,
$aWfs->accessconstraints,
Mapbender::session()->get("mb_user_id"),
- strtotime("now")
+ strtotime("now"),
+ $uuid
);
- $t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i');
+ $t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 'i','s');
$res = db_prep_query($sql, $v, $t);
@@ -430,18 +432,20 @@
* @param $aWfsFeatureType WfsFeatureType
*/
private static function insertFeatureType ($aWfsFeatureType) {
+ $uuid = new Uuid();
$sql = "INSERT INTO wfs_featuretype (fkey_wfs_id, featuretype_name, " .
- "featuretype_title, featuretype_abstract, featuretype_srs) " .
- "VALUES($1, $2, $3, $4, $5)";
+ "featuretype_title, featuretype_abstract, featuretype_srs, uuid) " .
+ "VALUES($1, $2, $3, $4, $5, $6)";
$v = array(
$aWfsFeatureType->wfs->id,
$aWfsFeatureType->name,
$aWfsFeatureType->title,
$aWfsFeatureType->summary,
- $aWfsFeatureType->srs
+ $aWfsFeatureType->srs,
+ $uuid
);
- $t = array('i','s','s','s','s');
+ $t = array('i','s','s','s','s','s');
$e = new mb_exception("INSERTING FT (FT: $aWfsFeatureType->name)");
$res = db_prep_query($sql,$v,$t);
@@ -747,4 +751,4 @@
return false;
}
}
-?>
\ No newline at end of file
+?>
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2011-01-17 16:15:05 UTC (rev 7443)
+++ trunk/mapbender/http/classes/class_wms.php 2011-01-17 17:51:56 UTC (rev 7444)
@@ -8,6 +8,7 @@
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
require_once dirname(__FILE__) . "/class_connector.php";
require_once dirname(__FILE__) . "/class_user.php";
+require_once dirname(__FILE__) . "//class_Uuid.php";
require_once dirname(__FILE__) . "/class_administration.php";
require_once dirname(__FILE__) . "/class_georss_factory.php";
require_once dirname(__FILE__) . "/class_mb_exception.php";
@@ -1449,7 +1450,7 @@
$authType = '';
}
$admin = new administration();
-
+ $uuid = new Uuid();
$this->checkObj();
db_begin();
@@ -1459,8 +1460,8 @@
$sql .= "accessconstraints, contactperson, contactposition, contactorganization, address, city, ";
$sql .= "stateorprovince, postcode, country, contactvoicetelephone, contactfacsimiletelephone, contactelectronicmailaddress, ";
$sql .= "wms_owner,wms_timestamp,wms_timestamp_create,wms_username,wms_password,wms_auth_type,";
- $sql .= "wms_supportsld, wms_userlayer, wms_userstyle, wms_remotewfs) ";
- $sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32)";
+ $sql .= "wms_supportsld, wms_userlayer, wms_userstyle, wms_remotewfs, uuid) ";
+ $sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33)";
$v = array(
$this->wms_version,
$this->wms_title,
@@ -1493,7 +1494,8 @@
$this->wms_supportsld,
$this->wms_userlayer,
$this->wms_userstyle,
- $this->wms_remotewfs
+ $this->wms_remotewfs,
+ $uuid
);
$t = array(
's','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s',
@@ -1596,14 +1598,15 @@
}
function insertLayer($i,$myWMS){
global $con;
+ $uuid = new Uuid();
$sql = <<<SQL
INSERT INTO layer
(fkey_wms_id, layer_pos, layer_parent, layer_name, layer_title,
layer_queryable, layer_minscale, layer_maxscale, layer_dataurl,
-layer_metadataurl, layer_searchable, layer_abstract)
+layer_metadataurl, layer_searchable, layer_abstract, uuid)
VALUES
-($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
+($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
SQL;
if($this->objLayer[$i]->layer_id != null){
@@ -1620,8 +1623,9 @@
$this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
$this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
$this->objLayer[$i]->layer_metadataurl, $this->objLayer[$i]->layer_searchable,
- $this->objLayer[$i]->layer_abstract);
- $t = array('i','i','s','s','s','i','i','i','s','s','i','s');
+ $this->objLayer[$i]->layer_abstract,
+ $uuid);
+ $t = array('i','i','s','s','s','i','i','i','s','s','i','s','s');
$res = db_prep_query($sql,$v,$t);
if(!$res){
db_rollback();
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql 2011-01-17 16:15:05 UTC (rev 7443)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql 2011-01-17 17:51:56 UTC (rev 7444)
@@ -120,3 +120,9 @@
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION mb_monitor_after() OWNER TO postgres;
+--new columns with uuids for resources wms, layer, wfs, featuretype - is needed to generate konsistent metadatasets
+--you need a postgres >= 8.3 cause the new datatype uuid is used!
+ALTER TABLE wms ADD COLUMN uuid UUID;
+ALTER TABLE layer ADD COLUMN uuid UUID;
+ALTER TABLE wfs ADD COLUMN uuid UUID;
+ALTER TABLE wfs_featuretype ADD COLUMN uuid UUID;
Added: trunk/mapbender/tools/mod_updateDatabaseUuid.php
===================================================================
--- trunk/mapbender/tools/mod_updateDatabaseUuid.php (rev 0)
+++ trunk/mapbender/tools/mod_updateDatabaseUuid.php 2011-01-17 17:51:56 UTC (rev 7444)
@@ -0,0 +1,147 @@
+<?php
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/*
+ALTER TABLE wms ADD COLUMN uuid UUID;
+ALTER TABLE layer ADD COLUMN uuid UUID;
+ALTER TABLE wfs ADD COLUMN uuid UUID;
+ALTER TABLE wfs_featuretype ADD COLUMN uuid UUID;
+*/
+
+
+require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
+/*
+//DROP uuid columns
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wms DROP COLUMN uuid;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE layer DROP COLUMN uuid;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wfs DROP COLUMN uuid;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wfs_featuretype DROP COLUMN uuid;";
+$res = db_prep_query($sql,$v,$t);
+
+//generate new columns
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wms ADD COLUMN uuid UUID;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE layer ADD COLUMN uuid UUID;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wfs ADD COLUMN uuid UUID;";
+$res = db_prep_query($sql,$v,$t);
+
+$v = array();
+$t = array();
+$sql = "ALTER TABLE wfs_featuretype ADD COLUMN uuid UUID;";
+$res = db_prep_query($sql,$v,$t);
+
+*/
+
+//update wms table
+$v = array();
+$t = array();
+$sql = "SELECT wms_id FROM wms WHERE uuid IS NULL;";
+$res = db_prep_query($sql,$v,$t);
+$countWmsWithoutUuid = 0;
+while($row = db_fetch_array($res)){
+ $wmsId = $row['wms_id'];
+ $uuid = new Uuid();
+ $vUpdate = array($uuid,$wmsId);
+ $tUpdate = array('s');
+ $sqlUpdate = "UPDATE wms set uuid = $1 WHERE wms_id = $2;";
+ $resUpdate = db_prep_query($sqlUpdate,$vUpdate,$tUpdate);
+ $countWmsWithoutUuid++;
+}
+echo $countWmsWithoutUuid." WMS updated!";
+echo "<br>";
+//end -- update wms table
+//update layer table
+$v = array();
+$t = array();
+$sql = "SELECT layer_id FROM layer WHERE uuid IS NULL;";
+$res = db_prep_query($sql,$v,$t);
+$countLayerWithoutUuid = 0;
+while($row = db_fetch_array($res)){
+ $layerId = $row['layer_id'];
+ $uuid = new Uuid();
+ $vUpdate = array($uuid,$layerId);
+ $tUpdate = array('s');
+ $sqlUpdate = "UPDATE layer set uuid = $1 WHERE layer_id = $2;";
+ $resUpdate = db_prep_query($sqlUpdate,$vUpdate,$tUpdate);
+ $countLayerWithoutUuid++;
+}
+echo $countLayerWithoutUuid." Layer updated!";
+echo "<br>";
+//end -- update layer table
+//update wfs table
+$v = array();
+$t = array();
+$sql = "SELECT wfs_id FROM wfs WHERE uuid IS NULL;";
+$res = db_prep_query($sql,$v,$t);
+$countWfsWithoutUuid = 0;
+while($row = db_fetch_array($res)){
+ $wfsId = $row['wfs_id'];
+ $uuid = new Uuid();
+ $vUpdate = array($uuid,$wfsId);
+ $tUpdate = array('s');
+ $sqlUpdate = "UPDATE wfs set uuid = $1 WHERE wfs_id = $2;";
+ $resUpdate = db_prep_query($sqlUpdate,$vUpdate,$tUpdate);
+ $countWfsWithoutUuid++;
+}
+echo $countWfsWithoutUuid." Wfs updated!";
+echo "<br>";
+//end -- update wfs table
+//update featuretype table
+$v = array();
+$t = array();
+$sql = "SELECT featuretype_id FROM wfs_featuretype WHERE uuid IS NULL;";
+$res = db_prep_query($sql,$v,$t);
+$countFeaturetypeWithoutUuid = 0;
+while($row = db_fetch_array($res)){
+ $featuretypeId = $row['featuretype_id'];
+ $uuid = new Uuid();
+ $vUpdate = array($uuid,$featuretypeId);
+ $tUpdate = array('s');
+ $sqlUpdate = "UPDATE wfs_featuretype set uuid = $1 WHERE featuretype_id = $2;";
+ $resUpdate = db_prep_query($sqlUpdate,$vUpdate,$tUpdate);
+ $countFeaturetypeWithoutUuid++;
+}
+echo $countFeaturetypeWithoutUuid." Featuretype updated!";
+echo "<br>";
+//end -- update featuretype table
+
+?>
More information about the Mapbender_commits
mailing list