use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createParameter.
private Parameter createParameter(String name, Object value, boolean global) {
Parameter parameter = new Parameter();
parameter.name = name;
boolean formula = value instanceof String;
parameter.isInputParameter = !formula;
if (formula)
parameter.formula = value.toString();
else
parameter.value = (double) value;
if (global)
parameter.scope = ParameterScope.GLOBAL;
else
parameter.scope = ParameterScope.PROCESS;
return parameter;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createParameterRedef.
private ParameterRedef createParameterRedef(String name, Object contextOrValue) {
ParameterRedef redef = new ParameterRedef();
redef.name = name;
redef.value = 1d;
if (contextOrValue instanceof Long) {
redef.contextType = ModelType.IMPACT_METHOD;
redef.contextId = (long) contextOrValue;
} else {
if (!parameters.containsKey(name)) {
Parameter parameter = createParameter(name, contextOrValue.toString(), true);
parameters.put(name, db.insert(parameter));
}
}
return redef;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ParameterIOTests method testGlobalParameters.
@Test
public void testGlobalParameters() {
Parameter param = new Parameter();
param.refId = UUID.randomUUID().toString();
param.description = "test parameter";
param.isInputParameter = true;
param.scope = ParameterScope.GLOBAL;
param.name = "p_342637";
param.value = 42;
parameterDao.insert(param);
Tests.emptyCache();
Parameter alias = parameterDao.getForId(param.id);
Assert.assertEquals("p_342637", alias.name);
Assert.assertTrue(parameterDao.getGlobalParameters().contains(alias));
parameterDao.delete(alias);
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProcessParameterConversion method addDatabaseParams.
private void addDatabaseParams(List<org.openlca.ilcd.processes.Parameter> params) {
ParameterDao dao = new ParameterDao(config.db);
for (Parameter param : dao.getGlobalParameters()) {
if (!valid(param))
continue;
org.openlca.ilcd.processes.Parameter iParam = convertParam(param);
params.add(iParam);
addScope(iParam, ParameterScope.GLOBAL);
}
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProcessParameterConversion method processParams.
private List<org.openlca.ilcd.processes.Parameter> processParams(Process process) {
List<org.openlca.ilcd.processes.Parameter> iParameters = new ArrayList<>();
for (Parameter oParam : process.parameters) {
if (!valid(oParam))
continue;
org.openlca.ilcd.processes.Parameter iParam = convertParam(oParam);
iParameters.add(iParam);
addScope(iParam, ParameterScope.PROCESS);
}
return iParameters;
}
Aggregations