Search in sources :

Example 6 with Project

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);
}
Also used : Project(org.openlca.core.model.Project) NwSetDescriptor(org.openlca.core.model.descriptors.NwSetDescriptor) ArrayList(java.util.ArrayList)

Example 7 with Project

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);
}
Also used : Project(org.openlca.core.model.Project) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao)

Example 8 with Project

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;
}
Also used : Project(org.openlca.core.model.Project) Category(org.openlca.core.model.Category) ProjectVariant(org.openlca.core.model.ProjectVariant) Parameter(org.openlca.core.model.Parameter) ParameterRedef(org.openlca.core.model.ParameterRedef) ImpactMethod(org.openlca.core.model.ImpactMethod)

Example 9 with 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);
}
Also used : Project(org.openlca.core.model.Project) ProjectVariant(org.openlca.core.model.ProjectVariant) ProjectDao(org.openlca.core.database.ProjectDao) Test(org.junit.Test)

Example 10 with 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);
}
Also used : Project(org.openlca.core.model.Project) ProjectVariant(org.openlca.core.model.ProjectVariant)

Aggregations

Project (org.openlca.core.model.Project)14 ProjectVariant (org.openlca.core.model.ProjectVariant)8 Test (org.junit.Test)5 ParameterRedef (org.openlca.core.model.ParameterRedef)4 Parameter (org.openlca.core.model.Parameter)3 Process (org.openlca.core.model.Process)3 ArrayList (java.util.ArrayList)2 ProductSystem (org.openlca.core.model.ProductSystem)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Action (org.eclipse.jface.action.Action)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 SWT (org.eclipse.swt.SWT)1 Image (org.eclipse.swt.graphics.Image)1