Skip to content

Commit 019e331

Browse files
authored
Merge pull request #85 from ODM2/edit_branch
Edit branch
2 parents b27cf6e + 0a8ce50 commit 019e331

21 files changed

+416
-359
lines changed

setup/Mac/sdl_setup.packproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<key>GID</key>
7676
<integer>80</integer>
7777
<key>Path</key>
78-
<string>Dist/SDLLoader.app</string>
78+
<string>../../src/dist/StreamingDataLoader</string>
7979
<key>Path Type</key>
8080
<integer>2</integer>
8181
<key>Privileges</key>
@@ -91,7 +91,7 @@
9191
<key>GID</key>
9292
<integer>80</integer>
9393
<key>Path</key>
94-
<string>Dist/SDLWizard.app</string>
94+
<string>../../src/dist/StreamingDataLoaderWizard</string>
9595
<key>Path Type</key>
9696
<integer>2</integer>
9797
<key>Privileges</key>
@@ -495,9 +495,9 @@
495495
<key>IFPkgDescriptionDescription</key>
496496
<string></string>
497497
<key>IFPkgDescriptionTitle</key>
498-
<string>StreamingDataLoader_v0.4</string>
498+
<string>StreamingDataLoader_v0.6</string>
499499
<key>IFPkgDescriptionVersion</key>
500-
<string>0.4 Beta</string>
500+
<string>0.6 Beta</string>
501501
</dict>
502502
</dict>
503503
<key>Display Information</key>
@@ -513,7 +513,7 @@
513513
<key>CFBundleName</key>
514514
<string>Streaming DataLoader</string>
515515
<key>CFBundleShortVersionString</key>
516-
<string>1.2.1</string>
516+
<string>0.6</string>
517517
</dict>
518518
<key>Options</key>
519519
<dict>
@@ -541,14 +541,14 @@
541541
<key>IFMajorVersion</key>
542542
<integer>0</integer>
543543
<key>IFMinorVersion</key>
544-
<integer>1</integer>
544+
<integer>6</integer>
545545
</dict>
546546
</dict>
547547
</dict>
548548
<key>IFPkgFlagPackageSelection</key>
549549
<integer>0</integer>
550550
<key>Name</key>
551-
<string>StreamingDataLoader_v0.4-beta_Mac_installer</string>
551+
<string>StreamingDataLoader_v0.6-beta_Mac_installer</string>
552552
<key>Status</key>
553553
<integer>1</integer>
554554
<key>Type</key>

src/StreamingDataLoader.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,22 @@ def main(arguments):
148148
logger.info('Completed execution.')
149149

150150

151-
152151
# Application entry point.
153152
if __name__ == "__main__":
154153
parser = ArgumentParser(description="StreamingDataLoader")
155-
parser.add_argument('-r', '--restart',\
156-
action='store_true', help="Read the entire CSV file to ensure that data is correct and accounted for. This option affects performance. While the integrity of the data is checked each time the program executes, it is still recommended to use this option if you have manually modified your data file between executions.")
157-
parser.add_argument('-v', '--verbose',\
158-
action='store_true', help="Enable more verbose logging in the logfile.")
159-
parser.add_argument('-c', '--config', nargs='+', dest="yamlFile",\
160-
help="Specify a YAML configuration file in the form of one of these formats:\n1. A single YAML (.yaml) file.\n2. A list of YAML files (.yaml), deliminated by white space.\n3. A directory containing multiple YAML (.yaml) files.", required=True, action="store")
161-
parser.add_argument('-f', '--file', dest="csvFile",\
162-
help="Specify a single CSV data file to target instead of the one listed in the configuration file.", required=False, action="store")
154+
parser.add_argument('-r', '--restart', action='store_true', help="Read the entire CSV file to ensure that data is correct and accounted for. This option affects performance. While the integrity of the data is checked each time the program executes, it is still recommended to use this option if you have manually modified your data file between executions.")
155+
parser.add_argument('-v', '--verbose', action='store_true', help="Enable more verbose logging in the logfile.")
156+
parser.add_argument('-c', '--config', nargs='+', dest="yamlFile", help="Specify a YAML configuration file in the form of one of these formats:\n1. A single YAML (.yaml) file.\n2. A list of YAML files (.yaml), deliminated by white space.\n3. A directory containing multiple YAML (.yaml) files.", required=True, action="store")
157+
parser.add_argument('-f', '--file', dest="csvFile", help="Specify a single CSV data file to target instead of the one listed in the configuration file.", required=False, action="store")
163158
args = parser.parse_args()
164159

160+
correct_path = ""
161+
for path in args.yamlFile:
162+
correct_path += path + " "
163+
164+
args.yamlFile = [correct_path.strip()]
165165
start_time = time.time()
166166
main(args)
167167

168168
logger = logging.getLogger('SDL_logger')
169169
logger.info("Running time: %s seconds" % (time.time() - start_time))
170-
171-

src/wizard/controller/frmActionsSelectPanel.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, parent, existing_result=None):
2525
self.new_button.Enable(False)
2626

2727
self.select_existing_series()
28+
self.auto_size_table()
2829

2930
self.list_ctrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.enable)
3031
self.list_ctrl.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.disable)
@@ -66,21 +67,14 @@ def getSeriesData(self):
6667
return []
6768

6869
def onButtonAdd(self, event):
69-
dlg = NewSeriesDialog(self,
70-
u'Create New Action')
71-
newActionsPanel = AddNewActionsPanelController(dlg,
72-
self.parent.database)
73-
dlg.addPanel(newActionsPanel)
70+
dlg = NewSeriesDialog(self, 'Create New Action')
71+
controller = AddNewActionsPanelController(dlg, self.parent.database)
72+
dlg.addPanel(controller)
7473
dlg.CenterOnScreen()
74+
7575
if dlg.ShowModal() == wx.ID_OK:
76-
self.list_ctrl.SetObjects(self.getSeriesData())
76+
pass;
77+
#self.list_ctrl.SetObjects(self.getSeriesData())
7778

78-
#else:
79-
# pass
8079
dlg.Destroy()
8180
event.Skip()
82-
83-
def __del__( self ):
84-
pass
85-
86-
Lines changed: 38 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,59 @@
1-
21
import wx
32
from datetime import datetime
43
import dateutil.parser as dparser
5-
64
from collections import namedtuple
75
from src.controllers.Database import Database
8-
from src.common.functions import wxdate2pydate
9-
106
from src.wizard.view.clsAddNewActionsPanel import AddNewActionsPanelView
11-
#from src.wizard.view.clsAddAffiliationPanel import NewAffiliationView
12-
#from src.wizard.controller.frmAffiliationDialog import AffiliationDialog
137
from src.wizard.controller.frmPersonPanel import PersonPanel
148
from src.wizard.controller.frmOrganizationPanel import OrganizationPanel
159
from src.wizard.controller.frmAffiliationPanel import AffiliationPanel
16-
from src.wizard.controller.AffiliationWizard \
17-
import AffiliationWizard
18-
from src.wizard.view.clsCustomDialog \
19-
import CustomDialog
20-
from src.wizard.controller.frmAddNewMethodPanel \
21-
import AddNewMethodPanelController
22-
10+
from src.wizard.controller.AffiliationWizard import AffiliationWizard
11+
from src.wizard.view.clsCustomDialog import CustomDialog
12+
from src.wizard.controller.frmAddNewMethodPanel import AddNewMethodPanelController
2313
from odm2api.ODM2.models import Actions, ActionBy
2414

25-
class Test:
26-
def __init__(self, name, org):
27-
self.name = name
28-
self.org = org
2915

3016
class AddNewActionsPanelController(AddNewActionsPanelView):
31-
def __init__(self, daddy, db, **kwargs):
32-
super(AddNewActionsPanelController, self).__init__(daddy,
33-
**kwargs)
17+
def __init__(self, daddy, db):
18+
super(AddNewActionsPanelController, self).__init__(daddy)
3419
self.parent = daddy
3520
self.db = db
36-
37-
self.m_comboBox13.Bind(wx.EVT_COMBOBOX, self.onActionTypeSelect)
21+
self.action = None
22+
23+
self.action_type_combo.Bind(wx.EVT_COMBOBOX, self.onActionTypeSelect)
3824
self.m_b.Bind(wx.EVT_BUTTON, self.onNewAffiliation)
3925
self.btnNewMethod.Bind(wx.EVT_BUTTON, self.onNewMethod)
4026
self.btnNewMethod.Enable(False)
41-
#self.affList.Bind(wx.EVT_LEFT_DOWN, self.onAffListClick)
42-
#self.affList.Bind(wx.EVT_LIST_INSERT_ITEM, self.onAffInsert)
43-
#self.affList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onAffSelect)
4427
self.read = self.db.getReadSession()
45-
28+
4629
self.populateFields()
4730

4831
def populateFields(self):
49-
#read = self.db.getReadSession()
32+
action_controlled_vocabulary = self.read.getCVs(type='actiontype')
33+
action_types = [vocab.Name for vocab in action_controlled_vocabulary]
5034

51-
actionTypes = [i.Name for i in self.read.getCVs(type = "actiontype")]
52-
self.m_comboBox13.AppendItems(actionTypes)
35+
self.action_type_combo.AppendItems(action_types)
5336

54-
#self.affList.SetObjects(self.read.getDetailedAffiliationInfo())
55-
self.affList.AddObjects(self.read.getDetailedAffiliationInfo())
37+
self.affList.SetObjects(self.read.getDetailedAffiliationInfo())
5638

5739
def onActionTypeSelect(self, event):
58-
# self.sp_ref = [{i.SRSName:i.SpatialReferenceID}\
59-
# for i in read.getCVSpacialReferenceTypes()]
6040
self.btnNewMethod.Enable(True)
61-
self.m_comboBox134.Clear()
62-
self.m_comboBox134.SetValue("Select Method")
41+
self.method_combo.Clear()
42+
self.method_combo.SetValue("Select Method")
6343
self.methods = [{i.MethodName:i.MethodID} for i in self.read.getMethods(type=event.GetString())]
64-
self.m_comboBox134.SetItems(\
65-
[y for x in [i.keys() for i in self.methods] for y in x]
66-
)
44+
self.method_combo.SetItems([y for x in [i.keys() for i in self.methods] for y in x])
6745
#self.m_comboBox134.SetItems(methodTypes)
6846

6947
def onNewMethod(self, event):
7048
dlg = CustomDialog(self, u'Create New Method')
7149
newMethodPanel = AddNewMethodPanelController(dlg, self.db)
7250
dlg.addPanel(newMethodPanel)
73-
newMethodPanel.setTypeFilter(str(self.m_comboBox13.GetStringSelection()))
51+
newMethodPanel.setTypeFilter(str(self.action_type_combo.GetStringSelection()))
7452
if dlg.ShowModal() == wx.ID_OK:
7553
newMethod = newMethodPanel.method
7654
self.methods = [{i.MethodName:i.MethodID}\
7755
for i in [newMethod]]
78-
self.m_comboBox134.AppendItems([y for x in [i.keys() for i in self.methods] for y in x])
56+
self.method_combo.AppendItems([y for x in [i.keys() for i in self.methods] for y in x])
7957
#self.m_comboBox134.SetValue(newMethod.MethodName)
8058
dlg.Destroy()
8159
event.Skip()
@@ -108,28 +86,37 @@ def onOK(self, event):
10886
self.getFieldValues()
10987
try:
11088
write = self.db.getWriteSession()
111-
action= Actions(ActionTypeCV=self.actionType,
89+
action = Actions(
90+
ActionTypeCV=self.actionType,
11291
MethodID=self.methodID,
11392
BeginDateTime=self.beginDT,
11493
BeginDateTimeUTCOffset=self.beginDTUTC,
11594
EndDateTime=self.endDT,
11695
EndDateTimeUTCOffset=self.endDTUTC,
11796
ActionDescription=self.actionDesc,
118-
ActionFileLink=self.actionLink)
97+
ActionFileLink=self.actionLink
98+
)
11999
action = write.createAction(action)
120100

121101
self.actionID = action.ActionID
122102

123103
for affID in self.affiliationList:
124-
actionby=ActionBy(\
104+
actionby = ActionBy(
125105
ActionID=self.actionID,
126106
AffiliationID=affID,
127-
IsActionLead=(affID == self.actionLead))
107+
IsActionLead=(affID == self.actionLead)
108+
)
128109
write.createActionby(actionby)
110+
111+
self.parent.parent.list_ctrl.SetObjects(self.parent.parent.getSeriesData())
112+
length = self.parent.parent.list_ctrl.GetItemCount.im_self.ItemCount
113+
length = length - 1
114+
self.parent.parent.list_ctrl.Focus(length)
115+
self.parent.parent.list_ctrl.Select(length, 1)
129116

130-
except Exception as e:
131-
print e
132-
#todo Catch error and display message
117+
except Exception as error:
118+
print error
119+
133120
event.Skip()
134121

135122
def getFieldValues(self):
@@ -138,11 +125,12 @@ def getFieldValues(self):
138125
vals = [y for x in [i.values() for i in self.methods] for y in x]
139126
d = dict(zip(keys, vals))
140127

141-
self.actionType = str(self.m_comboBox13.GetStringSelection())
142-
self.methodID = d[str(self.m_comboBox134.GetStringSelection())]
128+
self.actionType = str(self.action_type_combo.GetStringSelection())
129+
self.methodID = d[str(self.method_combo.GetStringSelection())]
143130
self.beginDT = self._getTime(self.m_datePicker5, self.m_timePicker1)
144131
self.beginDTUTC = self.spinUTCBegin.GetValue()
145-
self.affiliationList = [i.affiliationID for i in self.affList.GetSelectedObjects()]
132+
self.affiliationList = [aff.AffiliationID for aff in self.affList.GetSelectedObjects()]
133+
146134
for i in self.affList.GetSelectedObjects():
147135
if self.affList.IsChecked(i):
148136
self.actionLead = i.affiliationID
@@ -175,24 +163,3 @@ def _getTime(self, d, t):
175163
begin = datetime.strptime(date, '%A, %B %d, %Y %X %p').strftime('%Y-%m-%d')
176164
begin = begin + ' ' + str(time)
177165
return dparser.parse(begin)
178-
179-
180-
181-
182-
if __name__ == '__main__':
183-
db = Database()
184-
Credentials = namedtuple('Credentials', 'engine, host, db_name, uid, pwd')
185-
db.createConnection(Credentials(\
186-
'mysql',
187-
'rambo.bluezone.usu.edu',
188-
'odm2',
189-
'odm',
190-
'odm'))
191-
app = wx.App()
192-
frame = wx.Frame(None)
193-
frame.SetSizer(wx.BoxSizer(wx.VERTICAL))
194-
pnl = AddNewActionsPanelController(frame, db)
195-
frame.CenterOnScreen()
196-
frame.Show()
197-
app.MainLoop()
198-

src/wizard/controller/frmAddNewProcLevelPanel.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from odm2api.ODM2.models import ProcessingLevels
66

77
class AddNewProcLevelPanelController(AddNewProcLevelPanelView):
8-
def __init__(self, daddy, db, **kwargs):
9-
super(AddNewProcLevelPanelController, self).__init__(daddy,
10-
**kwargs)
8+
def __init__(self, daddy, db):
9+
super(AddNewProcLevelPanelController, self).__init__(daddy)
1110
self.parent = daddy
1211
self.db = db
12+
self.processing_level = None
1313

1414
self.populateFields()
1515

@@ -26,13 +26,22 @@ def onOK(self, event):
2626
self.getFieldValues()
2727
try:
2828
write = self.db.getWriteSession()
29-
proc = ProcessingLevels(\
29+
proc = ProcessingLevels(
3030
ProcessingLevelCode=self.procLevelCode,
3131
Definition=self.definition,
32-
Explanation=self.explanation)
32+
Explanation=self.explanation
33+
)
34+
3335
write.createProcessingLevel(proc)
36+
37+
self.parent.parent.list_ctrl.SetObjects(self.parent.parent.getSeriesData())
38+
length = self.parent.parent.list_ctrl.GetItemCount.im_self.ItemCount
39+
length = length - 1
40+
self.parent.parent.list_ctrl.Focus(length)
41+
self.parent.parent.list_ctrl.Select(length, 1)
3442
except Exception as e:
3543
print e
44+
3645
event.Skip()
3746

3847
def getFieldValues(self):

0 commit comments

Comments
 (0)