Search in sources :

Example 1 with FlowDescriptor

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);
    }
}
Also used : DataSetType(org.openlca.ilcd.commons.DataSetType) Technology(org.openlca.ilcd.models.Technology) QuantitativeReference(org.openlca.ilcd.models.QuantitativeReference) ProcessDao(org.openlca.core.database.ProcessDao) LoggerFactory(org.slf4j.LoggerFactory) Connection(org.openlca.ilcd.models.Connection) HashMap(java.util.HashMap) Ref(org.openlca.ilcd.commons.Ref) ProductSystem(org.openlca.core.model.ProductSystem) ModelName(org.openlca.ilcd.models.ModelName) Modelling(org.openlca.ilcd.models.Modelling) Map(java.util.Map) FlowDao(org.openlca.core.database.FlowDao) Models(org.openlca.ilcd.util.Models) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) ProcessLink(org.openlca.core.model.ProcessLink) FlowType(org.openlca.core.model.FlowType) Version(org.openlca.core.model.Version) DownstreamLink(org.openlca.ilcd.models.DownstreamLink) Logger(org.slf4j.Logger) Process(org.openlca.ilcd.processes.Process) Set(java.util.Set) NativeSql(org.openlca.core.database.NativeSql) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Parameter(org.openlca.ilcd.models.Parameter) Model(org.openlca.ilcd.models.Model) ProcessInstance(org.openlca.ilcd.models.ProcessInstance) DataSetInfo(org.openlca.ilcd.models.DataSetInfo) Classification(org.openlca.ilcd.commons.Classification) LangString(org.openlca.ilcd.commons.LangString) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) FlowDao(org.openlca.core.database.FlowDao) ProcessDao(org.openlca.core.database.ProcessDao) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) LangString(org.openlca.ilcd.commons.LangString)

Example 2 with FlowDescriptor

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;
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor)

Example 3 with FlowDescriptor

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);
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor)

Example 4 with FlowDescriptor

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();
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ProcessDao(org.openlca.core.database.ProcessDao) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor)

Example 5 with FlowDescriptor

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);
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor)

Aggregations

FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)26 ArrayList (java.util.ArrayList)9 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)9 CostResultDescriptor (org.openlca.app.util.CostResultDescriptor)4 FlowDao (org.openlca.core.database.FlowDao)4 ImpactDescriptor (org.openlca.core.model.descriptors.ImpactDescriptor)4 ProcessDao (org.openlca.core.database.ProcessDao)3 TechFlow (org.openlca.core.matrix.index.TechFlow)3 Location (org.openlca.core.model.Location)3 CategoryPair (org.openlca.io.CategoryPair)3 JsonArray (com.google.gson.JsonArray)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 EntityCache (org.openlca.core.database.EntityCache)2 FlowType (org.openlca.core.model.FlowType)2 ProcessLink (org.openlca.core.model.ProcessLink)2 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)2 Contribution (org.openlca.core.results.Contribution)2 ProcessInstance (org.openlca.ilcd.models.ProcessInstance)2