use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterImport method run.
public void run() {
log.trace("import global parameters");
try {
Set<String> existing = getExisting();
for (Parameter param : sourceDao.getGlobalParameters()) {
if (param.name == null)
continue;
if (existing.contains(param.name))
continue;
Parameter c = param.copy();
destDao.insert(c);
}
} catch (Exception e) {
log.error("Global parameter import failed", e);
}
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterSheet method readParams.
private List<Parameter> readParams(String section, ParameterScope scope, boolean input) {
int row = findSection(section);
if (row < 0)
return Collections.emptyList();
List<Parameter> list = new ArrayList<>();
row += 2;
while (true) {
String name = config.getString(sheet, row, 0);
if (Strings.isNullOrEmpty(name))
break;
Parameter p = input ? readInputParam(row, name, scope) : readDependentParam(row, name, scope);
list.add(p);
row++;
}
return list;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterSheet method readInputParam.
private Parameter readInputParam(int row, String name, ParameterScope scope) {
Parameter p = new Parameter();
p.name = name;
p.isInputParameter = true;
p.scope = scope;
p.value = config.getDouble(sheet, row, 1);
p.uncertainty = config.getUncertainty(sheet, row, 2);
p.description = config.getString(sheet, row, 7);
return p;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterSheet method syncGlobals.
private void syncGlobals(List<Parameter> sheetParams) {
ParameterDao dao = new ParameterDao(config.database);
List<Parameter> globals = new ArrayList<>();
globals.addAll(dao.getGlobalParameters());
for (Parameter p : sheetParams) {
boolean found = false;
for (Parameter global : globals) {
String name = global.name;
if (name == null)
continue;
if (name.equalsIgnoreCase(p.name)) {
found = true;
break;
}
}
if (!found)
globals.add(dao.insert(p));
}
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterSheet method readDependentParam.
private Parameter readDependentParam(int row, String name, ParameterScope scope) {
Parameter p = new Parameter();
p.name = name;
p.isInputParameter = false;
p.scope = scope;
p.formula = config.getString(sheet, row, 1);
p.value = config.getDouble(sheet, row, 2);
p.description = config.getString(sheet, row, 3);
return p;
}
Aggregations