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));
}
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;
}
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);
}
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);
}
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);
}
Aggregations