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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations