Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Future deprecation warning for ODM2 modules #145

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,930 changes: 5 additions & 1,925 deletions odm2api/ODM2/models.py

Large diffs are not rendered by default.

157 changes: 11 additions & 146 deletions odm2api/ODM2/services/createService.py
Original file line number Diff line number Diff line change
@@ -1,154 +1,19 @@
from __future__ import (absolute_import, division, print_function)

import uuid
import warnings

from odm2api.ODM2 import serviceBase
from odm2api.ODM2.models import TimeSeriesResultValues
from odm2api.services import CreateODM2 as newClass

__author__ = 'sreeder'


class CreateODM2(serviceBase):
# Annotations

def create(self, value):
self._session.add(value)
self._session.commit()
return value

def createAll(self, values):
self._session.add_all(values)
self._session.commit()
return values

def createVariable(self, var):
self._session.add(var)
self._session.commit()

return var

def createMethod(self, method):
self._session.add(method)
self._session.commit()
return method

def createProcessingLevel(self, proclevel):
self._session.add(proclevel)
self._session.commit()
return proclevel

def createSamplingFeature(self, samplingfeature):
if samplingfeature.SamplingFeatureUUID is None:
samplingfeature.SamplingFeatureUUID = str(uuid.uuid1())
self._session.add(samplingfeature)
self._session.commit()
return samplingfeature

def createUnit(self, unit):
self._session.add(unit)
self._session.commit()
return unit

def createOrganization(self, org):
self._session.add(org)
self._session.commit()
return org

def createPerson(self, person):
self._session.add(person)
self._session.commit()
return person

def createAffiliation(self, affiliation):
self._session.add(affiliation)
self._session.commit()
return affiliation
warnings.warn('The module odm2api.ODM2.services.createService will be deprecated. '
'Please use odm2api.services.createService instead.',
FutureWarning, stacklevel=2)

def createDataset(self, dataset):
self._session.add(dataset)
self._session.commit()
return dataset

def createDatasetResults(self, datasetresult):
self._session.add(datasetresult)
self._session.commit()
return datasetresult

def createAction(self, action):
self._session.add(action)
self._session.commit()
return action

def createActionby(self, actionby):

self._session.add(actionby)
self._session.commit()
return actionby

def createFeatureAction(self, action):
self._session.add(action)
self._session.commit()
return action

def createAnnotations(self, anno):
self._session.add(anno)
self._session.commit()
return anno

def createRelatedAction(self, relatedaction):
self._session.add(relatedaction)
self._session.commit()
return relatedaction

def createResult(self, result):
if result.ResultUUID is None:
result.ResultUUID = str(uuid.uuid1())
self._session.add(result)
self._session.commit()
return result

def createResultValue(self, value):
self._session.add(value)
self._session.commit()
self._session.flush()
return value

def createSpatialReference(self, spatialref):
self._session.add(spatialref)
self._session.commit()
return spatialref

def createModel(self, model):
self._session.add(model)
self._session.commit()

return model

def createRelatedModel(self, relatedmodel):
self._session.add(relatedmodel)
self._session.commit()
return relatedmodel

def createSimulation(self, simulation):
self._session.add(simulation)
self._session.commit()
return simulation
__author__ = 'sreeder'

def createTimeSeriesResultValues(self, datavalues):
try:
# FXIME: F841 local variable 'tablename' is assigned to but never used.
# tablename = TimeSeriesResultValues.__tablename__
datavalues.to_sql(
name='TimeSeriesResultValues',
schema=TimeSeriesResultValues.__table_args__['schema'],
if_exists='append',
chunksize=1000,
con=self._session_factory.engine,
index=False
)
self._session.commit()

return datavalues
except Exception as e:
print(e)
return None
def CreateODM2(*args, **kwargs):
warnings.warn('The class odm2api.ODM2.services.readService.CreateODM2 will be deprecated. '
'Please use odm2api.services.readService.CreateODM2 instead.',
FutureWarning, stacklevel=2)
return newClass(*args, **kwargs)
45 changes: 12 additions & 33 deletions odm2api/ODM2/services/deleteService.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
from __future__ import (absolute_import, division, print_function)

from odm2api.ODM2 import serviceBase
from odm2api.ODM2.models import TimeSeriesResultValues
import warnings

from odm2api.services.deleteService import DeleteODM2 as newClass

__author__ = 'jmeline'
warnings.warn('The module odm2api.ODM2.services.deleteService will be deprecated. '
'Please use odm2api.services.deleteService instead.',
FutureWarning, stacklevel=2)

# Annotations

__author__ = 'jmeline'

class DeleteODM2(serviceBase):
# Annotations

def remove(self, obj):
self._session.delete(obj)

# CV
# Core
# Data Quality
# Equipment
# Extension Properties
# External Identifiers
# Lab Analyses
# Provenance
# Annotations
# Sampling Features
# Sensors
# Result Values

def deleteTSRValues(self, ids=None, startdate=None, dates=None):

q = self._session.query(TimeSeriesResultValues)
if ids:
q = q.filter(TimeSeriesResultValues.ResultID.in_(ids))
if startdate:
# delete all values on or after the startdate.
q = q.filter(TimeSeriesResultValues.ValueDateTime >= startdate)
if dates:
q = q.filter(TimeSeriesResultValues.ValueDateTime.in_(dates))
numvals = q.count()
q.delete(False)
return numvals
def DeleteODM2(*args, **kwargs):
warnings.warn('The class odm2api.ODM2.services.readService.DeleteODM2 will be deprecated. '
'Please use odm2api.services.readService.DeleteODM2 instead.',
FutureWarning, stacklevel=2)
return newClass(*args, **kwargs)
Loading