/** * Update an existing batch operation. * * @param context * @param token * @param request * @return * @throws SiteWhereException */ public static IBatchOperation updateBatchOperation(IHBaseContext context, String token, IBatchOperationUpdateRequest request) throws SiteWhereException { BatchOperation updated = assertBatchOperation(context, token); BatchOperationStatus oldProcessingStatus = updated.getProcessingStatus(); SiteWherePersistence.batchOperationUpdateLogic(request, updated); Map<byte[], byte[]> qualifiers = new HashMap<byte[], byte[]>(); if (updated.getProcessingStatus() != oldProcessingStatus) { qualifiers.put(PROCESSING_STATUS, Bytes.toBytes(String.valueOf(updated.getProcessingStatus().getCode()))); } return HBaseUtils.createOrUpdate(context, context.getPayloadMarshaler(), ISiteWhereHBase.DEVICES_TABLE_NAME, updated, token, KEY_BUILDER, qualifiers); }
@Override public IBatchOperation updateBatchOperation(String token, IBatchOperationUpdateRequest request) throws SiteWhereException { MongoCollection<Document> batchops = getMongoClient().getBatchOperationsCollection(getTenant()); Document match = assertBatchOperation(token); BatchOperation operation = MongoBatchOperation.fromDocument(match); SiteWherePersistence.batchOperationUpdateLogic(request, operation); Document updated = MongoBatchOperation.toDocument(operation); Document query = new Document(MongoBatchOperation.PROP_TOKEN, token); MongoPersistence.update(batchops, query, updated); return MongoBatchOperation.fromDocument(updated); }