Search in sources :

Example 1 with SocialAspect

use of org.openlca.core.model.SocialAspect 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;
}
Also used : Exchange(org.openlca.core.model.Exchange) Category(org.openlca.core.model.Category) SocialAspect(org.openlca.core.model.SocialAspect) DQSystem(org.openlca.core.model.DQSystem) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process) ProcessDocumentation(org.openlca.core.model.ProcessDocumentation) Source(org.openlca.core.model.Source) Location(org.openlca.core.model.Location)

Example 2 with SocialAspect

use of org.openlca.core.model.SocialAspect in project olca-modules by GreenDelta.

the class ProcessImport method switchSocialAspectRefs.

private void switchSocialAspectRefs(Process destProcess) {
    for (SocialAspect aspect : destProcess.socialAspects) {
        aspect.indicator = refs.switchRef(aspect.indicator);
        aspect.source = refs.switchRef(aspect.source);
    }
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect)

Example 3 with SocialAspect

use of org.openlca.core.model.SocialAspect in project olca-app by GreenDelta.

the class SocialAspectsPage method addIndicator.

private void addIndicator() {
    var list = ModelSelector.multiSelect(ModelType.SOCIAL_INDICATOR);
    if (list.isEmpty())
        return;
    for (var d : list) {
        SocialAspect aspect = Aspects.find(getModel(), d);
        if (aspect != null)
            continue;
        addIndicator(d);
    }
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect)

Example 4 with SocialAspect

use of org.openlca.core.model.SocialAspect in project olca-app by GreenDelta.

the class SocialAspectsPage method deleteAspect.

private void deleteAspect() {
    Object o = Viewers.getFirstSelected(tree);
    if (!(o instanceof SocialAspect))
        return;
    SocialAspect a = (SocialAspect) o;
    Aspects.remove(getModel(), a);
    treeModel.remove(a);
    tree.refresh();
    editor.setDirty(true);
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect)

Example 5 with SocialAspect

use of org.openlca.core.model.SocialAspect in project olca-app by GreenDelta.

the class SocialAspectsPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    for (SocialAspect a : getModel().socialAspects) treeModel.addAspect(a);
    form = UI.formHeader(this);
    FormToolkit tk = managedForm.getToolkit();
    Composite body = UI.formBody(form, tk);
    createEntrySection(tk, body);
    form.reflow(true);
}
Also used : SocialAspect(org.openlca.core.model.SocialAspect) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite)

Aggregations

SocialAspect (org.openlca.core.model.SocialAspect)14 Process (org.openlca.core.model.Process)3 SocialIndicator (org.openlca.core.model.SocialIndicator)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)2 Source (org.openlca.core.model.Source)2 JsonElement (com.google.gson.JsonElement)1 Date (java.util.Date)1 Composite (org.eclipse.swt.widgets.Composite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IDatabase (org.openlca.core.database.IDatabase)1 ProcessDao (org.openlca.core.database.ProcessDao)1 Category (org.openlca.core.model.Category)1 DQSystem (org.openlca.core.model.DQSystem)1 Exchange (org.openlca.core.model.Exchange)1 Location (org.openlca.core.model.Location)1 Parameter (org.openlca.core.model.Parameter)1