use of org.openlca.core.database.EntityCache in project olca-modules by GreenDelta.
the class Utils method contribution.
RpcResponse contribution(RpcRequest req, ContributionHandler handler) {
if (req == null || req.params == null || !req.params.isJsonObject())
return Responses.invalidParams("No parameter given", req);
JsonObject json = req.params.getAsJsonObject();
ContributionResult result = getResult(json);
EntityCache cache = EntityCache.create(ctx.db);
return Responses.ok(handler.handle(result, cache), req);
}
use of org.openlca.core.database.EntityCache in project olca-modules by GreenDelta.
the class Utils method full.
RpcResponse full(RpcRequest req, Full handler) {
if (req == null || req.params == null || !req.params.isJsonObject())
return Responses.invalidParams("No parameter given", req);
JsonObject json = req.params.getAsJsonObject();
FullResult result = getResult(json);
EntityCache cache = EntityCache.create(ctx.db);
return Responses.ok(handler.handle(result, cache), req);
}
use of org.openlca.core.database.EntityCache in project olca-app by GreenDelta.
the class ModelEditor method doAfterUpdate.
protected void doAfterUpdate() {
setDirty(false);
var descriptor = getEditorInput().getDescriptor();
EntityCache cache = Cache.getEntityCache();
cache.refresh(descriptor.getClass(), descriptor.id);
cache.invalidate(modelClass, model.id);
this.setPartName(Labels.name(model));
Cache.evict(descriptor);
emitEvent(ON_SAVED);
Navigator.refresh(Navigator.findElement(descriptor));
}
use of org.openlca.core.database.EntityCache in project olca-app by GreenDelta.
the class ProviderDialog method getLabel.
private <T extends Descriptor> String getLabel(Class<T> clazz, long id) {
EntityCache cache = Cache.getEntityCache();
if (cache == null)
return "?";
T d = cache.get(clazz, id);
if (d == null)
return "?";
return Labels.name(d);
}
use of org.openlca.core.database.EntityCache 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;
}
Aggregations