Source code for odm2api.services.createService

from __future__ import (absolute_import, division, print_function)

import uuid

from odm2api import serviceBase
from odm2api.models import TimeSeriesResultValues

__author__ = 'sreeder'


[docs]class CreateODM2(serviceBase): # Annotations
[docs] def create(self, value): self._session.add(value) self._session.commit() return value
[docs] def createAll(self, values): self._session.add_all(values) self._session.commit() return values
[docs] def createVariable(self, var): self._session.add(var) self._session.commit() return var
[docs] def createMethod(self, method): self._session.add(method) self._session.commit() return method
[docs] def createProcessingLevel(self, proclevel): self._session.add(proclevel) self._session.commit() return proclevel
[docs] def createSamplingFeature(self, samplingfeature): if samplingfeature.SamplingFeatureUUID is None: samplingfeature.SamplingFeatureUUID = str(uuid.uuid1()) self._session.add(samplingfeature) self._session.commit() return samplingfeature
[docs] def createUnit(self, unit): self._session.add(unit) self._session.commit() return unit
[docs] def createOrganization(self, org): self._session.add(org) self._session.commit() return org
[docs] def createPerson(self, person): self._session.add(person) self._session.commit() return person
[docs] def createAffiliation(self, affiliation): self._session.add(affiliation) self._session.commit() return affiliation
[docs] def createDataset(self, dataset): self._session.add(dataset) self._session.commit() return dataset
[docs] def createDatasetResults(self, datasetresult): self._session.add(datasetresult) self._session.commit() return datasetresult
[docs] def createAction(self, action): self._session.add(action) self._session.commit() return action
[docs] def createActionby(self, actionby): self._session.add(actionby) self._session.commit() return actionby
[docs] def createFeatureAction(self, action): self._session.add(action) self._session.commit() return action
[docs] def createAnnotations(self, anno): self._session.add(anno) self._session.commit() return anno
[docs] def createRelatedAction(self, relatedaction): self._session.add(relatedaction) self._session.commit() return relatedaction
[docs] def createResult(self, result): if result.ResultUUID is None: result.ResultUUID = str(uuid.uuid1()) self._session.add(result) self._session.commit() return result
[docs] def createResultValue(self, value): self._session.add(value) self._session.commit() self._session.flush() return value
[docs] def createSpatialReference(self, spatialref): self._session.add(spatialref) self._session.commit() return spatialref
[docs] def createModel(self, model): self._session.add(model) self._session.commit() return model
[docs] def createRelatedModel(self, relatedmodel): self._session.add(relatedmodel) self._session.commit() return relatedmodel
[docs] def createSimulation(self, simulation): self._session.add(simulation) self._session.commit() return simulation
[docs] 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