Search in sources :

Example 1 with ActorDao

use of org.openlca.core.database.ActorDao in project olca-modules by GreenDelta.

the class Sequence method init.

private void init(IDatabase db) {
    index(CATEGORY, new CategoryDao(db));
    index(LOCATION, new LocationDao(db));
    index(ACTOR, new ActorDao(db));
    index(SOURCE, new SourceDao(db));
    index(UNIT, new UnitDao(db));
    index(UNIT_GROUP, new UnitGroupDao(db));
    index(FLOW_PROPERTY, new FlowPropertyDao(db));
    index(FLOW, new FlowDao(db));
    index(CURRENCY, new CurrencyDao(db));
    index(PROCESS, new ProcessDao(db));
    index(PRODUCT_SYSTEM, new ProductSystemDao(db));
    index(IMPACT_CATEGORY, new ImpactCategoryDao(db));
    index(IMPACT_METHOD, new ImpactMethodDao(db));
    index(NW_SET, new NwSetDao(db));
    index(PROJECT, new ProjectDao(db));
    index(DQ_SYSTEM, new DQSystemDao(db));
    index(SOCIAL_INDICATOR, new SocialIndicatorDao(db));
}
Also used : SourceDao(org.openlca.core.database.SourceDao) CurrencyDao(org.openlca.core.database.CurrencyDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) CategoryDao(org.openlca.core.database.CategoryDao) ActorDao(org.openlca.core.database.ActorDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) LocationDao(org.openlca.core.database.LocationDao) UnitDao(org.openlca.core.database.UnitDao) DQSystemDao(org.openlca.core.database.DQSystemDao) NwSetDao(org.openlca.core.database.NwSetDao) FlowDao(org.openlca.core.database.FlowDao) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao) ProcessDao(org.openlca.core.database.ProcessDao) UnitGroupDao(org.openlca.core.database.UnitGroupDao) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) ProjectDao(org.openlca.core.database.ProjectDao)

Example 2 with ActorDao

use of org.openlca.core.database.ActorDao in project olca-modules by GreenDelta.

the class DocImportMapper method mapDataEntryBy.

private void mapDataEntryBy(AdminInfo adminInfo) {
    DataEntry dataEntry = adminInfo.dataEntry;
    if (dataEntry == null || dataEntry.personId == null)
        return;
    ActorDao dao = new ActorDao(database);
    Actor actor = dao.getForRefId(dataEntry.personId);
    if (actor == null) {
        actor = new Actor();
        actor.refId = dataEntry.personId;
        actor.email = dataEntry.personEmail;
        actor.name = dataEntry.personName;
        actor = dao.insert(actor);
    }
    doc.dataDocumentor = actor;
}
Also used : DataEntry(spold2.DataEntry) ActorDao(org.openlca.core.database.ActorDao) Actor(org.openlca.core.model.Actor)

Example 3 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)

Example 4 with ActorDao

use of org.openlca.core.database.ActorDao in project olca-modules by GreenDelta.

the class DerbyDatabaseTest method testDumpMemoryDB.

@Test
public void testDumpMemoryDB() throws Exception {
    Derby db = Derby.createInMemory();
    Actor a = new Actor();
    a.name = "The Donald";
    a = new ActorDao(db).insert(a);
    long id = a.id;
    Path path = Files.createTempDirectory("_olca_test_");
    db.dump(path.toString());
    db.close();
    db = Derby.restoreInMemory(path.toString());
    a = new ActorDao(db).getForId(id);
    assertEquals("The Donald", a.name);
    db.close();
    Dirs.delete(path);
}
Also used : Path(java.nio.file.Path) Derby(org.openlca.core.database.Derby) ActorDao(org.openlca.core.database.ActorDao) Actor(org.openlca.core.model.Actor) Test(org.junit.Test)

Example 5 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)

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