Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion odmtools/controller/frmSeriesSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def refreshTableSeries(self, db):

:return:
"""

chcklist= self.tblSeries.GetCheckedObjects()


self.memDB.set_series_service(db)
object = self.series_service.get_all_series()
#checkedObjs = self.tblSeries.GetCheckedObjects()
Expand All @@ -93,6 +97,10 @@ def refreshTableSeries(self, db):
if x.id not in idList:
self.tblSeries.AddObject(x)


for c in chcklist:
self.tblSeries.SetCheckState(c, True)

#for x in checkedObjs:
# super(FastObjectListView, self.tblSeries).SetCheckState(x, True)

Expand All @@ -101,10 +109,18 @@ def refreshSeries(self):

:return:
"""
chcklist= self.tblSeries.GetCheckedObjects()
self.series_service = None

self.series_service = self.parent.Parent.createService()
#self.refreshTableSeries(self.dbservice)
self.resetDB(self.series_service)
for c in chcklist:
for val in self.tblSeries.GetObjects():
if c == val:
self.tblSeries.SetCheckState(val, True)
break

logger.debug("Repopulate Series Selector")

def initSVBoxes(self):
Expand Down Expand Up @@ -558,9 +574,14 @@ def stopEdit(self):

:return:
"""

self.isEditing = False
chcklist= self.tblSeries.GetCheckedObjects()

self.tblSeries.RefreshObject(self.tblSeries.editingObject)
self.tblSeries.editingObject = None
for c in chcklist:
self.tblSeries.SetCheckState(c, True)

self.memDB.stopEdit()

def isEditing(self):
Expand Down
20 changes: 10 additions & 10 deletions odmtools/controller/logicPlotOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,20 @@ def getEditSeriesID(self):
else:
return None




def updateEditSeries(self):
#update values
if self.editID in self._seriesInfos:
# self._seriesInfos[self.editID].dataTable = self.memDB.getEditDataValuesforGraph()
data =self.memDB.getEditDataValuesforGraph()
self._seriesInfos[self.editID].dataTable = data

def setEditSeries(self, seriesID):

self.editID = int(seriesID)
# self.memDB.initEditValues(self.editID)

if self.editID not in self._seriesInfos:
self.update(self.editID, True)
# self.getSeriesInfo(self.editID)
Expand All @@ -144,15 +153,6 @@ def setEditSeries(self, seriesID):
self._seriesInfos[self.editID].plotcolor = self._seriesInfos[self.editID].color
self._seriesInfos[self.editID].color = "Black"


def updateEditSeries(self):
#update values
if self.editID in self._seriesInfos:
# self._seriesInfos[self.editID].dataTable = self.memDB.getEditDataValuesforGraph()
data =self.memDB.getEditDataValuesforGraph()
self._seriesInfos[self.editID].dataTable = data


def stopEditSeries(self):
if self.editID in self._seriesInfos:
data = self.memDB.getDataValuesforGraph(
Expand Down
19 changes: 12 additions & 7 deletions odmtools/gui/frmODMTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class frmODMToolsMain(wx.Frame):

def __init__(self, **kwargs):
"""

"""

self.taskserver = kwargs.pop('taskServer')
Expand Down Expand Up @@ -438,12 +437,18 @@ def addEdit(self, event):

def stopEdit(self, event):

self.pnlSelector.stopEdit()
self.dataTable.stopEdit()
self.pnlPlot.stopEdit()
Publisher.sendMessage("toggleEdit", checked=False)
self.record_service = None
self._ribbon.toggleEditButtons(False)
val = wx.MessageBox( "Are you sure you want to stop editing",
'Stop Editing?', wx.YES_NO | wx.ICON_QUESTION, parent=self)
if val == 2: #_YES

self.pnlSelector.stopEdit()

self.dataTable.stopEdit()
self.pnlPlot.stopEdit()
Publisher.sendMessage("toggleEdit", checked=False)
self.memDB.reset_edit()
self.record_service = None
self._ribbon.toggleEditButtons(False)


def getRecordService(self):
Expand Down
3 changes: 3 additions & 0 deletions odmtools/gui/mnuPlotToolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ def stopEdit(self):
self.xys = None
self.editCurve = None
self.lassoAction = None
# untoggle select button
self.ToggleTool(self.select_tool.Id, False)
# disable select button
self.select_tool.Enable(False)

self.zoom_to_data.Enable(False)
self.Realize()
#untoggle lasso button
Expand Down
12 changes: 1 addition & 11 deletions odmtools/gui/plotTimeSeries.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def changePlotSelection(self, filtered_datetime):
def lassoChangeSelection(self, filtered_datetime):
self.parent.record_service.select_points(dataframe=filtered_datetime)


def onShowLegend(self, isVisible):
if isVisible:
self.isShowLegendEnabled = True
Expand Down Expand Up @@ -304,10 +303,6 @@ def Plot(self, seriesPlotInfo):
self.toolbar.update()
self.toolbar.push_current()

#self._views.home()
#self._positions.home()
#self.set_history_buttons()

#clear plot
def clear(self):
"""
Expand All @@ -319,12 +314,7 @@ def clear(self):
for key, ax in self.axislist.items():
ax.clear()
self.axislist = {}
#self.canvas.draw()
# self.stopEdit()
#print "TimeSeries: ", dir(self.timeSeries), type(self.timeSeries)
#plt.cla()
#plt.clf()
#self.timeSeries.plot([], [], picker=5)



def setUpYAxis(self):
Expand Down
16 changes: 16 additions & 0 deletions odmtools/odmdata/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ class Series(Base):
def __repr__(self):
return "<Series('%s', '%s', '%s', '%s')>" % (self.id, self.site_name, self.variable_code, self.variable_name)

def __eq__(self, other) :
# return self.__dict__ == other.__dict__
return [self.id, self.site_id, self.site_code, self.site_name, self.variable_id, self.variable_code,
self.variable_name, self.speciation, self.variable_units_id, self.variable_units_name,
self.sample_medium, self.value_type, self.time_support, self.time_units_id, self.time_units_name,
self.data_type, self.general_category, self.method_id, self.method_description,
self.source_id, self.source_description, self.organization, self.citation,
self.quality_control_level_id, self.quality_control_level_code, self.begin_date_time,
self.end_date_time, self.begin_date_time_utc, self.end_date_time_utc, self.value_count] ==\
[other.id, other.site_id, other.site_code, other.site_name, other.variable_id, other.variable_code,
other.variable_name, other.speciation, other.variable_units_id, other.variable_units_name,
other.sample_medium, other.value_type, other.time_support, other.time_units_id, other.time_units_name,
other.data_type, other.general_category, other.method_id, other.method_description,
other.source_id, other.source_description, other.organization, other.citation,
other.quality_control_level_id, other.quality_control_level_code, other.begin_date_time,
other.end_date_time, other.begin_date_time_utc, other.end_date_time_utc, other.value_count]

def get_table_columns(self):
return self.__table__.columns.keys()
Expand Down
44 changes: 38 additions & 6 deletions odmtools/odmservices/service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, debug=False):
f = self._get_file('r')
self._conn_dicts = []
self.version = 0
self._connection_format = "%s+%s://%s:%s@%s/%s"


# Read all lines (connections) in the connection.cfg file
while True:
Expand Down Expand Up @@ -185,30 +185,62 @@ def _get_file(self, mode):

return config_file

# def _build_connection_string(self, conn_dict):
# driver = ""
# connformat= self._connection_format
# if conn_dict['engine'] == 'mssql' and sys.platform != 'win32':
# driver = "pyodbc"
# quoted = urllib.quote_plus('DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password']))
# conn_string = 'mssql+pyodbc:///?odbc_connect={}'.format(quoted)
#
# else:
# if conn_dict['engine'] == 'mssql':
# driver = "pyodbc"
# connformat=self._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
# elif conn_dict['engine'] == 'mysql':
# driver = "pymysql"
# elif conn_dict['engine'] == 'postgresql':
# driver = "psycopg2"
# else:
# driver = "None"
#
# conn_string = connformat % (
# conn_dict['engine'], driver, conn_dict['user'], conn_dict['password'], conn_dict['address'],
# conn_dict['db'])
# return conn_string
def _build_connection_string(self, conn_dict):
driver = ""
connformat= self._connection_format
# driver = ""
# print "****", conn_dict

if conn_dict['engine'] == 'mssql' and sys.platform != 'win32':
driver = "pyodbc"
#'DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password'])
quoted = urllib.quote_plus('DRIVER={FreeTDS};DSN=%s;UID=%s;PWD=%s;' % (conn_dict['address'], conn_dict['user'], conn_dict['password']))
conn_string = 'mssql+pyodbc:///?odbc_connect={}'.format(quoted)

else:
self._connection_format = "%s+%s://%s:%s@%s/%s"
if conn_dict['engine'] == 'mssql':
driver = "pyodbc"
connformat=self._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
#self._connection_format = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+10.0"
conn = "%s+%s://%s:%s@%s/%s?driver=SQL+Server"
if "sqlncli11.dll" in os.listdir("C:\\Windows\\System32"):
conn = "%s+%s://%s:%s@%s/%s?driver=SQL+Server+Native+Client+11.0"
self._connection_format = conn
elif conn_dict['engine'] == 'mysql':
driver = "pymysql"
elif conn_dict['engine'] == 'postgresql':
driver = "psycopg2"
else:
driver = "None"

conn_string = connformat % (
conn_string = self._connection_format % (
conn_dict['engine'], driver, conn_dict['user'], conn_dict['password'], conn_dict['address'],
conn_dict['db'])

# print "******", conn_string
return conn_string


def _save_connections(self):
f = self._get_file('w')
for conn in self._conn_dicts:
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = 'stephanie'

pyodbc
pymysql
numpy
Expand All @@ -8,4 +8,5 @@ sqlalchemy
matplotlib
pandas
geoalchemy2
wxpython
#wxpython

4 changes: 2 additions & 2 deletions setup/version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ VSVersionInfo(
u'040904b0',
[StringStruct(u'CompanyName', u'Utah Water Research Laboratory'),
StringStruct(u'ProductName', u'ODMTools'),
StringStruct(u'ProductVersion', u'1.2.2 beta'),
StringStruct(u'ProductVersion', u'1.2.3 beta'),
StringStruct(u'InternalName', u'ODMTools'),
StringStruct(u'OriginalFilename', u'ODMTools.exe'),
StringStruct(u'FileVersion', u'1.2.2 beta'),
StringStruct(u'FileVersion', u'1.2.3 beta'),
StringStruct(u'FileDescription', u'ODMTools is a python application for managing observational data using the Observations Data Model. ODMTools allows you to query, visualize, and edit data stored in an Observations Data Model (ODM) database.ODMTools was originally developed as part of the CUAHSI Hydrologic Information System.'),
StringStruct(u'LegalCopyright', u'Copyright (c) 2013, Utah State University. All rights reserved.'),
StringStruct(u'LegalTrademarks', u'N/A'),])
Expand Down