use of org.openlca.proto.grpc.ProtoDataSet in project olca-modules by GreenDelta.
the class DataUpdateService method put.
@Override
public void put(ProtoDataSet dataSet, StreamObserver<ProtoRef> resp) {
var statusRef = new ImportStatus[1];
new ProtoImport(DataUtil.readerOf(dataSet), db).withUpdateMode(UpdateMode.ALWAYS).withStatusHandler(s -> statusRef[0] = s).run();
var status = statusRef[0];
if (status == null) {
Response.invalidArg(resp, "No model in data set found");
return;
}
if (status.isError()) {
Response.serverError(resp, "Import error: " + status.error());
return;
}
var ref = Refs.refOf(status.model());
resp.onNext(ref.build());
resp.onCompleted();
}
Aggregations