use of org.openlca.core.model.ProductSystem 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.ProductSystem in project olca-modules by GreenDelta.
the class ExchangeUseSearchTest method createSystem.
private void createSystem() {
ProductSystem system = new ProductSystem();
system.name = SYS_NAME;
system.referenceProcess = p;
system.referenceExchange = p.exchanges.get(0);
Flow linkFlow = p.exchanges.get(1).flow;
ProcessLink link = new ProcessLink();
link.providerId = p.id;
link.processId = q.id;
link.flowId = linkFlow.id;
system.processLinks.add(link);
system = new ProductSystemDao(db).insert(system);
modelStack.push(system);
}
use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createProjectVariant.
private ProjectVariant createProjectVariant(String p1Name, String p2Name, String p3Name, long methodId) {
ProjectVariant variant = new ProjectVariant();
variant.productSystem = db.insert(new ProductSystem());
variant.parameterRedefs.add(createParameterRedef(p1Name, methodId));
variant.parameterRedefs.add(createParameterRedef(p2Name, p3Name + "*5"));
FlowPropertyFactor factor = new FlowPropertyFactor();
factor.flowProperty = db.insert(new FlowProperty());
variant.flowPropertyFactor = factor;
UnitGroup unitGroup = new UnitGroup();
Unit unit = new Unit();
unit.name = "unit";
unitGroup.units.add(unit);
unitGroup = db.insert(unitGroup);
unit = unitGroup.getUnit(unit.name);
variant.unit = unit;
Flow flow = new Flow();
flow.flowPropertyFactors.add(factor);
// don't add flow to expected references, just for persisting the factor
flow = db.insert(flow);
return variant;
}
use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.
the class Update8Test method testSystemLink.
@Test
public void testSystemLink() {
ProductSystemDao dao = new ProductSystemDao(db);
ProductSystem system = new ProductSystem();
ProcessLink link = new ProcessLink();
link.providerType = ProcessLink.ProviderType.SUB_SYSTEM;
system.processLinks.add(link);
dao.insert(system);
system = dao.getForId(system.id);
assertTrue(system.processLinks.get(0).hasSubSystemProvider());
dao.delete(system);
}
use of org.openlca.core.model.ProductSystem in project olca-modules by GreenDelta.
the class ProductSystemDaoTest method testParameterRedefSets.
@Test
public void testParameterRedefSets() {
ProductSystemDao dao = new ProductSystemDao(Tests.getDb());
ProductSystem sys = new ProductSystem();
ParameterRedefSet s1 = new ParameterRedefSet();
sys.parameterSets.add(s1);
s1.name = "Baseline";
s1.isBaseline = true;
ParameterRedef p1 = new ParameterRedef();
p1.name = "p";
p1.description = "just for testing";
p1.value = 42.0;
s1.parameters.add(p1);
ParameterRedefSet s2 = new ParameterRedefSet();
sys.parameterSets.add(s2);
s2.name = "Something else";
s2.isBaseline = false;
s2.parameters.add(p1.copy());
dao.insert(sys);
sys = dao.getForId(sys.id);
Assert.assertEquals(2, sys.parameterSets.size());
for (ParameterRedefSet s : sys.parameterSets) {
if (s.isBaseline) {
Assert.assertEquals("Baseline", s.name);
} else {
Assert.assertEquals("Something else", s.name);
}
Assert.assertEquals("p", s.parameters.get(0).name);
}
dao.delete(sys);
}
Aggregations