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;
}
}
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);
}
}
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());
}
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);
}
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);
}
Aggregations