Skip to content

Commit 7133728

Browse files
author
sreeder
committed
add Annotation objects and query
1 parent 566609f commit 7133728

File tree

2 files changed

+143
-9
lines changed

2 files changed

+143
-9
lines changed

odm2api/ODM2/models.py

Lines changed: 116 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,29 +1136,137 @@ class ResultAnnotations(Base):
11361136
AnnotationObj = relationship(Annotations)
11371137
ResultObj = relationship(Results)
11381138

1139+
class SamplingFeatureAnnotations(Base):
1140+
__tablename__ = u'samplingfeatureannotations'
1141+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1142+
1143+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1144+
SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID),
1145+
nullable=False)
1146+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1147+
1148+
AnnotationObj = relationship(Annotations)
1149+
SamplingFeatureObj = relationship(SamplingFeatures)
11391150

1140-
class ResultValueAnnotations(Base):
1141-
__tablename__ = u'resultvalueannotations'
1151+
1152+
class CategoricalResultValueAnnotations(Base):
1153+
__tablename__ = u'categoricalresultvalueannotations'
11421154
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
11431155

11441156
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1145-
ValueID = Column('valueid', BigInteger, nullable=False)
1157+
ValueID = Column('valueid', BigInteger, ForeignKey(CategoricalResultValues.ValueID) ,nullable=False)
11461158
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
11471159

11481160
AnnotationObj = relationship(Annotations)
1161+
ValueObj = relationship(CategoricalResultValues)
11491162

11501163

1151-
class SamplingFeatureAnnotations(Base):
1152-
__tablename__ = u'samplingfeatureannotations'
1164+
class EquipmentAnnotations(Base):
1165+
__tablename__ = u'equipmentannotations'
11531166
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
11541167

11551168
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1156-
SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID),
1157-
nullable=False)
1169+
EquipmentID = Column('valueid', BigInteger, ForeignKey(Equipment.ValueID) ,nullable=False)
11581170
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
11591171

11601172
AnnotationObj = relationship(Annotations)
1161-
SamplingFeatureObj = relationship(SamplingFeatures)
1173+
EquipmentObj = relationship(Equipment)
1174+
1175+
1176+
class MeasurementResultValueAnnotations(Base):
1177+
__tablename__ = u'measurementresultvalueannotations'
1178+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1179+
1180+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1181+
ValueID = Column('valueid', BigInteger, ForeignKey(MeasurementResultValues.ValueID) ,nullable=False)
1182+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1183+
1184+
AnnotationObj = relationship(Annotations)
1185+
ValueObj = relationship(MeasurementResultValues)
1186+
1187+
1188+
class PointCoverageResultValueAnnotations(Base):
1189+
__tablename__ = u'pointcoverageresultvalueannotations'
1190+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1191+
1192+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1193+
ValueID = Column('valueid', BigInteger, ForeignKey(PointCoverageResultValues.ValueID) ,nullable=False)
1194+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1195+
1196+
AnnotationObj = relationship(Annotations)
1197+
ValueObj = relationship(PointCoverageResultValues)
1198+
1199+
1200+
class ProfileResultValueAnnotations(Base):
1201+
__tablename__ = u'profileresultvalueannotations'
1202+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1203+
1204+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1205+
ValueID = Column('valueid', BigInteger, ForeignKey(ProfileResultValues.ValueID) ,nullable=False)
1206+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1207+
1208+
AnnotationObj = relationship(Annotations)
1209+
ValueObj = relationship(ProfileResultValues)
1210+
1211+
1212+
class SectionResultValueAnnotations(Base):
1213+
__tablename__ = u'sectionResultValueAnnotations'
1214+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1215+
1216+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1217+
ValueID = Column('valueid', BigInteger, ForeignKey(SectionResultValues.ValueID) ,nullable=False)
1218+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1219+
1220+
AnnotationObj = relationship(Annotations)
1221+
ValueObj = relationship(SectionResultValues)
1222+
1223+
1224+
class SpectraResultValueAnnotations(Base):
1225+
__tablename__ = u'spectraresultvalueannotations'
1226+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1227+
1228+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1229+
ValueID = Column('valueid', BigInteger, ForeignKey(SpectraResultValues.ValueID) ,nullable=False)
1230+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1231+
1232+
AnnotationObj = relationship(Annotations)
1233+
ValueObj = relationship(SpectraResultValues)
1234+
1235+
1236+
class TimeSeriesResultValueAnnotations(Base):
1237+
__tablename__ = u'timeseriesresultvalueannotations'
1238+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1239+
1240+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1241+
ValueID = Column('valueid', BigInteger, ForeignKey(TimeSeriesResultValues.ValueID) ,nullable=False)
1242+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1243+
1244+
AnnotationObj = relationship(Annotations)
1245+
ValueObj = relationship(TimeSeriesResultValues)
1246+
1247+
1248+
class TrajectoryResultValueAnnotations(Base):
1249+
__tablename__ = u'trajectoryresultvalueannotations'
1250+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1251+
1252+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1253+
ValueID = Column('valueid', BigInteger, ForeignKey(TrajectoryResultValues.ValueID) ,nullable=False)
1254+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1255+
1256+
AnnotationObj = relationship(Annotations)
1257+
ValueObj = relationship(TrajectoryResultValues)
1258+
1259+
1260+
class TransectResultValueAnnotations(Base):
1261+
__tablename__ = u'transectresultvalueannotations'
1262+
__table_args__ = {u'schema': 'odm2'} # __table_args__ = {u'schema': Schema.getSchema()}
1263+
1264+
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
1265+
ValueID = Column('valueid', BigInteger, ForeignKey(TransectResultValues.ValueID) ,nullable=False)
1266+
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
1267+
1268+
AnnotationObj = relationship(Annotations)
1269+
ValueObj = relationship(TransectResultValues)
11621270

11631271

11641272
# ################################################################################

odm2api/ODM2/services/readService.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ def __init__(self, session):
5050
# Annotations
5151
# ################################################################################
5252

53+
def getAnnotations(self, type=None)
54+
55+
#TODO What keywords do I use for type
56+
a = Annotations
57+
if type =="action":
58+
a=ActionAnnotations
59+
elif type =="categoricalResultValue":
60+
a=CategoricalResultAnnotations
61+
elif type =="equipmentAnnotation":
62+
a=EquipmentAnnotations
63+
elif type =="measurementResultValue":
64+
elif type =="method":
65+
elif type =="pointCoverageResultValue":
66+
elif type =="profileResultValue":
67+
elif type =="result":
68+
elif type =="samplingFeature":
69+
elif type =="sectionResultValue":
70+
elif type =="spectraResultValue":
71+
elif type =="timeSeriesResultValue":
72+
elif type =="trajectoryResultValue":
73+
elif type =="transectResultValue":
74+
try:
75+
return self._session.query(a).all()
76+
except:
77+
return None
78+
5379

5480

5581

@@ -519,7 +545,7 @@ def getSiteBySFId(self, siteId):
519545
:param siteId:
520546
:type Integer:
521547
:return Return matching Site Object filtered by siteId:
522-
:type Site:
548+
:type Site:
523549
"""
524550
try:
525551
return self._session.query(Sites).filter_by(SamplingFeatureID=siteId).one()

0 commit comments

Comments
 (0)