Skip to content

Commit 5eac1c7

Browse files
author
stephanie
committed
begin adding saving functionality, add commit to editing db for temp fix)
1 parent ed8f5dd commit 5eac1c7

4 files changed

Lines changed: 285 additions & 246 deletions

File tree

odmtools/gui/wizSave.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,12 @@ def on_wizard_finished(self, event):
452452
result = self.record_service.saveAs(Variable, Method, QCL, True)
453453
'''
454454

455+
456+
TODO: move all of this stuff into the edit_service file
455457
# Create action
456458
new_result = self.series_service.createResult(var=variable, meth=method, proc=proc_level)
459+
#TODO create a timeseriesresult
460+
#TODO create a featureaction
457461
# action = self.series_service.create.createAction(action)
458462

459463
affiliation = self.action_page.get_affiliation()

odmtools/odmdata/memory_database.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(self, taskserver=None):
2929
# Memory_service handles in memory database
3030
sm = ServiceManager()
3131
self.mem_service = sm.get_series_service(conn_string="sqlite:///:memory:")
32+
3233
setSchema(self.mem_service._session_factory.engine)
3334

3435
# TODO clean up closing of program
@@ -68,13 +69,17 @@ def getDataValuesDF(self):
6869
#else:
6970
# self.updateDF()
7071
'''
72+
# TODO: fix me! this commit location is only temoporarily. should be flushing so that we can restore
73+
self.mem_service._session.commit()
7174
setSchema(self.mem_service._session_factory.engine)
7275
self.updateDF()
7376
# pick up thread here before it is needed
7477
logging.debug("done updating memory dataframe")
7578
return self.df
7679

7780
def getDataValues(self):
81+
# TODO: fix me! this commit location is only temoporarily. should be flushing so that we can restore
82+
self.mem_service._session.commit()
7883
setSchema(self.mem_service._session_factory.engine)
7984
return self.mem_service.get_all_values()
8085

@@ -97,6 +102,7 @@ def getEditDataValuesforGraph(self):
97102

98103
def commit(self):
99104
self.mem_service._session.commit()
105+
# self.mem_service._session.commit()
100106

101107
def rollback(self):
102108
self.mem_service._session.rollback()
@@ -143,6 +149,7 @@ def updateValue(self, ids, operator, value):
143149
q=self.mem_service._session.query(TSRV).filter(TSRV.ValueDateTime.in_(c))
144150
q.update({TSRV.DataValue: query}, False)
145151

152+
146153
#self.updateDF()
147154

148155
def chunking(self, data):
@@ -175,6 +182,7 @@ def updateFlag(self, ids, value):
175182
frames = [self.annotation_list, flags]
176183
self.annotation_list=pd.concat(frames)
177184
print self.annotation_list
185+
#todo: remove duplicates before saving
178186

179187

180188

@@ -199,9 +207,12 @@ def addPoints(self, points):
199207
vals = {"datavalue": point[0], "valuedatetime": point[1],
200208
"valuedatetimeutcoffset": point[3],
201209
"censorcodecv": point[4], "qualitycodecv": point[5],
202-
"timeaggregationinterval": point[6], "timeaggregationintervalunitsid": point[7]
210+
"timeaggregationinterval": point[6], "timeaggregationintervalunitsid": point[7],
211+
"resultid":self.df["resultid"][0]
203212
# todo: Add annotations
204213
}
214+
if point[8]:
215+
self.updateFlag(point[1], self.series_service.get_annotation_by_code(point[8].split(':')[0]).AnnotationID)
205216

206217
setSchema(self.mem_service._session_factory.engine)
207218
self.mem_service._session.execute(stmt, vals)

0 commit comments

Comments
 (0)