Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rename singular code to plural codes
  • Loading branch information
Stephanie Reeder committed Apr 12, 2016
commit d476fe871fc8de179d012cfa59ffd9e3dcb884b8
10 changes: 5 additions & 5 deletions Examples/Sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
# ------------------------------
# Get all of the variables from the database and print their names to the console
allVars = read.getVariables()

print "\n-------- Information about Variables ---------"
for x in allVars:
print x.VariableCode + ": " + x.VariableNameCV



# Get all of the people from the database
allPeople = read.getPeople()

print "\n-------- Information about People ---------"
for x in allPeople:
print x.PersonFirstName + " " + x.PersonLastName

Expand All @@ -55,6 +55,7 @@

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

Expand All @@ -66,8 +67,7 @@

# Now get the SamplingFeature object for a SamplingFeature code
try:
sf = read.getSamplingFeatures(code='USU-LBR-Mendon')[0]
print sf
sf = read.getSamplingFeatures(code=['USU-LBR-Mendon'])[0]
print "\n-------- Information about an individual SamplingFeature ---------"
print "The following are some of the attributes of a SamplingFeature retrieved using getSamplingFeature(code = x): \n"
print "SamplingFeatureCode: " + sf.SamplingFeatureCode
Expand Down Expand Up @@ -118,7 +118,7 @@
# Now get a particular Result using a ResultID
print "\n------- Example of Retrieving Attributes of a Time Series Result -------"
try:
tsResult = read.getResults(id = 1)[0]
tsResult = read.getResults(ids = [1])[0]
print (
"The following are some of the attributes for the TimeSeriesResult retrieved using getTimeSeriesResultByResultID(): \n" +
"ResultTypeCV: " + tsResult.ResultTypeCV + "\n" +
Expand Down
37 changes: 19 additions & 18 deletions odm2api/ODM2/services/readService.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def getTaxonomicClassifiers(self):
Variable
"""

def getVariables(self, ids=None, code=None):
def getVariables(self, ids=None, codes=None):
"""
getVariables()
* Pass nothing - returns full list of variable objects
Expand All @@ -210,7 +210,7 @@ def getVariables(self, ids=None, code=None):

query = self._session.query(Variables)
if ids: query = query.filter(Variables.VariableID.in_(ids))
if code: query = query.filter(Variables.VariableCode.in_(code))
if codes: query = query.filter(Variables.VariableCode.in_(codes))
try:
return query.all()
except:
Expand All @@ -220,7 +220,7 @@ def getVariables(self, ids=None, code=None):
Method
"""

def getMethods(self, ids=None, code=None, type=None):
def getMethods(self, ids=None, codes=None, type=None):

"""
getMethods()
Expand All @@ -231,7 +231,7 @@ def getMethods(self, ids=None, code=None, type=None):
"""
q = self._session.query(Methods)
if ids: q = q.filter(Methods.MethodID.in_(ids))
if code: q = q.filter(Methods.MethodCode.in_(code))
if codes: q = q.filter(Methods.MethodCode.in_(codes))
if type: q = q.filter_by(MethodTypeCV=type)

try:
Expand All @@ -243,7 +243,7 @@ def getMethods(self, ids=None, code=None, type=None):
ProcessingLevel
"""

def getProcessingLevels(self, ids=None, code=None):
def getProcessingLevels(self, ids=None, codes=None):
"""
getProcessingLevels()
* Pass nothing - returns full list of ProcessingLevel objects
Expand All @@ -252,7 +252,7 @@ def getProcessingLevels(self, ids=None, code=None):
"""
q = self._session.query(ProcessingLevels)
if ids: q = q.filter(ProcessingLevels.ProcessingLevels.in_(ids))
if code: q = q.filter(ProcessingLevels.ProcessingLevelCode.in_(code))
if codes: q = q.filter(ProcessingLevels.ProcessingLevelCode.in_(codes))

try:
return q.all()
Expand All @@ -263,7 +263,7 @@ def getProcessingLevels(self, ids=None, code=None):
Sampling Feature
"""

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

if type: q = q.filter_by(SamplingFeatureTypeCV=type)
if ids: q = q.filter(SamplingFeatures.SamplingFeatureID.in_(ids))
if code: q = q.filter(SamplingFeatures.SamplingFeatureCode.in_(code))
if codes: q = q.filter(SamplingFeatures.SamplingFeatureCode.in_(codes))
if wkt: q = q.filter_by(FeatureGeometryWKT=wkt)
try:
return q.all()
Expand Down Expand Up @@ -364,7 +364,7 @@ def getUnits(self, ids=None, name=None, type=None):
Organization
"""

def getOrganizations(self, ids=None, code=None):
def getOrganizations(self, ids=None, codes=None):
"""
getOrganizations()
* Pass nothing - returns a list of all organization objects
Expand All @@ -373,7 +373,7 @@ def getOrganizations(self, ids=None, code=None):
"""
q = self._session.query(Organizations)
if ids: q = q.filter(Organizations.OrganizationID.in_(ids))
if code: q = q.filter(Organizations.OrganizationCode.in_(code))
if codes: q = q.filter(Organizations.OrganizationCode.in_(codes))
try:
return q.all()
except:
Expand Down Expand Up @@ -474,16 +474,16 @@ def getResults(self, ids=None, actionid=None):
Datasets
"""

def getDataSets(self, code=None):
def getDataSets(self, codes=None):
"""
getDataSets()
* Pass nothing - returns a list of all DataSet objects
* Pass a list of DataSetCode - returns a single DataSet object for each code

"""
q = self._session.query(DataSets)
if code:
q = q.filter(DataSets.DataSetCode.in_(code))
if codes:
q = q.filter(DataSets.DataSetCode.in_(codes))
try:
return q.all()
except:
Expand Down Expand Up @@ -519,7 +519,7 @@ def getResultsDataQuality(self):
# ################################################################################

# TODO Equipment Schema Queries
def getEquipment(self, code=None, type=None, sfid=None, actionid=None):
def getEquipment(self, codes=None, type=None, sfid=None, actionid=None):
"""
getEquipment()
* Pass nothing - returns a list of all Equipment objects
Expand All @@ -532,6 +532,7 @@ def getEquipment(self, code=None, type=None, sfid=None, actionid=None):
.join(Actions) \
.join(FeatureActions) \
.filter(FeatureActions.SamplingFeatureID == sfid)
if codes: e = e.filter(Equipment.EquipmentCode.in_(codes))
if actionid: e = e.join(EquipmentUsed).join(Actions) \
.filter(Actions.ActionID == actionid)
return e.all()
Expand Down Expand Up @@ -710,14 +711,14 @@ def getResultValues(self, resultid, starttime=None, endtime=None):
Site
"""

def getSpatialReference(self, srsCode=None):
def getSpatialReference(self, srsCodes=None):
"""
getSpatialReference()
* Pass a ResultID - Returns a result values object of type that is specific to the result type
* 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
"""
q = self._session.query(SpatialReferences)
if srsCode: q.filter(SpatialReferences.SRSCode.ilike(srsCode))
if srsCodes: q.filter(SpatialReferences.SRSCode.in_(srsCodes))
try:
return q.first()
except:
Expand Down Expand Up @@ -756,9 +757,9 @@ def getSimulations(self, name=None, actionid=None):
# print e
# return None

def getModels(self, code=None):
def getModels(self, codes=None):
m = self._session.query(Models)
if code: m = m.filter(Models.ModelCode.ilike(code))
if codes: m = m.filter(Models.ModelCode.in_(codes))
try:
return m.all()
except:
Expand Down