Search in sources :

Example 21 with ProductSystem

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

the class ProductSystemImport method copy.

private void copy(ProductSystemDescriptor descriptor) {
    ProductSystem srcSystem = srcDao.getForId(descriptor.id);
    ProductSystem destSystem = srcSystem.copy();
    destSystem.refId = srcSystem.refId;
    destSystem.category = refs.switchRef(srcSystem.category);
    destSystem.referenceProcess = refs.switchRef(srcSystem.referenceProcess);
    switchRefExchange(srcSystem, destSystem);
    destSystem.targetUnit = refs.switchRef(srcSystem.targetUnit);
    switchRefFlowProp(srcSystem, destSystem);
    switchParameterRedefs(destSystem);
    ProductSystemDao destDao = new ProductSystemDao(dest);
    ProductSystemLinks.map(source, dest, destSystem);
    destSystem = destDao.insert(destSystem);
    seq.put(seq.PRODUCT_SYSTEM, srcSystem.refId, destSystem.id);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) ProductSystemDao(org.openlca.core.database.ProductSystemDao)

Example 22 with ProductSystem

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

the class ProjectImport method switchVariantProperty.

private void switchVariantProperty(ProjectVariant variant) {
    if (variant.flowPropertyFactor == null)
        return;
    ProductSystem destSystem = variant.productSystem;
    if (destSystem == null || destSystem.referenceExchange == null) {
        variant.flowPropertyFactor = null;
        return;
    }
    Flow destFlow = destSystem.referenceExchange.flow;
    variant.flowPropertyFactor = refs.switchRef(variant.flowPropertyFactor, destFlow);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) Flow(org.openlca.core.model.Flow)

Example 23 with ProductSystem

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

the class ProductSystemUseSearchTest method setup.

@Before
public void setup() {
    system = new ProductSystem();
    system.name = "system";
    system = db.insert(system);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) Before(org.junit.Before)

Example 24 with ProductSystem

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

the class SystemUseSearchTest method setUp.

@Before
public void setUp() {
    project = db.insert(Project.of("test project"));
    system = new ProductSystem();
    system.name = "test system";
    system = db.insert(system);
}
Also used : ProductSystem(org.openlca.core.model.ProductSystem) Before(org.junit.Before)

Example 25 with ProductSystem

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

the class CostTests method testAddCostsForSameProduct.

@Test
public void testAddCostsForSameProduct() {
    Process p1 = TestProcess.refProduct("p1", 1, "kg").addCosts("p1", 1, "EUR").prodIn("p1", 0.5, "kg").elemIn("water", 1, "m3").get();
    long exchangeId = -1;
    for (Exchange e : p1.exchanges) {
        if (e.flow.name.equals("p1") && e.isInput) {
            e.costs = 0.4d;
            e.currency = p1.quantitativeReference.currency;
            exchangeId = e.id;
            break;
        }
    }
    p1 = db.update(p1);
    ProductSystem system = TestSystem.of(p1).get();
    // add a link to the process itself
    ProcessLink selfLink = new ProcessLink();
    selfLink.flowId = p1.quantitativeReference.flow.id;
    selfLink.providerId = p1.id;
    selfLink.processId = p1.id;
    selfLink.exchangeId = exchangeId;
    system.processLinks.add(selfLink);
    system = db.update(system);
    FullResult r = TestSystem.calculate(system);
    Assert.assertEquals(-1.2, r.totalCosts(), 1e-10);
}
Also used : Exchange(org.openlca.core.model.Exchange) ProcessLink(org.openlca.core.model.ProcessLink) FullResult(org.openlca.core.results.FullResult) ProductSystem(org.openlca.core.model.ProductSystem) Process(org.openlca.core.model.Process) TestProcess(org.openlca.core.TestProcess) 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