Search in sources :

Example 1 with Source

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

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

the class DataSetRef method setUriAndType.

private static void setUriAndType(RootEntity iModel, Ref ref) {
    String uri = "../";
    if (iModel instanceof Actor) {
        ref.type = DataSetType.CONTACT;
        uri += "contacts/";
    } else if (iModel instanceof Source) {
        ref.type = DataSetType.SOURCE;
        uri += "sources/";
    } else if (iModel instanceof UnitGroup) {
        ref.type = DataSetType.UNIT_GROUP;
        uri += "unitgroups/";
    } else if (iModel instanceof FlowProperty) {
        ref.type = DataSetType.FLOW_PROPERTY;
        uri += "flowproperties/";
    } else if (iModel instanceof Flow) {
        ref.type = DataSetType.FLOW;
        uri += "flows/";
    } else if (iModel instanceof Process) {
        ref.type = DataSetType.PROCESS;
        uri += "processes/";
    }
    uri += iModel.refId;
    ref.uri = uri + ".xml";
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) Actor(org.openlca.core.model.Actor) Process(org.openlca.core.model.Process) LangString(org.openlca.ilcd.commons.LangString) FlowProperty(org.openlca.core.model.FlowProperty) Source(org.openlca.core.model.Source) Flow(org.openlca.core.model.Flow)

Example 3 with Source

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

the class ModelingSheet method readSources.

private void readSources() {
    int row = 17;
    while (true) {
        String name = config.getString(sheet, row, 0);
        if (Strings.isNullOrEmpty(name)) {
            break;
        }
        String category = config.getString(sheet, row, 1);
        Source source = config.refData.getSource(name, category);
        if (source != null) {
            doc.sources.add(source);
        }
        row++;
    }
}
Also used : Source(org.openlca.core.model.Source)

Example 4 with Source

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

the class SourceSheet method readSource.

private void readSource(String uuid, int row) {
    String name = config.getString(sheet, row, 1);
    String category = config.getString(sheet, row, 3);
    Source source = dao.getForRefId(uuid);
    if (source != null) {
        config.refData.putSource(name, category, source);
        return;
    }
    source = new Source();
    source.refId = uuid;
    source.name = name;
    source.description = config.getString(sheet, row, 2);
    source.category = config.getCategory(category, ModelType.SOURCE);
    setAttributes(row, source);
    source = dao.insert(source);
    config.refData.putSource(name, category, source);
}
Also used : Source(org.openlca.core.model.Source)

Example 5 with Source

use of org.openlca.core.model.Source 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);
    }
}
Also used : UnitGroup(org.openlca.core.model.UnitGroup) ProductSystem(org.openlca.core.model.ProductSystem) Process(org.openlca.core.model.Process) FlowExport(org.openlca.io.ilcd.output.FlowExport) UnitGroupExport(org.openlca.io.ilcd.output.UnitGroupExport) SourceExport(org.openlca.io.ilcd.output.SourceExport) ImpactMethod(org.openlca.core.model.ImpactMethod) Source(org.openlca.core.model.Source) Flow(org.openlca.core.model.Flow) FlowPropertyExport(org.openlca.io.ilcd.output.FlowPropertyExport) Actor(org.openlca.core.model.Actor) ActorExport(org.openlca.io.ilcd.output.ActorExport) ImpactMethodExport(org.openlca.io.ilcd.output.ImpactMethodExport) ProcessExport(org.openlca.io.ilcd.output.ProcessExport) FlowProperty(org.openlca.core.model.FlowProperty) SystemExport(org.openlca.io.ilcd.output.SystemExport)

Aggregations

Source (org.openlca.core.model.Source)31 Process (org.openlca.core.model.Process)5 ProcessDocumentation (org.openlca.core.model.ProcessDocumentation)5 SourceDao (org.openlca.core.database.SourceDao)4 Actor (org.openlca.core.model.Actor)4 ISource (org.openlca.ecospold.ISource)4 DQSystem (org.openlca.core.model.DQSystem)3 Flow (org.openlca.core.model.Flow)3 FlowProperty (org.openlca.core.model.FlowProperty)3 UnitGroup (org.openlca.core.model.UnitGroup)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Category (org.openlca.core.model.Category)2 ImpactMethod (org.openlca.core.model.ImpactMethod)2 Location (org.openlca.core.model.Location)2 Parameter (org.openlca.core.model.Parameter)2 ProductSystem (org.openlca.core.model.ProductSystem)2 SocialAspect (org.openlca.core.model.SocialAspect)2