X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph.loader%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Floader%2FScenegraphLoaderUtils.java;h=da1e7d8eb1385422eabf7ed98181fd440b5c06a2;hb=4b2ffb1be3b95a8d7b87fc9267e2b3921643a9b3;hp=e40773002ebfb68fb5bab610b5896c1e0f699001;hpb=7a7ad0a2319ce70a184e099adad8a69c23562bd9;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java index e40773002..da1e7d8eb 100644 --- a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java +++ b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/ScenegraphLoaderUtils.java @@ -22,7 +22,7 @@ import org.simantics.db.common.request.ResourceRead; import org.simantics.db.common.request.UnaryRead; import org.simantics.db.exception.AssumptionException; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.exception.VariableException; +import org.simantics.db.layer0.exception.InvalidVariableException; import org.simantics.db.layer0.request.VariableName; import org.simantics.db.layer0.request.VariableURI; import org.simantics.db.layer0.variable.Variable; @@ -42,9 +42,12 @@ import org.simantics.utils.DataContainer; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.threads.IThreadWorkQueue; import org.simantics.utils.threads.ThreadUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ScenegraphLoaderUtils { - + + private static final Logger LOGGER = LoggerFactory.getLogger(ScenegraphLoaderUtils.class); static Map, Collection>> externalMap = new HashMap, Collection>>(); static Map, Object> externalValueMap = new HashMap, Object>(); @@ -291,11 +294,13 @@ public class ScenegraphLoaderUtils { } public static Resource getRuntime(ReadGraph graph, Variable context) throws DatabaseException { - SceneGraphContext vc = getContext(graph, context); - if(vc != null) return vc.getRuntime(); - Variable parent = context.getParent(graph); - if(parent == null) throw new DatabaseException("Runtime resource was not found from context Variable."); - return getRuntime(graph, parent); + SceneGraphContext vc = getContext(graph, context); + if (vc != null) + return vc.getRuntime(); + Variable parent = context.getParent(graph); + if (parent == null) + throw new InvalidVariableException("Runtime resource was not found from context Variable. " + context.getURI(graph)); + return getRuntime(graph, parent); } public static SceneGraphContext getContext(ReadGraph graph, Variable context) throws DatabaseException { @@ -379,29 +384,25 @@ public class ScenegraphLoaderUtils { } - public static Variable getVariableSelection(ReadGraph graph, Variable context) throws DatabaseException { - - Variable runtimeVariable = getRuntimeVariable(graph, context); - if (runtimeVariable == null) - throw new VariableException("no runtime variable for context " + context.getURI(graph)); - return runtimeVariable.getPropertyValue(graph, "variable"); - - } - - public static Variable getPossibleVariableSelection(ReadGraph graph, Variable context) throws DatabaseException { - Variable runtimeVariable = getRuntimeVariable(graph, context); - return runtimeVariable == null ? null : (Variable) runtimeVariable.getPossiblePropertyValue(graph, "variable"); - } - - public static Resource getResourceSelection(ReadGraph graph, Variable context) throws DatabaseException { + public static Variable getVariableSelection(ReadGraph graph, Variable context) throws DatabaseException { + Variable runtimeVariable = getRuntimeVariable(graph, context); + if (runtimeVariable == null) + throw new InvalidVariableException("no runtime variable for context " + context.getURI(graph)); + return runtimeVariable.getPropertyValue(graph, "variable"); + } - Variable runtimeVariable = getRuntimeVariable(graph, context); - if (runtimeVariable == null) - throw new VariableException("no runtime variable for context " + context.getURI(graph)); - Resource sel = runtimeVariable.getPropertyValue(graph, "resource"); - return sel; + public static Variable getPossibleVariableSelection(ReadGraph graph, Variable context) throws DatabaseException { + Variable runtimeVariable = getRuntimeVariable(graph, context); + return runtimeVariable == null ? null : (Variable) runtimeVariable.getPossiblePropertyValue(graph, "variable"); + } - } + public static Resource getResourceSelection(ReadGraph graph, Variable context) throws DatabaseException { + Variable runtimeVariable = getRuntimeVariable(graph, context); + if (runtimeVariable == null) + throw new InvalidVariableException("no runtime variable for context " + context.getURI(graph)); + Resource sel = runtimeVariable.getPropertyValue(graph, "resource"); + return sel; + } public static Resource getPossibleResourceSelection(ReadGraph graph, Variable context) throws DatabaseException { @@ -506,10 +507,9 @@ public class ScenegraphLoaderUtils { try { return node.getClass().getField(propertyName); } catch (SecurityException e) { - e.printStackTrace(); + LOGGER.error("node: " + node, e); } catch (NoSuchFieldException e) { - System.err.println("node:" + node); - e.printStackTrace(); + LOGGER.error("node: " + node, e); } return null; }