Search in sources :

Example 1 with ProductSystem

use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.

the class ProductSystemReferenceSearchTest method createModel.

@Override
protected ProductSystem createModel() {
    ProductSystem system = new ProductSystem();
    system.category = insertAndAddExpected("category", new Category());
    system.referenceProcess = createProcess();
    system.referenceExchange = system.referenceProcess.exchanges.get(0);
    system.targetFlowPropertyFactor = system.referenceExchange.flowPropertyFactor;
    system.targetUnit = system.targetFlowPropertyFactor.flowProperty.unitGroup.units.get(0);
    system.processes.add(system.referenceProcess.id);
    Process p1 = insertAndAddExpected("processes", new Process());
    Process p2 = insertAndAddExpected("processes", new Process());
    Process p3 = insertAndAddExpected("processes", new Process());
    system.processes.add(p1.id);
    system.processes.add(p2.id);
    system.processes.add(p3.id);
    system.processLinks.add(createLink(p1, p2));
    system.processLinks.add(createLink(p2, p3));
    String n1 = generateName();
    String n2 = generateName();
    String n3 = generateName();
    // TODO: find parameter references
    // system.parameterRedefs.add(createParameterRedef(n1, p1.id));
    // formula with parameter to see if added as reference (unexpected)
    // system.parameterRedefs.add(createParameterRedef(n2, n3 + "*5"));
    Parameter globalUnreferenced = createParameter(n1, "3*3", true);
    Parameter globalUnreferenced2 = createParameter(n3, "3*3", true);
    // must be inserted manually
    globalUnreferenced = db.insert(globalUnreferenced);
    globalUnreferenced2 = db.insert(globalUnreferenced2);
    return db.insert(system);
}
Also used : Category(org.openlca.core.model.Category) ProductSystem(org.openlca.core.model.ProductSystem) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process)

Example 2 with ProductSystem

use of org.openlca.core.model.ProductSystem 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 3 with ProductSystem

use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.

the class ProjectReferenceSearchTest method createProjectVariant.

private ProjectVariant createProjectVariant(String p1Name, String p2Name, String p3Name, long methodId) {
    ProjectVariant variant = new ProjectVariant();
    variant.productSystem = db.insert(new ProductSystem());
    variant.parameterRedefs.add(createParameterRedef(p1Name, methodId));
    variant.parameterRedefs.add(createParameterRedef(p2Name, p3Name + "*5"));
    FlowPropertyFactor factor = new FlowPropertyFactor();
    factor.flowProperty = db.insert(new FlowProperty());
    variant.flowPropertyFactor = factor;
    UnitGroup unitGroup = new UnitGroup();
    Unit unit = new Unit();
    unit.name = "unit";
    unitGroup.units.add(unit);
    unitGroup = db.insert(unitGroup);
    unit = unitGroup.getUnit(unit.name);
    variant.unit = unit;
    Flow flow = new Flow();
    flow.flowPropertyFactors.add(factor);
    // don't add flow to expected references, just for persisting the factor
    flow = db.insert(flow);
    return variant;
}
Also used : ProjectVariant(org.openlca.core.model.ProjectVariant) UnitGroup(org.openlca.core.model.UnitGroup) ProductSystem(org.openlca.core.model.ProductSystem) FlowPropertyFactor(org.openlca.core.model.FlowPropertyFactor) Unit(org.openlca.core.model.Unit) FlowProperty(org.openlca.core.model.FlowProperty) Flow(org.openlca.core.model.Flow)

Example 4 with ProductSystem

use of org.openlca.core.model.ProductSystem 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 5 with ProductSystem

use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.

the class ProductSystemDaoTest method testParameterRedefSets.

@Test
public void testParameterRedefSets() {
    ProductSystemDao dao = new ProductSystemDao(Tests.getDb());
    ProductSystem sys = new ProductSystem();
    ParameterRedefSet s1 = new ParameterRedefSet();
    sys.parameterSets.add(s1);
    s1.name = "Baseline";
    s1.isBaseline = true;
    ParameterRedef p1 = new ParameterRedef();
    p1.name = "p";
    p1.description = "just for testing";
    p1.value = 42.0;
    s1.parameters.add(p1);
    ParameterRedefSet s2 = new ParameterRedefSet();
    sys.parameterSets.add(s2);
    s2.name = "Something else";
    s2.isBaseline = false;
    s2.parameters.add(p1.copy());
    dao.insert(sys);
    sys = dao.getForId(sys.id);
    Assert.assertEquals(2, sys.parameterSets.size());
    for (ParameterRedefSet s : sys.parameterSets) {
        if (s.isBaseline) {
            Assert.assertEquals("Baseline", s.name);
        } else {
            Assert.assertEquals("Something else", s.name);
        }
        Assert.assertEquals("p", s.parameters.get(0).name);
    }
    dao.delete(sys);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) ParameterRedef(org.openlca.core.model.ParameterRedef) ParameterRedefSet(org.openlca.core.model.ParameterRedefSet) Test(org.junit.Test)

Aggregations

ProductSystem (org.openlca.core.model.ProductSystem)37 Test (org.junit.Test)12 Process (org.openlca.core.model.Process)12 TestProcess (org.openlca.core.TestProcess)7 ProductSystemDao (org.openlca.core.database.ProductSystemDao)7 ProductSystemNode (org.openlca.app.editors.graphical.model.ProductSystemNode)5 Flow (org.openlca.core.model.Flow)5 Parameter (org.openlca.core.model.Parameter)5 FullResult (org.openlca.core.results.FullResult)5 ImpactMethod (org.openlca.core.model.ImpactMethod)4 ProcessLink (org.openlca.core.model.ProcessLink)4 Before (org.junit.Before)3 FlowProperty (org.openlca.core.model.FlowProperty)3 ParameterRedef (org.openlca.core.model.ParameterRedef)3 ParameterRedefSet (org.openlca.core.model.ParameterRedefSet)3 UnitGroup (org.openlca.core.model.UnitGroup)3 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)3 Actor (org.openlca.core.model.Actor)2 Category (org.openlca.core.model.Category)2 ImpactCategory (org.openlca.core.model.ImpactCategory)2