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));
}
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);
}
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);
}
Aggregations