use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class TestData method flow.
public static Flow flow(String name, String unit, FlowType type) {
String flowId = KeyGen.get("flow", name, unit);
FlowDao dao = new FlowDao(Tests.getDb());
Flow flow = dao.getForRefId(flowId);
if (flow != null)
return flow;
flow = new Flow();
flow.name = name;
flow.refId = flowId;
flow.flowType = type;
FlowProperty property = property(unit);
FlowPropertyFactor factor = new FlowPropertyFactor();
factor.flowProperty = property;
factor.conversionFactor = 1;
flow.flowPropertyFactors.add(factor);
flow.referenceFlowProperty = property;
return dao.insert(flow);
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class ExchangeUseSearchTest method addExchanges.
private void addExchanges() {
for (int i = 1; i < 4; i++) {
Flow flow = new Flow();
flow.name = "flow_" + 1;
flow = new FlowDao(db).insert(flow);
modelStack.push(flow);
Exchange ep = new Exchange();
ep.flow = flow;
ep.isInput = false;
p.exchanges.add(ep);
Exchange eq = ep.copy();
eq.isInput = true;
q.exchanges.add(eq);
}
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method setup.
@Before
public void setup() {
flow = new Flow();
flow.name = "flow";
property = new FlowProperty();
property.name = "property";
factor = new FlowPropertyFactor();
factor.flowProperty = property;
flow.flowPropertyFactors.add(factor);
property = new FlowPropertyDao(database).insert(property);
flow = new FlowDao(database).insert(flow);
factor = flow.getFactor(property);
search = new FlowPropertyFactorUseSearch(flow, database);
}
use of org.openlca.core.database.FlowDao 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.FlowDao 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