use of org.openlca.core.model.ParameterRedef in project olca-modules by GreenDelta.
the class ParameterTableTest method testGloablRedef.
@Test
public void testGloablRedef() throws Exception {
ParameterRedef redef = new ParameterRedef();
redef.name = "inp_param";
redef.value = 99;
var fi = ParameterTable.interpreter(Tests.getDb(), Collections.singleton(process.id), Collections.singleton(redef));
// global
assertEquals(99.0, fi.eval("inp_param"), 1e-6);
assertEquals(2 * 99.0, fi.eval("dep_param"), 1e-6);
// local
var scope = fi.getScope(process.id);
assertTrue(scope.isPresent());
assertEquals(84.0, scope.get().eval("inp_param"), 1e-6);
assertEquals(3 * 84.0, scope.get().eval("dep_param"), 1e-6);
}
use of org.openlca.core.model.ParameterRedef in project olca-app by GreenDelta.
the class ParameterClipboard method read.
static List<ParameterRedef> read(String text) {
if (text == null)
return Collections.emptyList();
String[] lines = text.toString().split("\n");
List<ParameterRedef> list = new ArrayList<>();
Mapper mapper = new Mapper();
for (String line : lines) {
String[] row = line.split("\t");
for (int k = 0; k < row.length; k++) {
row[k] = row[k].trim();
}
if (row.length > 2 && Strings.nullOrEqual(row[2], M.Amount))
// the header row
continue;
ParameterRedef p = mapper.doIt(row);
if (p != null) {
list.add(p);
}
}
return list;
}
Aggregations