- DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
- Resource symbolFunctionResource = graph.getPossibleObject(entry, DN.HasSymbolFunction);
- if (symbolFunctionResource == null)
- return null;
-
- Function symbolFunction = (Function) graph.getPossibleValue2(symbolFunctionResource, null);
- if (symbolFunction == null)
- return null;
-
- return (String) symbolFunction.apply(graph, entry);
+ // Prevent PendingVariableExceptions from coming through
+ boolean wasSynchronous = graph.setSynchronous(true);
+ try {
+ Function symbolFunction = getSymbolFunction(graph, entry);
+ if (symbolFunction == null)
+ return null;
+
+ try {
+ return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
+ } catch (Exception e) {
+ LOGGER.error("Getting dynamic symbol for " + groupItem + " (" + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
+ return null;
+ }
+ }
+ finally {
+ graph.setSynchronous(wasSynchronous);
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ protected static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
+ // Cache function read for profile entry
+ return graph.syncRequest(new SymbolFunctionRequest(entry), TransientCacheListener.<Function>instance());