X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics%2Fsrc%2Forg%2Fsimantics%2FSimantics.java;h=35808bd929fa74d63f18f860bdc51680abeababf;hp=c19efde85913a10c0ed6befba804d01f90b1fab7;hb=e460fd6f0af60314e2ca28391ef7ff2043016d97;hpb=346cd36c02aad1e33652a67e03b1508cc58e723f diff --git a/bundles/org.simantics/src/org/simantics/Simantics.java b/bundles/org.simantics/src/org/simantics/Simantics.java index c19efde85..35808bd92 100644 --- a/bundles/org.simantics/src/org/simantics/Simantics.java +++ b/bundles/org.simantics/src/org/simantics/Simantics.java @@ -25,7 +25,6 @@ import org.simantics.application.arguments.IArguments; import org.simantics.application.arguments.SimanticsArguments; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; -import org.simantics.db.RequestProcessorSpecific; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.WriteGraph; @@ -45,6 +44,7 @@ import org.simantics.db.management.SessionContextProvider; import org.simantics.db.management.SingleSessionContextProviderSource; import org.simantics.db.request.ReadInterface; import org.simantics.db.request.WriteInterface; +import org.simantics.db.service.XSupport; import org.simantics.internal.FileServiceImpl; import org.simantics.layer0.Layer0; import org.simantics.project.IProject; @@ -468,6 +468,14 @@ public class Simantics { } } + public static void saveQueries(Session session) { + try { + XSupport xs = session.getService(XSupport.class); + xs.saveQueries(); + } catch (Exception e) { + LOGGER.error("Saving database queries failed.", e); + } + } @SuppressWarnings({ "unchecked", "rawtypes" }) public static T applySCL(String module, String function, Object ... args) throws DatabaseException { @@ -477,11 +485,12 @@ public class Simantics { } catch (ValueNotFound e) { throw new DatabaseException("SCL Value not found: " + e.name); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } } - @SuppressWarnings({ "unchecked", "rawtypes" }) public static T applySCL(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException { SCLContext sclContext = SCLContext.getCurrent(); Object oldGraph = sclContext.put("graph", graph); @@ -503,6 +512,8 @@ public class Simantics { try { return (T)f.applyArray(args); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } finally { sclContext.put("graph", oldGraph); @@ -516,6 +527,8 @@ public class Simantics { try { return (T)f.applyArray(args); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } finally { sclContext.put("graph", oldGraph); @@ -528,6 +541,8 @@ public class Simantics { try { return function.apply(p0); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } finally { sclContext.put("graph", oldGraph); @@ -540,6 +555,8 @@ public class Simantics { try { return function.apply(p0); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } finally { sclContext.put("graph", oldGraph); @@ -552,6 +569,8 @@ public class Simantics { try { return function.apply(p0, p1); } catch (Throwable t) { + if (t instanceof DatabaseException) + throw (DatabaseException) t; throw new DatabaseException(t); } finally { sclContext.put("graph", oldGraph);