Search in sources :

Example 1 with IntermediateExchange

use of spold2.IntermediateExchange in project olca-modules by GreenDelta.

the class PriceMapper method findPrice.

private Property findPrice(IntermediateExchange ie) {
    for (Property p : ie.properties) {
        String name = p.name;
        String unit = p.unit;
        if (name == null || unit == null)
            continue;
        if ("price".equalsIgnoreCase(name) && unit.startsWith("EUR"))
            return p;
    }
    return null;
}
Also used : Property(spold2.Property)

Example 2 with IntermediateExchange

use of spold2.IntermediateExchange in project olca-modules by GreenDelta.

the class PriceMapper method map.

void map(IntermediateExchange ie, Exchange e) {
    if (currency == null || ie == null || ie.amount == null || e == null)
        return;
    Property price = findPrice(ie);
    if (price == null)
        return;
    double val = ie.amount * price.amount;
    if (val == 0)
        return;
    e.costs = val;
    e.currency = currency;
}
Also used : Property(spold2.Property)

Example 3 with IntermediateExchange

use of spold2.IntermediateExchange in project olca-modules by GreenDelta.

the class ProcessImport method valid.

private boolean valid(DataSet ds) {
    Activity activity = Spold2.getActivity(ds);
    if (activity.id == null || activity.name == null)
        return false;
    IntermediateExchange refFlow = null;
    for (IntermediateExchange techFlow : Spold2.getProducts(ds)) {
        if (techFlow.outputGroup == null)
            continue;
        if (techFlow.outputGroup != 0)
            continue;
        if (techFlow.amount == null || techFlow.amount == 0)
            continue;
        refFlow = techFlow;
        break;
    }
    return refFlow != null;
}
Also used : IntermediateExchange(spold2.IntermediateExchange) Activity(spold2.Activity)

Example 4 with IntermediateExchange

use of spold2.IntermediateExchange in project olca-modules by GreenDelta.

the class ProcessImport method getProcessName.

/**
 * The name of the process has the following pattern:
 * <p>
 * <process name> | <product name> | <system model>, <process type>
 * <p>
 * Where <system model> is a mnemonic like "APOS" or "Cutoff" and the process
 * type is "U" when it is a unit process or "S" when it is a LCI result
 */
private String getProcessName(DataSet ds) {
    // the process and ref. product name
    Activity a = Spold2.getActivity(ds);
    String name = a != null ? a.name : "?";
    IntermediateExchange qRef = Spold2.getReferenceProduct(ds);
    if (qRef != null && qRef.name != null) {
        name += " | " + qRef.name;
    }
    // we try to infer a short name for the system model here
    // because the short name is part of the master data which
    // is not always available (or can be found) when importing
    // a data set
    String model = null;
    Representativeness repri = Spold2.getRepresentativeness(ds);
    if (repri.systemModelName != null) {
        String sys = repri.systemModelName.toLowerCase();
        if (sys.contains("consequential")) {
            model = "Consequential";
        } else if (sys.contains("apos") || sys.contains("allocation at the point of substitution")) {
            model = "APOS";
        } else if (sys.contains("cut-off") || sys.contains("cutoff")) {
            model = "Cutoff";
        } else if (sys.contains("legacy")) {
            model = "Legacy";
        } else {
            model = repri.systemModelName;
        }
    }
    if (model != null) {
        name += " | " + model;
    }
    // the process type
    String type = a != null && a.type == 2 ? "S" : "U";
    name += ", " + type;
    return name;
}
Also used : Representativeness(spold2.Representativeness) IntermediateExchange(spold2.IntermediateExchange) Activity(spold2.Activity)

Example 5 with IntermediateExchange

use of spold2.IntermediateExchange in project olca-modules by GreenDelta.

the class RefDataImport method importDataSet.

public void importDataSet(DataSet ds) {
    if (ds == null)
        return;
    try {
        classification(ds);
        geography(ds);
        for (IntermediateExchange e : Spold2.getProducts(ds)) {
            if (e.amount == 0 && config.skipNullExchanges)
                continue;
            productFlow(ds, e);
        }
        for (ElementaryExchange e : Spold2.getElemFlows(ds)) {
            elementaryFlow(e);
        }
    } catch (Exception e) {
        log.error("failed to import reference data from data set", e);
    }
}
Also used : IntermediateExchange(spold2.IntermediateExchange) ElementaryExchange(spold2.ElementaryExchange)

Aggregations

IntermediateExchange (spold2.IntermediateExchange)9 Activity (spold2.Activity)3 ElementaryExchange (spold2.ElementaryExchange)3 Exchange (org.openlca.core.model.Exchange)2 Flow (org.openlca.core.model.Flow)2 Property (spold2.Property)2 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)1 Classification (spold2.Classification)1 Exchange (spold2.Exchange)1 FlowData (spold2.FlowData)1 Representativeness (spold2.Representativeness)1 UserMasterData (spold2.UserMasterData)1