From fba24a51dc762357609cdbb6576a0df91cc3c308 Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Mon, 8 Jan 2018 15:55:04 -0800 Subject: [PATCH 1/6] Cleanup readServices and base --- odm2api/ODM2/services/readService.py | 100 ++++++++++++++------------- odm2api/base.py | 8 +-- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/odm2api/ODM2/services/readService.py b/odm2api/ODM2/services/readService.py index 75b8e2f..8383062 100644 --- a/odm2api/ODM2/services/readService.py +++ b/odm2api/ODM2/services/readService.py @@ -1,5 +1,7 @@ from __future__ import (absolute_import, division, print_function) +import warnings + from odm2api.ODM2 import serviceBase from odm2api.ODM2.models import ( ActionAnnotations, ActionDirectives, ActionExtensionPropertyValues, Actions, @@ -29,7 +31,7 @@ SpatialReferenceExternalIdentifiers, SpatialReferences, SpecimenBatchPositions, SpectraResultValueAnnotations, SpectraResultValues, TaxonomicClassifierExternalIdentifiers, TaxonomicClassifiers, TimeSeriesResultValueAnnotations, TimeSeriesResultValues, - TimeSeriesResults, TrajectoryResultValueAnnotations, TrajectoryResultValues, + TrajectoryResultValueAnnotations, TrajectoryResultValues, TransectResultValueAnnotations, TransectResultValues, Units, VariableExtensionPropertyValues, VariableExternalIdentifiers, Variables, ) @@ -38,8 +40,6 @@ from sqlalchemy import distinct, exists -import warnings - __author__ = 'sreeder' @@ -75,8 +75,9 @@ def __init__(self, affiliation, person, org): class SamplingFeatureDataSet(): - datasets={} - related_features={} + datasets = {} + related_features = {} + def __init__(self, samplingfeature, datasetresults, relatedfeatures): sf = samplingfeature @@ -94,7 +95,6 @@ def __init__(self, samplingfeature, datasetresults, relatedfeatures): self.assignDatasets(datasetresults) self.assignRelatedFeatures(relatedfeatures) - print(self.datasets) def assignDatasets(self, datasetresults): @@ -102,18 +102,17 @@ def assignDatasets(self, datasetresults): if datasetresults: for dsr in datasetresults: if dsr.DataSetObj not in self.datasets: - #if the dataset is not in the dictionary, add it and the first result - self.datasets[dsr.DataSetObj]=[] + # if the dataset is not in the dictionary, add it and the first result + self.datasets[dsr.DataSetObj] = [] res = dsr.ResultObj # res.FeatureActionObj = None self.datasets[dsr.DataSetObj].append(res) else: - #if the dataset is in the dictionary, append the result object to the list + # if the dataset is in the dictionary, append the result object to the list res = dsr.ResultObj # res.FeatureActionObj = None self.datasets[dsr.DataSetObj].append(res) - def assignRelatedFeatures(self, relatedfeatures): self.related_features = {} if relatedfeatures: @@ -169,7 +168,8 @@ def resultExists(self, result): ) return ret.scalar() - except: + except Exception as e: + print('Error running Query: {}'.format(e)) return None # Annotations @@ -225,7 +225,8 @@ def getAnnotations(self, annottype=None, codes=None, ids=None, **kwargs): query = query.filter(Annotations.AnnotationID.in_(ids)) return query.all() - except: + except Exception as e: + print('Error running Query: {}'.format(e)) return None # CV @@ -384,15 +385,16 @@ def getVariables(self, ids=None, codes=None, sitecode=None, results=False): variables = [ x[0] for x in self._session.query(distinct(Results.VariableID)) - .filter(Results.FeatureActionID == FeatureActions.FeatureActionID) - .filter(FeatureActions.SamplingFeatureID == SamplingFeatures.SamplingFeatureID) - .filter(SamplingFeatures.SamplingFeatureCode == sitecode).all() + .filter(Results.FeatureActionID == FeatureActions.FeatureActionID) + .filter(FeatureActions.SamplingFeatureID == SamplingFeatures.SamplingFeatureID) + .filter(SamplingFeatures.SamplingFeatureCode == sitecode).all() ] if ids: ids = list(set(ids).intersection(variables)) else: ids = variables - except: + except Exception as e: + print('Error running Query: {}'.format(e)) pass if results: @@ -402,7 +404,8 @@ def getVariables(self, ids=None, codes=None, sitecode=None, results=False): ids = list(set(ids).intersection(variables)) else: ids = variables - except: + except Exception as e: + print('Error running Query: {}'.format(e)) pass query = self._session.query(Variables) @@ -520,10 +523,10 @@ def getSamplingFeatures(self, ids=None, codes=None, uuids=None, if results: try: fas = [x[0] for x in self._session.query(distinct(Results.FeatureActionID)).all()] - except: + except Exception as e: + print('Error running Query: {}'.format(e)) return None - sf = [x[0] for x in self._session.query(distinct(FeatureActions.SamplingFeatureID)) - .filter(FeatureActions.FeatureActionID.in_(fas)).all()] + sf = [x[0] for x in self._session.query(distinct(FeatureActions.SamplingFeatureID)).filter(FeatureActions.FeatureActionID.in_(fas)).all()] # noqa if ids: ids = list(set(ids).intersection(sf)) else: @@ -557,8 +560,8 @@ def getRelatedSamplingFeatures(self, sfid=None, rfid=None, relationshiptype=None """ - sf = self._session.query(distinct(SamplingFeatures.SamplingFeatureID))\ - .select_from(RelatedFeatures) + sf = self._session.query(distinct(SamplingFeatures.SamplingFeatureID)) \ + .select_from(RelatedFeatures) if sfid: sf = sf.join(RelatedFeatures.RelatedFeatureObj).filter(RelatedFeatures.SamplingFeatureID == sfid) @@ -576,8 +579,6 @@ def getRelatedSamplingFeatures(self, sfid=None, rfid=None, relationshiptype=None print('Error running Query: {}'.format(e)) return None - - # Action def getActions(self, ids=None, acttype=None, sfid=None, **kwargs): """ @@ -656,7 +657,6 @@ def getUnits(self, ids=None, name=None, unittype=None, **kwargs): print('Error running Query: {}'.format(e)) return None - # Organization def getOrganizations(self, ids=None, codes=None): """ @@ -738,7 +738,7 @@ def getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=N return None # Results - def getResults(self, ids=None, restype = None, uuids=None, actionid=None, simulationid=None, + def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulationid=None, variableid=None, siteid=None, sfids=None, sfuuids=None, sfcodes=None, **kwargs): # TODO what if user sends in both type and actionid vs just actionid @@ -791,10 +791,10 @@ def getResults(self, ids=None, restype = None, uuids=None, actionid=None, simula if uuids: query = query.filter(Results.ResultUUID.in_(uuids)) if simulationid: - query = query.join(FeatureActions)\ - .join(Actions)\ - .join(Simulations)\ - .filter_by(SimulationID=simulationid) + query = query.join(FeatureActions) \ + .join(Actions) \ + .join(Simulations) \ + .filter_by(SimulationID=simulationid) if actionid: query = query.join(FeatureActions).filter_by(ActionID=actionid) if 'sfid' in kwargs: @@ -810,16 +810,15 @@ def getResults(self, ids=None, restype = None, uuids=None, actionid=None, simula query = query.join(FeatureActions).filter(FeatureActions.SamplingFeatureID.in_(sfids)) if siteid: - sfids = [x[0] for x in self._session.query( distinct(SamplingFeatures.SamplingFeatureID)) .select_from(RelatedFeatures) .join(RelatedFeatures.SamplingFeatureObj) .filter(RelatedFeatures.RelatedFeatureID == siteid) .all() - ] + ] - #TODO does this code do the same thing as the code above? + # TODO does this code do the same thing as the code above? # sf_list = self.getRelatedSamplingFeatures(rfid=siteid) # sfids = [] # for sf in sf_list: @@ -834,7 +833,7 @@ def getResults(self, ids=None, restype = None, uuids=None, actionid=None, simula return None # Datasets - def getDataSets(self, ids= None, codes=None, uuids=None, dstype=None): + def getDataSets(self, ids=None, codes=None, uuids=None, dstype=None): """ Retrieve a list of Datasets @@ -906,7 +905,7 @@ def getDataSetsResults(self, ids=None, codes=None, uuids=None, dstype=None): if all(v is None for v in [ids, codes, uuids]): raise ValueError('Expected DataSetID OR DataSetUUID OR DataSetCode argument') - q = self._session.query(DataSetsResults)\ + q = self._session.query(DataSetsResults) \ .join(DataSets) if ids: q = q.filter(DataSets.DataSetID.in_(ids)) @@ -955,12 +954,11 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None): resids.append(ds.ResultID) try: - return self.getResultValues(resultids = resids) + return self.getResultValues(resultids=resids) except Exception as e: print('Error running Query {}'.format(e)) return None - def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=None, sftype=None): """ Retrieve a list of Datasets associated with the given sampling feature data. @@ -990,11 +988,12 @@ def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=No """ - # make sure one of the three arguments has been sent in if all(v is None for v in [ids, codes, uuids, sftype]): - raise ValueError('Expected samplingFeatureID OR samplingFeatureUUID OR samplingFeatureCode OR samplingFeatureType ' - 'argument') + raise ValueError( + 'Expected samplingFeatureID OR samplingFeatureUUID ' + 'OR samplingFeatureCode OR samplingFeatureType ' + 'argument') sf_query = self._session.query(SamplingFeatures) if sftype: @@ -1011,18 +1010,17 @@ def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=No sf_list.append(sf) try: - sfds=[] + sfds = [] for sf in sf_list: - q = self._session.query(DataSetsResults)\ - .join(Results)\ - .join(FeatureActions)\ + q = self._session.query(DataSetsResults) \ + .join(Results) \ + .join(FeatureActions) \ .filter(FeatureActions.SamplingFeatureID == sf.SamplingFeatureID) if dstype: q = q.filter_by(DatasetTypeCV=dstype) - vals = q.all() related = self.getRelatedSamplingFeatures(sf.SamplingFeatureID) @@ -1081,17 +1079,21 @@ def getEquipment(self, codes=None, equiptype=None, sfid=None, actionid=None, **k warnings.warn('The parameter \'type\' is deprecated. Please use the equiptype parameter instead.', DeprecationWarning, stacklevel=2) equiptype = kwargs['type'] + + # NOTE: Equiptype currently unused! + if equiptype: + pass e = self._session.query(Equipment) if sfid: e = e.join(EquipmentUsed) \ - .join(Actions) \ - .join(FeatureActions) \ - .filter(FeatureActions.SamplingFeatureID == sfid) + .join(Actions) \ + .join(FeatureActions) \ + .filter(FeatureActions.SamplingFeatureID == sfid) if codes: e = e.filter(Equipment.EquipmentCode.in_(codes)) if actionid: e = e.join(EquipmentUsed).join(Actions) \ - .filter(Actions.ActionID == actionid) + .filter(Actions.ActionID == actionid) return e.all() def CalibrationReferenceEquipment(self): diff --git a/odm2api/base.py b/odm2api/base.py index a164a1d..6887017 100644 --- a/odm2api/base.py +++ b/odm2api/base.py @@ -1,5 +1,6 @@ from __future__ import (absolute_import, division, print_function) + class serviceBase(object): def __init__(self, session_factory, debug=False): """Must send in either a session_factory.""" @@ -42,10 +43,9 @@ def __repr__(self): if 'obj' in v.lower(): del valuedict[v] - if v == "_sa_instance_state": - del valuedict["_sa_instance_state"] - return "<%s(%s)>" % (self.__class__.__name__, str(valuedict)) - + if v == '_sa_instance_state': + del valuedict['_sa_instance_state'] + return '<%s(%s)>' % (self.__class__.__name__, str(valuedict)) class modelBase(): From 007550f5918001bf925ec3307c5d246b318953bd Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Wed, 10 Jan 2018 09:48:42 -0800 Subject: [PATCH 2/6] Clean up updateService --- odm2api/ODM2/services/updateService.py | 67 ++++++-------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/odm2api/ODM2/services/updateService.py b/odm2api/ODM2/services/updateService.py index 1bec3ce..87e77b8 100644 --- a/odm2api/ODM2/services/updateService.py +++ b/odm2api/ODM2/services/updateService.py @@ -5,7 +5,7 @@ from datetime import datetime from odm2api.ODM2 import serviceBase -from odm2api.ODM2.models import * +from odm2api.ODM2.models import (Actions, Results) # ################################################################################ @@ -13,39 +13,39 @@ # ################################################################################ class UpdateODM2(serviceBase): - def update(self, value): self._session.add(value) self._session.commit() return value -# ################################################################################ -# Core -# ################################################################################ + # ################################################################################ + # Core + # ################################################################################ def updateResultValidDateTime(self, resultId, dateTime): - #check type of "validdatetime' - #if not datetime do this: + # check type of "validdatetime' + # if not datetime do this: # dt = dateTime.to_datetime() - #else dt = dateTime + # else dt = dateTime if (type(dateTime) != datetime): dt = dateTime.to_datetime() else: dt = dateTime - q = self._session.query(Results).filter(Results.ResultID == int(resultId)).update({'ValidDateTime': dt}) + q = self._session.query(Results).filter(Results.ResultID == int(resultId)) + q.update({'ValidDateTime': dt}) + self._session.commit() def updateResult(self, resultID=None, valuecount=None, result=None): if resultID: q = self._session.query(Results).filter(Results.ResultID == int(resultID)) if valuecount: - q.update({"ValueCount": valuecount}) + q.update({'ValueCount': valuecount}) if result: self._session.add(result) self._session.commit() - - def updateAction(self, actionID=None, begin=None, end=None, action = None): + def updateAction(self, actionID=None, begin=None, end=None, action=None): if actionID: q = self._session.query(Actions).filter(Actions.ActionID == int(actionID)) # if (type(begin) != datetime): @@ -54,77 +54,40 @@ def updateAction(self, actionID=None, begin=None, end=None, action = None): # end = end.to_datetime() if begin: - q.update({"BeginDateTime": begin}) + q.update({'BeginDateTime': begin}) if end: - q.update({"EndDateTime": end}) + q.update({'EndDateTime': end}) elif action: self._session.add(action) self._session.commit() - # ################################################################################ # Data Quality # ################################################################################ - - - - # ################################################################################ # Equipment # ################################################################################ - - - - - # ################################################################################ # Extension Properties # ################################################################################ - - - - # ################################################################################ # External Identifiers # ################################################################################ - - - - # ################################################################################ # Lab Analyses # ################################################################################ - - - - # ################################################################################ # Provenance # ################################################################################ - - - - # ################################################################################ # Results # ################################################################################ - - - - # ################################################################################ # Sampling Features # ################################################################################ - - - - # ################################################################################ # Sensors # ################################################################################ - - - -# ################################################################################ +################################################################################ # ODM2 # ################################################################################ From 26099a04a622d5e78c81ab33229b3a39fefbc540 Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Wed, 10 Jan 2018 09:49:13 -0800 Subject: [PATCH 3/6] Cleanup model --- odm2api/ODM2/models.py | 110 ++++------------------------------------- 1 file changed, 10 insertions(+), 100 deletions(-) diff --git a/odm2api/ODM2/models.py b/odm2api/ODM2/models.py index af30d3a..5f8c4ac 100644 --- a/odm2api/ODM2/models.py +++ b/odm2api/ODM2/models.py @@ -5,6 +5,7 @@ from sqlalchemy import BigInteger, Boolean, Column, Date, DateTime, Float, ForeignKey, Integer, String, case from sqlalchemy.dialects import mysql, postgresql, sqlite from sqlalchemy.orm import relationship + Base = modelBase.Base BigIntegerType = BigInteger() @@ -27,7 +28,7 @@ def is_hex(s): ################################################################################ # CV ################################################################################ -class CV (object): +class CV(object): __table_args__ = {u'schema': 'odm2'} Term = Column('term', String(255), nullable=False) @@ -183,7 +184,6 @@ class Organizations(Base): class Affiliations(Base): - AffiliationID = Column('affiliationid', Integer, primary_key=True, nullable=False) PersonID = Column('personid', ForeignKey(People.PersonID), nullable=False) OrganizationID = Column('organizationid', ForeignKey(Organizations.OrganizationID)) @@ -232,7 +232,6 @@ class Actions(Base): class ActionBy(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), nullable=False) AffiliationID = Column('affiliationid', ForeignKey(Affiliations.AffiliationID), nullable=False) @@ -264,22 +263,22 @@ class SamplingFeatures(Base): index=True) """str: Dimensionality of SamplingFeature; point2d, line2d, etc.""" Elevation_m = Column('elevation_m', Float(53)) - """float: The elevation of the sampling feature in meters, or in the case of Specimen, - the elevation from where the SamplingFeature.Specimen was collected""" + """float: The elevation of the sampling feature in meters, or in the case of Specimen, + the elevation from where the SamplingFeature.Specimen was collected""" # noqa ElevationDatumCV = Column('elevationdatumcv', ForeignKey(CVElevationDatum.Name), index=True) """str: The code for the vertical geodetic datum that specifies the zero point for - the Sampling Feature Elevation""" + the Sampling Feature Elevation""" # noqa # FeatureGeometry = Column('featuregeometry', String(50)) """object: The location geometry of the sampling feature on the Earth expressed using a geometry data type. Can be a Point, Curve (profile, trajectory, etc), Surface (flat polygons, etc) or Solid/Volume (although often limited to - 2D geometries). """ + 2D geometries). """ # noqa FeatureGeometryWKT = Column('featuregeometrywkt', String(50)) """str: The location geometry of the sampling feature on the Earth expressed as well known text (WKT). Can be a Point, Curve (profile, trajectory, etc.), Surface (flat polygons, etc.), or Solid/Volume (although often limited to - 2D geometries).""" + 2D geometries).""" # noqa __mapper_args__ = { 'polymorphic_on': case( [ @@ -443,7 +442,6 @@ class Results(Base): class DataLoggerProgramFiles(Base): - ProgramID = Column('programid', Integer, primary_key=True, nullable=False) AffiliationID = Column('affiliationid', Integer, ForeignKey(Affiliations.AffiliationID), nullable=False) ProgramName = Column('programname', String(255), nullable=False) @@ -455,7 +453,6 @@ class DataLoggerProgramFiles(Base): class DataLoggerFiles(Base): - DataLoggerFileID = Column('dataloggerfileid', Integer, primary_key=True, nullable=False) ProgramID = Column('programid', Integer, ForeignKey(DataLoggerProgramFiles.ProgramID), nullable=False) DataLoggerFileName = Column('dataloggerfilename', String(255), nullable=False) @@ -466,7 +463,6 @@ class DataLoggerFiles(Base): class EquipmentModels(Base): - ModelID = Column('modelid', Integer, primary_key=True, nullable=False) ModelManufacturerID = Column('modelmanufacturerid', Integer, ForeignKey(Organizations.OrganizationID), nullable=False) @@ -481,7 +477,6 @@ class EquipmentModels(Base): class InstrumentOutputVariables(Base): - InstrumentOutputVariableID = Column( 'instrumentoutputvariableid', Integer, @@ -503,7 +498,6 @@ class InstrumentOutputVariables(Base): class DataLoggerFileColumns(Base): - DataLoggerFileColumnID = Column('dataloggerfilecolumnid', Integer, primary_key=True, nullable=False) ResultID = Column('resultid', BigIntegerType, ForeignKey(Results.ResultID)) DataLoggerFileID = Column('dataloggerfileid', Integer, @@ -539,7 +533,6 @@ class DataLoggerFileColumns(Base): class Equipment(Base): - EquipmentID = Column('equipmentid', Integer, primary_key=True, nullable=False) EquipmentCode = Column('equipmentcode', String(50), nullable=False) EquipmentName = Column('equipmentname', String(255), nullable=False) @@ -559,7 +552,6 @@ class Equipment(Base): class CalibrationReferenceEquipment(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), nullable=False) EquipmentID = Column('equipmentid', Integer, ForeignKey(Equipment.EquipmentID), nullable=False) @@ -569,7 +561,6 @@ class CalibrationReferenceEquipment(Base): class EquipmentActions(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) EquipmentID = Column('equipmentid', ForeignKey(Equipment.EquipmentID), nullable=False) ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False) @@ -579,7 +570,6 @@ class EquipmentActions(Base): class EquipmentUsed(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), nullable=False) EquipmentID = Column('equipmentid', Integer, ForeignKey(Equipment.EquipmentID), nullable=False) @@ -589,8 +579,7 @@ class EquipmentUsed(Base): class MaintenanceActions(Base): - - ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), primary_key=True, nullable=False) + ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), primary_key=True, nullable=False) IsFactoryService = Column('isfactoryservce', Boolean, nullable=False) MaintenanceCode = Column('maintenancecode', String(50)) MantenanceReason = Column('maintenancereason', String(50)) @@ -599,7 +588,6 @@ class MaintenanceActions(Base): class RelatedEquipment(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=True) EquipmentID = Column('equipmentid', Integer, ForeignKey(Equipment.EquipmentID), nullable=True) RelationshipTypeCV = Column('relationshiptypecv', String(255), nullable=True, index=True) @@ -625,8 +613,7 @@ class RelatedEquipment(Base): class CalibrationActions(Base): - - ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), primary_key=True, nullable=False) + ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), primary_key=True, nullable=False) CalibrationCheckValue = Column('calibrationcheckvalue', Float(53)) InstrumentOutputVariableID = Column('instrumentoutputvariableid', Integer, ForeignKey(InstrumentOutputVariables.VariableID), nullable=False) @@ -635,20 +622,19 @@ class CalibrationActions(Base): ActionObj = relationship(Actions) InstrumentOutputVariableObj = relationship(InstrumentOutputVariables) + # ################################################################################ # Lab Analyses # ################################################################################ class Directives(Base): - DirectiveID = Column('directiveid', Integer, primary_key=True, nullable=False) DirectiveTypeCV = Column('directivetypecv', ForeignKey(CVDirectiveType.Name), nullable=False, index=True) DirectiveDescription = Column('directivedescription', String(500), nullable=False) class ActionDirectives(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False) DirectiveID = Column('directiveid', ForeignKey(Directives.DirectiveID), nullable=False) @@ -678,7 +664,6 @@ class SpecimenBatchPositions(Base): # Sampling Features # ################################################################################ class SpatialReferences(Base): - SpatialReferenceID = Column('spatialreferenceid', Integer, primary_key=True, nullable=False) SRSCode = Column('srscode', String(50)) SRSName = Column('srsname', String(255), nullable=False) @@ -687,7 +672,6 @@ class SpatialReferences(Base): class Specimens(SamplingFeatures): - SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), primary_key=True) SpecimenTypeCV = Column('specimentypecv', ForeignKey(CVSpecimenType.Name), nullable=False, index=True) @@ -700,7 +684,6 @@ class Specimens(SamplingFeatures): class SpatialOffsets(Base): - SpatialOffsetID = Column('spatialoffsetid', Integer, primary_key=True, nullable=False) SpatialOffsetTypeCV = Column('spatialoffsettypecv', ForeignKey(CVSpatialOffsetType.Name), nullable=False, index=True) @@ -717,7 +700,6 @@ class SpatialOffsets(Base): class Sites(SamplingFeatures): - SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), primary_key=True) SpatialReferenceID = Column('spatialreferenceid', ForeignKey(SpatialReferences.SpatialReferenceID), @@ -734,7 +716,6 @@ class Sites(SamplingFeatures): class RelatedFeatures(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=False) SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), nullable=False) @@ -759,7 +740,6 @@ class RelatedFeatures(Base): class SpecimenTaxonomicClassifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) SamplingFeatureID = Column('samplingfeatureid', ForeignKey(Specimens.SamplingFeatureID), nullable=False) TaxonomicClassifierID = Column('taxonomicclassifierid', @@ -774,7 +754,6 @@ class SpecimenTaxonomicClassifiers(Base): # Simulation # ################################################################################ class Models(Base): - ModelID = Column('modelid', Integer, primary_key=True, nullable=False) ModelCode = Column('modelcode', String(255), nullable=False) ModelName = Column('modelname', String(255), nullable=False) @@ -782,7 +761,6 @@ class Models(Base): class RelatedModels(Base): - RelatedID = Column('relatedid', Integer, primary_key=True, nullable=False) ModelID = Column('modelid', ForeignKey(Models.ModelID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -794,7 +772,6 @@ class RelatedModels(Base): class Simulations(Base): - SimulationID = Column('simulationid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False) SimulationName = Column('simulationname', String(255), nullable=False) @@ -817,7 +794,6 @@ class Simulations(Base): # Part of the Provenance table, needed here to meet dependencies class Citations(Base): - CitationID = Column('citationid', Integer, primary_key=True, nullable=False) Title = Column('title', String(255), nullable=False) Publisher = Column('publisher', String(255), nullable=False) @@ -829,7 +805,6 @@ class Citations(Base): # Annotations # ################################################################################ class Annotations(Base): - AnnotationID = Column('annotationid', Integer, primary_key=True, nullable=False) AnnotationTypeCV = Column( 'annotationtypecv', @@ -851,7 +826,6 @@ class Annotations(Base): class ActionAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -861,7 +835,6 @@ class ActionAnnotations(Base): class EquipmentAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) EquipmentID = Column('valueid', BigIntegerType, ForeignKey(Equipment.EquipmentID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -871,7 +844,6 @@ class EquipmentAnnotations(Base): class MethodAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) MethodID = Column('methodid', ForeignKey(Methods.MethodID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -881,7 +853,6 @@ class MethodAnnotations(Base): class ResultAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ResultID = Column('resultid', ForeignKey(Results.ResultID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -893,7 +864,6 @@ class ResultAnnotations(Base): class SamplingFeatureAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), nullable=False) @@ -907,7 +877,6 @@ class SamplingFeatureAnnotations(Base): # Data Quality # ################################################################################ class DataSetsResults(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) DataSetID = Column('datasetid', ForeignKey(DataSets.DataSetID), nullable=False) ResultID = Column('resultid', ForeignKey(Results.ResultID), nullable=False) @@ -917,7 +886,6 @@ class DataSetsResults(Base): class DataQuality(Base): - DataQualityID = Column('dataqualityid', Integer, primary_key=True, nullable=False) DataQualityTypeCV = Column('dataqualitytypecv', ForeignKey(CVDataQualityType.Name), nullable=False, index=True) @@ -931,7 +899,6 @@ class DataQuality(Base): class ReferenceMaterials(Base): - ReferenceMaterialID = Column('referencematerialid', Integer, primary_key=True, nullable=False) ReferenceMaterialMediumCV = Column( 'referencematerialmediumcv', @@ -953,7 +920,6 @@ class ReferenceMaterials(Base): class CalibrationStandards(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), nullable=False) ReferenceMaterialID = Column( @@ -968,7 +934,6 @@ class CalibrationStandards(Base): class ReferenceMaterialValues(Base): - ReferenceMaterialValueID = Column('referencematerialvalueid', Integer, primary_key=True, nullable=False) ReferenceMaterialID = Column('referencematerialid', ForeignKey(ReferenceMaterials.ReferenceMaterialID), nullable=False) @@ -985,7 +950,6 @@ class ReferenceMaterialValues(Base): class ResultNormalizationValues(Base): - ResultID = Column(u'resultid', ForeignKey(Results.ResultID), primary_key=True) ReferenceMaterialValueID = Column(u'referencematerialvalueid', ForeignKey(ReferenceMaterialValues.ReferenceMaterialValueID), @@ -996,7 +960,6 @@ class ResultNormalizationValues(Base): class ResultsDataQuality(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ResultID = Column('resultid', ForeignKey(Results.ResultID), nullable=False) DataQualityID = Column('dataqualityid', ForeignKey(DataQuality.DataQualityID), nullable=False) @@ -1009,7 +972,6 @@ class ResultsDataQuality(Base): # Extension Properties # ################################################################################ class ExtensionProperties(Base): - PropertyID = Column('propertyid', Integer, primary_key=True, nullable=False) PropertyName = Column('propertyname', String(255), nullable=False) PropertyDescription = Column('propertydescription', String(500)) @@ -1021,7 +983,6 @@ class ExtensionProperties(Base): class ActionExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ActionID = Column('actionid', ForeignKey(Actions.ActionID), nullable=False) PropertyID = Column('propertyid', ForeignKey(ExtensionProperties.PropertyID), nullable=False) @@ -1032,7 +993,6 @@ class ActionExtensionPropertyValues(Base): class CitationExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) CitationID = Column('citationid', ForeignKey(Citations.CitationID), nullable=False) PropertyID = Column('propertyid', ForeignKey(ExtensionProperties.PropertyID), nullable=False) @@ -1043,7 +1003,6 @@ class CitationExtensionPropertyValues(Base): class MethodExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) MethodID = Column('methodid', ForeignKey(Methods.MethodID), nullable=False) PropertyID = Column('propertyid', ForeignKey(ExtensionProperties.PropertyID), nullable=False) @@ -1054,7 +1013,6 @@ class MethodExtensionPropertyValues(Base): class ResultExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ResultID = Column('resultid', ForeignKey(Results.ResultID), nullable=False) PropertyID = Column('propertyid', ForeignKey(ExtensionProperties.PropertyID), nullable=False) @@ -1065,7 +1023,6 @@ class ResultExtensionPropertyValues(Base): class SamplingFeatureExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), nullable=False) @@ -1077,7 +1034,6 @@ class SamplingFeatureExtensionPropertyValues(Base): class VariableExtensionPropertyValues(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) VariableID = Column('variableid', ForeignKey(Variables.VariableID), nullable=False) PropertyID = Column('propertyid', ForeignKey(ExtensionProperties.PropertyID), nullable=False) @@ -1091,7 +1047,6 @@ class VariableExtensionPropertyValues(Base): # Extension Identifiers # ################################################################################ class ExternalIdentifierSystems(Base): - ExternalIdentifierSystemID = Column( 'externalidentifiersystemid', Integer, @@ -1108,7 +1063,6 @@ class ExternalIdentifierSystems(Base): class CitationExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) CitationID = Column('citationid', ForeignKey(Citations.CitationID), nullable=False) ExternalIdentifierSystemID = Column('externalidentifiersystemid', @@ -1122,7 +1076,6 @@ class CitationExternalIdentifiers(Base): class MethodExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) MethodID = Column('methodid', ForeignKey(Methods.MethodID), nullable=False) ExternalIdentifierSystemID = Column('externalidentifiersystemid', @@ -1137,7 +1090,6 @@ class MethodExternalIdentifiers(Base): class PersonExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) PersonID = Column('personid', ForeignKey(People.PersonID), nullable=False) ExternalIdentifierSystemID = Column('externalidentifiersystemid', @@ -1151,7 +1103,6 @@ class PersonExternalIdentifiers(Base): class ReferenceMaterialExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ReferenceMaterialID = Column(ForeignKey(ReferenceMaterials.ReferenceMaterialID), nullable=False) ExternalIdentifierSystemID = Column('externalidentifiersystemid', @@ -1169,7 +1120,6 @@ class ReferenceMaterialExternalIdentifiers(Base): class SamplingFeatureExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) SamplingFeatureID = Column('samplingfeatureid', ForeignKey(SamplingFeatures.SamplingFeatureID), nullable=False) @@ -1188,7 +1138,6 @@ class SamplingFeatureExternalIdentifiers(Base): class SpatialReferenceExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) SpatialReferenceID = Column('spatialreferenceid', ForeignKey(SpatialReferences.SpatialReferenceID), nullable=False) @@ -1207,7 +1156,6 @@ class SpatialReferenceExternalIdentifiers(Base): class TaxonomicClassifierExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) TaxonomicClassifierID = Column('taxonomicclassifierid', ForeignKey(TaxonomicClassifiers.TaxonomicClassifierID), nullable=False) @@ -1226,7 +1174,6 @@ class TaxonomicClassifierExternalIdentifiers(Base): class VariableExternalIdentifiers(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) VariableID = Column('variableid', ForeignKey(Variables.VariableID), nullable=False) ExternalIdentifierSystemID = Column('externalidentifiersystemid', @@ -1244,7 +1191,6 @@ class VariableExternalIdentifiers(Base): # ################################################################################ class AuthorLists(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) CitationID = Column('citationid', ForeignKey(Citations.CitationID), nullable=False) PersonID = Column('personid', ForeignKey(People.PersonID), nullable=False) @@ -1255,7 +1201,6 @@ class AuthorLists(Base): class DataSetCitations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) DataSetID = Column('datasetid', ForeignKey(DataSets.DataSetID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1267,13 +1212,11 @@ class DataSetCitations(Base): class DerivationEquations(Base): - DerivationEquationID = Column('derivationequationid', Integer, primary_key=True, nullable=False) DerivationEquation = Column('derivationequation', String(255), nullable=False) class ResultDerivationEquations(Base): - ResultID = Column(u'resultid', ForeignKey(Results.ResultID), primary_key=True) DerivationEquationID = Column( u'derivationequationid', @@ -1286,7 +1229,6 @@ class ResultDerivationEquations(Base): class MethodCitations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) MethodID = Column('methodid', ForeignKey(Methods.MethodID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1298,7 +1240,6 @@ class MethodCitations(Base): class RelatedAnnotations(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1316,7 +1257,6 @@ class RelatedAnnotations(Base): class RelatedCitations(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=False) CitationID = Column('citationid', ForeignKey(Citations.CitationID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1331,7 +1271,6 @@ class RelatedCitations(Base): class RelatedDataSets(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=False) DataSetID = Column('datasetid', ForeignKey(DataSets.DataSetID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1347,7 +1286,6 @@ class RelatedDataSets(Base): class RelatedResults(Base): - RelationID = Column('relationid', Integer, primary_key=True, nullable=False) ResultID = Column('resultid', ForeignKey(Results.ResultID), nullable=False) RelationshipTypeCV = Column('relationshiptypecv', ForeignKey(CVRelationshipType.Name), nullable=False, @@ -1364,7 +1302,6 @@ class RelatedResults(Base): # Results # ################################################################################ class PointCoverageResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) ZLocation = Column('zlocation', Float(53)) ZLocationUnitsID = Column('zlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1396,7 +1333,6 @@ class PointCoverageResults(Results): class ProfileResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) XLocation = Column('xlocation', Float(53)) XLocationUnitsID = Column('xlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1426,7 +1362,6 @@ class ProfileResults(Results): class CategoricalResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) XLocation = Column('xlocation', Float(53)) XLocationUnitsID = Column('xlocationunitsid', Integer, ForeignKey(Units.UnitsID)) @@ -1455,7 +1390,6 @@ class CategoricalResults(Results): class TransectResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) ZLocation = Column('zlocation', Float(53)) ZLocationUnitsID = Column('zlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1482,7 +1416,6 @@ class TransectResults(Results): class SpectraResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) XLocation = Column('xlocation', Float(53)) XLocationUnitsID = Column('xlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1509,7 +1442,6 @@ class SpectraResults(Results): class TimeSeriesResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) XLocation = Column('xlocation', Float(53)) XLocationUnitsID = Column('xlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1536,7 +1468,6 @@ class TimeSeriesResults(Results): class SectionResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) YLocation = Column('ylocation', Float(53)) YLocationUnitsID = Column('ylocationunitsid', ForeignKey(Units.UnitsID)) @@ -1575,7 +1506,6 @@ class SectionResults(Results): class TrajectoryResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) SpatialReferenceID = Column('spatialreferenceid', ForeignKey(SpatialReferences.SpatialReferenceID)) IntendedTrajectorySpacing = Column('intendedtrajectoryspacing', Float(53)) @@ -1599,7 +1529,6 @@ class TrajectoryResults(Results): class MeasurementResults(Results): - ResultID = Column('resultid', ForeignKey(Results.ResultID), primary_key=True) XLocation = Column('xlocation', Float(53)) XLocationUnitsID = Column('xlocationunitsid', ForeignKey(Units.UnitsID)) @@ -1638,7 +1567,6 @@ class MeasurementResults(Results): class CategoricalResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(CategoricalResults.ResultID), nullable=False) DataValue = Column('datavalue', String(255), nullable=False) @@ -1649,7 +1577,6 @@ class CategoricalResultValues(Base): class MeasurementResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(MeasurementResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1660,7 +1587,6 @@ class MeasurementResultValues(Base): class PointCoverageResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(PointCoverageResults.ResultID), nullable=False) DataValue = Column('datavalue', BigIntegerType, nullable=False) @@ -1685,7 +1611,6 @@ class PointCoverageResultValues(Base): class ProfileResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(ProfileResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1712,7 +1637,6 @@ class ProfileResultValues(Base): class SectionResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(SectionResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1748,7 +1672,6 @@ class SectionResultValues(Base): class SpectraResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(SpectraResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1775,9 +1698,7 @@ class SpectraResultValues(Base): ) - class TimeSeriesResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(TimeSeriesResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1803,7 +1724,6 @@ def list_repr(self): class TrajectoryResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(TrajectoryResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1848,7 +1768,6 @@ class TrajectoryResultValues(Base): class TransectResultValues(Base): - ValueID = Column('valueid', BigIntegerType, primary_key=True) ResultID = Column('resultid', ForeignKey(TransectResults.ResultID), nullable=False) DataValue = Column('datavalue', Float(53), nullable=False) @@ -1896,7 +1815,6 @@ class TransectResultValues(Base): class CategoricalResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(CategoricalResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1906,7 +1824,6 @@ class CategoricalResultValueAnnotations(Base): class MeasurementResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(MeasurementResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1916,7 +1833,6 @@ class MeasurementResultValueAnnotations(Base): class PointCoverageResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(PointCoverageResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1926,7 +1842,6 @@ class PointCoverageResultValueAnnotations(Base): class ProfileResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(ProfileResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1936,7 +1851,6 @@ class ProfileResultValueAnnotations(Base): class SectionResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(SectionResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1946,7 +1860,6 @@ class SectionResultValueAnnotations(Base): class SpectraResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(SpectraResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1956,7 +1869,6 @@ class SpectraResultValueAnnotations(Base): class TimeSeriesResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(TimeSeriesResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1966,7 +1878,6 @@ class TimeSeriesResultValueAnnotations(Base): class TrajectoryResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(TrajectoryResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) @@ -1976,7 +1887,6 @@ class TrajectoryResultValueAnnotations(Base): class TransectResultValueAnnotations(Base): - BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False) ValueID = Column('valueid', BigIntegerType, ForeignKey(TransectResultValues.ValueID), nullable=False) AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False) From b751673c5fb3772efc6a0338e00b2f18a90e99cd Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Wed, 10 Jan 2018 09:50:18 -0800 Subject: [PATCH 4/6] Update Travis to exclude python code in forms, since this was auto created. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 422e41d..14975c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,7 +74,7 @@ script: fi - if [[ $TEST_TARGET == 'coding_standards' ]]; then - find . -type f -name "*.py" ! -name 'conf.py' ! -name '_version.py' ! -name 'versioneer.py' | xargs flake8 --max-line-length=110 ; + find . -type f -name "*.py" ! -name 'conf.py' ! -name '_version.py' ! -name 'versioneer.py' ! -name '*DBConfig.py' | xargs flake8 --max-line-length=110 ; fi - if [[ $TEST_TARGET == 'docs' ]]; then From 7b59e773aebeda2e8a636043517e0ccbd3483f61 Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Wed, 10 Jan 2018 09:53:48 -0800 Subject: [PATCH 5/6] Clean up tests --- tests/test_connection.py | 2 ++ tests/test_odm2/test_readservice.py | 38 +++++++++++++---------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index e233eff..a8bfacf 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -2,7 +2,9 @@ from odm2api.ODM2.models import CVElevationDatum from odm2api.ODMconnection import dbconnection + import pytest + from sqlalchemy.engine import reflection diff --git a/tests/test_odm2/test_readservice.py b/tests/test_odm2/test_readservice.py index f1ca669..f1189aa 100644 --- a/tests/test_odm2/test_readservice.py +++ b/tests/test_odm2/test_readservice.py @@ -11,7 +11,6 @@ import sqlalchemy from sqlalchemy.orm import class_mapper - globals_vars = {} @@ -75,7 +74,6 @@ def setup(self): self.engine = globals_vars['engine'] self.db = globals_vars['db'] - # Sampling Features def test_getAllSamplingFeatures(self): # get all models from the database @@ -91,7 +89,7 @@ def test_getSamplingFeatureByID(self): # get all simulations using the api resapi = self.reader.getSamplingFeatures(ids=[sfid]) assert resapi is not None - + def test_getSamplingFeatureByCode(self): # get all models from the database res = self.engine.execute('SELECT * FROM SamplingFeatures').fetchone() @@ -100,7 +98,7 @@ def test_getSamplingFeatureByCode(self): resapi = self.reader.getSamplingFeatures(codes=[code]) assert resapi is not None -#DataSets + # DataSets def test_getDataSets(self): # get all datasets from the database ds = self.engine.execute('SELECT * FROM DataSets').fetchone() @@ -124,14 +122,13 @@ def test_getDataSetsValues(self): dsr = self.engine.execute('SELECT * FROM DataSetsResults').fetchone() dsid = dsr[2] - values= self.reader.getDataSetsValues(ids=[dsid]) + values = self.reader.getDataSetsValues(ids=[dsid]) assert values is not None assert len(values) > 0 - def test_getSamplingFeatureDataSets(self): try: - #find a sampling feature that is associated with a dataset + # find a sampling feature that is associated with a dataset sf = self.engine.execute( 'SELECT * from SamplingFeatures as sf ' 'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID ' @@ -140,7 +137,7 @@ def test_getSamplingFeatureDataSets(self): ).fetchone() assert len(sf) > 0 - #get the dataset associated with the sampling feature + # get the dataset associated with the sampling feature ds = self.engine.execute( 'SELECT * from DataSetsResults as ds ' 'inner join Results as r on r.ResultID == ds.ResultID ' @@ -149,7 +146,7 @@ def test_getSamplingFeatureDataSets(self): ).fetchone() assert len(ds) > 0 - print (sf[0]) + print(sf[0]) # get the dataset associated with the sampling feature using hte api dsapi = self.reader.getSamplingFeatureDatasets(ids=[sf[0]]) @@ -159,11 +156,11 @@ def test_getSamplingFeatureDataSets(self): assert dsapi[0].SamplingFeatureID == sf[0] # assert ds[0] == dsapi[0] except Exception as ex: + print(ex) assert False finally: self.reader._session.rollback() - # Results def test_getAllResults(self): @@ -174,7 +171,6 @@ def test_getAllResults(self): resapi = self.reader.getResults() assert len(res) == len(resapi) - def test_getResultsByID(self): # get a result from the database res = self.engine.execute('SELECT * FROM Results').fetchone() @@ -186,18 +182,18 @@ def test_getResultsByID(self): def test_getResultsBySFID(self): sf = self.engine.execute( - 'SELECT * from SamplingFeatures as sf ' - 'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID ' - 'inner join Results as r on fa.FeatureActionID == r.FeatureActionID ' - ).fetchone() + 'SELECT * from SamplingFeatures as sf ' + 'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID ' + 'inner join Results as r on fa.FeatureActionID == r.FeatureActionID ' + ).fetchone() assert len(sf) > 0 sfid = sf[0] res = self.engine.execute( - 'SELECT * from Results as r ' - 'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID ' - 'where fa.SamplingFeatureID = ' + str(sfid) - ).fetchone() + 'SELECT * from Results as r ' + 'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID ' + 'where fa.SamplingFeatureID = ' + str(sfid) + ).fetchone() assert len(res) > 0 @@ -223,7 +219,6 @@ def test_getModelByCode(self): resapi = self.reader.getModels(codes=[modelCode]) assert resapi is not None - # RelatedModels def test_getRelatedModelsByID(self): # get related models by id using the api @@ -247,7 +242,8 @@ def test_getRelatedModelsByCode(self): # test invalid argument resapi = self.reader.getRelatedModels(code=234123) assert not resapi -# Simulations + + # Simulations def test_getAllSimulations(self): # get all simulation from the database res = self.engine.execute('SELECT * FROM Simulations').fetchall() From 27cf30b0e16553828160f5d385c347ae4c0acd40 Mon Sep 17 00:00:00 2001 From: lsetiawan Date: Wed, 10 Jan 2018 10:06:54 -0800 Subject: [PATCH 6/6] Ingore Sample.py --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 14975c2..5b99a41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,7 +74,7 @@ script: fi - if [[ $TEST_TARGET == 'coding_standards' ]]; then - find . -type f -name "*.py" ! -name 'conf.py' ! -name '_version.py' ! -name 'versioneer.py' ! -name '*DBConfig.py' | xargs flake8 --max-line-length=110 ; + find . -type f -name "*.py" ! -name 'conf.py' ! -name '_version.py' ! -name 'versioneer.py' ! -name '*DBConfig.py' ! -name 'Sample.py' | xargs flake8 --max-line-length=110 ; fi - if [[ $TEST_TARGET == 'docs' ]]; then