Skip to content

Commit e78bdb4

Browse files
author
Francisco Arrieta
committed
Bug fixes with add points and flag values
1 parent 0fd7217 commit e78bdb4

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

odmtools/controller/NewFlagValuesController.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,38 @@ def __init__(self, parent, series_service, qualifier_choice, record_service):
99
self.series_service = series_service
1010
self.qualifer_choice = qualifier_choice
1111
self.record_service = record_service
12+
self.__new_annotation = "[New Annontation]"
1213

1314
annotations = self.series_service.get_all_annotations()
1415
self.append_items_to_annotation(annotations)
1516
self.annotation_combo.SetSelection(0)
1617

1718
self.cancel_button.Bind(wx.EVT_BUTTON, self.on_cancel)
19+
self.Bind(wx.EVT_CLOSE, self.on_cancel)
1820
self.ok_button.Bind(wx.EVT_BUTTON, self.on_ok)
1921
self.MakeModal(True)
2022

2123
def append_items_to_annotation(self, annotations):
22-
self.annotation_combo.Append("[New Annontation]")
24+
self.annotation_combo.Append(self.__new_annotation)
2325
if not isinstance(annotations, list):
2426
print "type(annotations) must be list of annotations"
2527
return
2628

2729
for item in annotations:
28-
self.annotation_combo.Append(item.AnnotationCode + item.AnnotationText)
30+
self.annotation_combo.Append(str(item.AnnotationID))
2931

3032
def on_cancel(self, event):
3133
self.MakeModal(False)
3234
self.Destroy()
3335
event.Skip()
3436

3537
def on_ok(self, event):
36-
code = self.code_textbox.GetValue()
37-
text = self.text_textbox.GetValue()
38+
selection = self.annotation_combo.GetValue()
39+
if selection == self.__new_annotation:
40+
code = self.code_textbox.GetValue()
41+
text = self.text_textbox.GetValue()
42+
43+
annotation = self.series_service.create_annotation(code, text)
44+
self.record_service.flag(annotation.AnnotationID)
3845

39-
self.series_service.create_annotation(code, text)
4046
self.on_cancel(event)

odmtools/controller/logicCellEdit.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#### Options ####
1010
utcOffSetBounds = (-12, 12)
1111
NULL = "NULL"
12-
NEW = "[New Qualifier]"
12+
NEW = "[New Annotation]"
1313

1414
class CellEdit():
1515
def __init__(self, parent, serviceManager, recordService):
@@ -18,21 +18,22 @@ def __init__(self, parent, serviceManager, recordService):
1818
self.serviceManager = serviceManager
1919
if self.serviceManager:
2020
self.series_service = self.serviceManager.get_series_service()
21-
self.qualifierChoices = OrderedDict((x.code + ':' + x.description, x.id)
22-
for x in self.series_service.get_all_qualifiers() if x.code and x.description)
23-
self.qualifierCodeChoices = [NULL] + self.qualifierChoices.keys() + [NEW]
24-
21+
self.annotationChoices = self.fetch_annotations()
22+
self.censorCodeChoices = self.fetchCensorCodeChoices()
23+
self.qualityCodeChoices = self.fetchQualityCodeChoices()
24+
self.timeAggregationInterval = -1
25+
self.timeAggretaionUnitChoices = self.fetchTimeUnitChoices()
2526
else:
2627
self.censorCodeChoices = [NULL] + ['SampleCensorCode1'] + ['SampleCensorCode2'] + ['SampleCensorCode3']
2728
self.labSampleChoices = [NULL] + ['SampleLabSample1'] + ['SampleLabSample2'] + ['SampleLabSample3']
2829
self.offSetTypeChoices = [NULL] + ['SampleOffsetType1'] + ['SampleOffsetType2'] + ['SampleOffsetType3']
29-
self.qualifierCodeChoices = [NULL] + ['SampleQualifierCode1'] + ['SampleQualifierCode2'] + ['SampleQualifierCode3']
30+
self.annotationChoices = [NULL] + ['SampleAnnotation1'] + ['SampleAnnotation2'] + ['SampleAnnotation3']
3031

31-
self.qualityCodeChoices = self.fetchQualityCodeChoices()
32-
self.censorCodeChoices = self.fetchCensorCodeChoices()
33-
self.timeAggregationInterval = -1
34-
self.timeAggretaionUnitChoices = self.fetchTimeUnitChoices()
35-
self.annotationChoices = [NULL]
32+
def fetch_annotations(self):
33+
qualifierChoices = OrderedDict((x.AnnotationCode + ':' + x.AnnotationText, x.AnnotationID)
34+
for x in self.series_service.get_all_qualifiers() if x.AnnotationCode and x.AnnotationText)
35+
qualifierCodeChoices = [NULL] + qualifierChoices.keys() + [NEW]
36+
return qualifierCodeChoices
3637

3738
def fetchCensorCodeChoices(self):
3839
if not self.serviceManager:

0 commit comments

Comments
 (0)