Skip to content

Commit

Permalink
Insert node: show message if catalog not found
Browse files Browse the repository at this point in the history
Bug fix getting rowcount after a SQL execution
  • Loading branch information
daviderill committed Aug 25, 2016
1 parent 83b358f commit 46aa54b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions dao/pg_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def execute_sql(self, sql, autocommit=True):
return status


def get_rowcount(self):
return self.cursor.rowcount


def commit(self):
self.conn.commit()

Expand Down
7 changes: 5 additions & 2 deletions map_tools/point_map_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ def __init__(self, iface, settings, action, index_action, controller, srid):
self.canvas = self.iface.mapCanvas()
self.settings = settings
self.index_action = index_action
self.controller = controller
self.srid = srid
self.elem_type_type = self.settings.value('insert_values/'+str(index_action)+'_elem_type_type')
self.dao = controller.dao
self.schema_name = controller.schema_name
self.dao = controller.dao
self.table_node = self.settings.value('db/table_node', 'v_edit_node')
QgsMapTool.__init__(self, self.canvas)
self.setAction(action)
Expand Down Expand Up @@ -52,6 +53,8 @@ def insert_node(self, x, y):
if row:
last_id = row[0]
return last_id
else:
self.controller.show_info("Any record found in table 'cat_node' related with selected 'node_type.type'")


''' QgsMapTools inherited event functions '''
Expand All @@ -69,7 +72,7 @@ def canvasReleaseEvent(self, e):
# Insert new node into selected point. Open its feature form
last_id = self.insert_node(int(self.point.x()), int(self.point.y()))
if last_id != -1:
filter_expr = "node_id = "+str(last_id)
filter_expr = "node_id = '"+str(last_id)+"'"
expr = QgsExpression(filter_expr)
f_request = QgsFeatureRequest(expr)
f_iterator = layer.getFeatures(f_request)
Expand Down
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name=giswater
qgisMinimumVersion=2.8
description=Plugin to enable additional features and capabilities of Giswater working together with QGIS and PostgreSQL
about=Giswater is a open source tool with the goal to move from acquired knowledge to shared knowledge in the areas of water management, such as supply, sewerage, urban drainage or flood risk assessment with to communicate any water simulation software through any Spatial database with any Geographic Information System (GIS) in order to give everybody a real way of open solution of water management.
version=0.8
version=0.9
author=David Erill, Vicente Medina, Xavi Torret

# End of mandatory metadata
Expand Down
2 changes: 1 addition & 1 deletion ws_node_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def save_tab_add_info(self):
sql+= " vmax = "+str(vmax)+ ", area = "+str(area)
sql+= " WHERE node_id = '"+self.id+"';"
self.dao.execute_sql(sql)
total = self.dao.rowcount
total = self.dao.get_rowcount()
# Perform an INSERT if any record has been updated
# TODO: If trigger was working correctly this wouldn't be necessary!
if total == 0:
Expand Down

0 comments on commit 46aa54b

Please sign in to comment.