Search in sources :

Example 1 with DQSystem

use of org.openlca.core.model.DQSystem 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 DQSystem

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

the class DQResultTest method createDQSystem.

private void createDQSystem() {
    dqSystem = new DQSystem();
    for (int i = 1; i <= 5; i++) {
        DQIndicator indicator = new DQIndicator();
        indicator.position = i;
        dqSystem.indicators.add(indicator);
        for (int j = 1; j <= 5; j++) {
            DQScore score = new DQScore();
            score.position = j;
            indicator.scores.add(score);
        }
    }
    dqSystem = new DQSystemDao(db).insert(dqSystem);
}
Also used : DQScore(org.openlca.core.model.DQScore) DQSystem(org.openlca.core.model.DQSystem) DQIndicator(org.openlca.core.model.DQIndicator) DQSystemDao(org.openlca.core.database.DQSystemDao)

Example 3 with DQSystem

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

the class SourceUseSearchTest method setUp.

@Before
public void setUp() {
    source = db.insert(Source.of("test source"));
    process = new Process();
    process.name = "test process";
    process.documentation = new ProcessDocumentation();
    process = db.insert(process);
    method = db.insert(ImpactMethod.of("test method"));
    dqSystem = db.insert(new DQSystem());
}
Also used : DQSystem(org.openlca.core.model.DQSystem) Process(org.openlca.core.model.Process) ProcessDocumentation(org.openlca.core.model.ProcessDocumentation) Before(org.junit.Before)

Example 4 with DQSystem

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

the class DataUtil method toDataSet.

static ProtoDataSet.Builder toDataSet(IDatabase db, RefEntity e) {
    var ds = ProtoDataSet.newBuilder();
    var conf = WriterConfig.of(db);
    if (e instanceof Actor)
        return ds.setActor(new ActorWriter(conf).write((Actor) e));
    if (e instanceof Category)
        return ds.setCategory(new CategoryWriter(conf).write((Category) e));
    if (e instanceof Currency)
        return ds.setCurrency(new CurrencyWriter(conf).write((Currency) e));
    if (e instanceof DQSystem)
        return ds.setDqSystem(new DQSystemWriter(conf).write((DQSystem) e));
    if (e instanceof Flow)
        return ds.setFlow(new FlowWriter(conf).write((Flow) e));
    if (e instanceof FlowProperty)
        return ds.setFlowProperty(new FlowPropertyWriter(conf).write((FlowProperty) e));
    if (e instanceof ImpactCategory)
        return ds.setImpactCategory(new ImpactCategoryWriter(conf).write((ImpactCategory) e));
    if (e instanceof ImpactMethod)
        return ds.setImpactMethod(new ImpactMethodWriter(conf).write((ImpactMethod) e));
    if (e instanceof Location)
        return ds.setLocation(new LocationWriter(conf).write((Location) e));
    if (e instanceof Parameter)
        return ds.setParameter(new ParameterWriter(conf).write((Parameter) e));
    if (e instanceof Process)
        return ds.setProcess(new ProcessWriter(conf).write((Process) e));
    if (e instanceof ProductSystem)
        return ds.setProductSystem(new ProductSystemWriter(conf).write((ProductSystem) e));
    if (e instanceof Project)
        return ds.setProject(new ProjectWriter(conf).write((Project) e));
    if (e instanceof SocialIndicator)
        return ds.setSocialIndicator(new SocialIndicatorWriter(conf).write((SocialIndicator) e));
    if (e instanceof Source)
        return ds.setSource(new SourceWriter(conf).write((Source) e));
    if (e instanceof UnitGroup)
        return ds.setUnitGroup(new UnitGroupWriter(conf).write((UnitGroup) e));
    return ds;
}
Also used : ImpactCategory(org.openlca.core.model.ImpactCategory) Category(org.openlca.core.model.Category) UnitGroup(org.openlca.core.model.UnitGroup) ImpactCategoryWriter(org.openlca.proto.io.output.ImpactCategoryWriter) ProductSystem(org.openlca.core.model.ProductSystem) Process(org.openlca.core.model.Process) UnitGroupWriter(org.openlca.proto.io.output.UnitGroupWriter) ImpactMethod(org.openlca.core.model.ImpactMethod) ProductSystemWriter(org.openlca.proto.io.output.ProductSystemWriter) Source(org.openlca.core.model.Source) CurrencyWriter(org.openlca.proto.io.output.CurrencyWriter) FlowPropertyWriter(org.openlca.proto.io.output.FlowPropertyWriter) Actor(org.openlca.core.model.Actor) Currency(org.openlca.core.model.Currency) CategoryWriter(org.openlca.proto.io.output.CategoryWriter) ImpactCategoryWriter(org.openlca.proto.io.output.ImpactCategoryWriter) FlowProperty(org.openlca.core.model.FlowProperty) FlowWriter(org.openlca.proto.io.output.FlowWriter) ImpactCategory(org.openlca.core.model.ImpactCategory) SourceWriter(org.openlca.proto.io.output.SourceWriter) Flow(org.openlca.core.model.Flow) LocationWriter(org.openlca.proto.io.output.LocationWriter) Project(org.openlca.core.model.Project) DQSystemWriter(org.openlca.proto.io.output.DQSystemWriter) ParameterWriter(org.openlca.proto.io.output.ParameterWriter) DQSystem(org.openlca.core.model.DQSystem) ActorWriter(org.openlca.proto.io.output.ActorWriter) ImpactMethodWriter(org.openlca.proto.io.output.ImpactMethodWriter) ProjectWriter(org.openlca.proto.io.output.ProjectWriter) Parameter(org.openlca.core.model.Parameter) SocialIndicator(org.openlca.core.model.SocialIndicator) ProcessWriter(org.openlca.proto.io.output.ProcessWriter) Location(org.openlca.core.model.Location) SocialIndicatorWriter(org.openlca.proto.io.output.SocialIndicatorWriter)

Example 5 with DQSystem

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

the class DqSystemImport method of.

@Override
public ImportStatus<DQSystem> of(String id) {
    var dqSystem = imp.get(DQSystem.class, id);
    // check if we are in update mode
    var update = false;
    if (dqSystem != null) {
        update = imp.shouldUpdate(dqSystem);
        if (!update) {
            return ImportStatus.skipped(dqSystem);
        }
    }
    // resolve the proto object
    var proto = imp.reader.getDQSystem(id);
    if (proto == null)
        return dqSystem != null ? ImportStatus.skipped(dqSystem) : ImportStatus.error("Could not resolve DQSystem " + id);
    var wrap = ProtoWrap.of(proto);
    if (update) {
        if (imp.skipUpdate(dqSystem, wrap))
            return ImportStatus.skipped(dqSystem);
    }
    // map the data
    if (dqSystem == null) {
        dqSystem = new DQSystem();
        dqSystem.refId = id;
    }
    wrap.mapTo(dqSystem, imp);
    map(proto, dqSystem);
    // insert or update it
    var dao = new DQSystemDao(imp.db);
    dqSystem = update ? dao.update(dqSystem) : dao.insert(dqSystem);
    imp.putHandled(dqSystem);
    return update ? ImportStatus.updated(dqSystem) : ImportStatus.created(dqSystem);
}
Also used : DQSystem(org.openlca.core.model.DQSystem) ProtoDQSystem(org.openlca.proto.ProtoDQSystem) DQSystemDao(org.openlca.core.database.DQSystemDao)

Aggregations

DQSystem (org.openlca.core.model.DQSystem)14 Process (org.openlca.core.model.Process)4 DQSystemDao (org.openlca.core.database.DQSystemDao)3 Source (org.openlca.core.model.Source)3 DataQualityShell (org.openlca.app.editors.processes.data_quality.DataQualityShell)2 Category (org.openlca.core.model.Category)2 DQIndicator (org.openlca.core.model.DQIndicator)2 DQScore (org.openlca.core.model.DQScore)2 Location (org.openlca.core.model.Location)2 Parameter (org.openlca.core.model.Parameter)2 ProcessDocumentation (org.openlca.core.model.ProcessDocumentation)2 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 BaseLabelProvider (org.eclipse.jface.viewers.BaseLabelProvider)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Color (org.eclipse.swt.graphics.Color)1 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)1