Search in sources :

Example 6 with ActorDao

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);
}
Also used : ActorDao(org.openlca.core.database.ActorDao) Actor(org.openlca.core.model.Actor)

Example 7 with ActorDao

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);
}
Also used : ActorDao(org.openlca.core.database.ActorDao) ProtoActor(org.openlca.proto.ProtoActor) Actor(org.openlca.core.model.Actor)

Aggregations

ActorDao (org.openlca.core.database.ActorDao)7 Actor (org.openlca.core.model.Actor)6 Test (org.junit.Test)2 Path (java.nio.file.Path)1 CategoryDao (org.openlca.core.database.CategoryDao)1 CurrencyDao (org.openlca.core.database.CurrencyDao)1 DQSystemDao (org.openlca.core.database.DQSystemDao)1 Derby (org.openlca.core.database.Derby)1 FlowDao (org.openlca.core.database.FlowDao)1 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)1 LocationDao (org.openlca.core.database.LocationDao)1 NwSetDao (org.openlca.core.database.NwSetDao)1 ProcessDao (org.openlca.core.database.ProcessDao)1 ProductSystemDao (org.openlca.core.database.ProductSystemDao)1 ProjectDao (org.openlca.core.database.ProjectDao)1 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)1 SourceDao (org.openlca.core.database.SourceDao)1 UnitDao (org.openlca.core.database.UnitDao)1