def upsert_document(collection, doc_id, document): """ Function to upsert document into couchbase server using Java sdk :param collection: Collection object to the default collection of the bucket :type collection: Collection :param doc_id: Document id to upsert :type doc_id: str :param document: Document to insert :type document: dict :return: Nothing :rtype: None """ doc_to_insert = get_json_object(document) duration = Duration.ofDays(7) upsert_option = UpsertOptions.upsertOptions().expiry(duration) try: collection.upsert(doc_id, doc_to_insert, upsert_option) print('upserted %s' % doc_id) except Exception as e: print(e)
from mil.army.usace.hec.vortex.io import DataReader from java.time import ZonedDateTime from java.time import LocalDateTime from java.time import ZoneId from java.time import Duration source = "C:/Temp/qpe.dss" normals = "C:/Temp/prism.dss" sourceGrids = DataReader.getVariables(source) normalGrids = DataReader.getVariables(normals) start = ZonedDateTime.of(LocalDateTime.of(2017, 1, 1, 0, 0), ZoneId.of("UTC")) end = ZonedDateTime.of(LocalDateTime.of(2017, 1, 3, 0, 0), ZoneId.of("UTC")) interval = Duration.ofDays(1) destination = 'C:/Temp/normalized.dss' options = {'partF': 'my normalized grids'} normalizer = Normalizer.builder() \ .startTime(start) \ .endTime(end) \ .interval(interval) \ .pathToSource(source) \ .sourceVariables(sourceGrids) \ .pathToNormals(normals) \ .normalsVariables(normalGrids) \ .destination(destination) \ .writeOptions(options) \