use of org.openlca.proto.io.input.ProtoImport 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();
}
use of org.openlca.proto.io.input.ProtoImport in project olca-modules by GreenDelta.
the class ImportExample method main.
public static void main(String[] args) {
var zipPath = "C:/Users/ms/Desktop/rems/test_json.zip";
var dbPath = "C:/Users/ms/openLCA-data-1.4/databases/proto_test";
try (var store = ZipStore.open(new File(zipPath));
var db = new Derby(new File(dbPath))) {
var imp = new ProtoImport(store, db);
imp.run();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations