Search in sources :

Example 1 with ProtoDataSet

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();
}
Also used : Empty(com.google.protobuf.Empty) Refs(org.openlca.proto.io.output.Refs) Strings(org.openlca.util.Strings) StreamObserver(io.grpc.stub.StreamObserver) IDatabase(org.openlca.core.database.IDatabase) DataUpdateServiceGrpc(org.openlca.proto.grpc.DataUpdateServiceGrpc) UpdateMode(org.openlca.jsonld.input.UpdateMode) ProtoRef(org.openlca.proto.ProtoRef) DeleteRequest(org.openlca.proto.grpc.DeleteRequest) ProtoDataSet(org.openlca.proto.grpc.ProtoDataSet) ImportStatus(org.openlca.proto.io.input.ImportStatus) ProtoImport(org.openlca.proto.io.input.ProtoImport) ImportStatus(org.openlca.proto.io.input.ImportStatus) ProtoImport(org.openlca.proto.io.input.ProtoImport)

Aggregations

Empty (com.google.protobuf.Empty)1 StreamObserver (io.grpc.stub.StreamObserver)1 IDatabase (org.openlca.core.database.IDatabase)1 UpdateMode (org.openlca.jsonld.input.UpdateMode)1 ProtoRef (org.openlca.proto.ProtoRef)1 DataUpdateServiceGrpc (org.openlca.proto.grpc.DataUpdateServiceGrpc)1 DeleteRequest (org.openlca.proto.grpc.DeleteRequest)1 ProtoDataSet (org.openlca.proto.grpc.ProtoDataSet)1 ImportStatus (org.openlca.proto.io.input.ImportStatus)1 ProtoImport (org.openlca.proto.io.input.ProtoImport)1 Refs (org.openlca.proto.io.output.Refs)1 Strings (org.openlca.util.Strings)1