use of org.openlca.core.database.ActorDao in project olca-modules by GreenDelta.
the class ActorSheet method write.
private void write() {
Excel.trackSize(sheet, 0, 5);
writeHeader();
var actors = new ActorDao(config.database).getAll();
actors.sort(new EntitySorter());
for (Actor actor : actors) {
row++;
write(actor);
}
Excel.autoSize(sheet, 0, 5);
}
use of org.openlca.core.database.ActorDao in project olca-modules by GreenDelta.
the class ActorImport method of.
@Override
public ImportStatus<Actor> of(String id) {
var actor = imp.get(Actor.class, id);
// check if we are in update mode
var update = false;
if (actor != null) {
update = imp.shouldUpdate(actor);
if (!update)
return ImportStatus.skipped(actor);
}
// resolve the proto object
var proto = imp.reader.getActor(id);
if (proto == null)
return actor != null ? ImportStatus.skipped(actor) : ImportStatus.error("Could not resolve Actor " + id);
var wrap = ProtoWrap.of(proto);
if (update) {
if (imp.skipUpdate(actor, wrap))
return ImportStatus.skipped(actor);
}
// map the data
if (actor == null) {
actor = new Actor();
}
wrap.mapTo(actor, imp);
map(proto, actor);
// insert or update it
var dao = new ActorDao(imp.db);
actor = update ? dao.update(actor) : dao.insert(actor);
imp.putHandled(actor);
return update ? ImportStatus.updated(actor) : ImportStatus.created(actor);
}
Aggregations