import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.layer0.exception.PendingVariableException;
import org.simantics.district.network.ontology.DistrictNetworkResource;
import org.simantics.layer0.Layer0;
import org.simantics.scenegraph.INode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated
public class VertexSymbolStyle extends ThrottledStyleBase<String> {
private static final Logger LOGGER = LoggerFactory.getLogger(VertexSymbolStyle.class);
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
- Function symbolFunction = getSymbolFunction(graph, entry);
- if (symbolFunction == null)
- return null;
-
- try {
- return (String) Simantics.applySCLRead(graph, symbolFunction, groupItem);
- } catch (PendingVariableException e) {
- throw e;
- } catch (Exception e) {
- LOGGER.error("Getting dynamic symbol for " + groupItem + " (" + graph.getPossibleRelatedValue(groupItem, Layer0.getInstance(graph).HasName) + ") failed", e);
- return null;
- }
- }
+ @Override
+ public String calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
+ return calculateStyle(graph, entry, groupItem);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public static String calculateStyle(ReadGraph graph, Resource entry, Resource groupItem) throws DatabaseException {
+ // 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 {
+ public static Function getSymbolFunction(ReadGraph graph, Resource entry) throws DatabaseException {
// Cache function read for profile entry
return graph.syncRequest(new SymbolFunctionRequest(entry), TransientCacheListener.<Function>instance());
}