Search in sources :

Example 1 with CurrencyDao

use of org.openlca.core.database.CurrencyDao 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 CurrencyDao

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

the class CurrencyTest method testCurrency.

@Test
public void testCurrency() {
    CurrencyDao dao = new CurrencyDao(Tests.getDb());
    Currency currency = createModel(dao);
    doExport(currency, dao);
    doImport(dao, currency);
    dao.delete(currency);
}
Also used : CurrencyDao(org.openlca.core.database.CurrencyDao) Currency(org.openlca.core.model.Currency) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 3 with CurrencyDao

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

the class CostHandler method getReferenceCurrencyCode.

private String getReferenceCurrencyCode() {
    CurrencyDao dao = new CurrencyDao(db);
    Currency c = dao.getReferenceCurrency();
    if (c != null && c.code != null)
        return c.code;
    return "?";
}
Also used : CurrencyDao(org.openlca.core.database.CurrencyDao) Currency(org.openlca.core.model.Currency)

Example 4 with CurrencyDao

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

the class CurrencyTable method getOthers.

private List<Currency> getOthers() {
    CurrencyDao dao = new CurrencyDao(Database.get());
    List<Currency> others = new ArrayList<>();
    for (Currency c : dao.getAll()) {
        if (Objects.equals(c, currency))
            continue;
        if (!Objects.equals(c.referenceCurrency, currency.referenceCurrency))
            continue;
        others.add(c);
    }
    Collections.sort(others, (c1, c2) -> {
        return Strings.compare(c1.name, c2.name);
    });
    return others;
}
Also used : CurrencyDao(org.openlca.core.database.CurrencyDao) Currency(org.openlca.core.model.Currency) ArrayList(java.util.ArrayList)

Example 5 with CurrencyDao

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

the class ReportFiller method appendCostResults.

private void appendCostResults(Report report) {
    var currency = new CurrencyDao(db).getReferenceCurrency();
    for (var v : result.getVariants()) {
        double costs = result.getResult(v).totalCosts();
        report.netCosts.add(ReportCostResult.of(v, currency, costs));
        double addedValue = costs == 0 ? 0 : -costs;
        report.addedValues.add(ReportCostResult.of(v, currency, addedValue));
    }
    Comparator<ReportCostResult> c = (r1, r2) -> Strings.compare(r1.variant, r2.variant);
    report.netCosts.sort(c);
    report.addedValues.sort(c);
}
Also used : ResultItemView(org.openlca.core.results.ResultItemView) ProjectResult(org.openlca.core.results.ProjectResult) Strings(org.openlca.util.Strings) IDatabase(org.openlca.core.database.IDatabase) ProjectResultData(org.openlca.app.editors.projects.ProjectResultData) Project(org.openlca.core.model.Project) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) Comparator(java.util.Comparator) Collectors(java.util.stream.Collectors) CurrencyDao(org.openlca.core.database.CurrencyDao) ArrayList(java.util.ArrayList) CurrencyDao(org.openlca.core.database.CurrencyDao)

Aggregations

CurrencyDao (org.openlca.core.database.CurrencyDao)12 Currency (org.openlca.core.model.Currency)9 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Comparator (java.util.Comparator)1 Collectors (java.util.stream.Collectors)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 ProjectResultData (org.openlca.app.editors.projects.ProjectResultData)1 ActorDao (org.openlca.core.database.ActorDao)1 CategoryDao (org.openlca.core.database.CategoryDao)1 DQSystemDao (org.openlca.core.database.DQSystemDao)1 FlowDao (org.openlca.core.database.FlowDao)1 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)1 IDatabase (org.openlca.core.database.IDatabase)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