Search in sources :

Example 6 with Source

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

the class DocImportMapper method mapPublicationSource.

private void mapPublicationSource(AdminInfo adminInfo) {
    DataGenerator gen = adminInfo.dataGenerator;
    if (gen == null || gen.publishedSourceId == null)
        return;
    SourceDao dao = new SourceDao(database);
    Source source = dao.getForRefId(gen.publishedSourceId);
    if (source == null) {
        source = new Source();
        source.refId = gen.publishedSourceId;
        StringBuilder title = new StringBuilder();
        StringBuilder shortTitle = new StringBuilder();
        if (gen.publishedSourceFirstAuthor != null) {
            title.append(gen.publishedSourceFirstAuthor);
            shortTitle.append(gen.publishedSourceFirstAuthor);
        }
        if (gen.publishedSourceYear != null) {
            title.append(gen.publishedSourceYear);
            shortTitle.append(gen.publishedSourceYear);
        }
        source.textReference = title.toString();
        source.name = shortTitle.toString();
        source = dao.insert(source);
    }
    doc.publication = source;
}
Also used : SourceDao(org.openlca.core.database.SourceDao) DataGenerator(spold2.DataGenerator) Source(org.openlca.core.model.Source)

Example 7 with Source

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

the class SourceImport method createNew.

private Source createNew() {
    source = new Source();
    String[] path = Categories.getPath(ilcdSource.getValue());
    source.category = new CategoryDao(config.db()).sync(ModelType.SOURCE, path);
    setDescriptionAttributes();
    importExternalFile();
    return config.insert(source);
}
Also used : CategoryDao(org.openlca.core.database.CategoryDao) Source(org.openlca.core.model.Source)

Example 8 with Source

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

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

the class SourceTest method doImport.

private void doImport(SourceDao dao, Source source) {
    with(zip -> {
        JsonImport jImport = new JsonImport(zip, Tests.getDb());
        jImport.run();
    });
    Assert.assertTrue(dao.contains(source.refId));
    Source clone = dao.getForRefId(source.refId);
    Assert.assertEquals(source.name, clone.name);
}
Also used : JsonImport(org.openlca.jsonld.input.JsonImport) Source(org.openlca.core.model.Source)

Example 10 with Source

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

the class ProcessDocReader method addSources.

private void addSources(ProcessDocumentation doc) {
    JsonElement sources = json.get("sources");
    if (sources == null || !sources.isJsonArray())
        return;
    for (JsonElement e : sources.getAsJsonArray()) {
        if (!e.isJsonObject())
            return;
        String refId = Json.getString(e.getAsJsonObject(), "@id");
        Source source = SourceImport.run(refId, conf);
        if (source != null)
            doc.sources.add(source);
    }
}
Also used : JsonElement(com.google.gson.JsonElement) 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