Skip to content

Commit d476fe8

Browse files
author
Stephanie Reeder
committed
rename singular code to plural codes
1 parent ee6b859 commit d476fe8

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

Examples/Sample.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
# ------------------------------
3434
# Get all of the variables from the database and print their names to the console
3535
allVars = read.getVariables()
36-
36+
print "\n-------- Information about Variables ---------"
3737
for x in allVars:
3838
print x.VariableCode + ": " + x.VariableNameCV
3939

4040

4141

4242
# Get all of the people from the database
4343
allPeople = read.getPeople()
44-
44+
print "\n-------- Information about People ---------"
4545
for x in allPeople:
4646
print x.PersonFirstName + " " + x.PersonLastName
4747

@@ -55,6 +55,7 @@
5555

5656
# Get all of the SamplingFeatures from the database that are Sites
5757
try:
58+
print "\n-------- Information about Sites ---------"
5859
siteFeatures = read.getSamplingFeatures(type='Site')
5960
numSites = len(siteFeatures)
6061

@@ -66,8 +67,7 @@
6667

6768
# Now get the SamplingFeature object for a SamplingFeature code
6869
try:
69-
sf = read.getSamplingFeatures(code='USU-LBR-Mendon')[0]
70-
print sf
70+
sf = read.getSamplingFeatures(code=['USU-LBR-Mendon'])[0]
7171
print "\n-------- Information about an individual SamplingFeature ---------"
7272
print "The following are some of the attributes of a SamplingFeature retrieved using getSamplingFeature(code = x): \n"
7373
print "SamplingFeatureCode: " + sf.SamplingFeatureCode
@@ -118,7 +118,7 @@
118118
# Now get a particular Result using a ResultID
119119
print "\n------- Example of Retrieving Attributes of a Time Series Result -------"
120120
try:
121-
tsResult = read.getResults(id = 1)[0]
121+
tsResult = read.getResults(ids = [1])[0]
122122
print (
123123
"The following are some of the attributes for the TimeSeriesResult retrieved using getTimeSeriesResultByResultID(): \n" +
124124
"ResultTypeCV: " + tsResult.ResultTypeCV + "\n" +

odm2api/ODM2/services/readService.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def getTaxonomicClassifiers(self):
200200
Variable
201201
"""
202202

203-
def getVariables(self, ids=None, code=None):
203+
def getVariables(self, ids=None, codes=None):
204204
"""
205205
getVariables()
206206
* Pass nothing - returns full list of variable objects
@@ -210,7 +210,7 @@ def getVariables(self, ids=None, code=None):
210210

211211
query = self._session.query(Variables)
212212
if ids: query = query.filter(Variables.VariableID.in_(ids))
213-
if code: query = query.filter(Variables.VariableCode.in_(code))
213+
if codes: query = query.filter(Variables.VariableCode.in_(codes))
214214
try:
215215
return query.all()
216216
except:
@@ -220,7 +220,7 @@ def getVariables(self, ids=None, code=None):
220220
Method
221221
"""
222222

223-
def getMethods(self, ids=None, code=None, type=None):
223+
def getMethods(self, ids=None, codes=None, type=None):
224224

225225
"""
226226
getMethods()
@@ -231,7 +231,7 @@ def getMethods(self, ids=None, code=None, type=None):
231231
"""
232232
q = self._session.query(Methods)
233233
if ids: q = q.filter(Methods.MethodID.in_(ids))
234-
if code: q = q.filter(Methods.MethodCode.in_(code))
234+
if codes: q = q.filter(Methods.MethodCode.in_(codes))
235235
if type: q = q.filter_by(MethodTypeCV=type)
236236

237237
try:
@@ -243,7 +243,7 @@ def getMethods(self, ids=None, code=None, type=None):
243243
ProcessingLevel
244244
"""
245245

246-
def getProcessingLevels(self, ids=None, code=None):
246+
def getProcessingLevels(self, ids=None, codes=None):
247247
"""
248248
getProcessingLevels()
249249
* Pass nothing - returns full list of ProcessingLevel objects
@@ -252,7 +252,7 @@ def getProcessingLevels(self, ids=None, code=None):
252252
"""
253253
q = self._session.query(ProcessingLevels)
254254
if ids: q = q.filter(ProcessingLevels.ProcessingLevels.in_(ids))
255-
if code: q = q.filter(ProcessingLevels.ProcessingLevelCode.in_(code))
255+
if codes: q = q.filter(ProcessingLevels.ProcessingLevelCode.in_(codes))
256256

257257
try:
258258
return q.all()
@@ -263,7 +263,7 @@ def getProcessingLevels(self, ids=None, code=None):
263263
Sampling Feature
264264
"""
265265

266-
def getSamplingFeatures(self, ids=None, code=None, uuid=None, type=None, wkt=None):
266+
def getSamplingFeatures(self, ids=None, codes=None, uuid=None, type=None, wkt=None):
267267
"""
268268
getSamplingFeatures
269269
* Pass nothing - returns a list of all sampling feature objects with each object of type specific to that sampling feature
@@ -277,7 +277,7 @@ def getSamplingFeatures(self, ids=None, code=None, uuid=None, type=None, wkt=Non
277277

278278
if type: q = q.filter_by(SamplingFeatureTypeCV=type)
279279
if ids: q = q.filter(SamplingFeatures.SamplingFeatureID.in_(ids))
280-
if code: q = q.filter(SamplingFeatures.SamplingFeatureCode.in_(code))
280+
if codes: q = q.filter(SamplingFeatures.SamplingFeatureCode.in_(codes))
281281
if wkt: q = q.filter_by(FeatureGeometryWKT=wkt)
282282
try:
283283
return q.all()
@@ -364,7 +364,7 @@ def getUnits(self, ids=None, name=None, type=None):
364364
Organization
365365
"""
366366

367-
def getOrganizations(self, ids=None, code=None):
367+
def getOrganizations(self, ids=None, codes=None):
368368
"""
369369
getOrganizations()
370370
* Pass nothing - returns a list of all organization objects
@@ -373,7 +373,7 @@ def getOrganizations(self, ids=None, code=None):
373373
"""
374374
q = self._session.query(Organizations)
375375
if ids: q = q.filter(Organizations.OrganizationID.in_(ids))
376-
if code: q = q.filter(Organizations.OrganizationCode.in_(code))
376+
if codes: q = q.filter(Organizations.OrganizationCode.in_(codes))
377377
try:
378378
return q.all()
379379
except:
@@ -474,16 +474,16 @@ def getResults(self, ids=None, actionid=None):
474474
Datasets
475475
"""
476476

477-
def getDataSets(self, code=None):
477+
def getDataSets(self, codes=None):
478478
"""
479479
getDataSets()
480480
* Pass nothing - returns a list of all DataSet objects
481481
* Pass a list of DataSetCode - returns a single DataSet object for each code
482482
483483
"""
484484
q = self._session.query(DataSets)
485-
if code:
486-
q = q.filter(DataSets.DataSetCode.in_(code))
485+
if codes:
486+
q = q.filter(DataSets.DataSetCode.in_(codes))
487487
try:
488488
return q.all()
489489
except:
@@ -519,7 +519,7 @@ def getResultsDataQuality(self):
519519
# ################################################################################
520520

521521
# TODO Equipment Schema Queries
522-
def getEquipment(self, code=None, type=None, sfid=None, actionid=None):
522+
def getEquipment(self, codes=None, type=None, sfid=None, actionid=None):
523523
"""
524524
getEquipment()
525525
* Pass nothing - returns a list of all Equipment objects
@@ -532,6 +532,7 @@ def getEquipment(self, code=None, type=None, sfid=None, actionid=None):
532532
.join(Actions) \
533533
.join(FeatureActions) \
534534
.filter(FeatureActions.SamplingFeatureID == sfid)
535+
if codes: e = e.filter(Equipment.EquipmentCode.in_(codes))
535536
if actionid: e = e.join(EquipmentUsed).join(Actions) \
536537
.filter(Actions.ActionID == actionid)
537538
return e.all()
@@ -710,14 +711,14 @@ def getResultValues(self, resultid, starttime=None, endtime=None):
710711
Site
711712
"""
712713

713-
def getSpatialReference(self, srsCode=None):
714+
def getSpatialReference(self, srsCodes=None):
714715
"""
715716
getSpatialReference()
716717
* Pass a ResultID - Returns a result values object of type that is specific to the result type
717718
* Pass a ResultID and a date range - returns a result values object of type that is specific to the result type with values between the input date range
718719
"""
719720
q = self._session.query(SpatialReferences)
720-
if srsCode: q.filter(SpatialReferences.SRSCode.ilike(srsCode))
721+
if srsCodes: q.filter(SpatialReferences.SRSCode.in_(srsCodes))
721722
try:
722723
return q.first()
723724
except:
@@ -756,9 +757,9 @@ def getSimulations(self, name=None, actionid=None):
756757
# print e
757758
# return None
758759

759-
def getModels(self, code=None):
760+
def getModels(self, codes=None):
760761
m = self._session.query(Models)
761-
if code: m = m.filter(Models.ModelCode.ilike(code))
762+
if codes: m = m.filter(Models.ModelCode.in_(codes))
762763
try:
763764
return m.all()
764765
except:

0 commit comments

Comments
 (0)