Search in sources :

Example 26 with Source

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

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

Example 28 with Source

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

the class SourceTest method createModel.

private Source createModel(SourceDao dao) {
    Source source = new Source();
    source.name = "Source";
    source.refId = UUID.randomUUID().toString();
    dao.insert(source);
    return source;
}
Also used : Source(org.openlca.core.model.Source)

Example 29 with Source

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

the class SourceImport method of.

@Override
public ImportStatus<Source> of(String id) {
    var source = imp.get(Source.class, id);
    // check if we are in update mode
    var update = false;
    if (source != null) {
        update = imp.shouldUpdate(source);
        if (!update) {
            return ImportStatus.skipped(source);
        }
    }
    // resolve the proto object
    var proto = imp.reader.getSource(id);
    if (proto == null)
        return source != null ? ImportStatus.skipped(source) : ImportStatus.error("Could not resolve Source " + id);
    var wrap = ProtoWrap.of(proto);
    if (update) {
        if (imp.skipUpdate(source, wrap))
            return ImportStatus.skipped(source);
    }
    // map the data
    if (source == null) {
        source = new Source();
    }
    wrap.mapTo(source, imp);
    map(proto, source);
    // insert or update it
    var dao = new SourceDao(imp.db);
    source = update ? dao.update(source) : dao.insert(source);
    imp.putHandled(source);
    return update ? ImportStatus.updated(source) : ImportStatus.created(source);
}
Also used : SourceDao(org.openlca.core.database.SourceDao) Source(org.openlca.core.model.Source) ProtoSource(org.openlca.proto.ProtoSource)

Example 30 with Source

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

the class ImageSection method update.

void update() {
    for (Control c : controls) {
        c.dispose();
    }
    controls.clear();
    ProcessDocumentation doc = editor.getModel().documentation;
    if (doc == null)
        return;
    List<File> files = new ArrayList<>();
    for (Source s : doc.sources) {
        if (!isImage(s.externalFile))
            continue;
        File dir = new FileStore(Database.get()).getFolder(s);
        File file = new File(dir, s.externalFile);
        if (!file.exists())
            continue;
        files.add(file);
    }
    if (files.isEmpty())
        return;
    if (comp == null) {
        comp = UI.formSection(body, tk, "Attached images");
    }
    files.forEach(this::createControls);
    comp.pack();
    Composite container = comp;
    while (container != null) {
        container = container.getParent();
        if (container instanceof ScrolledForm) {
            ((ScrolledForm) container).reflow(true);
            break;
        }
    }
}
Also used : FileStore(org.openlca.core.database.FileStore) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) ArrayList(java.util.ArrayList) ProcessDocumentation(org.openlca.core.model.ProcessDocumentation) File(java.io.File) 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