Search in sources :

Example 1 with ProcessDao

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();
}
Also used : ProcessDao(org.openlca.core.database.ProcessDao) Process(org.openlca.core.model.Process) Before(org.junit.Before)

Example 2 with ProcessDao

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));
}
Also used : ProcessDao(org.openlca.core.database.ProcessDao) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Process(org.openlca.core.model.Process) Test(org.junit.Test)

Example 3 with ProcessDao

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

Example 4 with ProcessDao

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);
    }
}
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 5 with ProcessDao

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));
}
Also used : SourceDao(org.openlca.core.database.SourceDao) CurrencyDao(org.openlca.core.database.CurrencyDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) CategoryDao(org.openlca.core.database.CategoryDao) ActorDao(org.openlca.core.database.ActorDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) LocationDao(org.openlca.core.database.LocationDao) UnitDao(org.openlca.core.database.UnitDao) DQSystemDao(org.openlca.core.database.DQSystemDao) NwSetDao(org.openlca.core.database.NwSetDao) FlowDao(org.openlca.core.database.FlowDao) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao) ProcessDao(org.openlca.core.database.ProcessDao) UnitGroupDao(org.openlca.core.database.UnitGroupDao) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) ProjectDao(org.openlca.core.database.ProjectDao)

Aggregations

ProcessDao (org.openlca.core.database.ProcessDao)52 Process (org.openlca.core.model.Process)27 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)14 IDatabase (org.openlca.core.database.IDatabase)13 FlowDao (org.openlca.core.database.FlowDao)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 ProductSystemDao (org.openlca.core.database.ProductSystemDao)6 Exchange (org.openlca.core.model.Exchange)6 File (java.io.File)5 HashMap (java.util.HashMap)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Before (org.junit.Before)4 ParameterDao (org.openlca.core.database.ParameterDao)4 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)4 Map (java.util.Map)3 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)3 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)3 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)3