From c61c54a6d841c663bd43b40577fe469bffa15453 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Mon, 19 Aug 2019 11:26:51 +0300 Subject: [PATCH] DB and Layer0 modifications for related issues gitlab #347 gitlab #348 Change-Id: Ic5d2209d9865fc44583ea4814cc1d26d212a5f87 --- .../META-INF/MANIFEST.MF | 4 +- .../db/common/SimanticsInternal.java | 157 ++++++++++++++++++ .../request/RuntimeEnvironmentRequest.java | 153 +++++++++++++++++ .../db/common/utils/CommonDBUtils.java | 34 +++- .../db/common/validation/L0Validations.java | 49 +++--- .../org.simantics.db.layer0/build.properties | 3 +- .../scl/Simantics/Layer0.scl | 9 + .../db/layer0/internal/SimanticsInternal.java | 134 +-------------- .../simantics/db/layer0/util/Layer0Utils.java | 18 +- .../util/RuntimeEnvironmentRequest.java | 140 +--------------- .../db/layer0/validation/ValidationUtils.java | 9 +- .../META-INF/MANIFEST.MF | 6 +- .../db/management/SessionContext.java | 41 +---- .../internal/SessionManagerProvider.java | 68 -------- .../META-INF/MANIFEST.MF | 8 +- .../services/adaption/AdapterRegistry2.java | 6 +- .../reflection/ReflectionAdapter2.java | 79 ++++----- .../META-INF/MANIFEST.MF | 4 +- .../org.simantics.layer0/graph/Layer0.pgraph | 4 + .../graph/Layer0Constraints.pgraph | 6 +- .../graph/Layer0Templates.pgraph | 7 + .../graph/Layer0Validations.pgraph | 24 ++- .../src/org/simantics/SimanticsPlatform.java | 14 +- 23 files changed, 503 insertions(+), 474 deletions(-) create mode 100644 bundles/org.simantics.db.common/src/org/simantics/db/common/SimanticsInternal.java create mode 100644 bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java create mode 100644 bundles/org.simantics.db.layer0/scl/Simantics/Layer0.scl delete mode 100644 bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java diff --git a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF index c45b276d7..27e433851 100644 --- a/bundles/org.simantics.db.common/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.common/META-INF/MANIFEST.MF @@ -15,7 +15,9 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0";visibility:=reexport, org.simantics.user.ontology;bundle-version="1.0.0", org.simantics.layer0x.ontology;bundle-version="1.0.0", org.simantics.issues.ontology;bundle-version="1.2.0", - org.slf4j.api + org.slf4j.api, + org.simantics.db.management;bundle-version="1.1.0", + org.simantics.scl.osgi Export-Package: org.simantics.db.common, org.simantics.db.common.adaption, org.simantics.db.common.auth, diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/SimanticsInternal.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/SimanticsInternal.java new file mode 100644 index 000000000..e59e36ffa --- /dev/null +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/SimanticsInternal.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.common; + +import java.util.concurrent.TimeUnit; + +import org.simantics.db.Session; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.management.ISessionContext; +import org.simantics.db.management.ISessionContextProvider; +import org.simantics.db.management.ISessionContextProviderSource; +import org.simantics.db.request.ReadInterface; +import org.simantics.db.request.WriteInterface; +import org.simantics.layer0.Layer0; +import org.simantics.operation.Layer0X; +import org.simantics.utils.threads.ThreadUtils; + +/** + * An internal facade for accessing basic Simantics platform services. + * Usable without a graphical UI, i.e. in headless contexts. + * + * Use org.simantics.Simantics instead where ever possible. + */ +public class SimanticsInternal { + + private static ISessionContextProviderSource providerSource = null; + + /** + * Queue execution of a runnable. + * + * @param runnable + */ + public static void async(Runnable runnable) { + ThreadUtils.getBlockingWorkExecutor().execute(runnable); + } + + public static void async(Runnable runnable, int delay, TimeUnit unit) { + ThreadUtils.getTimer().schedule(runnable, delay, unit); + } + + /** + * Queue execution of a non-blocking runnable. Use this method with caution. + * A non-blocking runnable nevers locks anything, No Locks, No semaphores, + * No Object.wait(), No synchronized() {} blocks. + * + * @param runnable a non-blocking runnable + */ + public static void asyncNonblocking(Runnable runnable) { + ThreadUtils.getNonBlockingWorkExecutor().execute(runnable); + } + + /** + * Schedule execution of a non-blocking runnable. Use this method with caution. + * A non-blocking runnable never locks anything, No Locks, No semaphores, + * No Object,wait(), No synchronized() {} blocks. + * + * @param runnable a non-blocking runnable + * @param initialDelay + * @param period + */ + public static void asyncNonblocking(Runnable runnable, int initialDelay, int period) { + ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(runnable, initialDelay, period, TimeUnit.MILLISECONDS); + } + + public static synchronized ISessionContext setSessionContext(ISessionContext ctx) { + return getSessionContextProvider().setSessionContext(ctx); + } + + public static void setSessionContextProviderSource(ISessionContextProviderSource source) { + if (source == null) + throw new IllegalArgumentException("null provider source"); + providerSource = source; + } + + public static ISessionContextProviderSource getProviderSource() { + if (providerSource == null) + throw new IllegalStateException( + "providerSource must be initialized by the application before using class Simantics"); + return providerSource; + } + + public static ISessionContextProvider getSessionContextProvider() { + return getProviderSource().getActive(); + } + + /** + * Returns the database session context associated with the currently active + * context. This method should be used to retrieve session contexts only + * when the client is sure that the correct context is active. + * + * @return the session context associated with the currently active context + * or null if the context has no session context + */ + public static ISessionContext getSessionContext() { + ISessionContextProvider provider = getSessionContextProvider(); + return provider != null ? provider.getSessionContext() : null; + } + + /** + * Returns the database Session bound to the currently active context. + * + *

+ * The method always returns a non-null Session or produces an + * IllegalStateException if a Session was not attainable. + *

+ * + * @return the Session bound to the currently active workbench window + * @throws IllegalStateException if no Session was available + */ + public static Session getSession() { + ISessionContext ctx = getSessionContext(); + if (ctx == null) + throw new IllegalStateException("Session unavailable, no database session open"); + return ctx.getSession(); + } + + /** + * Returns the database Session bound to the currently active context. + * Differently from {@link #getSession()}, this method returns + * null if there is no current Session available. + * + * @see #getSession() + * @return the Session bound to the currently active context or + * null + */ + public static Session peekSession() { + ISessionContext ctx = getSessionContext(); + return ctx == null ? null : ctx.peekSession(); + } + + public static Layer0 getLayer0() throws DatabaseException { + return Layer0.getInstance(getSession()); + } + + public static Layer0X getLayer0X() throws DatabaseException { + return Layer0X.getInstance(getSession()); + } + + + public static T sync(ReadInterface r) throws DatabaseException { + return getSession().sync(r); + } + + public static T sync(WriteInterface r) throws DatabaseException { + return getSession().sync(r); + } + +} diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java new file mode 100644 index 000000000..24a5c10c9 --- /dev/null +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java @@ -0,0 +1,153 @@ +package org.simantics.db.common.request; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.SimanticsInternal; +import org.simantics.db.common.utils.CommonDBUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.procedure.Listener; +import org.simantics.db.request.Read; +import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification; +import org.simantics.scl.compiler.module.repository.ImportFailureException; +import org.simantics.scl.compiler.module.repository.UpdateListener; +import org.simantics.scl.compiler.runtime.RuntimeEnvironment; +import org.simantics.scl.osgi.SCLOsgi; +import org.simantics.scl.runtime.SCLContext; + +/** + * Finds the runtime environment of a model or other index root. + * + * @author Hannu Niemistö + * @author Antti Villberg + */ +public class RuntimeEnvironmentRequest extends UnaryRead { + + public RuntimeEnvironmentRequest(Resource parameter) { + super(parameter); + } + + protected void fillEnvironmentSpecification(EnvironmentSpecification environmentSpecification) { + } + + static class UpdateListenerImpl extends UpdateListener { + + final EnvironmentSpecification environmentSpecification; + final Listener callback; + + UpdateListenerImpl(EnvironmentSpecification environmentSpecification, Listener callback) { + this.environmentSpecification = environmentSpecification; + this.callback = callback; + } + + @Override + public void notifyAboutUpdate() { + if(callback.isDisposed()) { + stopListening(); + return; + } + getRuntimeEnvironment(environmentSpecification, callback, this); + } + }; + + public static void getRuntimeEnvironment(EnvironmentSpecification environmentSpecification, Listener callback, UpdateListenerImpl listener) { + + try { + + SCLContext context = SCLContext.getCurrent(); + + RuntimeEnvironment env; + Object graph = context.get("graph"); + if(graph == null) + try { + env = SimanticsInternal.getSession().syncRequest(new Read() { + @Override + public RuntimeEnvironment perform(ReadGraph graph) throws DatabaseException { + + SCLContext sclContext = SCLContext.getCurrent(); + Object oldGraph = sclContext.get("graph"); + try { + sclContext.put("graph", graph); + return SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment( + environmentSpecification, + callback.getClass().getClassLoader(), listener); + } catch (ImportFailureException e) { + throw new DatabaseException(e); + } catch (Throwable t) { + throw new DatabaseException(t); + } finally { + sclContext.put("graph", oldGraph); + } + } + }); + } catch (DatabaseException e) { + callback.exception(e); + return; + } + else + env = SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment( + environmentSpecification, + callback.getClass().getClassLoader(), listener); + callback.execute(env); + } catch (ImportFailureException e) { + callback.exception(new DatabaseException(e)); + } + + } + + @Override + public RuntimeEnvironment perform(ReadGraph graph) + throws DatabaseException { + final EnvironmentSpecification environmentSpecification = EnvironmentSpecification.of( + "Builtin", "", + "StandardLibrary", "", + "Simantics/All", ""); + fillEnvironmentSpecification(environmentSpecification); + + Resource mainModule = CommonDBUtils.getPossibleChild(graph, parameter, "SCLMain"); + String mainModuleUri; + if(mainModule != null) { + mainModuleUri = graph.getURI(mainModule); + environmentSpecification.importModule(mainModuleUri, ""); + } + else + mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI + + return graph.syncRequest(new ParametrizedPrimitiveRead(mainModuleUri) { + + UpdateListenerImpl sclListener; + + @Override + public void register(ReadGraph graph, Listener procedure) { + + SCLContext context = SCLContext.getCurrent(); + Object oldGraph = context.put("graph", graph); + try { + + if(procedure.isDisposed()) { + getRuntimeEnvironment(environmentSpecification, procedure, null); + } else { + sclListener = new UpdateListenerImpl(environmentSpecification, procedure); + sclListener.notifyAboutUpdate(); + } + + } finally { + context.put("graph", oldGraph); + } + + } + + @Override + public void unregistered() { + if(sclListener != null) + sclListener.stopListening(); + } + + }); + } + + @Override + public int hashCode() { + return 31*getClass().hashCode() + super.hashCode(); + } + +} diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/CommonDBUtils.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/CommonDBUtils.java index a07d42519..dcd3939a4 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/CommonDBUtils.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/CommonDBUtils.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -16,8 +15,10 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.procedure.adapter.DirectStatementProcedure; import org.simantics.db.common.request.IsParent; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.request.PossibleChild; import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.common.request.PossibleOwner; +import org.simantics.db.common.request.RuntimeEnvironmentRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.InvalidResourceReferenceException; import org.simantics.db.service.ClusterUID; @@ -26,6 +27,10 @@ import org.simantics.db.service.DirectQuerySupport; import org.simantics.db.service.SerialisationSupport; import org.simantics.db.service.XSupport; import org.simantics.layer0.Layer0; +import org.simantics.scl.compiler.environment.Environments; +import org.simantics.scl.compiler.runtime.RuntimeEnvironment; +import org.simantics.scl.compiler.top.SCLExpressionCompilationException; +import org.simantics.scl.compiler.types.Type; import org.simantics.utils.datastructures.collections.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -313,5 +318,32 @@ public class CommonDBUtils { return xs.isClusterLoaded(clusterUID); } + public static Type getSCLType(ReadGraph graph, RuntimeEnvironment runtimeEnvironment, String typeText) throws DatabaseException { + try { + return Environments.getType(runtimeEnvironment.getEnvironment(), typeText); + } catch (SCLExpressionCompilationException e) { + throw new DatabaseException(e); + } + } + + public static Type getSCLType(ReadGraph graph, Resource resource, String typeText) throws DatabaseException { + try { + RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest(resource)); + return Environments.getType(runtimeEnvironment.getEnvironment(), typeText); + } catch (SCLExpressionCompilationException e) { + throw new DatabaseException(e); + } + } + + public static Resource getPossibleChild(ReadGraph graph, Resource resource, String name) throws DatabaseException { + return graph.sync(new PossibleChild(resource, name)); + } + + public static Resource getPossibleChild(ReadGraph graph, Resource resource, Resource type, String name) throws DatabaseException { + Resource child = graph.sync(new PossibleChild(resource, name)); + if(child == null) return null; + if(!graph.isInstanceOf(child, type)) return null; + return child; + } } diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java index a1ed10e77..99ef91b7a 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java @@ -3,41 +3,50 @@ package org.simantics.db.common.validation; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.utils.CommonDBUtils; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; +import org.simantics.scl.compiler.types.Type; public class L0Validations { public static String checkValueType(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException { + if (subject == null) return null; if (predicate == null) return null; Layer0 L0 = Layer0.getInstance(graph); - if(graph.isSubrelationOf(predicate, L0.HasProperty)) { + if(graph.isSubrelationOf(predicate, L0.HasProperty)) { Resource object = graph.getPossibleObject(subject, predicate); if(object == null) return null; - String valueType = graph.getPossibleRelatedValue(predicate, L0.RequiresValueType, Bindings.STRING); - if(valueType != null) { - String valueType2 = graph.getPossibleRelatedValue(object, L0.HasValueType, Bindings.STRING); - if(!valueType.equals(valueType2)) { - StringBuilder sb = new StringBuilder() - .append("The value type ") - .append(valueType) - .append(" of predicate ") - .append(NameUtils.getSafeName(graph, predicate, true)) - .append(" does not match the value type ") - .append(valueType2) - .append(" of object ") - .append(NameUtils.getSafeName(graph, object, true)) - .append("."); - return sb.toString(); - } - } - } - return null; + String valueTypeText = graph.getPossibleRelatedValue(predicate, L0.RequiresValueType, Bindings.STRING); + if(valueTypeText != null) { + Type valueType = CommonDBUtils.getSCLType(graph, subject, valueTypeText); + String valueTypeText2 = graph.getPossibleRelatedValue(object, L0.HasValueType, Bindings.STRING); + if(valueTypeText2 != null) { + Type valueType2 = CommonDBUtils.getSCLType(graph, subject, valueTypeText2); + if(!valueType.equals(valueType2)) { + StringBuilder sb = new StringBuilder() + .append("The value type ") + .append(valueType) + .append(" of predicate ") + .append(NameUtils.getSafeName(graph, predicate, true)) + .append(" does not match the value type ") + .append(valueType2) + .append(" of object ") + .append(NameUtils.getSafeName(graph, object, true)) + .append("."); + return sb.toString(); + } + } + } + } + + return null; + } } diff --git a/bundles/org.simantics.db.layer0/build.properties b/bundles/org.simantics.db.layer0/build.properties index f686835b4..edf9665de 100644 --- a/bundles/org.simantics.db.layer0/build.properties +++ b/bundles/org.simantics.db.layer0/build.properties @@ -15,4 +15,5 @@ exclude.. = org/simantics/db/layer0/spm/org.simantics.db.build.zip bin.includes = META-INF/,\ .,\ plugin.xml,\ - adapters.xml + adapters.xml,\ + scl/ diff --git a/bundles/org.simantics.db.layer0/scl/Simantics/Layer0.scl b/bundles/org.simantics.db.layer0/scl/Simantics/Layer0.scl new file mode 100644 index 000000000..0b034a14d --- /dev/null +++ b/bundles/org.simantics.db.layer0/scl/Simantics/Layer0.scl @@ -0,0 +1,9 @@ +include "Simantics/DB" +include "Simantics/Issue" + +importJava "org.simantics.db.layer0.function.All" where + uriValidator :: Resource -> [Issue] + valueValidator :: Resource -> [Issue] + relationValidator :: Resource -> [Issue] + propertyValidator :: Resource -> [Issue] + clusterValidator :: Resource -> [Issue] \ No newline at end of file diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/internal/SimanticsInternal.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/internal/SimanticsInternal.java index 8ae309e68..d30be8ffc 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/internal/SimanticsInternal.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/internal/SimanticsInternal.java @@ -12,22 +12,12 @@ package org.simantics.db.layer0.internal; import java.io.File; -import java.util.concurrent.TimeUnit; import org.eclipse.core.runtime.Platform; import org.simantics.db.Resource; -import org.simantics.db.Session; -import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.SimanticsClipboard; import org.simantics.db.layer0.util.SimanticsKeys; import org.simantics.db.management.ISessionContext; -import org.simantics.db.management.ISessionContextProvider; -import org.simantics.db.management.ISessionContextProviderSource; -import org.simantics.db.request.ReadInterface; -import org.simantics.db.request.WriteInterface; -import org.simantics.layer0.Layer0; -import org.simantics.operation.Layer0X; -import org.simantics.utils.threads.ThreadUtils; /** * An internal facade for accessing basic Simantics platform services. @@ -35,112 +25,7 @@ import org.simantics.utils.threads.ThreadUtils; * * Use org.simantics.Simantics instead where ever possible. */ -public class SimanticsInternal { - - private static ISessionContextProviderSource providerSource = null; - - /** - * Queue execution of a runnable. - * - * @param runnable - */ - public static void async(Runnable runnable) { - ThreadUtils.getBlockingWorkExecutor().execute(runnable); - } - - public static void async(Runnable runnable, int delay, TimeUnit unit) { - ThreadUtils.getTimer().schedule(runnable, delay, unit); - } - - /** - * Queue execution of a non-blocking runnable. Use this method with caution. - * A non-blocking runnable nevers locks anything, No Locks, No semaphores, - * No Object.wait(), No synchronized() {} blocks. - * - * @param runnable a non-blocking runnable - */ - public static void asyncNonblocking(Runnable runnable) { - ThreadUtils.getNonBlockingWorkExecutor().execute(runnable); - } - - /** - * Schedule execution of a non-blocking runnable. Use this method with caution. - * A non-blocking runnable never locks anything, No Locks, No semaphores, - * No Object,wait(), No synchronized() {} blocks. - * - * @param runnable a non-blocking runnable - * @param initialDelay - * @param period - */ - public static void asyncNonblocking(Runnable runnable, int initialDelay, int period) { - ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(runnable, initialDelay, period, TimeUnit.MILLISECONDS); - } - - public static synchronized ISessionContext setSessionContext(ISessionContext ctx) { - return getSessionContextProvider().setSessionContext(ctx); - } - - public static void setSessionContextProviderSource(ISessionContextProviderSource source) { - if (source == null) - throw new IllegalArgumentException("null provider source"); - providerSource = source; - } - - public static ISessionContextProviderSource getProviderSource() { - if (providerSource == null) - throw new IllegalStateException( - "providerSource must be initialized by the application before using class Simantics"); - return providerSource; - } - - public static ISessionContextProvider getSessionContextProvider() { - return getProviderSource().getActive(); - } - - /** - * Returns the database session context associated with the currently active - * context. This method should be used to retrieve session contexts only - * when the client is sure that the correct context is active. - * - * @return the session context associated with the currently active context - * or null if the context has no session context - */ - public static ISessionContext getSessionContext() { - ISessionContextProvider provider = getSessionContextProvider(); - return provider != null ? provider.getSessionContext() : null; - } - - /** - * Returns the database Session bound to the currently active context. - * - *

- * The method always returns a non-null Session or produces an - * IllegalStateException if a Session was not attainable. - *

- * - * @return the Session bound to the currently active workbench window - * @throws IllegalStateException if no Session was available - */ - public static Session getSession() { - ISessionContext ctx = getSessionContext(); - if (ctx == null) - throw new IllegalStateException("Session unavailable, no database session open"); - return ctx.getSession(); - } - - /** - * Returns the database Session bound to the currently active context. - * Differently from {@link #getSession()}, this method returns - * null if there is no current Session available. - * - * @see #getSession() - * @return the Session bound to the currently active context or - * null - */ - public static Session peekSession() { - ISessionContext ctx = getSessionContext(); - return ctx == null ? null : ctx.peekSession(); - } +public class SimanticsInternal extends org.simantics.db.common.SimanticsInternal { /** * @return the currently open and active project as an IProject @@ -179,23 +64,6 @@ public class SimanticsInternal { return clipboard; } - public static Layer0 getLayer0() throws DatabaseException { - return Layer0.getInstance(getSession()); - } - - public static Layer0X getLayer0X() throws DatabaseException { - return Layer0X.getInstance(getSession()); - } - - - public static T sync(ReadInterface r) throws DatabaseException { - return getSession().sync(r); - } - - public static T sync(WriteInterface r) throws DatabaseException { - return getSession().sync(r); - } - public static File getTemporaryDirectory() { File workspace = Platform.getLocation().toFile(); File temp = new File(workspace, "tempFiles"); diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java index 62c7093da..610c8c8bd 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java @@ -74,6 +74,7 @@ import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.PossibleChild; import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.common.utils.CommonDBUtils; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.event.ChangeListener; import org.simantics.db.exception.CancelTransactionException; @@ -353,13 +354,9 @@ public class Layer0Utils { throw new IllegalArgumentException("Unable to convert datatype into SCL type: " + type); } - + @Deprecated public static Type getSCLType(ReadGraph graph, RuntimeEnvironment runtimeEnvironment, String typeText) throws DatabaseException { - try { - return Environments.getType(runtimeEnvironment.getEnvironment(), typeText); - } catch (SCLExpressionCompilationException e) { - throw new DatabaseException(e); - } + return CommonDBUtils.getSCLType(graph, runtimeEnvironment, typeText); } public static Type getSCLType(ReadGraph graph, Variable property) throws DatabaseException { @@ -646,15 +643,14 @@ public class Layer0Utils { return graph.getPossibleResource(graph.getURI(root) + suffix); } + @Deprecated public static Resource getPossibleChild(ReadGraph graph, Resource resource, String name) throws DatabaseException { - return graph.sync(new PossibleChild(resource, name)); + return CommonDBUtils.getPossibleChild(graph, resource, name); } + @Deprecated public static Resource getPossibleChild(ReadGraph graph, Resource resource, Resource type, String name) throws DatabaseException { - Resource child = graph.sync(new PossibleChild(resource, name)); - if(child == null) return null; - if(!graph.isInstanceOf(child, type)) return null; - return child; + return CommonDBUtils.getPossibleChild(graph, resource, type, name); } public static RelationContext relationContext(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException { diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest.java index 9f6b8fe53..17fbf1e7c 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest.java @@ -1,19 +1,6 @@ package org.simantics.db.layer0.util; -import org.simantics.db.ReadGraph; import org.simantics.db.Resource; -import org.simantics.db.common.request.ParametrizedPrimitiveRead; -import org.simantics.db.common.request.UnaryRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.internal.SimanticsInternal; -import org.simantics.db.procedure.Listener; -import org.simantics.db.request.Read; -import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification; -import org.simantics.scl.compiler.module.repository.ImportFailureException; -import org.simantics.scl.compiler.module.repository.UpdateListener; -import org.simantics.scl.compiler.runtime.RuntimeEnvironment; -import org.simantics.scl.osgi.SCLOsgi; -import org.simantics.scl.runtime.SCLContext; /** * Finds the runtime environment of a model or other index root. @@ -21,134 +8,11 @@ import org.simantics.scl.runtime.SCLContext; * @author Hannu Niemistö * @author Antti Villberg */ -public class RuntimeEnvironmentRequest extends UnaryRead { +@Deprecated +public class RuntimeEnvironmentRequest extends org.simantics.db.common.request.RuntimeEnvironmentRequest { public RuntimeEnvironmentRequest(Resource parameter) { super(parameter); } - protected void fillEnvironmentSpecification(EnvironmentSpecification environmentSpecification) { - } - - static class UpdateListenerImpl extends UpdateListener { - - final EnvironmentSpecification environmentSpecification; - final Listener callback; - - UpdateListenerImpl(EnvironmentSpecification environmentSpecification, Listener callback) { - this.environmentSpecification = environmentSpecification; - this.callback = callback; - } - - @Override - public void notifyAboutUpdate() { - if(callback.isDisposed()) { - stopListening(); - return; - } - getRuntimeEnvironment(environmentSpecification, callback, this); - } - }; - - public static void getRuntimeEnvironment(EnvironmentSpecification environmentSpecification, Listener callback, UpdateListenerImpl listener) { - - try { - - SCLContext context = SCLContext.getCurrent(); - - RuntimeEnvironment env; - Object graph = context.get("graph"); - if(graph == null) - try { - env = SimanticsInternal.getSession().syncRequest(new Read() { - @Override - public RuntimeEnvironment perform(ReadGraph graph) throws DatabaseException { - - SCLContext sclContext = SCLContext.getCurrent(); - Object oldGraph = sclContext.get("graph"); - try { - sclContext.put("graph", graph); - return SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment( - environmentSpecification, - callback.getClass().getClassLoader(), listener); - } catch (ImportFailureException e) { - throw new DatabaseException(e); - } catch (Throwable t) { - throw new DatabaseException(t); - } finally { - sclContext.put("graph", oldGraph); - } - } - }); - } catch (DatabaseException e) { - callback.exception(e); - return; - } - else - env = SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment( - environmentSpecification, - callback.getClass().getClassLoader(), listener); - callback.execute(env); - } catch (ImportFailureException e) { - callback.exception(new DatabaseException(e)); - } - - } - - @Override - public RuntimeEnvironment perform(ReadGraph graph) - throws DatabaseException { - final EnvironmentSpecification environmentSpecification = EnvironmentSpecification.of( - "Builtin", "", - "StandardLibrary", "", - "Simantics/All", ""); - fillEnvironmentSpecification(environmentSpecification); - - Resource mainModule = Layer0Utils.getPossibleChild(graph, parameter, "SCLMain"); - String mainModuleUri; - if(mainModule != null) { - mainModuleUri = graph.getURI(mainModule); - environmentSpecification.importModule(mainModuleUri, ""); - } - else - mainModuleUri = graph.getURI(parameter) + "/#"; // Add something dummy to the model uri that cannot be in a real URI - - return graph.syncRequest(new ParametrizedPrimitiveRead(mainModuleUri) { - - UpdateListenerImpl sclListener; - - @Override - public void register(ReadGraph graph, Listener procedure) { - - SCLContext context = SCLContext.getCurrent(); - Object oldGraph = context.put("graph", graph); - try { - - if(procedure.isDisposed()) { - getRuntimeEnvironment(environmentSpecification, procedure, null); - } else { - sclListener = new UpdateListenerImpl(environmentSpecification, procedure); - sclListener.notifyAboutUpdate(); - } - - } finally { - context.put("graph", oldGraph); - } - - } - - @Override - public void unregistered() { - if(sclListener != null) - sclListener.stopListening(); - } - - }); - } - - @Override - public int hashCode() { - return 31*getClass().hashCode() + super.hashCode(); - } - } diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/ValidationUtils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/ValidationUtils.java index 673eeaee5..47c829cd8 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/ValidationUtils.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/ValidationUtils.java @@ -1,7 +1,6 @@ package org.simantics.db.layer0.validation; -import gnu.trove.set.hash.THashSet; - +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -18,6 +17,8 @@ import org.simantics.db.layer0.util.DomainProcessor3; import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest; import org.simantics.layer0.Layer0; +import gnu.trove.set.hash.THashSet; + public class ValidationUtils { /** @@ -62,7 +63,7 @@ public class ValidationUtils { return validateConstraints(graph, r, null); } - public static Set validateConstraintsForDomain(ReadGraph graph, Resource r) throws DatabaseException { + public static List validateConstraintsForDomain(ReadGraph graph, Resource r) throws DatabaseException { Set result = null; DomainProcessor3 dp = ModelTransferableGraphSourceRequest.getDomainOnly(graph, null, r); @@ -75,7 +76,7 @@ public class ValidationUtils { } } - return result != null ? result : Collections.emptySet(); + return result != null ? new ArrayList(result) : Collections.emptyList(); } } diff --git a/bundles/org.simantics.db.management/META-INF/MANIFEST.MF b/bundles/org.simantics.db.management/META-INF/MANIFEST.MF index ecf2439e8..75fdb8b6f 100644 --- a/bundles/org.simantics.db.management/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.management/META-INF/MANIFEST.MF @@ -5,9 +5,9 @@ Bundle-SymbolicName: org.simantics.db.management Bundle-Version: 1.1.0.qualifier Bundle-Activator: org.simantics.db.management.internal.Activator Bundle-Vendor: VTT Technical Research Centre of Finland -Require-Bundle: org.simantics.db.services;bundle-version="0.8.0", - org.simantics.db.procore;bundle-version="0.8.0", - org.eclipse.core.runtime;bundle-version="3.5.0" +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0", + org.simantics.utils;bundle-version="1.1.0", + org.simantics.layer0;bundle-version="1.1.0" Bundle-ActivationPolicy: lazy Export-Package: org.simantics.db.management, org.simantics.db.management.discovery diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java index dae8bea75..88293f42b 100644 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java +++ b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java @@ -16,19 +16,14 @@ import java.util.Arrays; import java.util.UUID; import java.util.concurrent.TimeoutException; -import org.eclipse.core.runtime.IStatus; import org.simantics.db.Disposable; import org.simantics.db.ReadGraph; import org.simantics.db.Session; import org.simantics.db.VirtualGraph; -import org.simantics.db.common.processor.MergingDelayedWriteProcessor; -import org.simantics.db.common.processor.MergingGraphRequestProcessor; -import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.management.internal.Activator; +import org.simantics.db.request.Read; import org.simantics.db.service.LifecycleSupport; import org.simantics.db.service.VirtualGraphSupport; -import org.simantics.db.services.GlobalServiceInitializer; import org.simantics.layer0.Layer0; import org.simantics.utils.datastructures.disposable.DisposeState; import org.simantics.utils.datastructures.disposable.IDisposable; @@ -46,16 +41,11 @@ import org.simantics.utils.threads.SyncListenerList; * @author Tuukka Lehtonen */ public class SessionContext extends HintContext implements ISessionContext, Disposable { - private static final boolean SESSION_DEBUG = false; -// private final IServerAddress address; + private static final boolean SESSION_DEBUG = false; private Session session; - private boolean servicesRegistered = false; - - private IStatus servicesRegisteredStatus = null; - public static SessionContext create(Session session, boolean initialize) throws DatabaseException { return new SessionContext(session, initialize); } @@ -67,40 +57,21 @@ public class SessionContext extends HintContext implements ISessionContext, Disp } private void initializeSession(Session s) throws DatabaseException { - s.registerService(MergingGraphRequestProcessor.class, new MergingGraphRequestProcessor("SessionService", s, 20)); - s.registerService(MergingDelayedWriteProcessor.class, new MergingDelayedWriteProcessor(s, 20)); s.registerService(VirtualGraph.class, s.getService(VirtualGraphSupport.class).getMemoryPersistent(UUID.randomUUID().toString())); // Builtins needs to be initialized for the new session before // anything useful can be done with it. - s.syncRequest(new ReadRequest() { + s.syncRequest(new Read() { @Override - public void run(ReadGraph g) { + public Object perform(ReadGraph g) { // Registers Builtins with the ServiceLocator of the Graph's session. Layer0.getInstance(g); + return null; } }); + } - public void registerServices() { - if (servicesRegistered) - return; - - // Register any services available for the SessionLocator of the new - // Session. - servicesRegisteredStatus = new GlobalServiceInitializer().initialize(session); - if (!servicesRegisteredStatus.isOK()) { - Activator.getDefault().getLog().log(servicesRegisteredStatus); - } - - servicesRegistered = true; - } - -// @Override -// public IServerAddress getAddress() { -// return address; -// } - @Override public Session getSession() { if (session == null) diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java deleted file mode 100644 index 81967124d..000000000 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.management.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Properties; - -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; -import org.simantics.db.SessionManager; -import org.simantics.utils.FileUtils; - -import fi.vtt.simantics.procore.SessionManagerSource; - -/** - * Complete hack for the time being. Simply provides the SessionManager behind - * procore's SessionManagerSource with proper initialization. - */ -public final class SessionManagerProvider { - - // TODO: move this into BundleContext as a service ? - private static SessionManagerProvider provider; - - private SessionManager sessionManager; - - public static SessionManagerProvider getInstance() { - if (provider == null) - provider = new SessionManagerProvider(); - return provider; - } - - public SessionManager getSessionManager() throws IOException { - if (sessionManager == null) { - sessionManager = SessionManagerSource.getSessionManager(loadProperties()); - } - return sessionManager; - } - - private Properties loadProperties() { - Bundle procore = Platform.getBundle("org.simantics.db.procore"); - URL url = procore.getResource("log4j.properties"); - if (url != null) { - InputStream in = null; - try { - in = url.openStream(); - Properties props = new Properties(); - props.load(in); - return props; - } catch (Exception e) { - } finally { - FileUtils.uncheckedClose(in); - } - } - return null; - } - -} diff --git a/bundles/org.simantics.db.services/META-INF/MANIFEST.MF b/bundles/org.simantics.db.services/META-INF/MANIFEST.MF index 7403f3d70..bb78bf41e 100644 --- a/bundles/org.simantics.db.services/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.db.services/META-INF/MANIFEST.MF @@ -6,9 +6,13 @@ Bundle-Version: 1.1.0.qualifier Bundle-Vendor: VTT Technical Research Centre of Finland Require-Bundle: org.eclipse.core.runtime, gnu.trove3, - org.simantics.layer0.utils;bundle-version="1.1.0", org.simantics.layer0x.ontology;bundle-version="1.0.0", - org.slf4j.api;bundle-version="1.7.25" + org.slf4j.api;bundle-version="1.7.25", + org.simantics.utils;bundle-version="1.1.0", + org.simantics.db;bundle-version="1.1.0", + org.simantics.scl.reflection, + org.simantics.db.common;bundle-version="1.1.0", + org.simantics.layer0.utils Export-Package: org.simantics.db.services, org.simantics.db.services.activation, org.simantics.db.services.adaption diff --git a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java index 578b42a61..fe9bab552 100644 --- a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java +++ b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java @@ -36,6 +36,7 @@ import org.simantics.db.adaption.AdapterInstaller; import org.simantics.db.adaption.AdaptionService; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.Read; import org.simantics.db.services.adaption.reflection.AdaptingDynamicAdapter2; import org.simantics.db.services.adaption.reflection.AtMostOneRelatedResource2; import org.simantics.db.services.adaption.reflection.ConstantAdapter; @@ -337,9 +338,9 @@ public class AdapterRegistry2 { } public void updateAdaptionService(Session s, final AdaptionService service) throws DatabaseException { - s.syncRequest(new ReadRequest() { + s.syncRequest(new Read() { @Override - public void run(ReadGraph g) { + public Object perform(ReadGraph g) { for(AdapterInstaller t : installerSources.keySet()) { try { t.install(g, service); @@ -347,6 +348,7 @@ public class AdapterRegistry2 { AdapterRegistry2.this.handleException(e, t); } } + return null; } }); } diff --git a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java index 187fc5219..42eb3d8be 100644 --- a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java +++ b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java @@ -18,12 +18,16 @@ import java.util.Arrays; import org.simantics.db.AsyncReadGraph; import org.simantics.db.Resource; import org.simantics.db.adaption.Adapter; -import org.simantics.db.common.request.AsyncReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.request.AsyncRead; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ReflectionAdapter2 implements Adapter { + private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionAdapter2.class); + Constructor constructor; IDynamicAdapter2[] parameters; @@ -40,22 +44,20 @@ public class ReflectionAdapter2 implements Adapter { if(parameters.length == 0) { -// System.out.println("ReflectionAdapter2 " + ReflectionAdapter2.this); - try { procedure.execute(g, constructor.newInstance()); } catch (IllegalArgumentException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InstantiationException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (IllegalAccessException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InvocationTargetException e) { procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e.getCause()); } } else if( parameters.length == 1 && parameters[0] instanceof ThisResource2) { @@ -64,49 +66,50 @@ public class ReflectionAdapter2 implements Adapter { procedure.execute(g, constructor.newInstance(r)); } catch (IllegalArgumentException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InstantiationException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (IllegalAccessException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InvocationTargetException e) { procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e.getCause()); } } else { - g.asyncRequest(new AsyncReadRequest() { - + g.asyncRequest(new AsyncRead() { + @Override - public void run(AsyncReadGraph graph) { - + public void perform(AsyncReadGraph graph, AsyncProcedure p) { + Object[] args = new Object[parameters.length]; try { - for(int i=0;i implements Adapter { return "ReflectionAdapter$1" + constructor + "$" + Arrays.toString(parameters); } - }); + }, procedure); } diff --git a/bundles/org.simantics.layer0.utils/META-INF/MANIFEST.MF b/bundles/org.simantics.layer0.utils/META-INF/MANIFEST.MF index f9f82e4a0..36f82a01d 100644 --- a/bundles/org.simantics.layer0.utils/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.layer0.utils/META-INF/MANIFEST.MF @@ -17,10 +17,10 @@ Export-Package: org.simantics.layer0.utils, org.simantics.layer0.utils.triggers, org.simantics.layer0.utils.writer Require-Bundle: gnu.trove3;bundle-version="3.0.3", - org.simantics.db.common;bundle-version="0.8.0";visibility:=reexport, org.eclipse.equinox.common;bundle-version="3.5.0", org.simantics.layer0;bundle-version="1.0.0", - org.simantics.layer0x.ontology;bundle-version="1.0.0" + org.simantics.layer0x.ontology;bundle-version="1.0.0", + org.simantics.db.common;bundle-version="1.1.0" Bundle-Vendor: VTT Technical Research Centre of Finland Bundle-ClassPath: . Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.simantics.layer0/graph/Layer0.pgraph b/bundles/org.simantics.layer0/graph/Layer0.pgraph index e3d00e8aa..d169c9684 100644 --- a/bundles/org.simantics.layer0/graph/Layer0.pgraph +++ b/bundles/org.simantics.layer0/graph/Layer0.pgraph @@ -4,6 +4,9 @@ L0 = : L0.Ontology L0.HasResourceClass "org.simantics.layer0.Layer0" +L0.SCLMain : L0.SCLModule + L0.SCLModule.definition """ include "Simantics/Layer0" """ + // Types L0.Entity : L0.Type L0.HasDescription "All types are inherited from this type." @@ -42,6 +45,7 @@ L0.Entity : L0.Type >-- L0.Entity.methods @L0.assert L0.Entity.methods _ : L0.Property + L0.HasValueType "StructuredProperty" L0.Entity.methods ==> "StructuredProperty" L0.Constraint -- L0.Constraint.Validator Resource -> [Issue]" + L0.RequiresValueType "Resource -> [Issue]" + +L0.SCLValidator [Issue]" + L0.HasConstraint L0.Entity - L0.HasConstraint L0.Entity.RelationConstraint : L0.Constraint - L0.Constraint.Validator L0.Functions.relationValidator - L0.HasConstraint L0.Entity.PropertyConstraint : L0.Constraint - L0.Constraint.Validator L0.Functions.propertyValidator - L0.HasConstraint L0.Entity.ValueConstraint : L0.Constraint - L0.Constraint.Validator L0.Functions.valueValidator - L0.HasConstraint L0.Entity.URIConstraint : L0.Constraint - L0.Constraint.Validator L0.Functions.uriValidator - L0.HasConstraint L0.Entity.ClusterConstraint : L0.Constraint - L0.Constraint.Validator L0.Functions.clusterValidator - - - \ No newline at end of file + L0.HasConstraint L0.Entity.RelationConstraint + @L0.sclConstraint "relationValidator" + L0.HasConstraint L0.Entity.PropertyConstraint + @L0.sclConstraint "propertyValidator" + L0.HasConstraint L0.Entity.ValueConstraint + @L0.sclConstraint "valueValidator" + L0.HasConstraint L0.Entity.ClusterConstraint + @L0.sclConstraint "clusterValidator" + L0.HasConstraint L0.Entity.URIConstraint + @L0.sclConstraint "uriValidator" + \ No newline at end of file diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 2504ba62d..7839ce70d 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -45,6 +45,8 @@ import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.service.resolver.BundleDescription; import org.ini4j.Ini; import org.ini4j.InvalidFileFormatException; +import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy; +import org.simantics.SimanticsPlatform.RecoveryPolicy; import org.simantics.databoard.Bindings; import org.simantics.databoard.Databoard; import org.simantics.datatypes.literal.Font; @@ -59,6 +61,8 @@ import org.simantics.db.SessionModel; import org.simantics.db.UndoContext; import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; +import org.simantics.db.common.processor.MergingDelayedWriteProcessor; +import org.simantics.db.common.processor.MergingGraphRequestProcessor; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.common.utils.Transaction; @@ -82,6 +86,7 @@ import org.simantics.db.service.QueryControl; import org.simantics.db.service.UndoRedoSupport; import org.simantics.db.service.VirtualGraphSupport; import org.simantics.db.service.XSupport; +import org.simantics.db.services.GlobalServiceInitializer; import org.simantics.graph.db.GraphDependencyAnalyzer; import org.simantics.graph.db.GraphDependencyAnalyzer.IU; import org.simantics.graph.db.GraphDependencyAnalyzer.IdentityNode; @@ -950,6 +955,13 @@ public class SimanticsPlatform implements LifecycleListener { } + public void registerServices(SessionContext context) { + new GlobalServiceInitializer().initialize(session); + session.registerService(MergingGraphRequestProcessor.class, new MergingGraphRequestProcessor("SessionService", session, 20)); + session.registerService(MergingDelayedWriteProcessor.class, new MergingDelayedWriteProcessor(session, 20)); + } + + public SessionContext createSessionContext(boolean init) throws PlatformException { try { // Construct and initialize SessionContext from Session. @@ -957,7 +969,7 @@ public class SimanticsPlatform implements LifecycleListener { String message = "Session context created"; LOGGER.info(message); if (init) { - sessionContext.registerServices(); + registerServices(sessionContext); message = "Session services registered"; LOGGER.info(message); } -- 2.43.2