Search in sources :

Example 1 with SourceDao

use of org.openlca.core.database.SourceDao in project olca-modules by GreenDelta.

the class Sequence method init.

private void init(IDatabase db) {
    index(CATEGORY, new CategoryDao(db));
    index(LOCATION, new LocationDao(db));
    index(ACTOR, new ActorDao(db));
    index(SOURCE, new SourceDao(db));
    index(UNIT, new UnitDao(db));
    index(UNIT_GROUP, new UnitGroupDao(db));
    index(FLOW_PROPERTY, new FlowPropertyDao(db));
    index(FLOW, new FlowDao(db));
    index(CURRENCY, new CurrencyDao(db));
    index(PROCESS, new ProcessDao(db));
    index(PRODUCT_SYSTEM, new ProductSystemDao(db));
    index(IMPACT_CATEGORY, new ImpactCategoryDao(db));
    index(IMPACT_METHOD, new ImpactMethodDao(db));
    index(NW_SET, new NwSetDao(db));
    index(PROJECT, new ProjectDao(db));
    index(DQ_SYSTEM, new DQSystemDao(db));
    index(SOCIAL_INDICATOR, new SocialIndicatorDao(db));
}
Also used : SourceDao(org.openlca.core.database.SourceDao) CurrencyDao(org.openlca.core.database.CurrencyDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) CategoryDao(org.openlca.core.database.CategoryDao) ActorDao(org.openlca.core.database.ActorDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) LocationDao(org.openlca.core.database.LocationDao) UnitDao(org.openlca.core.database.UnitDao) DQSystemDao(org.openlca.core.database.DQSystemDao) NwSetDao(org.openlca.core.database.NwSetDao) FlowDao(org.openlca.core.database.FlowDao) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao) ProcessDao(org.openlca.core.database.ProcessDao) UnitGroupDao(org.openlca.core.database.UnitGroupDao) SocialIndicatorDao(org.openlca.core.database.SocialIndicatorDao) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) ProjectDao(org.openlca.core.database.ProjectDao)

Example 2 with SourceDao

use of org.openlca.core.database.SourceDao 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 3 with SourceDao

use of org.openlca.core.database.SourceDao in project olca-app by GreenDelta.

the class Dialog method sourceRow.

private void sourceRow(Composite body, FormToolkit tk) {
    UI.formLabel(body, tk, M.Source);
    TextDropComponent drop = new TextDropComponent(body, tk, ModelType.SOURCE);
    UI.gridData(drop, true, false);
    if (aspect.source != null) {
        drop.setContent(Descriptor.of(aspect.source));
    }
    drop.onChange(d -> {
        if (d == null) {
            aspect.source = null;
        } else {
            SourceDao dao = new SourceDao(Database.get());
            aspect.source = dao.getForId(d.id);
        }
    });
    UI.filler(body, tk);
}
Also used : SourceDao(org.openlca.core.database.SourceDao) TextDropComponent(org.openlca.app.components.TextDropComponent)

Example 4 with SourceDao

use of org.openlca.core.database.SourceDao in project olca-modules by GreenDelta.

the class SourceSheet method write.

private void write() {
    Excel.trackSize(sheet, 0, 5);
    writeHeader();
    var sources = new SourceDao(config.database).getAll();
    sources.sort(new EntitySorter());
    for (Source source : sources) {
        row++;
        write(source);
    }
    Excel.autoSize(sheet, 0, 5);
}
Also used : SourceDao(org.openlca.core.database.SourceDao) Source(org.openlca.core.model.Source)

Example 5 with SourceDao

use of org.openlca.core.database.SourceDao in project olca-modules by GreenDelta.

the class SourceTest method testSource.

@Test
public void testSource() {
    SourceDao dao = new SourceDao(Tests.getDb());
    Source source = createModel(dao);
    doExport(source, dao);
    doImport(dao, source);
    dao.delete(source);
}
Also used : SourceDao(org.openlca.core.database.SourceDao) Source(org.openlca.core.model.Source) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Aggregations

SourceDao (org.openlca.core.database.SourceDao)6 Source (org.openlca.core.model.Source)4 Test (org.junit.Test)1 TextDropComponent (org.openlca.app.components.TextDropComponent)1 ActorDao (org.openlca.core.database.ActorDao)1 CategoryDao (org.openlca.core.database.CategoryDao)1 CurrencyDao (org.openlca.core.database.CurrencyDao)1 DQSystemDao (org.openlca.core.database.DQSystemDao)1 FlowDao (org.openlca.core.database.FlowDao)1 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)1 LocationDao (org.openlca.core.database.LocationDao)1 NwSetDao (org.openlca.core.database.NwSetDao)1 ProcessDao (org.openlca.core.database.ProcessDao)1 ProductSystemDao (org.openlca.core.database.ProductSystemDao)1 ProjectDao (org.openlca.core.database.ProjectDao)1 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)1 UnitDao (org.openlca.core.database.UnitDao)1 UnitGroupDao (org.openlca.core.database.UnitGroupDao)1