use of org.openlca.core.model.Location in project olca-modules by GreenDelta.
the class EcoSpold01Import method locations.
private void locations(DataSet ds) {
Set<String> codes = new HashSet<>();
IGeography geo = ds.getGeography();
if (geo != null && geo.getLocation() != null) {
codes.add(geo.getLocation());
}
for (IExchange e : ds.getExchanges()) {
if (e.getLocation() != null) {
codes.add(e.getLocation());
}
}
for (String code : codes) {
String id = KeyGen.get(code);
Location loc = db.findLocation(code, id);
if (loc != null) {
log.skipped(loc);
continue;
}
loc = new Location();
loc.refId = id;
loc.name = code;
loc.code = code;
db.put(loc, id);
log.imported(loc);
}
}
use of org.openlca.core.model.Location in project olca-modules by GreenDelta.
the class FlowInfo method getAll.
public static List<FlowInfo> getAll(SystemExportConfig conf, EnviIndex index) {
EntityCache cache = conf.getEntityCache();
Set<FlowDescriptor> flows = getFlowDescriptors(index);
List<FlowInfo> infos = new ArrayList<>();
for (FlowDescriptor flow : flows) {
CategoryPair catPair = CategoryPair.create(flow, cache);
FlowInfo info = new FlowInfo();
info.realId = flow.id;
info.id = flow.refId;
info.name = flow.name;
info.category = catPair.getCategory();
info.subCategory = catPair.getSubCategory();
if (flow.location != null) {
Location location = cache.get(Location.class, flow.location);
if (location != null)
info.location = location.code;
}
String unit = DisplayValues.referenceUnit(flow, cache);
info.unit = unit;
infos.add(info);
}
return infos;
}
use of org.openlca.core.model.Location in project olca-modules by GreenDelta.
the class ProductInfo method getAll.
public static List<ProductInfo> getAll(SystemExportConfig conf, TechIndex index) {
EntityCache cache = conf.getEntityCache();
List<ProductInfo> infos = new ArrayList<>(index.size() + 2);
for (int i = 0; i < index.size(); i++) {
TechFlow pair = index.at(i);
RootDescriptor process = pair.provider();
FlowDescriptor product = pair.flow();
ProductInfo info = new ProductInfo();
info.provider = pair;
info.ref = pair.equals(index.getRefFlow());
info.process = process.name;
info.processId = process.refId;
info.product = product.name;
info.productId = product.refId;
if (process.category != null) {
Category cat = cache.get(Category.class, process.category);
CategoryPair catPair = new CategoryPair(cat);
info.processCategory = catPair.getCategory();
info.processSubCategory = catPair.getSubCategory();
}
if (process instanceof ProcessDescriptor) {
ProcessDescriptor p = (ProcessDescriptor) process;
if (p.location != null) {
Location loc = cache.get(Location.class, p.location);
if (loc != null)
info.processLocation = loc.code;
}
}
infos.add(info);
}
return infos;
}
use of org.openlca.core.model.Location in project olca-modules by GreenDelta.
the class FlowReferenceSearchTest method createModel.
@Override
protected Flow createModel() {
Flow flow = new Flow();
flow.category = insertAndAddExpected("category", new Category());
flow.location = insertAndAddExpected("location", new Location());
flow.flowPropertyFactors.add(createFlowPropertyFactor());
flow.flowPropertyFactors.add(createFlowPropertyFactor());
flow = db.insert(flow);
for (FlowPropertyFactor f : flow.flowPropertyFactors) addExpected("flowProperty", f.flowProperty, "flowPropertyFactors", FlowPropertyFactor.class, f.id);
return flow;
}
use of org.openlca.core.model.Location in project olca-modules by GreenDelta.
the class LocationDescriptorTest method test.
@Test
public void test() {
Location loc = new Location();
loc.name = "LOC";
loc.refId = "LOC";
loc.code = "LOC";
LocationDao dao = new LocationDao(Tests.getDb());
loc = dao.insert(loc);
LocationDescriptor d = dao.descriptorMap().get(loc.id);
dao.delete(loc);
Assert.assertEquals(loc.name, d.name);
Assert.assertEquals(loc.refId, d.refId);
Assert.assertEquals(loc.code, d.code);
}
Aggregations