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