Search in sources :

Example 1 with IDatabase

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

the class ParameterTableTest method tearDown.

@After
public void tearDown() {
    IDatabase db = Tests.getDb();
    new ParameterDao(db).deleteAll();
    new ProcessDao(db).deleteAll();
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) After(org.junit.After)

Example 2 with IDatabase

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

the class SystemsInSystemsTests method testCalc.

@Test
public void testCalc() {
    IDatabase db = Tests.getDb();
    UnitGroupDao ugDao = new UnitGroupDao(db);
    FlowPropertyDao fpDao = new FlowPropertyDao(db);
    FlowDao flowDao = new FlowDao(db);
    ProcessDao processDao = new ProcessDao(db);
    ProductSystemDao systemDao = new ProductSystemDao(db);
    UnitGroup ug6939 = new UnitGroup();
    ug6939.refId = UUID.randomUUID().toString();
    ug6939.name = "Units of mass";
    Unit kg = new Unit();
    kg.name = "kg";
    kg.conversionFactor = 1.0;
    kg.refId = UUID.randomUUID().toString();
}
Also used : IDatabase(org.openlca.core.database.IDatabase) UnitGroup(org.openlca.core.model.UnitGroup) FlowDao(org.openlca.core.database.FlowDao) FlowPropertyDao(org.openlca.core.database.FlowPropertyDao) ProcessDao(org.openlca.core.database.ProcessDao) Unit(org.openlca.core.model.Unit) UnitGroupDao(org.openlca.core.database.UnitGroupDao) ProductSystemDao(org.openlca.core.database.ProductSystemDao) Test(org.junit.Test)

Example 3 with IDatabase

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

the class ParameterTableTest method setUp.

@Before
public void setUp() {
    IDatabase db = Tests.getDb();
    Parameter globalInp = inpParameter(42);
    globalInp.scope = ParameterScope.GLOBAL;
    Parameter globalDep = depParameter(2);
    globalDep.scope = ParameterScope.GLOBAL;
    ParameterDao paramDao = new ParameterDao(db);
    paramDao.insert(globalInp);
    paramDao.insert(globalDep);
    process = new Process();
    Parameter ppInp = inpParameter(84);
    ppInp.scope = ParameterScope.PROCESS;
    Parameter ppDep = depParameter(3);
    ppDep.scope = ParameterScope.PROCESS;
    process.parameters.add(ppInp);
    process.parameters.add(ppDep);
    new ProcessDao(db).insert(process);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process) Before(org.junit.Before)

Example 4 with IDatabase

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

the class ProcessTest method testCyclicProvider.

@Test
public void testCyclicProvider() {
    IDatabase db = Tests.getDb();
    ProcessDao dao = new ProcessDao(db);
    Process[] processes = createCyclicModel(db);
    doExport(processes[0]);
    dao.delete(processes[0]);
    dao.delete(processes[1]);
    doImport();
    assertTestCyclicProvider(processes, dao);
    delete(processes[0], Tests.getDb());
    delete(processes[1], Tests.getDb());
}
Also used : IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) Process(org.openlca.core.model.Process) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 5 with IDatabase

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

the class ProcessesTest method testFindForLabel.

@Test
public void testFindForLabel() {
    IDatabase db = Tests.getDb();
    Supplier<ProcessDescriptor> query = () -> Processes.findForLabel(db, "cow milking - CH");
    assertNull(query.get());
    ProcessDao dao = new ProcessDao(db);
    Process p1 = new Process();
    p1.name = "cow milking";
    dao.insert(p1);
    assertEquals(p1.id, query.get().id);
    Location loc = new Location();
    loc.code = "CH";
    Daos.base(db, Location.class).insert(loc);
    Process p2 = new Process();
    p2.name = "cow milking";
    p2.location = loc;
    dao.insert(p2);
    assertEquals(p2.id, query.get().id);
    Daos.base(db, Location.class).delete(loc);
    for (Process p : dao.getForName("cow milking")) {
        dao.delete(p);
    }
    assertNull(query.get());
}
Also used : IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) Process(org.openlca.core.model.Process) Location(org.openlca.core.model.Location) Test(org.junit.Test)

Aggregations

IDatabase (org.openlca.core.database.IDatabase)25 ProcessDao (org.openlca.core.database.ProcessDao)12 File (java.io.File)9 Process (org.openlca.core.model.Process)9 Test (org.junit.Test)8 Category (org.openlca.core.model.Category)4 Logger (org.slf4j.Logger)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 FlowDao (org.openlca.core.database.FlowDao)3 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CategoryDao (org.openlca.core.database.CategoryDao)2 Derby (org.openlca.core.database.Derby)2 NativeSql (org.openlca.core.database.NativeSql)2 ParameterDao (org.openlca.core.database.ParameterDao)2 ProductSystemDao (org.openlca.core.database.ProductSystemDao)2 ProductSystemBuilder (org.openlca.core.matrix.ProductSystemBuilder)2