Search in sources :

Example 1 with ProjectDao

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

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

the class ProjectImport method of.

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

Example 3 with ProjectDao

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

the class Update8Test method testProjectVariants.

@Test
public void testProjectVariants() {
    ProjectDao dao = new ProjectDao(db);
    Project project = new Project();
    ProjectVariant var = new ProjectVariant();
    var.isDisabled = true;
    project.variants.add(var);
    dao.insert(project);
    project = dao.getForId(project.id);
    assertTrue(project.variants.get(0).isDisabled);
    project.variants.get(0).isDisabled = false;
    dao.update(project);
    project = dao.getForId(project.id);
    assertFalse(project.variants.get(0).isDisabled);
    dao.delete(project);
}
Also used : Project(org.openlca.core.model.Project) ProjectVariant(org.openlca.core.model.ProjectVariant) ProjectDao(org.openlca.core.database.ProjectDao) Test(org.junit.Test)

Aggregations

ProjectDao (org.openlca.core.database.ProjectDao)3 Project (org.openlca.core.model.Project)2 Test (org.junit.Test)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 SocialIndicatorDao (org.openlca.core.database.SocialIndicatorDao)1 SourceDao (org.openlca.core.database.SourceDao)1 UnitDao (org.openlca.core.database.UnitDao)1 UnitGroupDao (org.openlca.core.database.UnitGroupDao)1 ProjectVariant (org.openlca.core.model.ProjectVariant)1