Skip to content

Commit bc8f423

Browse files
author
stephanie
committed
Merge branch 'odmtools' of http://github.com/ODM2/ODM2PythonAPI into odmtools
2 parents f900474 + 9eba975 commit bc8f423

17 files changed

Lines changed: 171 additions & 105 deletions

Examples/Sample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#connect to database
1818
# createconnection (dbtype, servername, dbname, username, password)
1919
# session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite
20-
session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
21-
# session_factory= dbconnection.createConnection('mssql', "(local)", "ODM2", "ODM", "odm")#win MSSQL
20+
# session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
21+
session_factory= dbconnection.createConnection('mssql', "(local)", "ODM2", "ODM", "odm")#win MSSQL
2222
# session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL
2323

2424

@@ -32,7 +32,7 @@
3232

3333
#_session = session_factory.getSession()
3434
read = ReadODM2(session_factory)
35-
create =CreateODM2(session_factory)
35+
create = CreateODM2(session_factory)
3636

3737

3838

odm2api/ODM1_1_1/services/edit_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
# import logging
14-
# from odmtools.common.logger import LoggerTool
14+
# from odmtools.utils.logger import LoggerTool
1515

1616
# tool = LoggerTool()
1717
# logger = tool.setupLogger(__name__, __name__ + '.log', 'w', logging.DEBUG)

odm2api/ODM1_1_1/services/series_service.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ def get_all_sources(self):
444444
except:
445445
return None
446446

447+
def get_source_by_organization(self):
448+
try:
449+
return self._session.query(sour)
450+
except:
451+
return None
452+
447453

448454
#####################
449455
#

odm2api/ODM2/LikeODM1/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

2-
'''from model import CensorCodeCV
3-
from model import DataTypeCV
4-
from model import DataValue
5-
from model import GeneralCategoryCV
6-
from model import ISOMetadata
7-
from model import LabMethod
8-
from model import Method
9-
from model import ODMVersion
10-
from model import OffsetType
11-
from model import Qualifier
12-
from model import QualityControlLevel
13-
from model import Sample
14-
from model import SampleMediumCV
2+
'''from converter import CensorCodeCV
3+
from converter import DataTypeCV
4+
from converter import DataValue
5+
from converter import GeneralCategoryCV
6+
from converter import ISOMetadata
7+
from converter import LabMethod
8+
from converter import Method
9+
from converter import ODMVersion
10+
from converter import OffsetType
11+
from converter import Qualifier
12+
from converter import QualityControlLevel
13+
from converter import Sample
14+
from converter import SampleMediumCV
1515
from sample_type_cv import SampleTypeCV
1616
from series import Series
1717
from session_factory import SessionFactory

odm2api/ODM2/LikeODM1/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Site(Base):
7272
comments = None
7373

7474
# relationships
75-
# 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'
75+
# TODO @sreeder, Please take a look at this line as it throws: sqlalchemy.exc.InvalidRequestError: Class <class 'ODM2.LikeODM1.converter.Site2'> does not have a mapped column named 'lat_long_datum_id'
7676
# :)
7777
# spatial_ref = relationship(SpatialReference, primaryjoin=("SpatialReference.id==Site2.lat_long_datum_id"))
7878
# spatial_ref = relationship(SpatialReference)

odm2api/ODM2/models.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class CVElevationDatum(Base, CV):
7878
class CVEquipmentType(Base, CV):
7979
__tablename__ = 'cv_equipmenttype'
8080

81+
8182
class CVMediumType(Base, CV):
8283
__tablename__ = 'cv_medium'
8384

@@ -97,6 +98,7 @@ class CVPropertyDataType(Base, CV):
9798
class CVQualityCode(Base, CV):
9899
__tablename__ = 'cv_qualitycode'
99100

101+
100102
class CVResultType(Base, CV):
101103
__tablename__ = 'cv_resulttype'
102104

@@ -116,6 +118,7 @@ class CVSamplingFeatureType(Base, CV):
116118
class CVSpatialOffsetType(Base, CV):
117119
__tablename__ = 'cv_spatialoffsettype'
118120

121+
119122
class CVSpeciation(Base, CV):
120123
__tablename__ = 'cv_speciation'
121124

@@ -157,7 +160,6 @@ class CVReferenceMaterialMedium(Base, CV):
157160
# ################################################################################
158161
class People(Base):
159162

160-
161163
PersonID = Column('personid', Integer, primary_key=True, nullable=False)
162164
PersonFirstName = Column('personfirstname', String(255), nullable=False)
163165
PersonMiddleName = Column('personmiddlename', String(255))
@@ -170,7 +172,6 @@ def __repr__(self):
170172

171173
class Organizations(Base):
172174

173-
174175
OrganizationID = Column('organizationid', Integer, primary_key=True, nullable=False)
175176
OrganizationTypeCV = Column('organizationtypecv', ForeignKey(CVOrganizationType.Name), nullable=False,
176177
index=True)
@@ -191,7 +192,6 @@ def __repr__(self):
191192

192193
class Affiliations(Base):
193194

194-
195195
AffiliationID = Column('affiliationid', Integer, primary_key=True, nullable=False)
196196
PersonID = Column('personid', ForeignKey(People.PersonID), nullable=False)
197197
OrganizationID = Column('organizationid', ForeignKey(Organizations.OrganizationID))
@@ -209,7 +209,6 @@ class Affiliations(Base):
209209

210210
class Methods(Base):
211211

212-
213212
MethodID = Column('methodid', Integer, primary_key=True, nullable=False)
214213
MethodTypeCV = Column('methodtypecv', ForeignKey(CVMethodType.Name), nullable=False, index=True)
215214
MethodCode = Column('methodcode', String(50), nullable=False)
@@ -247,7 +246,6 @@ def __repr__(self):
247246

248247
class ActionBy(Base):
249248

250-
251249
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
252250
ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), nullable=False)
253251
AffiliationID = Column('affiliationid', ForeignKey(Affiliations.AffiliationID), nullable=False)
@@ -260,7 +258,6 @@ class ActionBy(Base):
260258

261259
class SamplingFeatures(Base):
262260

263-
264261
SamplingFeatureID = Column('samplingfeatureid', Integer, primary_key=True, nullable=False)
265262
SamplingFeatureUUID = Column('samplingfeatureuuid', String(36), nullable=False)
266263
SamplingFeatureTypeCV = Column('samplingfeaturetypecv', ForeignKey(CVSamplingFeatureType.Name),
@@ -284,16 +281,13 @@ class SamplingFeatures(Base):
284281

285282
}
286283

287-
288284
def __repr__(self):
289-
290285
return "<SamplingFeatures('%s', '%s', '%s', '%s', '%s')>" % (
291286
self.SamplingFeatureCode, self.SamplingFeatureName, self.SamplingFeatureDescription,
292287
# self.Elevation_m, geomkt)
293288
self.Elevation_m, self.FeatureGeometryWKT)
294289

295290

296-
297291
class FeatureActions(Base):
298292
__tablename__ = u'featureactions'
299293
__table_args__ = {u'schema': 'odm2'}
@@ -509,7 +503,6 @@ class EquipmentModels(Base):
509503
OrganizationObj = relationship(Organizations)
510504

511505

512-
513506
class InstrumentOutputVariables(Base):
514507
__tablename__ = u'instrumentoutputvariables'
515508
__table_args__ = {u'schema': 'odm2'}
@@ -529,7 +522,6 @@ class InstrumentOutputVariables(Base):
529522
VariableObj = relationship(Variables)
530523

531524

532-
533525
class DataLoggerFileColumns(Base):
534526
__tablename__ = u'dataloggerfilecolumns'
535527
__table_args__ = {u'schema': 'odm2'}
@@ -557,6 +549,7 @@ class DataLoggerFileColumns(Base):
557549
ScanIntervalUnitsObj = relationship(Units, primaryjoin='DataLoggerFileColumns.ScanIntervalUnitsID == Units.UnitsID')
558550
RecordingIntervalUnitsObj = relationship(Units, primaryjoin='DataLoggerFileColumns.RecordingIntervalUnitsID == Units.UnitsID')
559551

552+
560553
class Equipment(Base):
561554
__tablename__ = u'equipment'
562555
__table_args__ = {u'schema': 'odm2'}
@@ -581,6 +574,7 @@ class Equipment(Base):
581574

582575
# parent = relationship(u'Equipment', remote_side=[EquipmentID])
583576

577+
584578
class CalibrationReferenceEquipment(Base):
585579
__tablename__ = u'calibrationreferenceequipment'
586580
__table_args__ = {u'schema': 'odm2'}
@@ -592,6 +586,7 @@ class CalibrationReferenceEquipment(Base):
592586
ActionObj = relationship(Actions)
593587
EquipmentObj = relationship(Equipment)
594588

589+
595590
class EquipmentActions(Base):
596591
__tablename__ = u'equipmentactions'
597592
__table_args__ = {u'schema': 'odm2'}
@@ -659,6 +654,8 @@ class CalibrationActions(Base):
659654
# ################################################################################
660655
# Lab Analyses
661656
# ################################################################################
657+
658+
662659
class Directives(Base):
663660
__tablename__ = u'directives'
664661
__table_args__ = {u'schema': 'odm2'}
@@ -679,6 +676,7 @@ class ActionDirectives(Base):
679676
ActionObj = relationship(Actions)
680677
DirectiveObj = relationship(Directives)
681678

679+
682680
class SpecimenBatchPositions(Base):
683681
#todo fix misspelling
684682
__tablename__ = u'specimenbatchpostions'
@@ -723,10 +721,12 @@ class Specimens(SamplingFeatures):
723721
__mapper_args__ = {
724722
'polymorphic_identity':'Specimen',
725723
}
724+
726725
def __repr__(self):
727726
return "<Specimens('%s', '%s', '%s', '%s',)>" \
728727
% (self.SamplingFeatureID, self.SamplingFeatureCode, self.SpecimenTypeCV,self.SamplingFeatureCode)
729728

729+
730730
class SpatialOffsets(Base):
731731
__tablename__ = u'spatialoffsets'
732732
__table_args__ = {u'schema': 'odm2'}
@@ -958,8 +958,6 @@ class SamplingFeatureAnnotations(Base):
958958
SamplingFeatureObj = relationship(SamplingFeatures)
959959

960960

961-
962-
963961
# ################################################################################
964962
# Data Quality
965963
# ################################################################################
@@ -1010,6 +1008,7 @@ class ReferenceMaterials(Base):
10101008
OrganizationObj = relationship(Organizations)
10111009
SamplingFeatureObj = relationship(SamplingFeatures)
10121010

1011+
10131012
class CalibrationStandards(Base):
10141013
__tablename__ = u'calibrationstandards'
10151014
__table_args__ = {u'schema': 'odm2'}
@@ -1403,7 +1402,7 @@ class MethodCitations(Base):
14031402
MethodObj = relationship(Methods)
14041403

14051404

1406-
# from odm2.Annotations.model import Annotation
1405+
# from odm2.Annotations.converter import Annotation
14071406
class RelatedAnnotations(Base):
14081407
__tablename__ = u'relatedannotations'
14091408
__table_args__ = {u'schema': 'odm2'}
@@ -1468,8 +1467,6 @@ class RelatedResults(Base):
14681467
# ################################################################################
14691468
# Results
14701469
# ################################################################################
1471-
1472-
14731470
class PointCoverageResults(Results):
14741471
__tablename__ = u'pointcoverageresults'
14751472
__table_args__ = {u'schema': 'odm2'}
@@ -1495,7 +1492,6 @@ class PointCoverageResults(Results):
14951492
__mapper_args__ = {'polymorphic_identity':'Point coverage'}
14961493

14971494

1498-
14991495
class ProfileResults(Results):
15001496
__tablename__ = u'profileresults'
15011497
__table_args__ = {u'schema': 'odm2'}
@@ -2037,6 +2033,7 @@ class TransectResultValueAnnotations(Base):
20372033
AnnotationObj = relationship(Annotations)
20382034
ValueObj = relationship(TransectResultValues)
20392035

2036+
20402037
def _changeSchema(schema):
20412038
import inspect
20422039
import sys
@@ -2065,13 +2062,12 @@ def _getSchema(engine):
20652062

20662063
return insp.default_schema_name
20672064

2065+
20682066
def setSchema(engine):
2069-
# import datetime
2070-
# start = datetime.datetime.now()
2067+
20712068
s = _getSchema(engine)
2072-
if s is None:
2073-
s = ''
2069+
# if s is None:
2070+
# s = ''
20742071
_changeSchema(s)
2075-
# end = datetime.datetime.now()
2076-
# print end-start, ": elapsed time to change schema"
2072+
20772073

odm2api/ODM2/services/createService.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import datetime as dt
44
import uuid
55

6-
# from src.api.ODM2.LikeODM1.model import Site
6+
# from src.api.ODM2.LikeODM1.converter import Site
77
from odm2api.ODM2.models import *
88
from odm2api.ODM2 import serviceBase
99

odm2api/ODM2/services/deleteService.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class DeleteODM2(serviceBase):
1111

12-
def test(self):
13-
return None
12+
def remove(self, obj):
13+
self._session.delete(obj)
1414

1515
# ################################################################################
1616
# CV

0 commit comments

Comments
 (0)