Skip to content
Snippets Groups Projects
Commit 56360e5a authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

DRAFT: Begin TransactionService class

parent 48cc8553
Branches
Tags
No related merge requests found
...@@ -17,7 +17,7 @@ echo "PROTO_DIR: $PROTO_DIR" ...@@ -17,7 +17,7 @@ echo "PROTO_DIR: $PROTO_DIR"
_OUT_DIR=$SRC_DIR/generated/ _OUT_DIR=$SRC_DIR/generated/
mkdir -p $_OUT_DIR mkdir -p $_OUT_DIR
PROTO_MODULE=info/v1 PROTO_MODULE=entity/v1
echo "generate javascript module proto/caosdb/$PROTO_MODULE" echo "generate javascript module proto/caosdb/$PROTO_MODULE"
PROTO_FILE=${PROTO_DIR}/caosdb/${PROTO_MODULE}/main.proto PROTO_FILE=${PROTO_DIR}/caosdb/${PROTO_MODULE}/main.proto
......
/*
* ** header v3.0
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021 Florian Spreckelsen <f.spreckelsen@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ** end header
*/
import {
api
} from "./EntityApi";
export class TransactionService {
constructor(uri) {
this.uri = uri || "/api";
}
_PrepareTransaction(retrieveRequest) {
const client = new api.v1.EntityTransactionServiceClient(this.uri, null, null);
var transactionRequest = new api.v1.Transactionrequest();
transactionRequest.setRetrieveRequest(retrieveRequest);
var request = new api.v1.MultiTransactionRequest();
request.addRequests(transactionRequest);
return (res_cb, err_cb) => {
client.multiTransaction(request, headers, (error_response, response) => {
if (error_response) {
err_cb(error_response);
}
res_cb(response);
});
};
}
_CreateRetrieveRequest(id) {
var retrieve_request = new api.v1.RetrieveRequest();
retrieve_request.setId(id);
retrieve_request.setRegisterFileDownload(false);
return retrieve_request;
}
_CreateQueryRequest(query_string) {
var query = new api.v1.Query();
query.setQuery(query_string);
var query_request = new api.v1.RetrieveRequest();
query_request.setQuery(query);
query_request.setRegisterFileDownload(false);
return query_request;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment