use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class FlowExport method doIt.
@Override
protected void doIt(CSVPrinter printer, IDatabase db) throws IOException {
log.trace("write flows");
FlowDao dao = new FlowDao(db);
List<Flow> flows = dao.getAll();
for (Flow flow : flows) {
Object[] line = createLine(flow);
printer.printRecord(line);
}
log.trace("{} flows written", flows.size());
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class FlowSheets method write.
private void write() {
Excel.trackSize(flowSheet, 0, 10);
Excel.trackSize(factorSheet, 0, 4);
writeFlowHeader();
writeFactorHeader();
var flows = new FlowDao(config.database).getAll();
flows.sort(new EntitySorter());
for (Flow flow : flows) {
flowRow++;
write(flow);
for (FlowPropertyFactor factor : flow.flowPropertyFactors) {
factorRow++;
writeFactor(flow, factor);
}
}
Excel.autoSize(flowSheet, 0, 10);
Excel.autoSize(factorSheet, 0, 4);
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class TechIndex method fillFrom.
private void fillFrom(IDatabase db, ProductSystem system) {
var systems = new ProductSystemDao(db).descriptorMap();
var processes = new ProcessDao(db).descriptorMap();
var results = new ResultDao(db).descriptorMap();
var flows = new FlowDao(db).descriptorMap();
for (var link : system.processLinks) {
RootDescriptor p = processes.get(link.providerId);
if (p == null) {
p = systems.get(link.providerId);
if (p == null) {
p = results.get(link.providerId);
}
}
if (p == null)
continue;
var flow = flows.get(link.flowId);
if (flow == null)
continue;
// the tech-index checks for duplicates of products and links
var provider = TechFlow.of(p, flow);
add(provider);
var exchange = new LongPair(link.processId, link.exchangeId);
putLink(exchange, provider);
}
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class ModelImport method collectFlows.
/**
* Collect the flows that are used in the process links. This function must
* be called after all processes are imported.
*/
private Map<String, Flow> collectFlows(Technology tech) {
Set<String> usedFlows = new HashSet<>();
for (ProcessInstance pi : tech.processes) {
for (Connection con : pi.connections) {
usedFlows.add(con.outputFlow);
for (DownstreamLink link : con.downstreamLinks) {
usedFlows.add(link.inputFlow);
}
}
}
FlowDao dao = new FlowDao(config.db());
Map<String, Flow> m = new HashMap<>();
for (Flow f : dao.getForRefIds(usedFlows)) {
m.put(f.refId, f);
}
return m;
}
use of org.openlca.core.database.FlowDao in project olca-modules by GreenDelta.
the class SystemsInSystemsTests method testCalc.
@Test
public void testCalc() {
IDatabase db = Tests.getDb();
UnitGroupDao ugDao = new UnitGroupDao(db);
FlowPropertyDao fpDao = new FlowPropertyDao(db);
FlowDao flowDao = new FlowDao(db);
ProcessDao processDao = new ProcessDao(db);
ProductSystemDao systemDao = new ProductSystemDao(db);
UnitGroup ug6939 = new UnitGroup();
ug6939.refId = UUID.randomUUID().toString();
ug6939.name = "Units of mass";
Unit kg = new Unit();
kg.name = "kg";
kg.conversionFactor = 1.0;
kg.refId = UUID.randomUUID().toString();
}
Aggregations