Search in sources :

Example 1 with ProductSystemDao

use of org.openlca.core.database.ProductSystemDao in project olca-modules by GreenDelta.

the class ExchangeUseSearchTest method createSystem.

private void createSystem() {
    ProductSystem system = new ProductSystem();
    system.name = SYS_NAME;
    system.referenceProcess = p;
    system.referenceExchange = p.exchanges.get(0);
    Flow linkFlow = p.exchanges.get(1).flow;
    ProcessLink link = new ProcessLink();
    link.providerId = p.id;
    link.processId = q.id;
    link.flowId = linkFlow.id;
    system.processLinks.add(link);
    system = new ProductSystemDao(db).insert(system);
    modelStack.push(system);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) ProductSystem(org.openlca.core.model.ProductSystem) Flow(org.openlca.core.model.Flow) ProductSystemDao(org.openlca.core.database.ProductSystemDao)

Example 2 with ProductSystemDao

use of org.openlca.core.database.ProductSystemDao in project olca-modules by GreenDelta.

the class Update8Test method testSystemLink.

@Test
public void testSystemLink() {
    ProductSystemDao dao = new ProductSystemDao(db);
    ProductSystem system = new ProductSystem();
    ProcessLink link = new ProcessLink();
    link.providerType = ProcessLink.ProviderType.SUB_SYSTEM;
    system.processLinks.add(link);
    dao.insert(system);
    system = dao.getForId(system.id);
    assertTrue(system.processLinks.get(0).hasSubSystemProvider());
    dao.delete(system);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) ProductSystem(org.openlca.core.model.ProductSystem) ProductSystemDao(org.openlca.core.database.ProductSystemDao) Test(org.junit.Test)

Example 3 with ProductSystemDao

use of org.openlca.core.database.ProductSystemDao 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)

Example 4 with ProductSystemDao

use of org.openlca.core.database.ProductSystemDao 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);
    }
}
Also used : FlowDao(org.openlca.core.database.FlowDao) ProcessDao(org.openlca.core.database.ProcessDao) ResultDao(org.openlca.core.database.ResultDao) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) ProductSystemDao(org.openlca.core.database.ProductSystemDao)

Example 5 with ProductSystemDao

use of org.openlca.core.database.ProductSystemDao 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();
}
Also used : IDatabase(org.openlca.core.database.IDatabase) UnitGroup(org.openlca.core.model.UnitGroup) FlowDao(org.openlca.core.database.FlowDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) ProcessDao(org.openlca.core.database.ProcessDao) Unit(org.openlca.core.model.Unit) UnitGroupDao(org.openlca.core.database.UnitGroupDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) Test(org.junit.Test)

Aggregations

ProductSystemDao (org.openlca.core.database.ProductSystemDao)14 ProcessDao (org.openlca.core.database.ProcessDao)6 ProductSystem (org.openlca.core.model.ProductSystem)6 Test (org.junit.Test)3 FlowDao (org.openlca.core.database.FlowDao)3 HashMap (java.util.HashMap)2 CategoryDao (org.openlca.core.database.CategoryDao)2 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)2 IDatabase (org.openlca.core.database.IDatabase)2 UnitGroupDao (org.openlca.core.database.UnitGroupDao)2 ProductSystemBuilder (org.openlca.core.matrix.ProductSystemBuilder)2 LinkingConfig (org.openlca.core.matrix.linking.LinkingConfig)2 ProcessLink (org.openlca.core.model.ProcessLink)2 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)2 JsonObject (com.google.gson.JsonObject)1 TLongIntHashMap (gnu.trove.map.hash.TLongIntHashMap)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1