Skip to content

Commit e0c274c

Browse files
author
stephanie
committed
update annotations
1 parent 21d22db commit e0c274c

2 files changed

Lines changed: 37 additions & 32 deletions

File tree

Examples/Sample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#connect to database
1818
# createconnection (dbtype, servername, dbname, username, password)
1919
# session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite
20-
# session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
20+
session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
2121
# session_factory= dbconnection.createConnection('mssql', "(local)", "ODM2", "ODM", "odm")#win MSSQL
22-
session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL
22+
# session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL
2323

2424

2525

odm2api/ODM2/services/readService.py

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,45 @@ def __init__(self, session):
5454
# Annotations
5555
# ################################################################################
5656

57-
def getAnnotations(self, type=None):
57+
def getAnnotations(self, type=None, codes = None):
5858

5959
# TODO What keywords do I use for type
6060
a = Annotations
61-
if type == "action":
62-
a = ActionAnnotations
63-
elif type == "categoricalresultvalue":
64-
a = CategoricalResultValueAnnotations
65-
elif type == "equipmentannotation":
66-
a = EquipmentAnnotations
67-
elif type == "measurementresultvalue":
68-
a = MeasurementResultValueAnnotations
69-
elif type == "method":
70-
a = MethodAnnotations
71-
elif type == "pointcoverageresultvalue":
72-
a = PointCoverageResultValueAnnotations
73-
elif type == "profileresultvalue":
74-
a = ProfileResultValueAnnotations
75-
elif type == "result":
76-
a = ResultAnnotations
77-
elif type == "samplingfeature":
78-
a = SamplingFeatureAnnotations
79-
elif type == "sectionresultvalue":
80-
a = SectionResultValueAnnotations
81-
elif type == "spectraresultvalue":
82-
a = SpectraResultValueAnnotations
83-
elif type == "timeseriesresultvalue":
84-
a = TimeSeriesResultValueAnnotations
85-
elif type == "trajectoryresultvalue":
86-
a = TrajectoryResultValueAnnotations
87-
elif type == "transectresultvalue":
88-
a = TransectResultValueAnnotations
61+
if type:
62+
if type == "action":
63+
a = ActionAnnotations
64+
elif type == "categoricalresultvalue":
65+
a = CategoricalResultValueAnnotations
66+
elif type == "equipmentannotation":
67+
a = EquipmentAnnotations
68+
elif type == "measurementresultvalue":
69+
a = MeasurementResultValueAnnotations
70+
elif type == "method":
71+
a = MethodAnnotations
72+
elif type == "pointcoverageresultvalue":
73+
a = PointCoverageResultValueAnnotations
74+
elif type == "profileresultvalue":
75+
a = ProfileResultValueAnnotations
76+
elif type == "result":
77+
a = ResultAnnotations
78+
elif type == "samplingfeature":
79+
a = SamplingFeatureAnnotations
80+
elif type == "sectionresultvalue":
81+
a = SectionResultValueAnnotations
82+
elif type == "spectraresultvalue":
83+
a = SpectraResultValueAnnotations
84+
elif type == "timeseriesresultvalue":
85+
a = TimeSeriesResultValueAnnotations
86+
elif type == "trajectoryresultvalue":
87+
a = TrajectoryResultValueAnnotations
88+
elif type == "transectresultvalue":
89+
a = TransectResultValueAnnotations
8990
try:
90-
return self._session.query(a).all()
91+
query=self._session.query(a)
92+
if codes:
93+
query = query.filter(Annotations.AnnotationCode.in_(codes))
94+
return query.all()
95+
9196
except:
9297
return None
9398

0 commit comments

Comments
 (0)