|
@@ -21,7 +21,6 @@ from .core import (
|
|
get_sql_template_path,
|
|
get_sql_template_path,
|
|
get_tgis_metadata,
|
|
get_tgis_metadata,
|
|
get_current_mapset,
|
|
get_current_mapset,
|
|
- get_enable_mapset_check,
|
|
|
|
get_tgis_db_version_from_metadata,
|
|
get_tgis_db_version_from_metadata,
|
|
)
|
|
)
|
|
from .abstract_dataset import AbstractDataset, AbstractDatasetComparisonKeyStartTime
|
|
from .abstract_dataset import AbstractDataset, AbstractDatasetComparisonKeyStartTime
|
|
@@ -1768,15 +1767,12 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
granularity
|
|
granularity
|
|
|
|
|
|
"""
|
|
"""
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to shift dataset <%(ds)s> of type "
|
|
"Unable to shift dataset <%(ds)s> of type "
|
|
"%(type)s in the temporal database. The mapset "
|
|
"%(type)s in the temporal database. The mapset "
|
|
- "of the dataset does not match the current "
|
|
|
|
|
|
+ "of the database does not match the current "
|
|
"mapset"
|
|
"mapset"
|
|
)
|
|
)
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
@@ -1946,15 +1942,12 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
|
|
|
|
"""
|
|
"""
|
|
|
|
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to snap dataset <%(ds)s> of type "
|
|
"Unable to snap dataset <%(ds)s> of type "
|
|
"%(type)s in the temporal database. The mapset "
|
|
"%(type)s in the temporal database. The mapset "
|
|
- "of the dataset does not match the current "
|
|
|
|
|
|
+ "of the database does not match the current "
|
|
"mapset"
|
|
"mapset"
|
|
)
|
|
)
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
@@ -2056,15 +2049,12 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
:param dbif: The database interface to be used
|
|
:param dbif: The database interface to be used
|
|
"""
|
|
"""
|
|
|
|
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to rename dataset <%(ds)s> of type "
|
|
"Unable to rename dataset <%(ds)s> of type "
|
|
"%(type)s in the temporal database. The mapset "
|
|
"%(type)s in the temporal database. The mapset "
|
|
- "of the dataset does not match the current "
|
|
|
|
|
|
+ "of the database does not match the current "
|
|
"mapset"
|
|
"mapset"
|
|
)
|
|
)
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
% ({"ds": self.get_id()}, {"type": self.get_type()})
|
|
@@ -2148,15 +2138,12 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
% (self.get_new_map_instance(ident=None).get_type(), self.get_id())
|
|
% (self.get_new_map_instance(ident=None).get_type(), self.get_id())
|
|
)
|
|
)
|
|
|
|
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to delete dataset <%(ds)s> of type "
|
|
"Unable to delete dataset <%(ds)s> of type "
|
|
"%(type)s from the temporal database. The mapset"
|
|
"%(type)s from the temporal database. The mapset"
|
|
- " of the dataset does not match the current "
|
|
|
|
|
|
+ " of the database does not match the current "
|
|
"mapset"
|
|
"mapset"
|
|
)
|
|
)
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
@@ -2212,6 +2199,8 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
|
|
|
|
is_registered = False
|
|
is_registered = False
|
|
|
|
|
|
|
|
+ # TODO: use mapset of the corresponding stds
|
|
|
|
+
|
|
# Check if map is already registered
|
|
# Check if map is already registered
|
|
if stds_register_table is not None:
|
|
if stds_register_table is not None:
|
|
if dbif.get_dbmi().paramstyle == "qmark":
|
|
if dbif.get_dbmi().paramstyle == "qmark":
|
|
@@ -2249,14 +2238,14 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
:return: True if success, False otherwise
|
|
:return: True if success, False otherwise
|
|
"""
|
|
"""
|
|
|
|
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ # only modify database in current mapset
|
|
|
|
+ mapset = get_current_mapset()
|
|
|
|
+
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to register map in dataset <%(ds)s> of "
|
|
"Unable to register map in dataset <%(ds)s> of "
|
|
- "type %(type)s. The mapset of the dataset does "
|
|
|
|
|
|
+ "type %(type)s. The mapset of the database does "
|
|
"not match the current mapset"
|
|
"not match the current mapset"
|
|
)
|
|
)
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
@@ -2264,7 +2253,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
|
|
|
|
dbif, connection_state_changed = init_dbif(dbif)
|
|
dbif, connection_state_changed = init_dbif(dbif)
|
|
|
|
|
|
- if map.is_in_db(dbif) is False:
|
|
|
|
|
|
+ if map.is_in_db(dbif, mapset=self.get_mapset()) is False:
|
|
dbif.close()
|
|
dbif.close()
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
@@ -2295,8 +2284,8 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
% (map.get_type(), map.get_map_id(), map.get_type(), self.get_id()),
|
|
% (map.get_type(), map.get_map_id(), map.get_type(), self.get_id()),
|
|
)
|
|
)
|
|
|
|
|
|
- # First select all data from the database
|
|
|
|
- map.select(dbif)
|
|
|
|
|
|
+ # First select all data from the database in the current mapset
|
|
|
|
+ map.select(dbif, mapset=mapset)
|
|
|
|
|
|
if not map.check_for_correct_time():
|
|
if not map.check_for_correct_time():
|
|
if map.get_layer():
|
|
if map.get_layer():
|
|
@@ -2390,9 +2379,11 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
% {"id": self.get_id(), "map": map.get_map_id()}
|
|
% {"id": self.get_id(), "map": map.get_map_id()}
|
|
)
|
|
)
|
|
|
|
|
|
- if get_enable_mapset_check() is True and stds_mapset != map_mapset:
|
|
|
|
|
|
+ if stds_mapset != mapset:
|
|
dbif.close()
|
|
dbif.close()
|
|
- self.msgr.fatal(_("Only maps from the same mapset can be registered"))
|
|
|
|
|
|
+ self.msgr.fatal(
|
|
|
|
+ _("Maps can only registered in a database in the current mapset")
|
|
|
|
+ )
|
|
|
|
|
|
# Check if map is already registered
|
|
# Check if map is already registered
|
|
if self.is_map_registered(map_id, dbif=dbif):
|
|
if self.is_map_registered(map_id, dbif=dbif):
|
|
@@ -2421,7 +2412,8 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
statement += dbif.mogrify_sql_statement((sql, (map_id,)))
|
|
statement += dbif.mogrify_sql_statement((sql, (map_id,)))
|
|
|
|
|
|
# Now execute the insert transaction
|
|
# Now execute the insert transaction
|
|
- dbif.execute_transaction(statement)
|
|
|
|
|
|
+ # only databases in the current mapset can be modified
|
|
|
|
+ dbif.execute_transaction(statement, mapset=stds_mapset)
|
|
|
|
|
|
if connection_state_changed:
|
|
if connection_state_changed:
|
|
dbif.close()
|
|
dbif.close()
|
|
@@ -2448,18 +2440,14 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
string, None in case of a failure
|
|
string, None in case of a failure
|
|
"""
|
|
"""
|
|
|
|
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+ # only modify database in current mapset
|
|
|
|
+ mapset = get_current_mapset()
|
|
|
|
+
|
|
|
|
+ if self.get_mapset() != mapset:
|
|
|
|
+ self.msgr.debug(1, "STDS name <%s>" % self.get_name())
|
|
|
|
+ dbif.close()
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
- _(
|
|
|
|
- "Unable to unregister map from dataset <%(ds)s>"
|
|
|
|
- " of type %(type)s in the temporal database."
|
|
|
|
- " The mapset of the dataset does not match the"
|
|
|
|
- " current mapset"
|
|
|
|
- )
|
|
|
|
- % {"ds": self.get_id(), "type": self.get_type()}
|
|
|
|
|
|
+ _("Maps can only unregistered in a database in the current mapset")
|
|
)
|
|
)
|
|
|
|
|
|
statement = ""
|
|
statement = ""
|
|
@@ -2509,7 +2497,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
statement += dbif.mogrify_sql_statement((sql, (map.get_id(),)))
|
|
statement += dbif.mogrify_sql_statement((sql, (map.get_id(),)))
|
|
|
|
|
|
if execute:
|
|
if execute:
|
|
- dbif.execute_transaction(statement)
|
|
|
|
|
|
+ dbif.execute_transaction(statement, mapset=mapset)
|
|
statement = ""
|
|
statement = ""
|
|
|
|
|
|
if connection_state_changed:
|
|
if connection_state_changed:
|
|
@@ -2535,15 +2523,13 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
|
|
|
|
:param dbif: The database interface to be used
|
|
:param dbif: The database interface to be used
|
|
"""
|
|
"""
|
|
- if (
|
|
|
|
- get_enable_mapset_check() is True
|
|
|
|
- and self.get_mapset() != get_current_mapset()
|
|
|
|
- ):
|
|
|
|
|
|
+
|
|
|
|
+ if self.get_mapset() != get_current_mapset():
|
|
self.msgr.fatal(
|
|
self.msgr.fatal(
|
|
_(
|
|
_(
|
|
"Unable to update dataset <%(ds)s> of type "
|
|
"Unable to update dataset <%(ds)s> of type "
|
|
"%(type)s in the temporal database. The mapset"
|
|
"%(type)s in the temporal database. The mapset"
|
|
- " of the dataset does not match the current "
|
|
|
|
|
|
+ " of the database does not match the current "
|
|
"mapset"
|
|
"mapset"
|
|
)
|
|
)
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
% {"ds": self.get_id(), "type": self.get_type()}
|
|
@@ -2614,7 +2600,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
sql_script += sql
|
|
sql_script += sql
|
|
sql_script += "\n"
|
|
sql_script += "\n"
|
|
|
|
|
|
- dbif.execute_transaction(sql_script)
|
|
|
|
|
|
+ dbif.execute_transaction(sql_script, mapset=self.base.mapset)
|
|
|
|
|
|
# Read and validate the selected end time
|
|
# Read and validate the selected end time
|
|
self.select(dbif)
|
|
self.select(dbif)
|
|
@@ -2694,7 +2680,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
|
|
sql = sql.replace("SPACETIME_ID", self.base.get_id())
|
|
sql = sql.replace("SPACETIME_ID", self.base.get_id())
|
|
sql = sql.replace("STDS", self.get_type())
|
|
sql = sql.replace("STDS", self.get_type())
|
|
|
|
|
|
- dbif.execute_transaction(sql)
|
|
|
|
|
|
+ dbif.execute_transaction(sql, mapset=self.base.mapset)
|
|
|
|
|
|
# Count the temporal map types
|
|
# Count the temporal map types
|
|
maps = self.get_registered_maps_as_objects(dbif=dbif)
|
|
maps = self.get_registered_maps_as_objects(dbif=dbif)
|