3838
3939from sqlalchemy import distinct , exists
4040
41+ import warnings
42+
4143__author__ = 'sreeder'
4244
4345
@@ -145,7 +147,7 @@ def resultExists(self, result):
145147 return None
146148
147149 # Annotations
148- def getAnnotations (self , type = None , codes = None , ids = None ):
150+ def getAnnotations (self , annottype = None , codes = None , ids = None , ** kwargs ):
149151 """
150152 * Pass Nothing - return a list of all objects
151153 * Pass AnnotationTypeCV - return a list of all objects of the fiven type
@@ -155,34 +157,38 @@ def getAnnotations(self, type=None, codes=None, ids=None):
155157 """
156158 # TODO What keywords do I use for type.
157159 a = Annotations
158- if type :
159- if type == 'action' :
160+ if 'type' in kwargs :
161+ warnings .warn (
162+ "The parameter 'type' is deprecated. Please use the annottype parameter instead." )
163+ annottype = kwargs ['type' ]
164+ if annottype :
165+ if annottype == 'action' :
160166 a = ActionAnnotations
161- elif type == 'categoricalresultvalue' :
167+ elif annottype == 'categoricalresultvalue' :
162168 a = CategoricalResultValueAnnotations
163- elif type == 'equipmentannotation' :
169+ elif annottype == 'equipmentannotation' :
164170 a = EquipmentAnnotations
165- elif type == 'measurementresultvalue' :
171+ elif annottype == 'measurementresultvalue' :
166172 a = MeasurementResultValueAnnotations
167- elif type == 'method' :
173+ elif annottype == 'method' :
168174 a = MethodAnnotations
169- elif type == 'pointcoverageresultvalue' :
175+ elif annottype == 'pointcoverageresultvalue' :
170176 a = PointCoverageResultValueAnnotations
171- elif type == 'profileresultvalue' :
177+ elif annottype == 'profileresultvalue' :
172178 a = ProfileResultValueAnnotations
173- elif type == 'result' :
179+ elif annottype == 'result' :
174180 a = ResultAnnotations
175- elif type == 'samplingfeature' :
181+ elif annottype == 'samplingfeature' :
176182 a = SamplingFeatureAnnotations
177- elif type == 'sectionresultvalue' :
183+ elif annottype == 'sectionresultvalue' :
178184 a = SectionResultValueAnnotations
179- elif type == 'spectraresultvalue' :
185+ elif annottype == 'spectraresultvalue' :
180186 a = SpectraResultValueAnnotations
181- elif type == 'timeseriesresultvalue' :
187+ elif annottype == 'timeseriesresultvalue' :
182188 a = TimeSeriesResultValueAnnotations
183- elif type == 'trajectoryresultvalue' :
189+ elif annottype == 'trajectoryresultvalue' :
184190 a = TrajectoryResultValueAnnotations
185- elif type == 'transectresultvalue' :
191+ elif annottype == 'transectresultvalue' :
186192 a = TransectResultValueAnnotations
187193 try :
188194 query = self ._session .query (a )
@@ -678,8 +684,8 @@ def getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=N
678684 return None
679685
680686 # Results
681- def getResults (self , ids = None , type = None , restype = None , uuids = None , actionid = None , simulationid = None , sfid = None ,
682- variableid = None , siteid = None , sfids = None , sfuuids = None , sfcodes = None ):
687+ def getResults (self , ids = None , restype = None , uuids = None , actionid = None , simulationid = None ,
688+ variableid = None , siteid = None , sfids = None , sfuuids = None , sfcodes = None , ** kwargs ):
683689
684690 # TODO what if user sends in both type and actionid vs just actionid
685691 """Retrieve a list of Result objects.
@@ -694,7 +700,6 @@ def getResults(self, ids=None, type=None, restype = None, uuids=None, actionid=N
694700 uuids (list, optional): List of UUIDs string.
695701 actionid (int, optional): ActionID.
696702 simulationid (int, optional): SimulationID.
697- sfid (int, optional): SamplingFeatureID.
698703 variableid (int, optional): VariableID.
699704 siteid (int, optional): SiteID. - goes through related features table and finds all of results
700705 recorded at the given site
@@ -719,11 +724,10 @@ def getResults(self, ids=None, type=None, restype = None, uuids=None, actionid=N
719724 """
720725 query = self ._session .query (Results )
721726
722- if type :
723- import warnings
727+ if 'type' in kwargs :
724728 warnings .warn (
725- "The parameter 'type' is no longer be supported . Please use the restype parameter instead." )
726- query = query . filter_by ( ResultTypeCV = type )
729+ "The parameter 'type' is deprecated . Please use the restype parameter instead." )
730+ restype = kwargs [ ' type' ]
727731 if restype :
728732 query = query .filter_by (ResultTypeCV = restype )
729733 if variableid :
@@ -739,10 +743,9 @@ def getResults(self, ids=None, type=None, restype = None, uuids=None, actionid=N
739743 .filter_by (SimulationID = simulationid )
740744 if actionid :
741745 query = query .join (FeatureActions ).filter_by (ActionID = actionid )
742- if sfid :
743- import warnings
744- warnings .warn ("The parameter 'sfid' is no longer be supported. Please use the sfids parameter and send in a list." )
745- query = query .join (FeatureActions ).filter_by (SamplingFeatureID = sfid )
746+ if 'sfid' in kwargs :
747+ warnings .warn ("The parameter 'sfid' is deprecated. Please use the sfids parameter and send in a list." )
748+ query = query .join (FeatureActions ).filter_by (SamplingFeatureID = kwargs ['sfid' ])
746749 if sfids or sfcodes or sfuuids :
747750 sf_list = self .getSamplingFeatures (ids = sfids , codes = sfcodes , uuids = sfuuids )
748751 sfids = []
0 commit comments