@@ -615,7 +615,7 @@ def getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=N
615615
616616 # Results
617617 def getResults (self , ids = None , type = None , uuids = None , actionid = None , simulationid = None , sfid = None ,
618- variableid = None , siteid = None ):
618+ variableid = None , siteid = None , sfids = None , sfuuids = None , sfcodes = None ):
619619
620620 # TODO what if user sends in both type and actionid vs just actionid
621621 """Retrieve a list of Result objects.
@@ -633,14 +633,17 @@ def getResults(self, ids=None, type=None, uuids=None, actionid=None, simulationi
633633 sfid (int, optional): SamplingFeatureID.
634634 variableid (int, optional): VariableID.
635635 siteid (int, optional): SiteID.
636+ sfids(list, optional): List of Sampling Feature IDs integer.
637+ sfuuids(list, optional): List of Sampling Feature UUIDs string.
638+ sfcodes=(list, optional): List of Sampling Feature codes string.
636639
637640 Returns:
638641 list: List of Result objects
639642
640643 Examples:
641644 >>> ReadODM2.getResults(ids=[39,40])
642645 >>> ReadODM2.getResults(type='Time series coverage')
643- >>> ReadODM2.getResults(sfid=65 )
646+ >>> ReadODM2.getResults(sfids=[65] )
644647 >>> ReadODM2.getResults(uuids=['a6f114f1-5416-4606-ae10-23be32dbc202',
645648 ... '5396fdf3-ceb3-46b6-aaf9-454a37278bb4'])
646649 >>> ReadODM2.getResults(simulationid=50)
@@ -667,16 +670,33 @@ def getResults(self, ids=None, type=None, uuids=None, actionid=None, simulationi
667670 if actionid :
668671 query = query .join (FeatureActions ).filter_by (ActionID = actionid )
669672 if sfid :
673+ import warnings
674+ warnings .warn ('the parameter sfid, will no longer be supported. please use the sfids parameter and send in a list. ' )
670675 query = query .join (FeatureActions ).filter_by (SamplingFeatureID = sfid )
676+ if sfids or sfcodes or sfuuids :
677+ sf_list = self .getSamplingFeatures (ids = sfids , codes = sfcodes , uuids = sfuuids )
678+ sfids = []
679+ for sf in sf_list :
680+ sfids .append (sf .SamplingFeatureID )
681+ query = query .join (FeatureActions ).filter (FeatureActions .SamplingFeatureID .in_ (sfids ))
671682
672683 if siteid :
684+
673685 sfids = [x [0 ] for x in self ._session .query (
674686 distinct (SamplingFeatures .SamplingFeatureID ))
675687 .select_from (RelatedFeatures )
676688 .join (RelatedFeatures .SamplingFeatureObj )
677689 .filter (RelatedFeatures .RelatedFeatureID == siteid )
678690 .all ()
679691 ]
692+
693+ # sf_list = self.getRelatedSamplingFeatures(rfid=siteid)
694+ # sfids = []
695+ # for sf in sf_list:
696+ # sfids.append(sf.SamplingFeatureID)
697+
698+
699+
680700 query = query .join (FeatureActions ).filter (FeatureActions .SamplingFeatureID .in_ (sfids ))
681701
682702 try :
0 commit comments