use of org.openlca.core.model.descriptors.FlowDescriptor 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.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.
the class SolverTest method flow.
private FlowDescriptor flow(int id) {
FlowDescriptor flow = new FlowDescriptor();
flow.id = id;
return flow;
}
use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.
the class ContributionTreeTest method provider.
private TechFlow provider(long id, long flowId) {
ProcessDescriptor process = new ProcessDescriptor();
process.name = "Process " + id;
process.id = id;
FlowDescriptor flow = new FlowDescriptor();
flow.name = "Flow " + flowId;
flow.id = flowId;
return TechFlow.of(process, flow);
}
use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-app by GreenDelta.
the class ReplaceProvidersDialog method okPressed.
@Override
protected void okPressed() {
ProcessDescriptor oldProcess = processViewer.getSelected();
FlowDescriptor product = productViewer.getSelected();
ProcessDescriptor newProcess = replacementViewer.getSelected();
ProcessDao dao = new ProcessDao(Database.get());
dao.replace(oldProcess.id, product.id, newProcess != null ? newProcess.id : null);
Database.get().getEntityFactory().getCache().evictAll();
super.okPressed();
}
use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-app by GreenDelta.
the class ReplaceFlowsDialog method updateButtons.
private void updateButtons() {
FlowDescriptor first = selectionViewer.getSelected();
FlowDescriptor second = replacementViewer.getSelected();
boolean enabled = first != null && first.id != 0L && second != null && second.id != 0L;
getButton(IDialogConstants.OK_ID).setEnabled(enabled);
}
Aggregations