Skip to content

Commit 6047f1b

Browse files
author
sreeder
committed
clean up queries and add them for lab analyses and Provenance schemas
1 parent fac6abb commit 6047f1b

File tree

2 files changed

+72
-50
lines changed

2 files changed

+72
-50
lines changed

odm2api/ODM2/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,17 @@ class ActionDirectives(Base):
990990
ActionObj = relationship(Actions)
991991
DirectiveObj = relationship(Directives)
992992

993+
class SpecimenBatchPositions(Base):
994+
#todo fix misspelling
995+
__tablename__ = u'specimenbatchpostions'
996+
__table_args__ = {u'schema': 'odm2'}
997+
998+
FeatureActionID = Column('featureactionid', Integer, ForeignKey(FeatureActions.FeatureActionID), primary_key=True, nullable=False)
999+
BatchPositionsNumber = Column('batchpositionnumber', Integer, nullable = False)
1000+
BatchPositionLabel =Column('batchpositionlabel', String(255))
1001+
1002+
FeatureActionObj = relationship(FeatureActions)
1003+
9931004

9941005
# ################################################################################
9951006
# Sampling Features

odm2api/ODM2/services/readService.py

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@ def CalibrationReferenceEquipment(self):
428428
def CalibrationStandards(self):
429429
return self._session.query(CalibrationStandards).all()
430430
def DataloggerFileColumns(self):
431-
return self._session.query(DataloggerFileColumns).all()
431+
return self._session.query(DataLoggerFileColumns).all()
432432
def DataLoggerFiles(self):
433433
return self._session.query(DataLoggerFiles).all()
434434
def DataloggerProgramFiles(self):
435-
return self._session.query(DataloggerProgramFiles).all()
435+
return self._session.query(DataLoggerProgramFiles).all()
436436
def EquipmentModels(self):
437437
return self._session.query(EquipmentModels).all()
438438
def EquipmentUsed(self):
@@ -448,20 +448,49 @@ def RelatedEquipment(self):
448448
# Extension Properties
449449
# ################################################################################
450450

451-
def getExtensionProperties(self ):
452-
pass
451+
def getExtensionProperties(self, type=None):
452+
#Todo what values to use for extensionproperties type
453+
e = ExtensionProperties
454+
if type =="Action": e = ActionExtensionPropertyValues
455+
elif type =="Citation": e= CitationExtensionPropertyValues
456+
elif type =="Method": e= MethodExtensionPropertyValues
457+
elif type =="Result":e=ResultExtensionPropertyValues
458+
elif type =="SamplingFeature": e= SamplingFeatureExtensionPropertyValues
459+
elif type =="Variable": e=VariableExtensionPropertyValues
460+
try:
461+
return self._session.query(e).all()
462+
except:
463+
return None
464+
453465

454466
# ################################################################################
455467
# External Identifiers
456468
# ################################################################################
457-
458-
469+
def getExternalIdentifiers(self, type=None):
470+
e = ExternalIdentifierSystems
471+
if type =="Citation": e = CitationExternalIdentifiers
472+
elif type =="Method": e = MethodExternalIdentifiers
473+
elif type =="Person": e = PersonExternalIdentifiers
474+
elif type =="ReferenceMaterial": e = ReferenceMaterialExternalIdentifiers
475+
elif type =="SamplingFeature": e = SamplingFeatureExternalIdentifiers
476+
elif type =="SpatialReference": e = SpatialReferenceExternalIdentifiers
477+
elif type =="TaxonomicClassifier": e = TaxonomicClassifierExternalIdentifiers
478+
elif type =="Variable": e = VariableExternalIdentifiers
479+
try:
480+
return self._session.query(e).all()
481+
except:
482+
return None
459483

460484

461485
# ################################################################################
462486
# Lab Analyses
463487
# ################################################################################
464-
488+
def getDirectives(self):
489+
return self._session.query(Directives).all()
490+
def getActionDirectives(self):
491+
return self._session.query(ActionDirectives).all()
492+
def getSpecimenBatchPositions(self):
493+
return self._session.query(SpecimenBatchPositions).all()
465494

466495

467496

@@ -470,12 +499,28 @@ def getExtensionProperties(self ):
470499
# ################################################################################
471500

472501

473-
"""
474-
Citation
475-
"""
476502

503+
#TODO functions for Provenance
504+
def getAuthorLists(self):
505+
self._session.query(AuthorLists).all()
477506
def getCitations(self):
478507
self._session.query(Citations).all()
508+
def getDatasetCitations(self):
509+
self._session.query(DataSetCitations).all()
510+
def getDerivationEquations(self):
511+
self._session.query(DerivationEquations).all()
512+
def getMethodCitations(self):
513+
self._session.query(MethodCitations).all()
514+
def getRelatedAnnotations(self):
515+
self._session.query(RelatedAnnotations).all()
516+
def getRelatedCitations(self):
517+
self._session.query(RelatedCitations).all()
518+
def getRelatedDatasets(self):
519+
self._session.query(RelatedDataSets).all()
520+
def getRelatedResults(self):
521+
self._session.query(RelatedResults).all()
522+
def getResultDerivationEquations(self):
523+
self._session.query(ResultDerivationEquations).all()
479524

480525
# ################################################################################
481526
# Results
@@ -522,15 +567,15 @@ def getResultValues(self, resultid= None, type=None, starttime=None, endtime=Non
522567

523568

524569

525-
# ################################################################################
526-
# Annotations
527-
# ################################################################################
570+
# ################################################################################
571+
# SamplingFeatures
572+
# ################################################################################
528573

529574
"""
530575
Site
531576
"""
532-
533-
def getAllSites(self):
577+
#ToDo function for get sampling features
578+
def getSites(self):
534579
"""Select all on Sites
535580
536581
:return Site Objects:
@@ -572,44 +617,10 @@ def getSpatialReferenceByCode(self, srsCode):
572617

573618

574619
# ################################################################################
575-
# Sensors
620+
# Equipment
576621
# ################################################################################
577622

578-
def getAllDeploymentAction(self):
579-
"""Select all on DeploymentAction
580623

581-
:return DeploymentAction Objects:
582-
:type list:
583-
"""
584-
return self._session.query(DeploymentActions).all()
585-
586-
# return self._session.query)
587-
588-
def getDeploymentActionById(self, deploymentId):
589-
"""Select by deploymentId
590-
591-
:param deploymentId:
592-
:type Integer:
593-
:return Return Matching DeploymentAction Object filtered by deploymentId:
594-
:type DeploymentAction:
595-
"""
596-
try:
597-
return self._session.query(DeploymentActions).filter_by(DeploymentActionID=deploymentId).one()
598-
except:
599-
return None
600-
601-
def getDeploymentActionByCode(self, deploymentCode):
602-
"""Select by deploymentCode
603-
604-
:param deploymentCode:
605-
:type String:
606-
:return Return matching DeploymentAction Object filtered by deploymentCode:
607-
:type DeploymentAction:
608-
"""
609-
try:
610-
return self._session.query(DeploymentActions).filter_by(DeploymentActionCode=deploymentCode).one()
611-
except:
612-
return None
613624

614625

615626
# ################################################################################

0 commit comments

Comments
 (0)