Search in sources :

Example 11 with Source

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

the class DBSearch method findSource.

public Source findSource(ISource source) {
    try {
        log.trace("Search for source {} in database", source.getTitle());
        String jpql = "select s from Source s where s.name = :name";
        Map<String, Object> args = new HashMap<>();
        int year = source.getYear() != null ? source.getYear().getYear() : 0;
        args.put("name", source.getFirstAuthor() + " " + year);
        Source candidate = Query.on(database).getFirst(Source.class, jpql, args);
        if (candidate == null)
            return null;
        if (Objects.equals(candidate.textReference, source.getTitle()))
            return candidate;
        return null;
    } catch (Exception e) {
        log.error("Failed to search for Source", e);
        return null;
    }
}
Also used : HashMap(java.util.HashMap) ISource(org.openlca.ecospold.ISource) Source(org.openlca.core.model.Source)

Example 12 with Source

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

the class EcoSpold01Import method sources.

private void sources(DataSet ds) {
    for (ISource eSource : ds.getSources()) {
        String id = ES1KeyGen.forSource(eSource);
        Source oSource = db.findSource(eSource, id);
        if (oSource != null) {
            log.skipped(oSource);
            continue;
        }
        oSource = new Source();
        oSource.refId = id;
        Mapper.mapSource(eSource, oSource);
        db.put(oSource, id);
        log.imported(oSource);
    }
}
Also used : ISource(org.openlca.ecospold.ISource) ISource(org.openlca.ecospold.ISource) Source(org.openlca.core.model.Source)

Example 13 with Source

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

the class EcoSpold01Import method mapSources.

private void mapSources(ProcessDocumentation doc, DataSet dataSet) {
    Map<Integer, Source> sources = new HashMap<>();
    for (ISource source : dataSet.getSources()) {
        Source s = db.findSource(source, ES1KeyGen.forSource(source));
        if (s != null) {
            sources.put(source.getNumber(), s);
            doc.sources.add(s);
        }
    }
    if (dataSet.getDataGeneratorAndPublication() != null && dataSet.getDataGeneratorAndPublication().getReferenceToPublishedSource() != null)
        doc.publication = sources.get(dataSet.getDataGeneratorAndPublication().getReferenceToPublishedSource());
}
Also used : HashMap(java.util.HashMap) ISource(org.openlca.ecospold.ISource) ISource(org.openlca.ecospold.ISource) Source(org.openlca.core.model.Source)

Example 14 with Source

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

the class SourceImport method map.

@Override
Source map(JsonObject json, long id) {
    if (json == null)
        return null;
    Source s = new Source();
    In.mapAtts(json, s, id, conf);
    mapAtts(json, s);
    return conf.db.put(s);
}
Also used : Source(org.openlca.core.model.Source)

Example 15 with Source

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

the class ProcessConverter method mapModelingAndValidation.

private void mapModelingAndValidation(ProcessDocumentation doc, DataSet dataSet) {
    mapValidation(doc, dataSet);
    for (Source source : doc.sources) actorSourceMapper.map(source, dataSet);
    if (doc.sampling == null)
        return;
    IRepresentativeness repr = dataSet.getRepresentativeness();
    if (repr == null) {
        repr = factory.createRepresentativeness();
        dataSet.setRepresentativeness(repr);
    }
    repr.setSamplingProcedure(doc.sampling);
}
Also used : IRepresentativeness(org.openlca.ecospold.IRepresentativeness) Source(org.openlca.core.model.Source)

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