use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ExchangeUseSearchTest method setUp.
@Before
public void setUp() {
db.clear();
p = new Process();
q = new Process();
addExchanges();
ProcessDao dao = new ProcessDao(db);
p = dao.insert(p);
q = dao.insert(q);
modelStack.push(p);
modelStack.push(q);
createSystem();
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method testFindInProcesses.
@Test
public void testFindInProcesses() {
Process process = createProcess();
List<RootDescriptor> results = search.findUses(factor);
new ProcessDao(database).delete(process);
Descriptor expected = Descriptor.of(process);
Assert.assertEquals(1, results.size());
Assert.assertEquals(expected, results.get(0));
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ExchangeConversion method setProvider.
private void setProvider(Exchange oExchange, ExchangeExtension ext) {
long provider = oExchange.defaultProviderId;
if (provider == 0)
return;
try {
ProcessDao dao = new ProcessDao(config.db);
ProcessDescriptor d = dao.getDescriptor(provider);
if (d != null) {
ext.setDefaultProvider(d.refId);
}
} catch (Exception e) {
Logger log = LoggerFactory.getLogger(getClass());
log.warn("could not load default provider " + provider, e);
}
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class SystemExport method loadMaps.
private void loadMaps() {
ProcessDao pDao = new ProcessDao(config.db);
for (ProcessDescriptor pd : pDao.getDescriptors()) {
processes.put(pd.id, pd);
processIDs.put(pd.id, processIDs.size());
}
FlowDao fDao = new FlowDao(config.db);
for (FlowDescriptor fd : fDao.getDescriptors()) {
flows.put(fd.id, fd);
}
Set<Long> exchanges = system.processLinks.stream().map(link -> link.exchangeId).collect(Collectors.toSet());
String query = "SELECT id, internal_id FROM tbl_exchanges";
try {
NativeSql.on(config.db).query(query, r -> {
long id = r.getLong(1);
if (exchanges.contains(id)) {
exchangeIDs.put(id, r.getInt(2));
}
return true;
});
} catch (Exception e) {
log.error("Failed to get internal exchange IDs", e);
}
}
use of org.openlca.core.database.ProcessDao 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));
}
Aggregations