Search in sources :

Example 11 with Location

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

the class LocationTest method createModel.

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

Example 12 with Location

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

the class LocationTest method doImport.

private void doImport(LocationDao dao, Location location) {
    with(zip -> {
        JsonImport jImport = new JsonImport(zip, Tests.getDb());
        jImport.run();
    });
    Assert.assertTrue(dao.contains(location.refId));
    Location clone = dao.getForRefId(location.refId);
    Assert.assertEquals(location.name, clone.name);
}
Also used : JsonImport(org.openlca.jsonld.input.JsonImport) Location(org.openlca.core.model.Location)

Example 13 with Location

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

the class LocationTest method testLocation.

@Test
public void testLocation() {
    LocationDao dao = new LocationDao(Tests.getDb());
    Location location = createModel(dao);
    doExport(location, dao);
    doImport(dao, location);
    dao.delete(location);
}
Also used : LocationDao(org.openlca.core.database.LocationDao) Location(org.openlca.core.model.Location) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 14 with Location

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

Example 15 with Location

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

the class ProcessConverter method mapRefFlow.

private void mapRefFlow(DataSet dataSet, Exchange exchange, IExchange iExchange) {
    iExchange.setOutputGroup(0);
    IReferenceFunction refFun = mapQuantitativeReference(exchange);
    dataSet.setReferenceFunction(refFun);
    refFun.setGeneralComment(process.description);
    refFun.setInfrastructureProcess(process.infrastructureProcess);
    Location location = process.location;
    if (location != null)
        iExchange.setLocation(location.code);
    else if (config.isCreateDefaults())
        iExchange.setLocation("GLO");
}
Also used : IReferenceFunction(org.openlca.ecospold.IReferenceFunction) Location(org.openlca.core.model.Location)

Aggregations

Location (org.openlca.core.model.Location)44 LocationDao (org.openlca.core.database.LocationDao)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)6 Test (org.junit.Test)5 FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)5 FeatureCollection (org.openlca.geo.geojson.FeatureCollection)5 AtomicDouble (com.google.common.util.concurrent.AtomicDouble)4 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)4 EnviFlow (org.openlca.core.matrix.index.EnviFlow)4 Category (org.openlca.core.model.Category)4 Flow (org.openlca.core.model.Flow)4 Process (org.openlca.core.model.Process)4 ImpactDescriptor (org.openlca.core.model.descriptors.ImpactDescriptor)4 List (java.util.List)3 CostResultDescriptor (org.openlca.app.util.CostResultDescriptor)3 Feature (org.openlca.geo.geojson.Feature)3 Pair (org.openlca.util.Pair)3 TLongByteHashMap (gnu.trove.map.hash.TLongByteHashMap)2