@@ -28,7 +28,7 @@ class SpatialReference(Base):
2828 srs_id = Column ('srsid' , String )
2929 srs_name = Column ('srsname' , String )
3030 is_geographic = None
31- #is_geographic = Column('IsGeographic', Boolean)
31+ # is_geographic = Column('IsGeographic', Boolean)
3232 notes = Column ('description' , String )
3333
3434 def __repr__ (self ):
@@ -65,21 +65,18 @@ class Site(Base):
6565
6666 local_x = None
6767 local_y = None
68- local_projection_id = None #Column('LocalProjectionID', Integer, ForeignKey('SpatialReferences.SpatialReferenceID'))
68+ local_projection_id = None # Column('LocalProjectionID', Integer, ForeignKey('SpatialReferences.SpatialReferenceID'))
6969 pos_accuracy_m = None
7070 state = None
7171 county = None
7272 comments = None
7373
74-
75-
7674 # relationships
7775 # TODO @sreeder, Please take a look at this line as it throws: sqlalchemy.exc.InvalidRequestError: Class <class 'ODM2.LikeODM1.model.Site2'> does not have a mapped column named 'lat_long_datum_id'
7876 # :)
79- #spatial_ref = relationship(SpatialReference, primaryjoin=("SpatialReference.id==Site2.lat_long_datum_id"))
80- #spatial_ref = relationship(SpatialReference)
81- #spatial_ref = relationship(SpatialReference, primaryjoin="Site.lat_long_datum_id == SpatialReference.id")
82-
77+ # spatial_ref = relationship(SpatialReference, primaryjoin=("SpatialReference.id==Site2.lat_long_datum_id"))
78+ # spatial_ref = relationship(SpatialReference)
79+ # spatial_ref = relationship(SpatialReference, primaryjoin="Site.lat_long_datum_id == SpatialReference.id")
8380
8481 def __repr__ (self ):
8582 return "<Site('%s', '%s', '%s')>" % (self .code , self .name , self .elevation_m )
@@ -208,7 +205,6 @@ class Source(Base):
208205 email = source_join .c .odm2_affiliations_primaryemail # Column('Email', String, nullable=False)
209206 address = source_join .c .odm2_affiliations_primaryaddress # Column('Address', String, nullable=False)
210207
211-
212208 @property
213209 def city (self ):
214210 return "Unknown"
@@ -233,7 +229,7 @@ def citation(self):
233229 #iso_metadata_id = Column('MetadataID', Integer, ForeignKey('ODM2.ISOMetadata.Metadataid'), nullable=False)
234230 '''
235231 # relationships
236- #iso_metadata = relationship(ISOMetadata)
232+ # iso_metadata = relationship(ISOMetadata)
237233
238234 def __repr__ (self ):
239235 return "<Source('%s', '%s', '%s', '%s', '%s', '%s', '%s')>" % \
@@ -530,29 +526,24 @@ class DataValue(Base):
530526 utc_offset = joined_table .c .odm2_timeseriesresultvalues_valuedatetimeutcoffset
531527 site_id = joined_table .c .odm2_featureactions_SFID #joined_table.c.odm2_featureactions_FeAID
532528 variable_id = joined_table .c .odm2_results_variableid
533- offset_value = None #column_property(-1) ## Question for jeff
534- offset_type_id = None #column_property(-1)#None ## Question for Jeff
529+ offset_value = None # column_property(-1) ## Question for jeff
530+ offset_type_id = None # column_property(-1)#None ## Question for Jeff
535531 censor_code = joined_table .c .odm2_timeseriesresultvalues_censorcodecv
536532
537533 method_id = joined_table .c .odm2_actions_methodid
538534 source_id = joined_table .c .odm2_actionby_affiliationid
539- sample_id = column_property (site_id ) ## Question for jeff
540- derived_from_id = None #column_property(-1)
535+ sample_id = column_property (site_id ) # Question for jeff
536+ derived_from_id = None # column_property(-1)
541537 quality_control_level_id = joined_table .c .odm2_timeseriesresultvalues_qualitycodecv
542538
543- qualifier_id = None ## Join with annotations..
544- # date_time_utc = column_property(local_date_time+utc_offset) ## column propertly datetimeutcoffset
539+ qualifier_id = None # Join with annotations..
540+ # date_time_utc = column_property(local_date_time+utc_offset) ## column property datetimeutcoffset
545541 # @declared_attr
542+
546543 @property
547544 def date_time_utc (cls ):
548545 return cls .local_date_time - timedelta (hours = cls .utc_offset )
549546
550- # @classmethod
551- # def date_time_utc(cls):
552- # return select([])
553-
554-
555-
556547 # relationships
557548 # site = relationship(Site, primaryjoin = site_id==Site.id)
558549 variable = relationship (Variable , primaryjoin = variable_id == Variable .id )
@@ -587,22 +578,27 @@ def __repr__(self):
587578method_table = select ([
588579 method_table .c .methodid ,
589580 method_table .c .methoddescription ,
590- #method_table.c.organizationid.label('methodorgid'),
581+ # method_table.c.organizationid.label('methodorgid'),
591582
592583]).alias ("odm2_methods" )
593584
594585processing_levels_table = ProcessingLevels ().__table__
595-
586+ '''
596587joined_table_2 = feature_action_table.join(result_aliased_table, feature_action_table.c.FeAID ==
597588 result_aliased_table.c.FAID)
589+ # Obtain TSResults
590+ joined_table_2 = joined_table_2.join(ts_table, joined_table_2.c.odm2_results_RID ==
591+ ts_table.c.resultid)
592+ '''
593+ joined_table_2 = result_aliased_table .join (ts_table , result_aliased_table .c .RID == ts_table .c .resultid )
594+ joined_table_2 = joined_table_2 .join (feature_action_table , joined_table_2 .c .odm2_results_FAID == feature_action_table .c .FeAID )
595+
598596joined_table_2 = joined_table_2 .join (site_join , joined_table_2 .c .odm2_featureactions_SFID ==
599597 site_join .c .odm2_sites_samplingfeatureid )
600598joined_table_2 = joined_table_2 .join (variables_table , joined_table_2 .c .odm2_results_variableid ==
601599 variables_table .c .variableid )
602600
603- # Obtain TSResults
604- joined_table_2 = joined_table_2 .join (ts_table , joined_table_2 .c .odm2_results_RID ==
605- ts_table .c .resultid )
601+
606602# Obtaining Action
607603joined_table_2 = joined_table_2 .join (action_aliased_table , joined_table_2 .c .odm2_featureactions_actid ==
608604 action_aliased_table .c .AID )
@@ -666,7 +662,7 @@ class Series(Base):
666662
667663 # begin_date_time_utc = None # Column('BeginDateTimeUTC', DateTime)
668664 # end_date_time_utc = None # Column('EndDateTimeUTC', DateTime)
669- utc_offset = - 7 #joined_table_2.c.odm2_timeseriesresultvalues_valuedatetimeutcoffset
665+ utc_offset = - 7 # joined_table_2.c.odm2_timeseriesresultvalues_valuedatetimeutcoffset
670666
671667 @property
672668 def begin_date_time_utc (cls ):
0 commit comments