@@ -72,6 +72,43 @@ def __init__(self, affiliation, person, org):
72
72
self .Organization = '(' + org .OrganizationCode + ') ' + org .OrganizationName
73
73
74
74
75
+ class SamplingFeatureDataSet ():
76
+ datasets = {}
77
+ def __init__ (self , samplingfeature , datasetresults ):
78
+ sf = samplingfeature
79
+
80
+ self .SamplingFeatureID = sf .SamplingFeatureID
81
+ self .SamplingFeatureUUID = sf .SamplingFeatureUUID
82
+ self .SamplingFeatureTypeCV = sf .SamplingFeatureTypeCV
83
+ self .SamplingFeatureCode = sf .SamplingFeatureCode
84
+ self .SamplingFeatureName = sf .SamplingFeatureName
85
+ self .SamplingFeatureDescription = sf .SamplingFeatureDescription
86
+ self .SamplingFeatureGeotypeCV = sf .SamplingFeatureGeotypeCV
87
+ self .Elevation_m = sf .Elevation_m
88
+ self .ElevationDatumCV = sf .ElevationDatumCV
89
+ self .FeatureGeometryWKT = sf .FeatureGeometryWKT
90
+ self .assignDatasets (datasetresults )
91
+
92
+ print (self .datasets )
93
+
94
+
95
+ def assignDatasets (self , datasetresults ):
96
+ for dsr in datasetresults :
97
+ if dsr .DataSetObj not in self .datasets :
98
+ #if the dataset is not in the dictionary, add it and the first result
99
+ self .datasets [dsr .DataSetObj ]= []
100
+ res = dsr .ResultObj
101
+ # res.FeatureActionObj = None
102
+ self .datasets [dsr .DataSetObj ].append (res )
103
+ else :
104
+ #if the dataset is in the dictionary, append the result object to the list
105
+ res = dsr .ResultObj
106
+ # res.FeatureActionObj = None
107
+ self .datasets [dsr .DataSetObj ].append (res )
108
+
109
+
110
+
111
+
75
112
class ReadODM2 (serviceBase ):
76
113
# Exists functions
77
114
def resultExists (self , result ):
@@ -871,7 +908,6 @@ def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=No
871
908
raise ValueError ('Expected samplingFeatureID OR samplingFeatureUUID OR samplingFeatureCode argument' )
872
909
873
910
sf_query = self ._session .query (SamplingFeatures )
874
-
875
911
if ids :
876
912
sf_query = sf_query .filter (SamplingFeatures .SamplingFeatureID .in_ (ids ))
877
913
if codes :
@@ -880,21 +916,29 @@ def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=No
880
916
sf_query = sf_query .filter (SamplingFeatures .SamplingFeatureUUID .in_ (uuids ))
881
917
sf_list = []
882
918
for sf in sf_query .all ():
883
- sf_list .append (sf . SamplingFeatureID )
919
+ sf_list .append (sf )
884
920
885
- q = self . _session . query ( DataSetsResults )\
886
- . join ( Results )\
887
- . join ( FeatureActions )\
888
- . filter ( FeatureActions . SamplingFeatureID . in_ ( sf_list ))
921
+ sfds = None
922
+ try :
923
+ sfds = []
924
+ for sf in sf_list :
889
925
890
- if dstype :
891
- q = q .filter_by (DatasetTypeCV = dstype )
926
+ q = self ._session .query (DataSetsResults )\
927
+ .join (Results )\
928
+ .join (FeatureActions )\
929
+ .filter (FeatureActions .SamplingFeatureID == sf .SamplingFeatureID )
892
930
893
- try :
894
- return q .all ()
931
+ if dstype :
932
+ q = q .filter_by (DatasetTypeCV = dstype )
933
+
934
+
935
+ vals = q .all ()
936
+
937
+ sfds .append (SamplingFeatureDataSet (sf , vals ))
895
938
except Exception as e :
896
939
print ('Error running Query: {}' .format (e ))
897
940
return None
941
+ return sfds
898
942
899
943
# Data Quality
900
944
def getDataQuality (self ):
0 commit comments