use of org.openlca.core.model.Project in project olca-app by GreenDelta.
the class CalculationSetupSection method setInitialSelection.
private void setInitialSelection() {
Project project = editor.getModel();
if (project.impactMethod == null)
return;
methodCombo.select(Descriptor.of(project.impactMethod));
// normalisation and weighting sets
var nws = new ArrayList<NwSetDescriptor>();
NwSetDescriptor selected = null;
for (var nwSet : project.impactMethod.nwSets) {
var d = Descriptor.of(nwSet);
nws.add(d);
if (project.nwSet != null && project.nwSet.id == nwSet.id) {
selected = d;
}
}
nwSetCombo.setInput(nws);
nwSetCombo.select(selected);
}
use of org.openlca.core.model.Project in project olca-app by GreenDelta.
the class CalculationSetupSection method onMethodChange.
private void onMethodChange(ImpactMethodDescriptor method) {
Project project = editor.getModel();
// first check if something changed
if (method == null && project.impactMethod == null)
return;
if (method != null && project.impactMethod != null && method.id == project.impactMethod.id)
return;
// handle change
project.impactMethod = method == null ? null : new ImpactMethodDao(db).getForId(method.id);
project.nwSet = null;
nwSetCombo.select(null);
nwSetCombo.setInput(method);
editor.setDirty(true);
}
use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class ProjectReferenceSearchTest method createModel.
@Override
protected Project createModel() {
Project project = new Project();
project.category = insertAndAddExpected("category", new Category());
project.impactMethod = insertAndAddExpected("impactMethodId", new ImpactMethod());
String n1 = generateName();
String n2 = generateName();
String n3 = generateName();
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);
project.variants.add(createProjectVariant(n1, n2, n3, project.impactMethod.id));
project.variants.add(createProjectVariant(n1, n2, n3, project.impactMethod.id));
project = db.insert(project);
for (ProjectVariant v : project.variants) {
addExpected("productSystem", v.productSystem, "variants", ProjectVariant.class, v.id);
addExpected("unit", v.unit, "variants", ProjectVariant.class, v.id);
addExpected("flowPropertyFactor", v.flowPropertyFactor, "variants", ProjectVariant.class, v.id);
for (ParameterRedef p : v.parameterRedefs) {
if (p.contextType == null) {
addExpected(p.name, parameters.get(p.name), "variants", ProjectVariant.class, v.id);
}
}
}
return project;
}
use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class Update8Test method testProjectVariants.
@Test
public void testProjectVariants() {
ProjectDao dao = new ProjectDao(db);
Project project = new Project();
ProjectVariant var = new ProjectVariant();
var.isDisabled = true;
project.variants.add(var);
dao.insert(project);
project = dao.getForId(project.id);
assertTrue(project.variants.get(0).isDisabled);
project.variants.get(0).isDisabled = false;
dao.update(project);
project = dao.getForId(project.id);
assertFalse(project.variants.get(0).isDisabled);
dao.delete(project);
}
use of org.openlca.core.model.Project in project olca-modules by GreenDelta.
the class ProjectImport method createProject.
private void createProject(ProjectDescriptor descriptor) {
Project srcProject = srcDao.getForId(descriptor.id);
Project destProject = srcProject.copy();
destProject.refId = srcProject.refId;
destProject.category = refs.switchRef(srcProject.category);
destProject.impactMethod = refs.switchRef(srcProject.impactMethod);
destProject.nwSet = refs.switchRef(srcProject.nwSet);
for (ProjectVariant variant : destProject.variants) switchVariantReferences(variant);
destProject = destDao.insert(destProject);
seq.put(seq.PROJECT, srcProject.refId, destProject.id);
}
Aggregations