use of org.openlca.core.model.ImpactMethod 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.ImpactMethod in project olca-modules by GreenDelta.
the class NwSetIOTest method setUp.
@Before
public void setUp() {
ImpactMethod method = new ImpactMethod();
for (int i = 0; i < NWSET_COUNT; i++) {
NwSet set = new NwSet();
set.name = "nwset_" + i;
method.nwSets.add(set);
}
ImpactCategoryDao cdao = new ImpactCategoryDao(db);
for (int i = 0; i < CATEGORY_COUNT; i++) {
ImpactCategory category = new ImpactCategory();
category.name = "category_" + i;
category = cdao.insert(category);
method.impactCategories.add(category);
for (NwSet set : method.nwSets) {
NwFactor factor = new NwFactor();
factor.weightingFactor = FACTOR;
factor.impactCategory = category;
factor.normalisationFactor = FACTOR;
set.factors.add(factor);
}
}
this.method = new ImpactMethodDao(db).insert(method);
Tests.emptyCache();
}
use of org.openlca.core.model.ImpactMethod in project olca-modules by GreenDelta.
the class ImpactMethods method exec.
private void exec() {
var version = block.version() != null ? new Version(block.version().major(), block.version().minor(), 0) : new Version(0, 0, 0);
var refId = KeyGen.get("SimaPro CSV", block.name(), version.toString());
var method = context.db().get(ImpactMethod.class, refId);
if (method != null) {
log.warn("an LCIA method refId='" + refId + "' already exists; skipped");
return;
}
method = new ImpactMethod();
method.refId = refId;
method.name = block.name();
method.version = version.getValue();
method.description = block.comment();
for (var csvImpact : block.impactCategories()) {
if (csvImpact.info() == null)
continue;
var impactId = KeyGen.get("SimaPro CSV", block.name(), version.toString(), csvImpact.info().name());
var impact = new ImpactCategory();
impact.refId = impactId;
impact.name = csvImpact.info().name();
impact.referenceUnit = csvImpact.info().unit();
addFactors(csvImpact, impact);
impact = context.insert(impact);
method.impactCategories.add(impact);
}
context.insert(method);
}
use of org.openlca.core.model.ImpactMethod in project olca-modules by GreenDelta.
the class MethodImport method run.
@Override
public void run() {
ImpactMethodDao dao = new ImpactMethodDao(db);
Spold2Files.parse(files, es2 -> {
if (es2.impactMethod == null)
return;
ImpactMethod m = dao.getForRefId(es2.impactMethod.id);
if (m != null) {
log.warn("an LCIA method with id={} " + "already exisis; not imported", m.refId);
return;
}
m = map(es2.impactMethod);
if (m != null) {
dao.insert(m);
log.info("saved new LCIA method {}", m);
}
});
}
use of org.openlca.core.model.ImpactMethod in project olca-modules by GreenDelta.
the class ILCDExport method tryExport.
private void tryExport(RootEntity component) throws Exception {
if (component instanceof ImpactMethod) {
ImpactMethodExport export = new ImpactMethodExport(config);
export.run((ImpactMethod) component);
} else if (component instanceof ProductSystem) {
SystemExport export = new SystemExport(config);
export.run((ProductSystem) component);
} else if (component instanceof Process) {
ProcessExport export = new ProcessExport(config);
export.run((Process) component);
} else if (component instanceof Flow) {
FlowExport flowExport = new FlowExport(config);
flowExport.run((Flow) component);
} else if (component instanceof FlowProperty) {
FlowPropertyExport export = new FlowPropertyExport(config);
export.run((FlowProperty) component);
} else if (component instanceof UnitGroup) {
UnitGroupExport export = new UnitGroupExport(config);
export.run((UnitGroup) component);
} else if (component instanceof Actor) {
ActorExport export = new ActorExport(config);
export.run((Actor) component);
} else if (component instanceof Source) {
SourceExport export = new SourceExport(config);
export.run((Source) component);
}
}
Aggregations