use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ImpactMethodReferenceSearchTest method createModel.
@Override
protected ImpactMethod createModel() {
ImpactMethod method = new ImpactMethod();
method.category = insertAndAddExpected("category", new Category());
String n1 = generateName();
// String n2 = generateName();
String n3 = generateName();
String n4 = generateName();
String n5 = generateName();
// method.parameters.add(createParameter(n1, 3d, false));
// method.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
insertAndAddExpected(n3, createParameter(n3, "5*5", true));
// formula with parameter to see if added as reference (unexpected)
insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
method.impactCategories.add(createImpactCategory(n4));
method.impactCategories.add(createImpactCategory(n4));
method = db.insert(method);
for (ImpactCategory category : method.impactCategories) for (ImpactFactor f : category.impactFactors) {
addExpected("flow", f.flow, "impactFactors", ImpactFactor.class, f.id);
addExpected("flowPropertyFactor", f.flowPropertyFactor, "impactFactors", ImpactFactor.class, f.id);
addExpected("flowProperty", f.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, f.flowPropertyFactor.id);
addExpected("unit", f.unit, "impactFactors", ImpactFactor.class, f.id);
}
return method;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ImpactMethodReferenceSearchTest method createParameter.
// TODO: LCIA method parameters moved down to LCIA categories but the
// reference search tests were not updated yet.
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.IMPACT;
return parameter;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProcessReferenceSearchTest method createModel.
@Override
protected Process createModel() {
Process process = new Process();
process.category = insertAndAddExpected("category", new Category());
process.location = insertAndAddExpected("location", new Location());
process.dqSystem = insertAndAddExpected("dqSystem", new DQSystem());
process.exchangeDqSystem = insertAndAddExpected("exchangeDqSystem", new DQSystem());
process.socialDqSystem = insertAndAddExpected("socialDqSystem", new DQSystem());
String n1 = generateName();
String n2 = generateName();
String n3 = generateName();
String n4 = generateName();
String n5 = generateName();
createExchange(process, 3d, true);
createExchange(process, "2*" + n4, false);
process.parameters.add(createParameter(n1, 3d, false));
process.parameters.add(createParameter(n2, n1 + "*2*" + n3, false));
process.socialAspects.add(createSocialAspect());
process.socialAspects.add(createSocialAspect());
process.documentation = createDocumentation();
insertAndAddExpected(n3, createParameter(n3, "5*5", true));
// formula with parameter to see if added as reference (unexpected)
insertAndAddExpected(n4, createParameter(n4, "3*" + n5, true));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n5, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
process = db.insert(process);
for (Exchange e : process.exchanges) {
addExpected("flow", e.flow, "exchanges", Exchange.class, e.id);
addExpected("flowPropertyFactor", e.flowPropertyFactor, "exchanges", Exchange.class, e.id);
addExpected("flowProperty", e.flowPropertyFactor.flowProperty, "flowPropertyFactor", FlowPropertyFactor.class, e.flowPropertyFactor.id);
addExpected("unit", e.unit, "exchanges", Exchange.class, e.id);
Process provider = processes.get(e.defaultProviderId);
if (provider != null)
addExpected("defaultProviderId", provider, "exchanges", Exchange.class, e.id);
}
for (SocialAspect a : process.socialAspects) {
addExpected("indicator", a.indicator, "socialAspects", SocialAspect.class, a.id);
addExpected("source", a.source, "socialAspects", SocialAspect.class, a.id);
}
ProcessDocumentation doc = process.documentation;
addExpected("dataDocumentor", doc.dataDocumentor, "documentation", ProcessDocumentation.class, doc.id);
addExpected("dataGenerator", doc.dataGenerator, "documentation", ProcessDocumentation.class, doc.id);
addExpected("dataSetOwner", doc.dataSetOwner, "documentation", ProcessDocumentation.class, doc.id);
addExpected("reviewer", doc.reviewer, "documentation", ProcessDocumentation.class, doc.id);
addExpected("publication", doc.publication, "documentation", ProcessDocumentation.class, doc.id);
for (Source s : process.documentation.sources) addExpected("sources", s, "documentation", ProcessDocumentation.class, doc.id);
return process;
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProductSystemReferenceSearchTest method createModel.
@Override
protected ProductSystem createModel() {
ProductSystem system = new ProductSystem();
system.category = insertAndAddExpected("category", new Category());
system.referenceProcess = createProcess();
system.referenceExchange = system.referenceProcess.exchanges.get(0);
system.targetFlowPropertyFactor = system.referenceExchange.flowPropertyFactor;
system.targetUnit = system.targetFlowPropertyFactor.flowProperty.unitGroup.units.get(0);
system.processes.add(system.referenceProcess.id);
Process p1 = insertAndAddExpected("processes", new Process());
Process p2 = insertAndAddExpected("processes", new Process());
Process p3 = insertAndAddExpected("processes", new Process());
system.processes.add(p1.id);
system.processes.add(p2.id);
system.processes.add(p3.id);
system.processLinks.add(createLink(p1, p2));
system.processLinks.add(createLink(p2, p3));
String n1 = generateName();
String n2 = generateName();
String n3 = generateName();
// TODO: find parameter references
// system.parameterRedefs.add(createParameterRedef(n1, p1.id));
// formula with parameter to see if added as reference (unexpected)
// system.parameterRedefs.add(createParameterRedef(n2, n3 + "*5"));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n3, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
return db.insert(system);
}
use of org.openlca.core.model.Parameter in project olca-modules by GreenDelta.
the class ProductSystemReferenceSearchTest 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;
}
Aggregations