use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class ParameterReferencesTest method testProjectRedef.
@Test
public void testProjectRedef() {
Parameter p1 = createParameter("p1", "3", null, null);
Parameter p2 = createParameter("p2", "3", ParameterScope.PROCESS, null);
ParameterRedef redef1 = createRedef(p1);
ParameterRedef redef2 = createRedef(p2);
Project project = createProject(redef1, redef2);
with((store) -> {
JsonExport export = new JsonExport(db, store);
export.write(project);
assertNotNull(store.get(ModelType.PROJECT, project.refId));
assertNotNull(store.get(ModelType.PARAMETER, p1.refId));
assertNull(store.get(ModelType.PARAMETER, p2.refId));
});
}
use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class ProjectCalculationTest method testScaleVariantByAmount.
@Test
public void testScaleVariantByAmount() {
Project project = new Project();
Process p = TestProcess.refProduct("p", 1, "kg").elemOut("e1", 0.5, "kg").elemOut("e2", 2.0, "kg").get();
ProjectVariant var1 = new ProjectVariant();
var1.productSystem = TestSystem.of(p).get();
var1.amount = 2.0;
project.variants.add(var1);
Process w = TestProcess.refWaste("w", 1, "kg").elemOut("e1", 0.5, "kg").elemOut("e2", 2.0, "kg").get();
ProjectVariant var2 = new ProjectVariant();
var2.productSystem = TestSystem.of(w).get();
var2.amount = 2.0;
project.variants.add(var2);
var result = ProjectResult.calculate(project, Tests.getDb());
var items = ResultItemView.of(result);
assertEquals(2, items.enviFlows().size());
AtomicInteger icount = new AtomicInteger(0);
for (EnviFlow f : items.enviFlows()) {
result.getContributions(f).forEach(item -> {
icount.incrementAndGet();
switch(f.flow().name) {
case "e1":
assertEquals(1.0, item.amount, 1e-10);
break;
case "e2":
assertEquals(4.0, item.amount, 1e-10);
break;
}
});
}
assertEquals(4, icount.get());
}
use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class ProductSystemUseSearchTest method testFindInProjects.
@Test
public void testFindInProjects() {
var project = new Project();
project.name = "project";
ProjectVariant variant = new ProjectVariant();
variant.productSystem = system;
project.variants.add(variant);
db.insert(project);
UsageTests.expectOne(system, project);
db.delete(project);
}
use of org.openlca.core.model.Project in project olca-app by GreenDelta.
the class ProjectParameterTable method onAdd.
private void onAdd() {
// collect the possible local parameter contexts
var contexts = new HashSet<Long>();
var project = editor.getModel();
if (project.impactMethod != null) {
contexts.add(project.impactMethod.id);
}
project.variants.stream().filter(v -> v.productSystem != null).forEach(v -> contexts.addAll(v.productSystem.processes));
var newRedefs = ParameterRedefDialog.select(contexts);
for (var redef : newRedefs) {
if (!this.redefs.add(redef))
continue;
for (Column column : columns) {
if (findVariantRedef(column.variant, redef) == null)
column.variant.parameterRedefs.add(redef.copy());
}
}
viewer.setInput(this.redefs);
editor.setDirty(true);
}
Aggregations