]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Initialize new cache in flush instead of setting it null"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 21 Aug 2019 09:49:28 +0000 (09:49 +0000)
committerGerrit Code Review <gerrit2@simantics>
Wed, 21 Aug 2019 09:49:28 +0000 (09:49 +0000)
170 files changed:
bundles/org.simantics.action.ontology/graph/Action.pgraph
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java
bundles/org.simantics.databoard/src/org/simantics/databoard/Bindings.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/BindingRepository.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/BindingRequest.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/ClassBindingFactory.java
bundles/org.simantics.db.common/META-INF/MANIFEST.MF
bundles/org.simantics.db.common/src/org/simantics/db/common/SimanticsInternal.java [new file with mode: 0644]
bundles/org.simantics.db.common/src/org/simantics/db/common/request/RuntimeEnvironmentRequest.java [new file with mode: 0644]
bundles/org.simantics.db.common/src/org/simantics/db/common/utils/CommonDBUtils.java
bundles/org.simantics.db.common/src/org/simantics/db/common/utils/ListUtils.java
bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java [deleted file]
bundles/org.simantics.db.impl/src/org/simantics/db/impl/ResourceImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/DelayedWriteGraph.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncMultiReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/AsyncReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CodeGen.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ExternalReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/MultiReadEntry.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCache.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCacheBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryCollectorImpl2.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryIdentityHash.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/QueryProcessor.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/ReadEntry.java
bundles/org.simantics.db.layer0/adapters.xml
bundles/org.simantics.db.layer0/build.properties
bundles/org.simantics.db.layer0/scl/Simantics/Layer0.scl [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/internal/SimanticsInternal.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/SCLAction.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DatabaseExceptionUtils.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/RuntimeEnvironmentRequest.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/validation/ValidationUtils.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java
bundles/org.simantics.db.management/META-INF/MANIFEST.MF
bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java
bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java [deleted file]
bundles/org.simantics.db.procore.server.environment/.classpath [deleted file]
bundles/org.simantics.db.procore.server.environment/.project [deleted file]
bundles/org.simantics.db.procore.server.environment/.settings/org.eclipse.jdt.core.prefs [deleted file]
bundles/org.simantics.db.procore.server.environment/META-INF/MANIFEST.MF [deleted file]
bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x64.exe [deleted file]
bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x86.exe [deleted file]
bundles/org.simantics.db.procore.server.environment/build.properties [deleted file]
bundles/org.simantics.db.procore.server.environment/msijni.dll [deleted file]
bundles/org.simantics.db.procore.server.environment/msijni64.dll [deleted file]
bundles/org.simantics.db.procore.server.environment/native/compile.bat [deleted file]
bundles/org.simantics.db.procore.server.environment/native/compile.sh [deleted file]
bundles/org.simantics.db.procore.server.environment/native/compile_x64.bat [deleted file]
bundles/org.simantics.db.procore.server.environment/native/compile_x86.bat [deleted file]
bundles/org.simantics.db.procore.server.environment/native/msijni.c [deleted file]
bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.sln [deleted file]
bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.vcproj [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ARCHType.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironment.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironmentException.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/InstallException.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/OSType.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/RebootRequiredException.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ServerEnvironment.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Msi.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Product.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductCodes.java [deleted file]
bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductState.java [deleted file]
bundles/org.simantics.db.server/build.properties
bundles/org.simantics.db.server/linux.x86_64/ProCoreServer [deleted file]
bundles/org.simantics.db.server/win32.x86/ACE.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/ProCoreServer.exe [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_chrono-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_date_time-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_filesystem-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_regex-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_system-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/boost_thread-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/msvcp110.dll [deleted file]
bundles/org.simantics.db.server/win32.x86/msvcr110.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/ACE.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/ProCoreServer.exe [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_chrono-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_date_time-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_filesystem-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_regex-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_system-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/boost_thread-vc110-mt-1_55.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/lzo2.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/msvcp110.dll [deleted file]
bundles/org.simantics.db.server/win32.x86_64/msvcr110.dll [deleted file]
bundles/org.simantics.db.services/META-INF/MANIFEST.MF
bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java
bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java
bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestHandler.java [deleted file]
bundles/org.simantics.db/src/org/simantics/db/DevelopmentKeys.java
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/StandardModelledView.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/NewFileDocument.java
bundles/org.simantics.layer0.utils/META-INF/MANIFEST.MF
bundles/org.simantics.layer0/graph/Layer0.pgraph
bundles/org.simantics.layer0/graph/Layer0Constraints.pgraph
bundles/org.simantics.layer0/graph/Layer0SCL.pgraph
bundles/org.simantics.layer0/graph/Layer0Templates.pgraph
bundles/org.simantics.layer0/graph/Layer0Validations.pgraph
bundles/org.simantics.layer0/graph/Layer0Values.pgraph
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/OpenDiagramFromConfigurationAdapter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/scl/scriptEditor/SCLScriptEditor.java
bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java
bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalInfo.java
bundles/org.simantics.objmap2/META-INF/MANIFEST.MF
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedList.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListAdd.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListGet.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListRem.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/UpdateMethod.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/CompoundRelatedGetSetValueRuleFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/DataTypeUtils.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory2.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedGetSetValueRuleFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/RelatedValueRuleFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/UpdateMethodFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/impl/Mapping.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/MappedElementsRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/ValueRule.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/CompoundValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/LinkedListAccessor.java [new file with mode: 0644]
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/MappingUtils.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedOrderedSetElementsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/RelatedValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/AdaptedLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/DynamicSimpleLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/MappingSchemas.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/OrderedSetSimpleLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/schema/SimpleLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/UpdateMethodFactory.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedOrderedSetElementsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/RelatedValueAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/rules/domain/StructuralRelatedObjectsAccessor.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/AdaptedLinkType.java
bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/schema/SimpleLinkType.java
bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java
bundles/org.simantics.project/src/org/simantics/project/management/org.simantics.db.build.zip [deleted file]
bundles/org.simantics.project/src/org/simantics/project/management/server_template.cnfg [deleted file]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SclDoc.css
bundles/org.simantics.scl.db/scl/Simantics/DB.scl
bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/outline/SCLModuleOutlinePage.java
bundles/org.simantics.selectionview.ontology/graph/Selectionview.pgraph
bundles/org.simantics.structural.ontology/graph/Structural.pgraph
bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java
bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java
bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/FileOrDirectorySelectionWidget.java
bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/widgets/FileSelectionWidget.java
bundles/org.simantics.workbench/META-INF/MANIFEST.MF
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java
bundles/org.simantics/META-INF/MANIFEST.MF
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java
bundles/org.simantics/src/org/simantics/internal/SessionUtil.java [deleted file]
bundles/pom.xml
features/org.simantics.workbench.feature/feature.xml

index 3b0cb14c086b65db2866ac393bb7bb55582ffbc1..11205dacc89eba7e0f6f59205376314b8493c4dc 100644 (file)
@@ -4,6 +4,6 @@ ACT = <http://www.simantics.org/Action-1.1> : L0.Ontology
     @L0.new
     L0.HasResourceClass "org.simantics.action.ontology.ActionResource"
     
-ACT.Action <T L0.Entity
+ACT.Action <T L0.Action
 
 ACT.DropAction <T L0.Entity
index 40c21585a7d83c5b0b6c6d1c89f845528af3ed50..6361401b48723f58aa62516387421f5f473ea8cc 100644 (file)
@@ -1076,7 +1076,6 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
         editor.setEditor(combo, item, columnIndex);
 
         combo.setFocus();
-        combo.setListVisible(true);
 
         GraphExplorerImpl.this.reconfigureTreeEditorForText(item, columnIndex, combo, combo.getText(), SWT.DEFAULT, 0, 0);
 
@@ -1085,6 +1084,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
         // Removed in comboListener
         currentlyModifiedNodes.add(context);
 
+        combo.setListVisible(true);
         //System.out.println("START ENUMERATION EDITING: " + item);
     }
 
index f9cf1002317a7c4ddd2285e8a6306bd17e3812a5..b1f53d0b611bb542197cdf7bb299b60a3438149b 100644 (file)
@@ -8,6 +8,7 @@
  *
  *  Contributors:
  *      VTT Technical Research Centre of Finland - initial API and implementation
+ *      Semantum Oy - gitlab #313
  *******************************************************************************/
 package org.simantics.databoard;
 
@@ -886,7 +887,14 @@ public class Bindings {
        
        databoard.initialize();
        
-               DATATYPE = getBindingUnchecked(Datatype.class);
+        DATATYPE = getBindingUnchecked(Datatype.class);
+        /**
+         * {@link Datatype} class has annotations but it can be considered a "class
+         * request" as it is a fundamental building block of Databoard and it has a
+         * fixed structure. Therefore {@link BindingRepository#classMap} is allowed
+         * to contain a cached Datatype.class -> Binding mapping.
+         */
+        bindingRepository.registerClassMapping(Datatype.class, DATATYPE);
     }
 
 }
index ba24353712c7f90f415b4b2652f7699dba5b27d0..5a0239f26199a6a54174857298ffc4b0581b4422 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2018 Association for Decentralized Information Management in
+ * Copyright (c) 2007, 2019 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
@@ -8,7 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
- *     Semantum Oy - gitlab #82
+ *     Semantum Oy - gitlab #82, gitlab #313
  *******************************************************************************/
 package org.simantics.databoard.binding.factory;
 
@@ -18,10 +18,12 @@ import java.util.Map.Entry;
 
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.reflection.BindingRequest;
-import org.simantics.databoard.type.Datatype;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class BindingRepository {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(BindingRepository.class);
        /**
         * This map contains all the bindings
         */
@@ -41,7 +43,7 @@ public class BindingRepository {
                this.requestMap = requests;
                for (Entry<BindingRequest, Binding> e : requests.entrySet()) {
                        if ( isClassRequest( e.getKey() ) ) {
-                               classMap.put(e.getKey().getClazz(), e.getValue());
+                               registerClassMapping(e.getKey().getClazz(), e.getValue());
                        }
                }
        }
@@ -76,11 +78,15 @@ public class BindingRepository {
         */
        public synchronized void put( BindingRequest request, Binding binding ) {
                if ( isClassRequest(request) ) {
-                       classMap.put( request.getClazz(), binding );
+                   registerClassMapping(request.getClazz(), binding);
+               }
+               Binding existing = requestMap.put( request, binding );
+               if (existing != null && !existing.equals(binding)) {
+                   LOGGER.error("Replacing existing binding with a different one! {} {} {}", request, binding, existing);
                }
-               requestMap.put( request, binding );
        }
-       
+
+       @SuppressWarnings("unlikely-arg-type")
        public synchronized void remove(Binding binding) {
                for (Entry<BindingRequest, Binding> e : requestMap.entrySet()) {
                        if (e.getValue() == binding) {
@@ -116,20 +122,15 @@ public class BindingRepository {
                classMap.clear();
        }
 
-       /**
-        * {@link Datatype} class has annotations but it can be considered a "class
-        * request" as it is a fundamental building block of Databoard and it has a
-        * fixed structure. Therefore {@link #classMap} is allowed to contain a cached
-        * Datatype.class -> Binding mapping.
-        */
-       private static final String DATATYPE_CLASS_NAME = Datatype.class.getName();
+       boolean isClassRequest(BindingRequest request) {
+               return (request.className != null && (request.annotations == null || request.annotations.length == 0));
+       }
 
-       boolean isClassRequest( BindingRequest request )
-       {
-               return (request.className != null
-                               && ((request.annotations==null || request.annotations.length==0)
-                                               || DATATYPE_CLASS_NAME.equals(request.className))
-                               );
+       public void registerClassMapping(Class<?> clazz, Binding binding) {
+               Binding previous = classMap.putIfAbsent(clazz, binding);
+               if (previous != null) {
+                       LOGGER.warn("WARN: Can not put same key again to classMap! {} mapping {} not replaced by {}", clazz, previous, binding);
+               }
        }
 
 }
index 51feb39c3815861e4edde721cb4970ddf33898c0..55f809f5138dc2a02bd7b6a57bee7189a7d0101d 100644 (file)
@@ -8,12 +8,13 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
- *     Semantum Oy - gitlab #82
+ *     Semantum Oy - gitlab #82, gitlab #313
  *******************************************************************************/
 package org.simantics.databoard.binding.reflection;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -44,6 +45,13 @@ public class BindingRequest {
        return new BindingRequest(fieldClass, annotations);
        }
        
+    public static BindingRequest create( Method method )
+    {
+        Annotation[] annotations = ClassBindingFactory.getMethodAnnotations(method);
+        Class<?> valueClass = method.getReturnType(); 
+        return new BindingRequest(valueClass, annotations);
+    }
+       
        /** Requested class */
     private Class<?> clazz;
     private ClassLoader cl;
@@ -60,6 +68,23 @@ public class BindingRequest {
     
     transient int hash;
 
+    /**
+     * Cloning constructor with replacement annotations.
+     * 
+     * @param other the request to clone
+     * @param annotations the annotations to use while cloning
+     */
+    private BindingRequest(BindingRequest other, Annotation...annotations)
+    {
+        this.clazz = other.clazz;
+        this.cl = other.cl;
+        this.annotations = annotations;
+        this.className = other.className;
+        this.signature = other.signature;
+        this.descriptor = other.descriptor;
+        hash = calcHash(clazz.getName());
+    }
+
     /**
      * Create BindingRequest that creates class lazily. 
      * 
@@ -76,10 +101,7 @@ public class BindingRequest {
        this.signature = classSignature;
        this.annotations = annotations;
        this.descriptor = classDescriptor;
-        hash = className.hashCode();
-        for (Annotation a : annotations) {
-            hash = 7*hash + a.hashCode();
-        }
+       hash = calcHash(className);
     }
 
     /**
@@ -114,17 +136,23 @@ public class BindingRequest {
         
         className = clazz.getCanonicalName();
         signature = getSignature(clazz);
-        List<Class<?>> args = createArgsList();
-        StringBuilder desc = new StringBuilder();
-        _buildDescriptor(desc, clazz, args, new MutableInteger(0));
-        descriptor = desc.toString();
-        hash = clazz.getName().hashCode();
-        for (Annotation a : annotations) {
-            hash = 7*hash + a.hashCode();
+        descriptor = _buildDescriptor(new StringBuilder(), clazz, createArgsList(), new MutableInteger(0)).toString();
+        hash = calcHash(clazz.getName());
+    }
+
+    public BindingRequest withAnnotations(Annotation... newAnnotations) {
+        return new BindingRequest(this, newAnnotations);
+    }
+
+    private int calcHash(String className) {
+        int hash = className.hashCode();
+        for (Annotation a : this.annotations) {
+            hash += a.hashCode();
         }
+        return hash;
     }
-    
-    private void _buildDescriptor(StringBuilder sb, Class<?> c, List<Class<?>> classes, MutableInteger pos)
+
+    private StringBuilder _buildDescriptor(StringBuilder sb, Class<?> c, List<Class<?>> classes, MutableInteger pos)
     {
        int genericCount = c.getTypeParameters().length;
        int genericsLeft = classes.size()-pos.value;
@@ -142,6 +170,7 @@ public class BindingRequest {
        } else {
                sb.append( getSignature(c) );
        }
+       return sb;
     }
 
     public BindingRequest(Class<?> clazz, List<Annotation> annotations)
index 8d29ad70c24ac4c8896293b22ac82817b1c617f3..ac860d3923d4661e3ef79a8bddbb88498cf4c94a 100644 (file)
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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
+ *     Semantum Oy - gitlab #313
+ *******************************************************************************/
 package org.simantics.databoard.binding.reflection;
 
 import java.lang.annotation.Annotation;
@@ -6,6 +18,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -200,8 +213,7 @@ public class ClassBindingFactory {
        if(request.hasAnnotation(Optional.class))
        {               
                Optional optional = request.getAnnotation(Optional.class); 
-               Annotation[] newAnnotations = ArrayUtils.dropElements(request.annotations, optional);
-               BindingRequest componentRequest = new BindingRequest(request.getClazz(), newAnnotations);
+               BindingRequest componentRequest = request.withAnnotations(ArrayUtils.dropElements(request.annotations, optional));
                OptionalType type = new OptionalType();
                OptionalBinding binding = new OptionalBindingDefault(type, null);
                        inprogress.put(request, binding);
@@ -209,6 +221,7 @@ public class ClassBindingFactory {
                        type.componentType = binding.componentBinding.type();
                        inprogress.remove(request);
                        
+                       repository.put(request, binding);
                        return binding;
        }
 
@@ -570,7 +583,7 @@ public class ClassBindingFactory {
                
                Identifier idAnnotation = componentRequest.getAnnotation( Identifier.class );
                if ( idAnnotation!=null ) {
-                       componentRequest.dropAnnotations(1, idAnnotation);
+                       componentRequest = componentRequest.withAnnotations(componentRequest.dropAnnotations(1, idAnnotation));
                        identifierIndices.add( i );
                }
                Binding componentBinding = componentBindings[i] = construct( componentRequest );
@@ -602,8 +615,6 @@ public class ClassBindingFactory {
                                        binding = defaultBinding;
                        }
                        
-                       repository.put(request, binding);
-                       
                        return binding;
                } catch (RangeException e) {
                        inprogress.remove( request );
@@ -719,7 +730,23 @@ public class ClassBindingFactory {
        Class<?> fieldClass = list.remove(0);
        Class<?>[] parameterClasses = list.isEmpty() ? NO_CLASSES : list.toArray( NO_CLASSES );
        
-       if (Set.class.isAssignableFrom(fieldClass) && parameterClasses!=null &&parameterClasses.length==1) {
+       return getTypeAnnotations(annotations, fieldClass, parameterClasses);
+    }
+
+    public static Annotation[] getMethodAnnotations(Method method) 
+    {
+        Annotation[] annotations = method.getAnnotations().clone();
+        ArrayList<Class<?>> list = new ArrayList<Class<?>>();
+        getTypes( method.getGenericReturnType(), list );
+        Class<?> valueClass = list.remove(0);
+        Class<?>[] parameterClasses = list.isEmpty() ? NO_CLASSES : list.toArray( NO_CLASSES );
+        
+        return getTypeAnnotations(annotations, valueClass, parameterClasses);
+    }
+
+    private static Annotation[] getTypeAnnotations(Annotation[] annotations, Class<?> fieldClass,
+            Class<?>[] parameterClasses) {
+        if (Set.class.isAssignableFrom(fieldClass) && parameterClasses!=null &&parameterClasses.length==1) {
                Annotation[] a2 = new Annotation[annotations.length+1];
                System.arraycopy(annotations, 0, a2, 0, annotations.length);
                
index c45b276d72eb7db405710daec9e89341c28af58f..27e43385191e53f6038eda67523c87df3594f5f4 100644 (file)
@@ -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 (file)
index 0000000..e59e36f
--- /dev/null
@@ -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 <code>null</code> 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.
+     * 
+     * <p>
+     * The method always returns a non-null Session or produces an
+     * IllegalStateException if a Session was not attainable.
+     * </p>
+     * 
+     * @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
+     * <code>null</code> if there is no current Session available.
+     * 
+     * @see #getSession()
+     * @return the Session bound to the currently active context or
+     *         <code>null</code>
+     */
+    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> T sync(ReadInterface<T> r) throws DatabaseException {
+       return getSession().sync(r);
+    }
+    
+    public static <T> T sync(WriteInterface<T> 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 (file)
index 0000000..24a5c10
--- /dev/null
@@ -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&ouml;
+ * @author Antti Villberg
+ */
+public class RuntimeEnvironmentRequest extends UnaryRead<Resource, RuntimeEnvironment> {
+
+    public RuntimeEnvironmentRequest(Resource parameter) {
+        super(parameter);
+    }
+
+    protected void fillEnvironmentSpecification(EnvironmentSpecification environmentSpecification) {
+    }
+
+    static class UpdateListenerImpl extends UpdateListener {
+
+        final EnvironmentSpecification environmentSpecification;
+        final Listener<RuntimeEnvironment> callback;
+
+        UpdateListenerImpl(EnvironmentSpecification environmentSpecification, Listener<RuntimeEnvironment> 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<RuntimeEnvironment> 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<RuntimeEnvironment>() {
+                        @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<String, RuntimeEnvironment>(mainModuleUri) {
+
+            UpdateListenerImpl sclListener;
+
+            @Override
+            public void register(ReadGraph graph, Listener<RuntimeEnvironment> 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();
+    }
+
+}
index a07d42519c45741c1cd5c8c038502ca06c4fab4e..dcd3939a4f2e64d73ed288a1856b471c1ab8fd46 100644 (file)
@@ -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;
+    }
     
 }
index a197de88013dec935b1a46c3fb680c5fdf1831e9..656dfeb27550b8acfe8e1f1c8801cbebefe6e879 100644 (file)
@@ -55,9 +55,14 @@ public class ListUtils {
      */
     public static Resource create(WriteGraph g, Iterable<Resource> elements) throws DatabaseException {
        Layer0 L0 = Layer0.getInstance(g);
-       return ListUtils.create(g,L0.List, L0.List_ElementWithInverse, L0.List_ElementWithInverse_Inverse, elements);
+       return ListUtils.create(g,L0.List, L0.List_Element, null, elements);
     }
-
+    
+    public static Resource createWithInverses(WriteGraph g, Iterable<Resource> elements) throws DatabaseException {
+       Layer0 L0 = Layer0.getInstance(g);
+       return ListUtils.create(g,L0.ListWithInverses, L0.List_ElementWithInverse, L0.List_ElementWithInverse_Inverse, elements);
+    }
+    
     /**
      * Creates a list of the given list type containing the given {@code elements}.
      */
@@ -85,6 +90,8 @@ public class ListUtils {
         Layer0 L0 = g.getService(Layer0.class);
         Resource list = g.newResource();
         g.claim(list, L0.InstanceOf, null, type);
+        if (!elementPredicate.equals(L0.List_Element))
+               g.claim(list, L0.List_ElementPredicate, L0.List_ElementPredicate_Inverse, elementPredicate);
         createExisting(g, list, elementPredicate, elementPredicateInverse, elements);
         return list;
     }
index a1ed10e77626c56c063aecbabfaa9fd313a2c642..99ef91b7aa0040815b23a4dae559fa1ad3d7d6dd 100644 (file)
@@ -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.impl/src/org/simantics/db/impl/DebugPolicy.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/DebugPolicy.java
deleted file mode 100644 (file)
index 752991c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.simantics.db.impl;
-
-
-/**
- * @author Antti Villberg
- */
-public final class DebugPolicy {
-
-    public static final boolean  QUERY_STATE = false;
-
-    public static final boolean  PERFORM = false;
-    
-    public static final boolean  DEPENDENCIES = false;
-
-    public static final boolean  RECOMPUTE = false;
-    
-    public static final boolean  CHANGES = false;
-
-    public static final boolean  LISTENER = false;
-
-    public static final boolean  SCHEDULE = false;
-
-    public static final boolean  COLLECT = false;
-
-    public static final boolean  VERBOSE = false;
-    
-}
index 3406d670031590beb58dfee439326cb2fb738e0c..78dacb98ff4ebad6997dcc1a027de5c0b902347e 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.simantics.db.impl;
 
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.Resource;
 import org.simantics.db.impl.support.ResourceSupport;
 import org.simantics.db.service.ClusterUID;
@@ -84,7 +85,7 @@ final public class ResourceImpl implements Resource {
         StringBuilder sb = new StringBuilder(32);
         try {
             long rid = getResourceId();
-            if(DebugPolicy.VERBOSE) {
+            if(DevelopmentKeys.VERBOSE) {
                 sb.append("[id=");
                 sb.append(id);
                 sb.append(" - rid=");
@@ -111,7 +112,7 @@ final public class ResourceImpl implements Resource {
     public String toString(ClusterSupport support) {
         StringBuilder sb = new StringBuilder(32);
         long rid = getResourceId();
-        if (DebugPolicy.VERBOSE) {
+        if (DevelopmentKeys.VERBOSE) {
             sb.append("[id=");
             sb.append(id);
             sb.append(" - rid=");
index f8797b251546b47cc169024f2e5cfb994f6fc529..84dd871c07929d32d84cd5208599023928c525a5 100644 (file)
@@ -36,6 +36,7 @@ import org.simantics.databoard.binding.error.BindingConstructionException;
 import org.simantics.databoard.serialization.Serializer;
 import org.simantics.databoard.type.Datatype;
 import org.simantics.databoard.util.binary.RandomAccessBinary;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.Metadata;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -54,7 +55,6 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 import org.simantics.db.exception.NoSingleResultException;
 import org.simantics.db.exception.ResourceNotFoundException;
 import org.simantics.db.exception.ServiceException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.ResourceImpl;
 import org.simantics.db.request.DelayedWrite;
 import org.simantics.db.request.WriteOnly;
@@ -199,7 +199,7 @@ public class DelayedWriteGraph extends ReadGraphImpl implements WriteGraph, Byte
         @Override
         public String toString() {
             StringBuilder sb = new StringBuilder(32);
-            if(DebugPolicy.VERBOSE) {
+            if(DevelopmentKeys.VERBOSE) {
                 sb.append("[delayed id=");
                 sb.append(id);
                 sb.append("]");
index 79fe974642d2a71e66054fe6de5d00a60424b7bf..cffbba51c75f852e44b215747e94efafa099e296 100644 (file)
@@ -6181,11 +6181,12 @@ public class ReadGraphImpl implements AsyncReadGraph {
     @Override
     public <T> T getRelatedValue2(Resource subject, Resource relation, Object context) throws DatabaseException {
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(this, subject, relation);
-                       if(error != null) {
-                               Logger.defaultLogError(new ValidationException(error));
-                               //throw new ValidationException(error);
-                               new ValidationException(error).printStackTrace();
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(this, subject, relation);
+                               if(error != null) {
+                                       Logger.defaultLogError(new ValidationException(error));
+                                       throw new ValidationException(error);
+                               }
                        }
                }
         return getValue2(getSingleObject(subject, relation), context);
@@ -6194,12 +6195,13 @@ public class ReadGraphImpl implements AsyncReadGraph {
     @Override
     public Variant getRelatedVariantValue2(Resource subject, Resource relation, Object context) throws DatabaseException {
         if(Development.DEVELOPMENT) {
-            String error = L0Validations.checkValueType(this, subject, relation);
-            if(error != null) {
-                Logger.defaultLogError(new ValidationException(error));
-                //throw new ValidationException(error);
-                new ValidationException(error).printStackTrace();
-            }
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(this, subject, relation);
+                               if(error != null) {
+                                       Logger.defaultLogError(new ValidationException(error));
+                                       throw new ValidationException(error);
+                               }
+                       }
         }
         return getVariantValue2(getSingleObject(subject, relation), context);
     }
index bc3cf0a4f52b7e2c37fbc101ceba389b0ae54f2b..ea88d179107c920f9f10193f727907a56d39356e 100644 (file)
@@ -27,26 +27,26 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase<AsyncMultiProce
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AsyncMultiReadEntry.class);
 
-    protected AsyncMultiRead<T> request;
+    protected AsyncMultiRead<T> id;
     
     AsyncMultiReadEntry(AsyncMultiRead<T> request) {
-       this.request = request;
+       this.id = request;
     }
     
     @Override
     int makeHash() {
-       return request.hashCode();
+       return id.hashCode();
     }
     
     @Override
     public Object getOriginalRequest() {
-        return request;
+        return id;
     }
     
     @Override
     public void discard() {
        super.discard();
-       request = null;
+       id = null;
        setResult(null);
     }
     
@@ -111,9 +111,9 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase<AsyncMultiProce
                                                        except(t);
                                                }
 
-                                       }, request);
+                                       }, id);
 
-                                       request.perform(graph , proc);
+                                       id.perform(graph , proc);
 
                                        proc.get();
 
@@ -137,8 +137,8 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase<AsyncMultiProce
                        
                        @Override
                        public String toString() {
-                               if(request == null) return "DISCARDED";
-                               else return request.toString() + statusOrException;
+                               if(id == null) return "DISCARDED";
+                               else return id.toString() + statusOrException;
                        }
                
         };
@@ -182,12 +182,12 @@ final public class AsyncMultiReadEntry<T> extends CacheEntryBase<AsyncMultiProce
        
        @Override
        public String toString() {
-               if(request == null) return "DISCARDED";
-               else return request.toString() + statusOrException;
+               if(id == null) return "DISCARDED";
+               else return id.toString() + statusOrException;
        }
 
        public Object compute(ReadGraphImpl graph, AsyncMultiProcedure<T> procedure) throws DatabaseException {
-               return graph.processor.cache.performQuery(graph, request, this, procedure);
+               return graph.processor.cache.performQuery(graph, id, this, procedure);
        }
 
 }
index 972bd381f222207b2ff91d02d33b13269321913c..72582ee605802bfe32fac38d10119f6200602586 100644 (file)
  *******************************************************************************/
 package org.simantics.db.impl.query;
 
+import org.simantics.databoard.Bindings;
 import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.BlockingAsyncProcedure;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.AsyncBarrierImpl;
 import org.simantics.db.impl.graph.BarrierTracing;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.impl.query.QueryProcessor.SessionTask;
 import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.request.AsyncRead;
+import org.simantics.utils.Development;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,22 +30,25 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AsyncReadEntry.class);
 
-    protected AsyncRead<T> request;
+    protected AsyncRead<T> id;
 
     AsyncReadEntry(AsyncRead<T> request) {
-        this.request = request;
-        if (DebugPolicy.QUERY_STATE)
-            System.out.println("[QUERY STATE]: created " + this);
+        this.id = request;
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                       System.err.println("[QUERY STATE]: created " + this);
+                       }
+               }
     }
 
     @Override
     int makeHash() {
-        return request.hashCode();
+        return id.hashCode();
     }
 
     @Override
     public Object getOriginalRequest() {
-        return request;
+        return id;
     }
 
     @Override
@@ -85,9 +90,9 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
                             except(t);
                         }
 
-                    }, request);
+                    }, id);
 
-                    request.perform(graph, proc);
+                    id.perform(graph, proc);
 
                     proc.get();
 
@@ -104,17 +109,17 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
 
             @Override
             public int type() {
-                return request.getFlags();
+                return id.getFlags();
             }
 
             @Override
             public String toString() {
-                if (request == null)
+                if (id == null)
                     return "DISCARDED";
                 else if (isExcepted())
-                    return request.toString() + " " + getResult();
+                    return id.toString() + " " + getResult();
                 else
-                    return request.toString() + " " + statusOrException;
+                    return id.toString() + " " + statusOrException;
             }
 
         };
@@ -237,11 +242,11 @@ final public class AsyncReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> i
     @Override
     public String toString() {
         if (isDiscarded())
-            return "DISCARDED " + request.toString();
+            return "DISCARDED " + id.toString();
         else if (isExcepted())
-            return request.toString() + " " + getResult();
+            return id.toString() + " " + getResult();
         else
-            return request.toString() + " " + statusOrException;
+            return id.toString() + " " + statusOrException;
     }
 
     @Override
index 8489256225da47bfa52c2aa29940ffbba386e24b..1cdcbde9dd0b11733b224877c4a5a0c7cf41cbe7 100644 (file)
@@ -29,7 +29,7 @@ public abstract class CacheEntry<Procedure> {
 
     abstract void setReady();
     abstract void refute();
-    abstract void setPending();
+    abstract void setPending(QuerySupport querySupport);
     abstract void discard();
     abstract void except(Throwable t);
     abstract void clearResult(QuerySupport support);
index 7fc0432f832f2f2d3fceaca007c2d1866c12a8b8..e79f99deae1d06ab4469e1496accd8fbcacb3e97 100644 (file)
@@ -14,10 +14,12 @@ package org.simantics.db.impl.query;
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.simantics.databoard.Bindings;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.impl.procedure.InternalProcedure;
+import org.simantics.utils.Development;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,7 +87,11 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     public void discard() {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: discarded " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: discarded " + this);
+                       }
+               }
        statusOrException = DISCARDED;
     }
     
@@ -96,7 +102,11 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     final public void refute() {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: refuted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: refuted " + this);
+                       }
+               }
        statusOrException = REQUIRES_COMPUTATION;
     }
     
@@ -107,7 +117,11 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
 
     @Override
     public void except(Throwable throwable) {
-       if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: excepted " + this);
+                       }
+               }
        if(statusOrException != DISCARDED) {
                statusOrException = EXCEPTED;
                result = throwable;
@@ -131,8 +145,9 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     }
 
     @Override
-    public void setPending() {
-       statusOrException = PENDING;
+    public void setPending(QuerySupport querySupport) {
+        statusOrException = PENDING;
+        clearResult(querySupport);
     }
     
     @Override
@@ -425,8 +440,7 @@ public abstract class CacheEntryBase<Procedure> extends CacheEntry<Procedure> {
     
     @Override
     void prepareRecompute(QuerySupport querySupport) {
-               setPending();
-               clearResult(querySupport);
+        setPending(querySupport);
     }
     
     @Override
index 8661428cb6b94349a034a095bb6e33c56365dc40..66ee865a6ed3355ee7eefd0571d7739235fde231 100644 (file)
@@ -11,203 +11,246 @@ import org.simantics.utils.FileUtils;
 
 public class CodeGen {
 
-       int indent = 4;
-
-       String[] signatureR1RelationInfo = { "int r", "r", "keyR", "long", "InternalProcedure<RelationInfo>", "entry.id" };
-       String[] signatureR1Bytes = { "int r", "r", "keyR", "long", "InternalProcedure<byte[]>", "entry.id" };
-       String[] signatureR1IntSet = { "int r", "r", "keyR", "long", "InternalProcedure<IntSet>", "entry.id" };
-       String[] signatureR1IP = { "int r", "r", "keyR", "long", "IntProcedure", "entry.id" };
-       String[] signatureR2IP = { "int r1, int r2", "r1,r2", "keyR2", "long", "IntProcedure", "entry.id" };
-       String[] signatureR2TIP = { "int r1, int r2", "r1,r2", "keyR2", "long", "TripleIntProcedure", "entry.id" };
-       String[] signatureID1 = { "String id", "id", "keyID", "String", "InternalProcedure<Integer>", "entry.id" };
-       String[] signatureID2 = { "String id", "id", "keyID", "String", "InternalProcedure<TObjectIntHashMap<String>>", "entry.id" };
-       String[] signatureChildMap = { "int r", "r", "keyR", "long", "InternalProcedure<ObjectResourceIdMap<String>>", "entry.id" };
-       String[] signatureRead = { "Read<?> r", "r", "id", "long", "AsyncProcedure", "entry.request" };
-       String[] signatureAsyncRead = { "AsyncRead<?> r", "r", "id", "long", "AsyncProcedure", "entry.request" };
-       String[] signatureMultiRead = { "MultiRead<?> r", "r", "id", "long", "SyncMultiProcedure", "entry.request" };
-       String[] signatureAsyncMultiRead = { "AsyncMultiRead<?> r", "r", "id", "long", "AsyncMultiProcedure", "entry.request" };
-       String[] signatureExternalRead = { "ExternalRead<?> r", "r", "id", "long", "AsyncProcedure", "entry.request" };
-
-       private void line(StringBuilder content, String line) {
-               for(int i=0;i<indent;i++)
-                       content.append(" ");
-               content.append(line);
-               content.append("\n");
-       }
-
-    public void generateQuery(StringBuilder content, String clazz, String[] signature, boolean runnerShortcut, boolean genReturn) {
-               generateGetOrCreate(content, clazz, signature);
-               generateRemove(content, clazz, signature);
-               generateRunner(content, clazz, signature, runnerShortcut, genReturn);
-       }
-
-       public void generateRunner(StringBuilder content, String clazz, String[] signature, boolean shortcut, boolean genReturn) {
-
-               line(content, "public static " + (genReturn ? "Object" : "void") + " runner" + clazz + "(ReadGraphImpl graph, " + signature[0] + ", CacheEntry parent, ListenerBase listener, final " + signature[4] + " procedure) throws DatabaseException {");
-               line(content, "    QueryCache cache  = graph.processor.cache;");
-               if(shortcut) {
-                       line(content, "    if(parent == null && listener == null && !cache.shouldCache(graph.processor, " + signature[1] + ")) {");
-                       line(content, "        if (SINGLE) {");
-                       line(content, "            " + clazz + " e = cache.peek" + clazz + "(" + signature[1] + ");");
-                       line(content, "            if (e != null && e.isReady()) {");
-                       line(content, "                " + (genReturn ? "return " : "") + "e.performFromCache(graph, procedure);");
-                       if(!genReturn) line(content, "                return;");
-                       line(content, "            }");
-                       line(content, "        }");
-                       line(content, "        " + (genReturn ? "return " : "") + clazz + ".computeForEach(graph, " + signature[1] + ", null, procedure);");
-                       if(!genReturn) line(content, "        return;");
-                       line(content, "    }");
-               }
-               line(content, "    " + clazz + " entry = (" + clazz + ")cache.getOrCreate" + clazz + "(graph, " + signature[1] + ");");
-               line(content, "    " + signature[4] + " procedure_ = procedure != null ? procedure : emptyProcedure" + clazz + ";");
-               line(content, "    ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false);");
-               line(content, "    if(entry.isReady()) " + (genReturn ? "return " : "") + "entry.performFromCache(graph, procedure_);");
-               line(content, "    else {");
-               line(content, "      assert(entry.isPending());");
-               if(shortcut) line(content, "      " + (genReturn ? "Object result = " : "") + clazz + ".computeForEach(graph, " + signature[1] + ", entry, procedure_);");
-               else line(content, "      entry.compute(graph, procedure_);"); 
-               line(content, "      if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult());");
-               if(genReturn) line(content, "      return result;");
-               line(content, "    }");
-               line(content, "}");
-               line(content, "");
+    int indent = 4;
+
+    class GenerationInfo {
+        String p1;
+        String keyName;
+        String keyToId;
+        String procedure;
+        boolean useNeedsToBlock;
+        String entryCreationArguments;
+        GenerationInfo(String p1, String keyName, String keyToId, String p4, String procedure, String entryCreationArguments, boolean useNeedsToBlock) {
+            this.p1 = p1;
+            this.keyName = keyName;
+            this.keyToId = keyToId;
+            this.procedure = procedure;
+            this.useNeedsToBlock = useNeedsToBlock;
+            this.entryCreationArguments = entryCreationArguments;
+        }
+    }
+
+    GenerationInfo signatureR1RelationInfo = new GenerationInfo  ( "int r", "r", "keyR", "long", "InternalProcedure<RelationInfo>", "", false );
+    GenerationInfo signatureR1Bytes = new GenerationInfo  ( "int r", "r", "keyR", "long", "InternalProcedure<byte[]>", "", false );
+    GenerationInfo signatureR1IntSet = new GenerationInfo  ( "int r", "r", "keyR", "long", "InternalProcedure<IntSet>", "", false );
+    GenerationInfo signatureR1IP = new GenerationInfo  ( "int r", "r", "keyR", "long", "IntProcedure", "", false );
+    GenerationInfo signatureR2IP = new GenerationInfo  ( "int r1, int r2", "r1,r2", "keyR2", "long", "IntProcedure", "", false );
+    GenerationInfo signatureR2TIP = new GenerationInfo  ( "int r1, int r2", "r1,r2", "keyR2", "long", "TripleIntProcedure", "", false );
+    GenerationInfo signatureID1 = new GenerationInfo  ( "String id", "id", "keyID", "String", "InternalProcedure<Integer>", "", false );
+    GenerationInfo signatureID2 = new GenerationInfo  ( "String id", "id", "keyID", "String", "InternalProcedure<TObjectIntHashMap<String>>", "", false );
+    GenerationInfo signatureChildMap = new GenerationInfo  ( "int r", "r", "keyR", "long", "InternalProcedure<ObjectResourceIdMap<String>>", "", false );
+    GenerationInfo signatureRead = new GenerationInfo  ( "Read<?> r", "r", "id", "long", "AsyncProcedure", "", true );
+    GenerationInfo signatureAsyncRead = new GenerationInfo  ( "AsyncRead<?> r", "r", "id", "long", "AsyncProcedure", "", true );
+    GenerationInfo signatureMultiRead = new GenerationInfo  ( "MultiRead<?> r", "r", "id", "long", "SyncMultiProcedure", "", false );
+    GenerationInfo signatureAsyncMultiRead = new GenerationInfo  ( "AsyncMultiRead<?> r", "r", "id", "long", "AsyncMultiProcedure", "", false );
+    GenerationInfo signatureExternalRead = new GenerationInfo  ( "ExternalRead<?> r", "r", "id", "long", "AsyncProcedure", ", graph", false );
+
+    private void line(StringBuilder content, String line) {
+        for(int i=0;i<indent;i++)
+            content.append(" ");
+        content.append(line);
+        content.append("\n");
+    }
+
+    public void generateQuery(StringBuilder content, String clazz, GenerationInfo signature, boolean runnerShortcut, boolean genReturn) {
+        generateGetOrCreate(content, clazz, signature);
+        generateRemove(content, clazz, signature);
+        generateRunner(content, clazz, signature, runnerShortcut, genReturn);
+    }
+
+    public void generateRunner(StringBuilder content, String clazz, GenerationInfo signature, boolean shortcut, boolean genReturn) {
+
+        line(content, "public static " + (genReturn ? "Object" : "void") + " runner" + clazz + "(ReadGraphImpl graph, " + signature.p1 + ", CacheEntry parent, ListenerBase listener, final " + signature.procedure + " procedure" + (signature.useNeedsToBlock ? ", boolean needsToBlock" : "") + ") throws DatabaseException {");
+        line(content, "    QueryCache cache  = graph.processor.cache;");
+        if(shortcut) {
+            line(content, "    if(parent == null && listener == null && !cache.shouldCache(graph.processor, " + signature.keyName + ")) {");
+            line(content, "        if (SINGLE) {");
+            line(content, "            " + clazz + " e = cache.peek" + clazz + "(" + signature.keyName + ");");
+            line(content, "            if (e != null && e.isReady()) {");
+            line(content, "                " + (genReturn ? "return " : "") + "e.performFromCache(graph, procedure);");
+            if(!genReturn) line(content, "                return;");
+            line(content, "            }");
+            line(content, "        }");
+            line(content, "        " + (genReturn ? "return " : "") + clazz + ".computeForEach(graph, " + signature.keyName + ", null, procedure" + (signature.useNeedsToBlock ? ", needsToBlock" : "") + ");");
+            if(!genReturn) line(content, "        return;");
+            line(content, "    }");
+        }
+        if(signature.useNeedsToBlock) {
+            line(content, "    " + clazz + " entry = (" + clazz + ")cache.getOrCreate" + clazz + "(graph, " + signature.keyName + ", needsToBlock);");
+            line(content, "    if(entry == null) {");
+            line(content, "      graph.processor.schedule(new SessionTask(graph) {");
+            line(content, "        @Override");
+            line(content, "        public void run0(int thread) {");
+            line(content, "          try {");
+            line(content, "            runner" + clazz + "(graph, r, parent, listener, procedure, needsToBlock);");
+            line(content, "          } catch (DatabaseException e) {");
+            line(content, "            Logger.defaultLogError(e);");
+            line(content, "          }");
+            line(content, "        }");
+            line(content, "      });");
+            line(content, "      return null;");
+            line(content, "    }");
+        } else {
+            line(content, "    " + clazz + " entry = (" + clazz + ")cache.getOrCreate" + clazz + "(graph, " + signature.keyName + ");");
+        }
+        line(content, "    " + signature.procedure + " procedure_ = procedure != null ? procedure : emptyProcedure" + clazz + ";");
+        line(content, "    ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false);");
+        line(content, "    if(entry.isReady()) " + (genReturn ? "return " : "") + "entry.performFromCache(graph, procedure_);");
+        line(content, "    else {");
+        line(content, "      assert(entry.isPending());");
+        if(shortcut) line(content, "      " + (genReturn ? "Object result = " : "") + clazz + ".computeForEach(graph, " + signature.keyName + ", entry, procedure_" + (signature.useNeedsToBlock ? ", needsToBlock" : "") + ");");
+        else line(content, "      entry.compute(graph, procedure_);"); 
+        line(content, "      if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult());");
+        if(genReturn) line(content, "      return result;");
+        line(content, "    }");
+        line(content, "}");
+        line(content, "");
+
+        String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
+
+        line(content, "private " + clazz + " peek" + clazz + "(" + signature.p1 + ") {");
+        line(content, "    synchronized(" + lower +"Map) {");
+        line(content, "        return (" + clazz + ") " + lower + "Map.get(" + signature.keyName + ");");
+        line(content, "    }");
+        line(content, "}");
+        line(content, "");
+    }
+
+    public void generateRemove(StringBuilder content, String clazz, GenerationInfo signature) {
+
+        String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
+
+        line(content, "void remove(" + clazz + " entry) {");
+        line(content, "    synchronized(" + lower + "Map) {");
+        line(content, "        " + lower + "Map.remove(entry.id);");
+        line(content, "    }");
+        line(content, "}");
+        line(content, "");
+
+    }
+
+    public void generateGetOrCreate(StringBuilder content, String clazz, GenerationInfo signature) {
 
         String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
 
-               line(content, "private " + clazz + " peek" + clazz + "(" + signature[0] + ") {");
-               line(content, "    synchronized(" + lower +"Map) {");
-               line(content, "        return (" + clazz + ") " + lower + "Map.get(" + signature[1] + ");");
-               line(content, "    }");
-               line(content, "}");
-               line(content, "");
-       }
-
-       public void generateRemove(StringBuilder content, String clazz, String[] signature) {
-
-               String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
-
-               line(content, "void remove(" + clazz + " entry) {");
-               line(content, "    synchronized(" + lower + "Map) {");
-               line(content, "        " + lower + "Map.remove(" + signature[5] + ");");
-               line(content, "    }");
-               line(content, "}");
-               line(content, "");
-
-       }
-
-       public void generateGetOrCreate(StringBuilder content, String clazz, String[] signature) {
-
-               String lower = Character.toLowerCase(clazz.charAt(0)) + clazz.substring(1);
-
-               line(content, "" + clazz + " getOrCreate" + clazz + "(ReadGraphImpl graph, " + signature[0] + ") throws DatabaseException {");
-               line(content, "    " + clazz + " existing = null;");
-               line(content, "    synchronized(" + lower + "Map) {");
-               line(content, "        existing = (" + clazz + ")" + lower + "Map.get(" + signature[1] + ");");
-               line(content, "        if(existing == null) {");
-               line(content, "            existing = new " + clazz + "(" + signature[1] + ");");
-               line(content, "            existing.clearResult(querySupport);");
-               line(content, "            existing.setPending();");
-               line(content, "            " + lower + "Map.put(" + signature[2] + "(" + signature[1] + "), existing);");
-               line(content, "            size++;");
-               line(content, "            return existing;");
-               line(content, "        }");
-               line(content, "        if(existing.requiresComputation()) {");
-               line(content, "            existing.setPending();");
-               line(content, "            return existing;");
-               line(content, "        }");
-               line(content, "    }");
-               line(content, "    if(existing.isPending()) waitPending(graph, existing);");
-               line(content, "    return existing;");
-               line(content, "}");
-               line(content, "");
-
-       }
-
-       public void generate() {
-
-               URL classLocation = CodeGen.class.getResource(".");
-               if (classLocation != null) {
-                       if (classLocation.getProtocol().equals("file")) {
-                               try {
-                                       URL resource = new URL(classLocation, ".");
-                                       File path = new File(URLDecoder.decode(resource.getPath(), "UTF-8"));
-                                       String target = path.getAbsolutePath().replace("\\", "/");
-                                       target = target.replace("/bin/", "/src/") + "/QueryCache.java";
-                                       System.err.println("target=" + target);
-                                       File source = new File(target);
-                                       StringBuilder content = new StringBuilder();
-                                       content.append("package org.simantics.db.impl.query;\n");
-                                       content.append("\n");
-
-                                       content.append("import org.simantics.db.ObjectResourceIdMap;\n");
-                                       content.append("import org.simantics.db.RelationInfo;\n");
-                                       content.append("import org.simantics.db.common.utils.Logger;\n");
-                                       content.append("import org.simantics.db.exception.DatabaseException;\n");
-                                       content.append("import org.simantics.db.impl.graph.ReadGraphImpl;\n");
-                                       content.append("import org.simantics.db.impl.procedure.InternalProcedure;\n");
-                                       content.append("import org.simantics.db.impl.query.QueryProcessor.SessionTask;\n");
-                                       content.append("import org.simantics.db.procedure.AsyncMultiProcedure;\n");
-                                       content.append("import org.simantics.db.procedure.AsyncProcedure;\n");
-                                       content.append("import org.simantics.db.procedure.ListenerBase;\n");
-                                       content.append("import org.simantics.db.procedure.SyncMultiProcedure;\n");
-                                       content.append("import org.simantics.db.request.AsyncMultiRead;\n");
-                                       content.append("import org.simantics.db.request.AsyncRead;\n");
-                                       content.append("import org.simantics.db.request.ExternalRead;\n");
-                                       content.append("import org.simantics.db.request.MultiRead;\n");
-                                       content.append("import org.simantics.db.request.Read;\n");
-                                       content.append("\n");
-
-                                       content.append("public class QueryCache extends QueryCacheBase {\n");
-                                       content.append("\n");
-                                       
-                                       line(content, "private static final boolean SINGLE = true;");
-                                       content.append("\n");
-                                       
-                                       line(content,"public QueryCache(QuerySupport querySupport, int threads) {");
-                                       line(content,"    super(querySupport, threads);");
-                                       line(content,"}");
-                                       content.append("\n");
-
-                                       generateQuery(content, "Objects", signatureR2IP, true, false);
-                                       generateQuery(content, "Statements", signatureR2TIP, true, false);
-                                       generateQuery(content, "DirectObjects", signatureR2IP, true, false);
-                                       generateQuery(content, "RelationInfoQuery", signatureR1RelationInfo, true, false);
-                                       generateQuery(content, "URIToResource", signatureID1, true, false);
-                                       generateQuery(content, "ValueQuery", signatureR1Bytes, true, false);
-                                       generateQuery(content, "OrderedSet", signatureR1IP, true, false);
-                                       generateQuery(content, "PrincipalTypes", signatureR1IP, true, false);
-                                       generateQuery(content, "DirectPredicates", signatureR1IntSet, true, false);
-                                       generateQuery(content, "Predicates", signatureR1IntSet, true, false);
-                                       generateQuery(content, "ReadEntry", signatureRead, true, true);
-                                       generateQuery(content, "AsyncReadEntry", signatureAsyncRead, true, true);
-                                       generateQuery(content, "Types", signatureR1IntSet, true, false);
-                                       generateQuery(content, "ChildMap", signatureChildMap, true, false);
-                                       generateQuery(content, "TypeHierarchy", signatureR1IntSet, true, false);
-                                       generateQuery(content, "SuperTypes", signatureR1IntSet, true, false);
-                                       generateQuery(content, "SuperRelations", signatureR1IntSet, true, false);
-
-                                       generateQuery(content, "AssertedPredicates", signatureR1IP, false, false);
-                                       generateQuery(content, "AssertedStatements", signatureR2TIP, false, false);
-                                       generateQuery(content, "DirectSuperRelations", signatureR1IP, false, false);
-                                       generateQuery(content, "MultiReadEntry", signatureMultiRead, false, false);
-                                       generateQuery(content, "AsyncMultiReadEntry", signatureAsyncMultiRead, false, false);
-                                       generateQuery(content, "ExternalReadEntry", signatureExternalRead, false, false);
-                                       content.append("}\n");
-                                       FileUtils.writeFile(source, content.toString().getBytes());
-                               } catch (MalformedURLException e) {
-                                       e.printStackTrace();
-                               } catch (UnsupportedEncodingException e) {
-                                       e.printStackTrace();
-                               } catch (IOException e) {
-                                       e.printStackTrace();
-                               }
-                       }
-               }
-
-       }
-
-       public static void main(String[] args) {
-               new CodeGen().generate();
-       }
+        line(content, "" + clazz + " getOrCreate" + clazz + "(ReadGraphImpl graph, " + signature.p1 + (signature.useNeedsToBlock ? ", boolean needsToBlock" : "") +  ") throws DatabaseException {");
+        line(content, "    " + clazz + " existing = null;");
+        line(content, "    synchronized(" + lower + "Map) {");
+        line(content, "        existing = (" + clazz + ")" + lower + "Map.get(" + signature.keyName + ");");
+        line(content, "        if(existing == null) {");
+        line(content, "            existing = new " + clazz + "(" + signature.keyName + signature.entryCreationArguments + ");");
+        line(content, "            existing.setPending(querySupport);");
+        line(content, "            " + lower + "Map.put(" + signature.keyToId + "(" + signature.keyName + "), existing);");
+        line(content, "            size++;");
+        line(content, "            return existing;");
+        line(content, "        }");
+        line(content, "        if(existing.requiresComputation()) {");
+        line(content, "            existing.setPending(querySupport);");
+        line(content, "            return existing;");
+        line(content, "        }");
+        line(content, "    }");
+        line(content, "    if(existing.isPending()) {");
+        if(signature.useNeedsToBlock) {
+            line(content, "      if(needsToBlock)");
+            line(content, "        waitPending(graph, existing);");
+            line(content, "      else {");
+            line(content, "        return null;");
+            line(content, "      }");
+        } else {
+            line(content, "      waitPending(graph, existing);");
+        }
+        line(content, "    }");
+        line(content, "    return existing;");
+        line(content, "}");
+        line(content, "");
+
+    }
+
+    public void generate() {
+
+        URL classLocation = CodeGen.class.getResource(".");
+        if (classLocation != null) {
+            if (classLocation.getProtocol().equals("file")) {
+                try {
+                    URL resource = new URL(classLocation, ".");
+                    File path = new File(URLDecoder.decode(resource.getPath(), "UTF-8"));
+                    String target = path.getAbsolutePath().replace("\\", "/");
+                    target = target.replace("/bin/", "/src/") + "/QueryCache.java";
+                    System.err.println("target=" + target);
+                    File source = new File(target);
+                    StringBuilder content = new StringBuilder();
+                    content.append("package org.simantics.db.impl.query;\n");
+                    content.append("\n");
+
+                    content.append("import org.simantics.db.ObjectResourceIdMap;\n");
+                    content.append("import org.simantics.db.RelationInfo;\n");
+                    content.append("import org.simantics.db.common.utils.Logger;\n");
+                    content.append("import org.simantics.db.exception.DatabaseException;\n");
+                    content.append("import org.simantics.db.impl.graph.ReadGraphImpl;\n");
+                    content.append("import org.simantics.db.impl.procedure.InternalProcedure;\n");
+                    content.append("import org.simantics.db.impl.query.QueryProcessor.SessionTask;\n");
+                    content.append("import org.simantics.db.procedure.AsyncMultiProcedure;\n");
+                    content.append("import org.simantics.db.procedure.AsyncProcedure;\n");
+                    content.append("import org.simantics.db.procedure.ListenerBase;\n");
+                    content.append("import org.simantics.db.procedure.SyncMultiProcedure;\n");
+                    content.append("import org.simantics.db.request.AsyncMultiRead;\n");
+                    content.append("import org.simantics.db.request.AsyncRead;\n");
+                    content.append("import org.simantics.db.request.ExternalRead;\n");
+                    content.append("import org.simantics.db.request.MultiRead;\n");
+                    content.append("import org.simantics.db.request.Read;\n");
+                    content.append("\n");
+
+                    content.append("public class QueryCache extends QueryCacheBase {\n");
+                    content.append("\n");
+
+                    line(content, "private static final boolean SINGLE = false;");
+                    content.append("\n");
+
+                    line(content,"public QueryCache(QuerySupport querySupport, int threads) {");
+                    line(content,"    super(querySupport, threads);");
+                    line(content,"}");
+                    content.append("\n");
+
+                    generateQuery(content, "Objects", signatureR2IP, true, false);
+                    generateQuery(content, "Statements", signatureR2TIP, true, false);
+                    generateQuery(content, "DirectObjects", signatureR2IP, true, false);
+                    generateQuery(content, "RelationInfoQuery", signatureR1RelationInfo, true, false);
+                    generateQuery(content, "URIToResource", signatureID1, true, false);
+                    generateQuery(content, "ValueQuery", signatureR1Bytes, true, false);
+                    generateQuery(content, "OrderedSet", signatureR1IP, true, false);
+                    generateQuery(content, "PrincipalTypes", signatureR1IP, true, false);
+                    generateQuery(content, "DirectPredicates", signatureR1IntSet, true, false);
+                    generateQuery(content, "Predicates", signatureR1IntSet, true, false);
+                    generateQuery(content, "ReadEntry", signatureRead, true, true);
+                    generateQuery(content, "AsyncReadEntry", signatureAsyncRead, true, true);
+                    generateQuery(content, "Types", signatureR1IntSet, true, false);
+                    generateQuery(content, "ChildMap", signatureChildMap, true, false);
+                    generateQuery(content, "TypeHierarchy", signatureR1IntSet, true, false);
+                    generateQuery(content, "SuperTypes", signatureR1IntSet, true, false);
+                    generateQuery(content, "SuperRelations", signatureR1IntSet, true, false);
+
+                    generateQuery(content, "AssertedPredicates", signatureR1IP, false, false);
+                    generateQuery(content, "AssertedStatements", signatureR2TIP, false, false);
+                    generateQuery(content, "DirectSuperRelations", signatureR1IP, false, false);
+                    generateQuery(content, "MultiReadEntry", signatureMultiRead, false, false);
+                    generateQuery(content, "AsyncMultiReadEntry", signatureAsyncMultiRead, false, false);
+                    generateQuery(content, "ExternalReadEntry", signatureExternalRead, false, false);
+                    content.append("}\n");
+                    FileUtils.writeFile(source, content.toString().getBytes());
+                } catch (MalformedURLException e) {
+                    e.printStackTrace();
+                } catch (UnsupportedEncodingException e) {
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+    }
+
+    public static void main(String[] args) {
+        new CodeGen().generate();
+    }
 
 }
index 661076e8604bacd47504ed86607df88bca54eee8..556d5fc3e12b8d2df0d5e42ea2efb2221a8fb65f 100644 (file)
@@ -13,30 +13,32 @@ package org.simantics.db.impl.query;
 
 import java.util.LinkedList;
 
+import org.simantics.databoard.Bindings;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.procedure.Listener;
 import org.simantics.db.request.ExternalRead;
 import org.simantics.db.request.RequestFlags;
+import org.simantics.utils.Development;
 
 final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implements Listener<T> {
 
     final LinkedList<T> items = new LinkedList<T>();
 
-    protected ExternalRead<T> request;
+    protected ExternalRead<T> id;
     protected ReadGraphImpl graph;
     protected boolean registered = false;
 
     @Override
     int makeHash() {
-       return request.hashCode();
+       return id.hashCode();
     }
     
     @Override
     public Object getOriginalRequest() {
-        return request;
+        return id;
     }
     
     @Override
@@ -45,14 +47,14 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     
     @Override
     public void discard() {
-        request.unregistered();
-        request = null;
+        id.unregistered();
+        id = null;
         graph = null;
         super.discard();
     }
 
     @Override
-    public void setPending() {
+    public void setPending(QuerySupport querySupport) {
         //if(result != NO_RESULT) {
             //new Exception("result = " + result).printStackTrace();
         //}
@@ -62,14 +64,19 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
     
     public ExternalReadEntry(ExternalRead<T> request, ReadGraphImpl graph) {
         assert request != null;
-        this.request = request;
+        this.id = request;
         this.graph = graph;
     }
     
     @Override
     public void except(Throwable t) {
        
-        if(DebugPolicy.QUERY_STATE) System.out.println("[QUERY STATE]: excepted " + this);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.CACHE_ENTRY_STATE, Bindings.BOOLEAN)) {
+                               System.err.println("[QUERY STATE]: excepted " + this);
+                       }
+               }
+
         if(statusOrException != DISCARDED) {
             statusOrException = EXCEPTED;
             result = t;
@@ -112,7 +119,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
                                        }
                                        // Reschedule
                                        if(!items.isEmpty()) {
-                                               graph.processor.updatePrimitive(request);
+                                               graph.processor.updatePrimitive(id);
                                        }
 
                                }
@@ -131,8 +138,8 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
                        
                        @Override
                        public String toString() {
-                               if(request == null) return "DISCARDED ExternalRead";
-                               else return request.toString();
+                               if(id == null) return "DISCARDED ExternalRead";
+                               else return id.toString();
                        }
                
         };
@@ -141,8 +148,8 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
 
        @Override
        public String toString() {
-               if(request == null) return "DISCARDED ExternalRead " + System.identityHashCode(this);
-               else return request.toString() + " " + + System.identityHashCode(this);
+               if(id == null) return "DISCARDED ExternalRead " + System.identityHashCode(this);
+               else return id.toString() + " " + + System.identityHashCode(this);
        }
 
     @Override
@@ -176,11 +183,11 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
                        ReadGraphImpl queryGraph = graph.withParent(this);
 
                        if(!registered) {
-                               request.register(graph, this);
+                               id.register(graph, this);
                                registered = true;
                        }
                        
-                       queryGraph.asyncBarrier.waitBarrier(request, graph);
+                       queryGraph.asyncBarrier.waitBarrier(id, graph);
 
                } catch (Throwable t) {
 
@@ -206,7 +213,7 @@ final public class ExternalReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>
 
                synchronized(items) {
                        items.addLast(result);
-                               graph.processor.updatePrimitive(request);
+                               graph.processor.updatePrimitive(id);
                        // TODO: implement flags/logic in ExternalRead to state that all but the latest request result can be evaporated
                        // In some cases where data is produced really fast this might be necessary but currently this queueing will do.
                }
index 6b7415c9780f7a45c715068c83c4f02f1fe1fb29..77e3b8d0fc0bd592b9b85c9ea49d34b3b64bcb79 100644 (file)
@@ -29,26 +29,26 @@ public final class MultiReadEntry<T> extends CacheEntryBase<SyncMultiProcedure<T
 
     private static final Logger LOGGER = LoggerFactory.getLogger(MultiReadEntry.class);
 
-    protected MultiRead<T> request;
+    protected MultiRead<T> id;
     
     MultiReadEntry(MultiRead<T> request) {
-       this.request = request;
+       this.id = request;
     }
 
     @Override
     int makeHash() {
-       return request.hashCode();
+       return id.hashCode();
     }
     
     @Override
     public Object getOriginalRequest() {
-        return request;
+        return id;
     }
     
     @Override
     public void discard() {
        super.discard();
-       request = null;
+       id = null;
        setResult(null);
     }
     
@@ -86,7 +86,7 @@ public final class MultiReadEntry<T> extends CacheEntryBase<SyncMultiProcedure<T
                                
                                try {
 
-                                   request.perform(graph , new SyncMultiProcedure<T>() {
+                                   id.perform(graph , new SyncMultiProcedure<T>() {
 
                         @Override
                         public void execute(ReadGraph graph, T result) {
@@ -123,8 +123,8 @@ public final class MultiReadEntry<T> extends CacheEntryBase<SyncMultiProcedure<T
                        
                        @Override
                        public String toString() {
-                               if(request == null) return "DISCARDED";
-                               else return request.toString() + statusOrException;
+                               if(id == null) return "DISCARDED";
+                               else return id.toString() + statusOrException;
                        }
                
         };
@@ -202,12 +202,12 @@ public final class MultiReadEntry<T> extends CacheEntryBase<SyncMultiProcedure<T
 
        @Override
        public String toString() {
-               if(request == null) return "DISCARDED";
-               else return request.toString() + statusOrException;
+               if(id == null) return "DISCARDED";
+               else return id.toString() + statusOrException;
        }
 
        public Object compute(ReadGraphImpl graph, SyncMultiProcedure<T> procedure) throws DatabaseException {
-               return graph.processor.cache.performQuery(graph, request, this, procedure);
+               return graph.processor.cache.performQuery(graph, id, this, procedure);
        }
 
 }
index 48d5646c27eaa3aaeee3ac636f78e165d968e7c9..06882a48943e711e502d725108ee2f0e4147f213 100644 (file)
@@ -19,9 +19,8 @@ import org.simantics.db.request.Read;
 
 public class QueryCache extends QueryCacheBase {
 
-    // Using QueryChaching breaks Diagram Editor (and probably something else). 
-       private static final boolean SINGLE = false;
-    
+    private static final boolean SINGLE = false;
+
     public QueryCache(QuerySupport querySupport, int threads) {
         super(querySupport, threads);
     }
@@ -32,18 +31,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (Objects)objectsMap.get(r1,r2);
             if(existing == null) {
                 existing = new Objects(r1,r2);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 objectsMap.put(keyR2(r1,r2), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -89,18 +89,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (Statements)statementsMap.get(r1,r2);
             if(existing == null) {
                 existing = new Statements(r1,r2);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 statementsMap.put(keyR2(r1,r2), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -146,18 +147,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (DirectObjects)directObjectsMap.get(r1,r2);
             if(existing == null) {
                 existing = new DirectObjects(r1,r2);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 directObjectsMap.put(keyR2(r1,r2), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -203,18 +205,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (RelationInfoQuery)relationInfoQueryMap.get(r);
             if(existing == null) {
                 existing = new RelationInfoQuery(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 relationInfoQueryMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -260,18 +263,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (URIToResource)uRIToResourceMap.get(id);
             if(existing == null) {
                 existing = new URIToResource(id);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 uRIToResourceMap.put(keyID(id), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -317,18 +321,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (ValueQuery)valueQueryMap.get(r);
             if(existing == null) {
                 existing = new ValueQuery(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 valueQueryMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -374,18 +379,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (OrderedSet)orderedSetMap.get(r);
             if(existing == null) {
                 existing = new OrderedSet(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 orderedSetMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -431,18 +437,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (PrincipalTypes)principalTypesMap.get(r);
             if(existing == null) {
                 existing = new PrincipalTypes(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 principalTypesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -488,18 +495,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (DirectPredicates)directPredicatesMap.get(r);
             if(existing == null) {
                 existing = new DirectPredicates(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 directPredicatesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -545,18 +553,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (Predicates)predicatesMap.get(r);
             if(existing == null) {
                 existing = new Predicates(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 predicatesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -602,32 +611,33 @@ public class QueryCache extends QueryCacheBase {
             existing = (ReadEntry)readEntryMap.get(r);
             if(existing == null) {
                 existing = new ReadEntry(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 readEntryMap.put(id(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
         if(existing.isPending()) {
-            if(needsToBlock) waitPending(graph, existing);
-            else return null;
+          if(needsToBlock)
+            waitPending(graph, existing);
+          else {
+            return null;
+          }
         }
         return existing;
     }
-
     
     void remove(ReadEntry entry) {
         synchronized(readEntryMap) {
-            readEntryMap.remove(entry.request);
+            readEntryMap.remove(entry.id);
         }
     }
     
-    public static Object runnerReadEntry(ReadGraphImpl graph, Read<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, final boolean needsToBlock) throws DatabaseException {
+    public static Object runnerReadEntry(ReadGraphImpl graph, Read<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, boolean needsToBlock) throws DatabaseException {
         QueryCache cache  = graph.processor.cache;
         if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
             if (SINGLE) {
@@ -636,33 +646,32 @@ public class QueryCache extends QueryCacheBase {
                     return e.performFromCache(graph, procedure);
                 }
             }
-            return ReadEntry.computeForEach(graph, r, null, procedure);
+            return ReadEntry.computeForEach(graph, r, null, procedure, needsToBlock);
         }
         ReadEntry entry = (ReadEntry)cache.getOrCreateReadEntry(graph, r, needsToBlock);
         if(entry == null) {
-            graph.processor.schedule(new SessionTask(graph) {
-                @Override
-                public void run0(int thread) {
-                    try {
-                        runnerReadEntry(graph, r, parent, listener, procedure, needsToBlock);
-                    } catch (DatabaseException e) {
-                        Logger.defaultLogError(e);
-                    }
-                }
-            });
-            return null;
+          graph.processor.schedule(new SessionTask(graph) {
+            @Override
+            public void run0(int thread) {
+              try {
+                runnerReadEntry(graph, r, parent, listener, procedure, needsToBlock);
+              } catch (DatabaseException e) {
+                Logger.defaultLogError(e);
+              }
+            }
+          });
+          return null;
         }
         AsyncProcedure procedure_ = procedure != null ? procedure : emptyProcedureReadEntry;
         ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false);
         if(entry.isReady()) return entry.performFromCache(graph, procedure_);
         else {
           assert(entry.isPending());
-          Object result = ReadEntry.computeForEach(graph, r, entry, procedure_);
+          Object result = ReadEntry.computeForEach(graph, r, entry, procedure_, needsToBlock);
           if(listenerEntry != null) cache.primeListenerEntry(listenerEntry, entry.getResult());
           return result;
         }
     }
-
     
     private ReadEntry peekReadEntry(Read<?> r) {
         synchronized(readEntryMap) {
@@ -676,32 +685,33 @@ public class QueryCache extends QueryCacheBase {
             existing = (AsyncReadEntry)asyncReadEntryMap.get(r);
             if(existing == null) {
                 existing = new AsyncReadEntry(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 asyncReadEntryMap.put(id(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
         if(existing.isPending()) {
-            if(needsToBlock) waitPending(graph, existing);
-            else return null;
+          if(needsToBlock)
+            waitPending(graph, existing);
+          else {
+            return null;
+          }
         }
         return existing;
     }
-
     
     void remove(AsyncReadEntry entry) {
         synchronized(asyncReadEntryMap) {
-            asyncReadEntryMap.remove(entry.request);
+            asyncReadEntryMap.remove(entry.id);
         }
     }
     
-    public static Object runnerAsyncReadEntry(ReadGraphImpl graph, AsyncRead<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, final boolean needsToBlock) throws DatabaseException {
+    public static Object runnerAsyncReadEntry(ReadGraphImpl graph, AsyncRead<?> r, CacheEntry parent, ListenerBase listener, final AsyncProcedure procedure, boolean needsToBlock) throws DatabaseException {
         QueryCache cache  = graph.processor.cache;
         if(parent == null && listener == null && !cache.shouldCache(graph.processor, r)) {
             if (SINGLE) {
@@ -714,17 +724,17 @@ public class QueryCache extends QueryCacheBase {
         }
         AsyncReadEntry entry = (AsyncReadEntry)cache.getOrCreateAsyncReadEntry(graph, r, needsToBlock);
         if(entry == null) {
-            graph.processor.schedule(new SessionTask(graph) {
-                @Override
-                public void run0(int thread) {
-                    try {
-                        runnerAsyncReadEntry(graph, r, parent, listener, procedure, needsToBlock);
-                    } catch (DatabaseException e) {
-                        Logger.defaultLogError(e);
-                    }
-                }
-            });
-            return null;
+          graph.processor.schedule(new SessionTask(graph) {
+            @Override
+            public void run0(int thread) {
+              try {
+                runnerAsyncReadEntry(graph, r, parent, listener, procedure, needsToBlock);
+              } catch (DatabaseException e) {
+                Logger.defaultLogError(e);
+              }
+            }
+          });
+          return null;
         }
         AsyncProcedure procedure_ = procedure != null ? procedure : emptyProcedureAsyncReadEntry;
         ListenerEntry listenerEntry = cache.registerDependencies(graph, entry, parent, listener, procedure_, false);
@@ -736,7 +746,6 @@ public class QueryCache extends QueryCacheBase {
           return result;
         }
     }
-
     
     private AsyncReadEntry peekAsyncReadEntry(AsyncRead<?> r) {
         synchronized(asyncReadEntryMap) {
@@ -750,18 +759,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (Types)typesMap.get(r);
             if(existing == null) {
                 existing = new Types(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 typesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -807,18 +817,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (ChildMap)childMapMap.get(r);
             if(existing == null) {
                 existing = new ChildMap(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 childMapMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -864,18 +875,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (TypeHierarchy)typeHierarchyMap.get(r);
             if(existing == null) {
                 existing = new TypeHierarchy(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 typeHierarchyMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -921,18 +933,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (SuperTypes)superTypesMap.get(r);
             if(existing == null) {
                 existing = new SuperTypes(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 superTypesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -978,18 +991,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (SuperRelations)superRelationsMap.get(r);
             if(existing == null) {
                 existing = new SuperRelations(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 superRelationsMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -1035,18 +1049,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (AssertedPredicates)assertedPredicatesMap.get(r);
             if(existing == null) {
                 existing = new AssertedPredicates(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 assertedPredicatesMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -1081,18 +1096,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (AssertedStatements)assertedStatementsMap.get(r1,r2);
             if(existing == null) {
                 existing = new AssertedStatements(r1,r2);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 assertedStatementsMap.put(keyR2(r1,r2), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -1127,18 +1143,19 @@ public class QueryCache extends QueryCacheBase {
             existing = (DirectSuperRelations)directSuperRelationsMap.get(r);
             if(existing == null) {
                 existing = new DirectSuperRelations(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 directSuperRelationsMap.put(keyR(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
@@ -1173,24 +1190,25 @@ public class QueryCache extends QueryCacheBase {
             existing = (MultiReadEntry)multiReadEntryMap.get(r);
             if(existing == null) {
                 existing = new MultiReadEntry(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 multiReadEntryMap.put(id(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
     void remove(MultiReadEntry entry) {
         synchronized(multiReadEntryMap) {
-            multiReadEntryMap.remove(entry.request);
+            multiReadEntryMap.remove(entry.id);
         }
     }
     
@@ -1219,24 +1237,25 @@ public class QueryCache extends QueryCacheBase {
             existing = (AsyncMultiReadEntry)asyncMultiReadEntryMap.get(r);
             if(existing == null) {
                 existing = new AsyncMultiReadEntry(r);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 asyncMultiReadEntryMap.put(id(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
     
     void remove(AsyncMultiReadEntry entry) {
         synchronized(asyncMultiReadEntryMap) {
-            asyncMultiReadEntryMap.remove(entry.request);
+            asyncMultiReadEntryMap.remove(entry.id);
         }
     }
     
@@ -1265,25 +1284,25 @@ public class QueryCache extends QueryCacheBase {
             existing = (ExternalReadEntry)externalReadEntryMap.get(r);
             if(existing == null) {
                 existing = new ExternalReadEntry(r, graph);
-                existing.clearResult(querySupport);
-                existing.setPending();
+                existing.setPending(querySupport);
                 externalReadEntryMap.put(id(r), existing);
                 size++;
                 return existing;
             }
             if(existing.requiresComputation()) {
-                existing.setPending();
+                existing.setPending(querySupport);
                 return existing;
             }
         }
-        if(existing.isPending()) waitPending(graph, existing);
+        if(existing.isPending()) {
+          waitPending(graph, existing);
+        }
         return existing;
     }
-
     
     void remove(ExternalReadEntry entry) {
         synchronized(externalReadEntryMap) {
-            externalReadEntryMap.remove(entry.request);
+            externalReadEntryMap.remove(entry.id);
         }
     }
     
index 6abaf6b6518e7b9239dad4830aa9acadd65492c5..446e9c641406464de62e4cb484c66d02df4ca70f 100644 (file)
@@ -3,21 +3,19 @@ package org.simantics.db.impl.query;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.concurrent.Semaphore;
-import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.simantics.databoard.Bindings;
 import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.ObjectResourceIdMap;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.RelationInfo;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.impl.procedure.InternalProcedure;
-import org.simantics.db.impl.query.QueryProcessor.SessionTask;
 import org.simantics.db.procedure.AsyncMultiProcedure;
 import org.simantics.db.procedure.AsyncProcedure;
-import org.simantics.db.procedure.Listener;
 import org.simantics.db.procedure.ListenerBase;
 import org.simantics.db.procedure.Procedure;
 import org.simantics.db.procedure.SyncMultiProcedure;
@@ -26,6 +24,7 @@ import org.simantics.db.request.AsyncRead;
 import org.simantics.db.request.ExternalRead;
 import org.simantics.db.request.MultiRead;
 import org.simantics.db.request.Read;
+import org.simantics.utils.Development;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.map.hash.TObjectIntHashMap;
@@ -328,7 +327,11 @@ public class QueryCacheBase {
                        } catch (DatabaseException e) {
                                Logger.defaultLogError(e);
                        }
-                       if(DebugPolicy.DEPENDENCIES) System.out.println(child + " -> " + parent);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, Bindings.BOOLEAN)) {
+                                       System.err.println(child + " -> " + parent);
+                               }
+                       }
                }
 
                if (listener != null) {
@@ -376,9 +379,11 @@ public class QueryCacheBase {
                        list.add(result);
                }
 
-               if(DebugPolicy.LISTENER) {
-                       new Exception().printStackTrace();
-                       System.out.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                               new Exception().printStackTrace();
+                               System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure);
+                       }
                }
 
                return result;
index 84273b81d63cf6921be763840b2c0cae172ba934..0efa49f56b7cfa3a03617669cf5ad892ef002d18 100644 (file)
@@ -6,9 +6,10 @@ import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.simantics.databoard.Bindings;
 import org.simantics.databoard.util.IdentityHashSet;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.common.exception.DebugException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.query.QueryProcessor.QueryCollectorSupport;
 import org.simantics.utils.Development;
 
@@ -28,21 +29,29 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
        private boolean findCollectables(CacheEntry<?> entry, Map<CacheEntry, Boolean> collectables, ArrayList<CacheEntry> result) {
 
                if (entry.isDiscarded()) {
-                       if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE)
-                               System.out.println("GC: discarded entry " + entry);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("GC: discarded entry " + entry);
+                               }
+                       }
                        return true;
                }
 
                if (entry.isPending()) {
-                       if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE)
-                               System.out.println("GC: pending entry " + entry + " was not collected.");
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("GC: pending entry " + entry + " was not collected.");
+                               }
+                       }
                        collectables.remove(entry);
                        return false;
                }
 
                if (this.queryProcessor.hasListenerAfterDisposing(entry)) {
-                       if (DebugPolicy.COLLECT && DebugPolicy.VERBOSE) {
-                               System.out.println("GC: listened entry " + entry + " was not collected. Entry=" + entry);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("GC: listened entry " + entry + " was not collected. Entry=" + entry);
+                               }
                        }
                        collectables.remove(entry);
                        return false;
@@ -60,8 +69,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
                        }
 
                        if(!parentIsCollectable) {
-                               if(DebugPolicy.COLLECT && DebugPolicy.VERBOSE)
-                                       System.out.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected.");
+                               if (Development.DEVELOPMENT) {
+                                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                               System.err.println("GC: due to bound parent " + parent + " the entry + " + entry + " was not collected.");
+                                       }
+                               }
                                collectables.remove(entry);
                                return false;
                        }
@@ -109,8 +121,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
                // Compute amount of free queries
                int freeCount = collectables.size();
 
-               if(DebugPolicy.COLLECT)
-                       System.out.println("collector found " + freeCount + " free queries.");
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                               System.err.println("collector found " + freeCount + " free queries.");
+                       }
+               }
 
                lastKnownFixedSize = currentSize - freeCount;
 
@@ -119,8 +134,13 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
 
                int target = freeCount - maxNumberOfCollectableQueries/2;
 
-               if(DebugPolicy.COLLECT)
-                       System.out.println("collector removes " + target + " free queries.");
+               
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                               System.err.println("collector found " + freeCount + " free queries.");
+                               System.err.println("collector removes " + target + " free queries.");
+                       }
+               }
 
                for(CacheEntry entry : collectables) {
                        if(queryProcessor.removeQuery(entry))
@@ -139,8 +159,11 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
                        removals.clear();
                }
 
-               if(DebugPolicy.COLLECT) {
-                       System.out.println("collect found " + freeCount + " collectable entries.");
+               
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                               System.err.println("collect found " + freeCount + " collectable entries.");
+                       }
                }
 
                return;
@@ -152,24 +175,34 @@ class QueryCollectorImpl2 implements QueryProcessor.QueryCollector {
 
                try {
 
-                       int current = support.calculateCurrentSize();
 
-                       if(DebugPolicy.COLLECT)
-                               new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace();
+                       int current = support.calculateCurrentSize();
 
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       new DebugException("checking the need for collecting queries (current=" + current + " , lastKnownFixedSize=" + lastKnownFixedSize + " max free=" + 0 + ")").printStackTrace();
+                               }
+                       }
+                       
                        queryProcessor.cache.collecting = true;
 
                        long start = System.nanoTime();
 
                        doCollect(current, 0);
 
-                       if(DebugPolicy.COLLECT)
-                               System.out.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ").");
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("collect finished with " + support.calculateCurrentSize() + " entries (lastKnownFixedSize=" + lastKnownFixedSize + ").");
+                               }
+                       }
 
                        long duration = System.nanoTime() - start;
 
-                       if(DebugPolicy.COLLECT)
-                               System.err.println("Collect took " + 1e-9*duration + "s.");
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYCOLLECTOR, Bindings.BOOLEAN)) {
+                                       System.err.println("Collect took " + 1e-9*duration + "s.");
+                               }
+                       }
 
                } catch (Throwable t) {
                        t.printStackTrace();
index 6db4726ac4de7eb859327b873f17dfdc6cddfaed..c2b21444fd17157753d2cfc303bd8b4932a488fa 100644 (file)
@@ -131,7 +131,7 @@ abstract public class QueryIdentityHash extends THash {
         }
 
         @Override
-        public void setPending() {
+        public void setPending(QuerySupport querySupport) {
             // TODO Auto-generated method stub
             
         }
index 5a37257e2531c051c39de0bea04af271e1adccce..9b54d15f6996fbf708a5fce9fc5ea00fd467e0ba 100644 (file)
@@ -49,7 +49,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 import org.simantics.db.exception.NoInverseException;
 import org.simantics.db.exception.ResourceNotFoundException;
-import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.ResourceImpl;
 import org.simantics.db.impl.graph.BarrierTracing;
 import org.simantics.db.impl.graph.ReadGraphImpl;
@@ -713,7 +712,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        } catch (DatabaseException e) {
                                Logger.defaultLogError(e);
                        }
-                       if(DebugPolicy.DEPENDENCIES) System.out.println(child + " -> " + parent);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, Bindings.BOOLEAN)) {
+                                       System.out.println(child + " -> " + parent);
+                               }
+                       }
                }
 
                if (listener != null) {
@@ -963,9 +966,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        list.add(result);
                }
 
-               if(DebugPolicy.LISTENER) {
-                       new Exception().printStackTrace();
-                       System.out.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                               new Exception().printStackTrace();
+                               System.err.println("addListener -> " + list.size() + " " + entry + " " + base + " " + procedure);
+                       }
                }
 
                return result;
@@ -974,7 +979,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
        private void scheduleListener(ListenerEntry entry) {
                assert (entry != null);
-               if(DebugPolicy.LISTENER) System.out.println("Scheduled " + entry.procedure);
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                               System.err.println("Scheduled " + entry.procedure);
+                       }
+               }
                scheduledListeners.add(entry);
        }
 
@@ -1257,11 +1266,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                for(CacheEntry entry : workarea.keySet()) {
                        Class<?> clazz = entry.getClass();
-                       if(entry instanceof ReadEntry) clazz = ((ReadEntry)entry).request.getClass(); 
-                       else if(entry instanceof MultiReadEntry) clazz = ((MultiReadEntry)entry).request.getClass(); 
-                       else if(entry instanceof AsyncReadEntry) clazz = ((AsyncReadEntry)entry).request.getClass(); 
-                       else if(entry instanceof AsyncMultiReadEntry) clazz = ((AsyncMultiReadEntry)entry).request.getClass(); 
-                       else if(entry instanceof ExternalReadEntry) clazz = ((ExternalReadEntry)entry).request.getClass(); 
+                       if(entry instanceof ReadEntry) clazz = ((ReadEntry)entry).id.getClass(); 
+                       else if(entry instanceof MultiReadEntry) clazz = ((MultiReadEntry)entry).id.getClass(); 
+                       else if(entry instanceof AsyncReadEntry) clazz = ((AsyncReadEntry)entry).id.getClass(); 
+                       else if(entry instanceof AsyncMultiReadEntry) clazz = ((AsyncMultiReadEntry)entry).id.getClass(); 
+                       else if(entry instanceof ExternalReadEntry) clazz = ((ExternalReadEntry)entry).id.getClass(); 
                        Integer c = counts.get(clazz);
                        if(c == null) counts.put(clazz, -1);
                        else counts.put(clazz, c-1);
@@ -1426,8 +1435,6 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                CacheEntry entry = e.entry;
 
-               //System.err.println("updateQuery " + entry);
-               
                /*
                 * If the dependency graph forms a DAG, some entries are inserted in the
                 * todo list many times. They only need to be processed once though.
@@ -1435,32 +1442,32 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                if (entry.isDiscarded()) {
                        if (Development.DEVELOPMENT) {
                                if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                                       System.out.print("D");
+                                       System.err.print("D");
                                        for (int i = 0; i < e.indent; i++)
-                                               System.out.print(" ");
-                                       System.out.println(entry.getQuery());
+                                               System.err.print(" ");
+                                       System.err.println(entry.getQuery());
                                }
                        }
 //                     System.err.println(" => DISCARDED");
                        return false;
                }
 
-               if (entry.isRefuted()) {
-                       if (Development.DEVELOPMENT) {
-                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                                       System.out.print("R");
-                                       for (int i = 0; i < e.indent; i++)
-                                               System.out.print(" ");
-                                       System.out.println(entry.getQuery());
-                               }
-                       }
-                       return false;
-               }
+//             if (entry.isRefuted()) {
+//                     if (Development.DEVELOPMENT) {
+//                             if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
+//                                     System.err.print("R");
+//                                     for (int i = 0; i < e.indent; i++)
+//                                             System.err.print(" ");
+//                                     System.err.println(entry.getQuery());
+//                             }
+//                     }
+//                     return false;
+//             }
 
                if (entry.isExcepted()) {
                        if (Development.DEVELOPMENT) {
                                if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                                       System.out.print("E");
+                                       System.err.print("E");
                                }
                        }
                }
@@ -1468,7 +1475,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                if (entry.isPending()) {
                        if (Development.DEVELOPMENT) {
                                if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                                       System.out.print("P");
+                                       System.err.print("P");
                                }
                        }
                }
@@ -1477,10 +1484,10 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                if (Development.DEVELOPMENT) {
                        if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                               System.out.print("U ");
+                               System.err.print("U ");
                                for (int i = 0; i < e.indent; i++)
-                                       System.out.print(" ");
-                               System.out.print(entry.getQuery());
+                                       System.err.print(" ");
+                               System.err.print(entry.getQuery());
                        }
                }
 
@@ -1492,9 +1499,9 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                if (Development.DEVELOPMENT) {
                        if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
                                if(hasListener(entry)) {
-                                       System.out.println(" (L)");
+                                       System.err.println(" (L)");
                                } else {
-                                       System.out.println("");
+                                       System.err.println("");
                                }
                        }
                }
@@ -1616,7 +1623,11 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                        Query query = entry.getQuery();
 
-                       if(DebugPolicy.RECOMPUTE) System.out.println("R " + query);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_RECOMPUTE, Bindings.BOOLEAN)) {
+                                       System.err.println("R " + query);
+                               }
+                       }
 
                        entry.prepareRecompute(querySupport);
                        
@@ -1629,10 +1640,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        Object newValue = entry.getResult();
 
                        if (ListenerEntry.NO_VALUE == oldValue) {
-                               if(DebugPolicy.CHANGES) {
-                                       System.out.println("C " + query);
-                                       System.out.println("- " + oldValue);
-                                       System.out.println("- " + newValue);
+                               if (Development.DEVELOPMENT) {
+                                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) {
+                                               System.out.println("C " + query);
+                                               System.out.println("- " + oldValue);
+                                               System.out.println("- " + newValue);
+                                       }
                                }
                                return newValue;
                        }
@@ -1648,10 +1661,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        } else
                                changed = (oldValue != null);
 
-                       if(DebugPolicy.CHANGES && changed) {
-                               System.out.println("C " + query);
-                               System.out.println("- " + oldValue);
-                               System.out.println("- " + newValue);
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) {
+                                       System.err.println("C " + query);
+                                       System.err.println("- " + oldValue);
+                                       System.err.println("- " + newValue);
+                               }
                        }
 
                        return changed ? newValue : ListenerEntry.NOT_CHANGED;
@@ -1696,7 +1711,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                                for (ListenerEntry listenerEntry : entries) {
 
                                        if (pruneListener(listenerEntry)) {
-                                               if(DebugPolicy.LISTENER) System.out.println("Pruned " + listenerEntry.procedure);
+                                               if (Development.DEVELOPMENT) {
+                                                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                                                               new Exception().printStackTrace();
+                                                               System.err.println("Pruned " + listenerEntry.procedure);
+                                                       }
+                                               }
                                                continue;
                                        }
 
@@ -1706,8 +1726,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                                        Object newValue = compareTo(graph, entry, listenerEntry.getLastKnown());
 
                                        if (newValue != ListenerEntry.NOT_CHANGED) {
-                                               if(DebugPolicy.LISTENER)
-                                                       System.out.println("Add to schedule " + listenerEntry.procedure + " with " + newValue);
+                                               if (Development.DEVELOPMENT) {
+                                                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                                                               new Exception().printStackTrace();
+                                                               System.err.println("Add to schedule " + listenerEntry.procedure + " with " + newValue);
+                                                       }
+                                               }
                                                schedule.add(listenerEntry);
                                                listenerEntry.setLastKnown(entry.getResult());
                                        }
@@ -1716,11 +1740,17 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                                for(ListenerEntry listenerEntry : schedule) {
                                        final CacheEntry entry = listenerEntry.entry;
-                                       if(DebugPolicy.LISTENER)
-                                               System.out.println("Firing " + listenerEntry.procedure);
+                                       if (Development.DEVELOPMENT) {
+                                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                                                       System.err.println("Firing " + listenerEntry.procedure);
+                                               }
+                                       }
                                        try {
-                                               if(DebugPolicy.LISTENER)
-                                                       System.out.println("Firing " + listenerEntry.procedure + " for " + listenerEntry.entry);
+                                               if (Development.DEVELOPMENT) {
+                                                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, Bindings.BOOLEAN)) {
+                                                               System.err.println("Firing " + listenerEntry.procedure + " for " + listenerEntry.entry);
+                                                       }
+                                               }
                                                entry.performFromCache(graph, listenerEntry.procedure);
                                        } catch (Throwable t) {
                                                t.printStackTrace();
@@ -1821,6 +1851,22 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
        private Object primitiveUpdateLock = new Object();
        private THashSet scheduledPrimitiveUpdates = new THashSet();
 
+       private ArrayList<CacheEntry> refutations = new ArrayList<>();
+       
+       private void markForUpdate(ReadGraphImpl graph, CacheEntry e) {
+               e.refute();
+               refutations.add(e);
+       }
+
+       private void updateRefutations(ReadGraphImpl graph) {
+               
+               for(CacheEntry e : refutations)
+                       update(graph, e);
+               
+               refutations.clear();
+               
+       }
+       
        public void performDirtyUpdates(final ReadGraphImpl graph) {
 
                cache.dirty = false;
@@ -1840,28 +1886,37 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        final int subject = (int)(arg0 >>> 32);
                        final int predicate = (int)(arg0 & 0xffffffff);
 
-                       for(Objects o : QueryCache.entriesObjects(QueryProcessor.this, subject)) update(graph, o);
-                       for(DirectObjects o : QueryCache.entriesDirectObjects(QueryProcessor.this, subject)) update(graph, o);
-                       for(Statements o : QueryCache.entriesStatements(QueryProcessor.this, subject)) update(graph, o);
+                       for(Objects o : QueryCache.entriesObjects(QueryProcessor.this, subject)) markForUpdate(graph, o);
+                       for(DirectObjects o : QueryCache.entriesDirectObjects(QueryProcessor.this, subject)) markForUpdate(graph, o);
+                       for(Statements o : QueryCache.entriesStatements(QueryProcessor.this, subject)) markForUpdate(graph, o);
 
                        if(predicate == instanceOf || predicate == inherits || predicate == subrelationOf) {
                                PrincipalTypes principalTypes = QueryCache.entryPrincipalTypes(QueryProcessor.this, subject);
-                               if(principalTypes != null) update(graph, principalTypes);
+                               if(principalTypes != null) markForUpdate(graph, principalTypes);
                                Types types = QueryCache.entryTypes(QueryProcessor.this, subject);
-                               if(types != null) update(graph, types);
+                               if(types != null) markForUpdate(graph, types);
                        }
 
                        if(predicate == subrelationOf) {
                                SuperRelations superRelations = SuperRelations.entry(QueryProcessor.this, subject);
-                               if(superRelations != null) update(graph, superRelations);
+                               if(superRelations != null) markForUpdate(graph, superRelations);
                        }
 
                        DirectPredicates dp = QueryCache.entryDirectPredicates(QueryProcessor.this, subject);
-                       if(dp != null) update(graph, dp);
+                       if(dp != null) markForUpdate(graph, dp);
                        OrderedSet os = QueryCache.entryOrderedSet(QueryProcessor.this, predicate);
-                       if(os != null) update(graph, os);
+                       if(os != null) markForUpdate(graph, os);
 
+                       updateRefutations(graph);
+                       
                        scheduledObjectUpdates.clear();
+
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
+                                       System.err.println("== Query update ends ==");
+                               }
+                       }
+
                        return;
 
                }
@@ -1872,9 +1927,18 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        int arg0 = scheduledValueUpdates.getFirst();
 
                        ValueQuery valueQuery = QueryCache.entryValueQuery(QueryProcessor.this, arg0);
-                       if(valueQuery != null) update(graph, valueQuery);
+                       if(valueQuery != null) markForUpdate(graph, valueQuery);
+
+                       updateRefutations(graph);
 
                        scheduledValueUpdates.clear();
+
+                       if (Development.DEVELOPMENT) {
+                               if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
+                                       System.err.println("== Query update ends ==");
+                               }
+                       }
+                       
                        return;
 
                }
@@ -1888,30 +1952,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        scheduledPrimitiveUpdates = new THashSet();
                }
 
-               primitiveUpdates.forEach(new TObjectProcedure() {
-
-                       @Override
-                       public boolean execute(Object arg0) {
-
-                               ExternalReadEntry query = (ExternalReadEntry)cache.externalReadEntryMap.get(arg0);
-                               if (query != null) {
-                                       boolean listening = update(graph, query);
-                                       if (!listening && !query.hasParents()) {
-                                               cache.externalReadEntryMap.remove(arg0);
-                                               query.discard();
-                                       }
-                               }
-                               return true;
-                       }
-
-               });
-
                scheduledValueUpdates.forEach(new TIntProcedure() {
 
                        @Override
                        public boolean execute(int arg0) {
                                ValueQuery valueQuery = QueryCache.entryValueQuery(QueryProcessor.this, arg0);
-                               if(valueQuery != null) update(graph, valueQuery);
+                               if(valueQuery != null) markForUpdate(graph, valueQuery);
                                return true;
                        }
 
@@ -1923,15 +1969,15 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        public boolean execute(int resource) {
                                
                                ValueQuery valueQuery = QueryCache.entryValueQuery(QueryProcessor.this, resource);
-                               if(valueQuery != null) update(graph, valueQuery);
+                               if(valueQuery != null) markForUpdate(graph, valueQuery);
                                
                                PrincipalTypes principalTypes = QueryCache.entryPrincipalTypes(QueryProcessor.this, resource);
-                               if(principalTypes != null) update(graph, principalTypes);
+                               if(principalTypes != null) markForUpdate(graph, principalTypes);
                                Types types = QueryCache.entryTypes(QueryProcessor.this, resource);
-                               if(types != null) update(graph, types);
+                               if(types != null) markForUpdate(graph, types);
 
                                SuperRelations superRelations = SuperRelations.entry(QueryProcessor.this, resource);
-                               if(superRelations != null) update(graph, superRelations);
+                               if(superRelations != null) markForUpdate(graph, superRelations);
 
                                predicates.add(resource);
                                
@@ -1950,14 +1996,14 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                                if(predicate == instanceOf || predicate == inherits || predicate == subrelationOf) {
                                        PrincipalTypes principalTypes = QueryCache.entryPrincipalTypes(QueryProcessor.this, subject);
-                                       if(principalTypes != null) update(graph, principalTypes);
+                                       if(principalTypes != null) markForUpdate(graph, principalTypes);
                                        Types types = QueryCache.entryTypes(QueryProcessor.this, subject);
-                                       if(types != null) update(graph, types);
+                                       if(types != null) markForUpdate(graph, types);
                                }
 
                                if(predicate == subrelationOf) {
                                        SuperRelations superRelations = SuperRelations.entry(QueryProcessor.this, subject);
-                                       if(superRelations != null) update(graph, superRelations);
+                                       if(superRelations != null) markForUpdate(graph, superRelations);
                                }
 
                                predicates.add(subject);
@@ -1974,12 +2020,12 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        @Override
                        public boolean execute(final int subject) {
 
-                               for(Objects o : QueryCache.entriesObjects(QueryProcessor.this, subject)) update(graph, o);
-                               for(DirectObjects o : QueryCache.entriesDirectObjects(QueryProcessor.this, subject)) update(graph, o);
-                               for(Statements o : QueryCache.entriesStatements(QueryProcessor.this, subject)) update(graph, o);
+                               for(Objects o : QueryCache.entriesObjects(QueryProcessor.this, subject)) markForUpdate(graph, o);
+                               for(DirectObjects o : QueryCache.entriesDirectObjects(QueryProcessor.this, subject)) markForUpdate(graph, o);
+                               for(Statements o : QueryCache.entriesStatements(QueryProcessor.this, subject)) markForUpdate(graph, o);
 
                                DirectPredicates entry = QueryCache.entryDirectPredicates(QueryProcessor.this, subject);
-                               if(entry != null) update(graph, entry);
+                               if(entry != null) markForUpdate(graph, entry);
 
                                return true;
 
@@ -1993,7 +2039,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
                        public boolean execute(int orderedSet) {
 
                                OrderedSet entry = QueryCache.entryOrderedSet(QueryProcessor.this, orderedSet);
-                               if(entry != null) update(graph, entry);
+                               if(entry != null) markForUpdate(graph, entry);
 
                                return true;
 
@@ -2001,21 +2047,35 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
 
                });
 
-               //              for (Integer subject : predicates) {
-               //                      DirectPredicates entry = DirectPredicates.entry(QueryProcessor.this, subject);
-               //                      if(entry != null) update(graph, entry);
-               //              }
+               updateRefutations(graph);
+
+               primitiveUpdates.forEach(new TObjectProcedure() {
 
+                       @Override
+                       public boolean execute(Object arg0) {
 
-               if (Development.DEVELOPMENT) {
-                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
-                               System.err.println("== Query update ends ==");
+                               ExternalReadEntry query = (ExternalReadEntry)cache.externalReadEntryMap.get(arg0);
+                               if (query != null) {
+                                       boolean listening = update(graph, query);
+                                       if (!listening && !query.hasParents()) {
+                                               cache.externalReadEntryMap.remove(arg0);
+                                               query.discard();
+                                       }
+                               }
+                               return true;
                        }
-               }
 
+               });
+               
                scheduledValueUpdates.clear();
                scheduledObjectUpdates.clear();
                scheduledInvalidates.clear();
+               
+               if (Development.DEVELOPMENT) {
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, Bindings.BOOLEAN)) {
+                               System.err.println("== Query update ends ==");
+                       }
+               }
 
        }
 
index 1ceca45a5a0cec7371f632941a13b3c1610fc60a..72f132288bf79990c5bf56ce591463993ccd8acd 100644 (file)
@@ -25,20 +25,20 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ReadEntry.class);
 
-    protected Read<T> request;
+    protected Read<T> id;
 
     public ReadEntry(Read<T> request) {
-        this.request = request;
+        this.id = request;
     }
 
     @Override
     int makeHash() {
-        return request.hashCode();
+        return id.hashCode();
     }
 
     @Override
     public Object getOriginalRequest() {
-        return request;
+        return id;
     }
 
     @Override
@@ -57,7 +57,7 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
                 try {
 
-                    T result = request.perform(graph);
+                    T result = id.perform(graph);
                     setResult(result);
                     setReady();
 
@@ -76,8 +76,8 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
             @Override
             public int type() {
-                if (request instanceof ReadExt) {
-                    return ((ReadExt) request).getType();
+                if (id instanceof ReadExt) {
+                    return ((ReadExt) id).getType();
                 } else {
                     return RequestFlags.INVALIDATE;
                 }
@@ -85,10 +85,10 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
             @Override
             public String toString() {
-                if (request == null)
+                if (id == null)
                     return "DISCARDED";
                 else
-                    return request.toString() + statusOrException;
+                    return id.toString() + statusOrException;
             }
 
         };
@@ -96,7 +96,7 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
     }
 
     public static <T> T computeForEach(ReadGraphImpl graph, Read<T> request, ReadEntry<T> entry,
-            AsyncProcedure<T> procedure_) throws DatabaseException {
+            AsyncProcedure<T> procedure_, boolean needsToBlock) throws DatabaseException {
 
         AsyncProcedure<T> procedure = entry != null ? entry : procedure_;
 
@@ -181,10 +181,10 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
     @Override
     public String toString() {
-        if (request == null)
+        if (id == null)
             return "DISCARDED";
         else
-            return request.toString() + " - " + statusOrException;
+            return id.toString() + " - " + statusOrException;
     }
 
     public Object get(ReadGraphImpl graph, AsyncProcedure<T> procedure) throws DatabaseException {
@@ -196,8 +196,8 @@ public final class ReadEntry<T> extends CacheEntryBase<AsyncProcedure<T>> implem
 
     @Override
     boolean isImmutable(ReadGraphImpl graph) throws DatabaseException {
-        if (request instanceof ReadExt) {
-            return ((ReadExt) request).isImmutable(graph);
+        if (id instanceof ReadExt) {
+            return ((ReadExt) id).isImmutable(graph);
         }
         return false;
     }
index 0aabf0b350e2c507f054766834058a560dc78fbf..11a3ff235c889257472f54e7d60e3af240b13f9f 100644 (file)
        </target>
 
        <target interface="org.simantics.db.layer0.adapter.ActionFactory">
-               <baseType uri="http://www.simantics.org/Action-0.0/Action" />
+               <baseType uri="http://www.simantics.org/Layer0-0.0/Action" />
+               <type uri="http://www.simantics.org/Layer0-0.0/SCLAction"
+                       class="org.simantics.db.layer0.scl.SCLAction">
+                       <graph/>
+                       <this/>
+               </type>
        </target>
 
        <target interface="org.simantics.db.layer0.migration.MigrationStep">
index f686835b49d03a38b07eba041fc387dddc0cc326..edf9665deb468a4671d1e4d1f19a3d3bb6163400 100644 (file)
@@ -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 (file)
index 0000000..0b034a1
--- /dev/null
@@ -0,0 +1,9 @@
+include "Simantics/DB"
+include "Simantics/Issue"
+
+importJava "org.simantics.db.layer0.function.All" where
+  uriValidator :: Resource -> <ReadGraph> [Issue]
+  valueValidator :: Resource -> <ReadGraph> [Issue]
+  relationValidator :: Resource -> <ReadGraph> [Issue]
+  propertyValidator :: Resource -> <ReadGraph> [Issue]
+  clusterValidator :: Resource -> <ReadGraph> [Issue]
\ No newline at end of file
index 8ae309e6825c9d01af3ded4c754db378a42d55e9..d30be8ffcd21fc9f8ff3dae4a5713e5328270b31 100644 (file)
 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 <code>null</code> 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.
-     * 
-     * <p>
-     * The method always returns a non-null Session or produces an
-     * IllegalStateException if a Session was not attainable.
-     * </p>
-     * 
-     * @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
-     * <code>null</code> if there is no current Session available.
-     * 
-     * @see #getSession()
-     * @return the Session bound to the currently active context or
-     *         <code>null</code>
-     */
-    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> T sync(ReadInterface<T> r) throws DatabaseException {
-       return getSession().sync(r);
-    }
-    
-    public static <T> T sync(WriteInterface<T> 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/scl/SCLAction.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/SCLAction.java
new file mode 100644 (file)
index 0000000..b2225f7
--- /dev/null
@@ -0,0 +1,73 @@
+package org.simantics.db.layer0.scl;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.db.layer0.internal.SimanticsInternal;
+import org.simantics.db.layer0.util.DatabaseExceptionUtils;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.layer0.Layer0;
+import org.simantics.scl.runtime.function.Function1;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SCLAction implements ActionFactory {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLAction.class);
+
+    private final Resource rule;
+
+    public SCLAction(ReadGraph graph, Resource rule) throws DatabaseException {
+        this.rule = rule;
+    }
+
+    static class RuleFunctionRequest extends ResourceRead<Function1<Resource, Object>> {
+
+        protected RuleFunctionRequest(Resource rule) {
+            super(rule);
+        }
+
+        @Override
+        public Function1<Resource, Object> perform(ReadGraph graph) throws DatabaseException {
+            Variable ruleVariable = Variables.getVariable(graph, resource);
+            Layer0 L0 = Layer0.getInstance(graph);
+            return ruleVariable.getPossiblePropertyValue(graph, L0.SCLAction_action);
+        }
+
+    }
+
+    static class SCLActionRunnable implements Runnable {
+
+        public final Resource rule;
+        public final Resource target;
+
+        public SCLActionRunnable(Resource rule, Resource target) {
+            this.rule = rule;
+            this.target = target;
+        }
+
+        @Override
+        public void run() {
+            Session s = SimanticsInternal.getSession();
+            Resource resource = (Resource) target;
+            s.markUndoPoint();
+            try {
+                Function1<Resource, Object> function = s.syncRequest(new RuleFunctionRequest(rule));
+                function.apply(resource);
+            } catch (DatabaseException e) {
+                LOGGER.error("Error while executing action " + DatabaseExceptionUtils.showResource(s, resource), e);
+            }
+        }
+
+    }
+
+    @Override
+    public Runnable create(final Object target) {
+        return new SCLActionRunnable(rule, (Resource) target);
+    }
+
+}
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DatabaseExceptionUtils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DatabaseExceptionUtils.java
new file mode 100644 (file)
index 0000000..2368713
--- /dev/null
@@ -0,0 +1,36 @@
+package org.simantics.db.layer0.util;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.UniqueRead;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.internal.SimanticsInternal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DatabaseExceptionUtils {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseExceptionUtils.class);
+
+    public static String showResource(Resource resource) {
+        return showResource(SimanticsInternal.getSession(), resource);
+    }
+
+    public static String showResource(RequestProcessor processor, Resource resource) {
+        try {
+            return processor.syncRequest(new UniqueRead<String>() {
+
+                @Override
+                public String perform(ReadGraph graph) throws DatabaseException {
+                    return NameUtils.getURIOrSafeNameInternal(graph, resource);
+                }
+            });
+        } catch (DatabaseException e) {
+            LOGGER.error("Unknown error while evaluating debug name for a resource " + resource, e);
+            return resource.toString();
+        }
+    }
+
+}
index 62c7093da11e999d7e22b60a17ccb1221088fe18..610c8c8bd42d8735868cf1f80e4603ae5e63b7d8 100644 (file)
@@ -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 {
index 9f6b8fe530799439bcad7f3d9fab82319fc2733a..17fbf1e7c8cb562a41bfc387b5b46b4478d48e36 100644 (file)
@@ -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&ouml;
  * @author Antti Villberg
  */
-public class RuntimeEnvironmentRequest extends UnaryRead<Resource, RuntimeEnvironment> {
+@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<RuntimeEnvironment> callback;
-
-        UpdateListenerImpl(EnvironmentSpecification environmentSpecification, Listener<RuntimeEnvironment> 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<RuntimeEnvironment> 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<RuntimeEnvironment>() {
-                        @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<String, RuntimeEnvironment>(mainModuleUri) {
-
-            UpdateListenerImpl sclListener;
-
-            @Override
-            public void register(ReadGraph graph, Listener<RuntimeEnvironment> 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();
-    }
-
 }
index 673eeaee5847e0bbc2c9dfba59f0038cc2143e0d..47c829cd86443ae0d04bfaf5803da028dabbc5d7 100644 (file)
@@ -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<Issue> validateConstraintsForDomain(ReadGraph graph, Resource r) throws DatabaseException {
+    public static List<Issue> validateConstraintsForDomain(ReadGraph graph, Resource r) throws DatabaseException {
         Set<Issue> result = null;
 
         DomainProcessor3 dp = ModelTransferableGraphSourceRequest.getDomainOnly(graph, null, r);
@@ -75,7 +76,7 @@ public class ValidationUtils {
             }
         }
 
-        return result != null ? result : Collections.<Issue>emptySet();
+        return result != null ? new ArrayList(result) : Collections.<Issue>emptyList();
     }
 
 }
index 9b0befc78442fa47d02022ca9e8863f01d1b5647..ed58556c7e570814bd4ce25e5473a6821f2c33bc 100644 (file)
@@ -11,6 +11,7 @@ import org.simantics.databoard.accessor.reference.ChildReference;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.impl.ObjectVariantBinding;
 import org.simantics.databoard.type.Datatype;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -19,7 +20,6 @@ import org.simantics.db.common.validation.L0Validations;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.DatatypeNotFoundException;
 import org.simantics.db.exception.ValidationException;
-import org.simantics.db.exception.VariableException;
 import org.simantics.db.layer0.exception.InvalidVariableException;
 import org.simantics.db.layer0.exception.MissingVariableValueException;
 import org.simantics.db.layer0.exception.PendingVariableException;
@@ -122,10 +122,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public <T> T getValue(ReadGraph graph) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               //throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                   LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
@@ -141,10 +143,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                        return getValue(graph);         
 
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
         
@@ -180,10 +184,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               //throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
@@ -195,10 +201,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public void setValue(WriteGraph graph, Object value) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
index ecf2439e8be4fdbbd352a8c17f125f9cae7141e7..75fdb8b6f209d4850f4bf5fa55b4b1ce2872ef6f 100644 (file)
@@ -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
index dae8bea7545184cbf7faf82dbc76f6ababa8ab35..88293f42b90f97e79dc9e2ff46113854ba48d43f 100644 (file)
@@ -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<Object>() {
             @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 (file)
index 8196712..0000000
+++ /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.procore.server.environment/.classpath b/bundles/org.simantics.db.procore.server.environment/.classpath
deleted file mode 100644 (file)
index eca7bdb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.simantics.db.procore.server.environment/.project b/bundles/org.simantics.db.procore.server.environment/.project
deleted file mode 100644 (file)
index 4a0c12b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.simantics.db.procore.server.environment</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/bundles/org.simantics.db.procore.server.environment/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.db.procore.server.environment/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 0c68a61..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/org.simantics.db.procore.server.environment/META-INF/MANIFEST.MF b/bundles/org.simantics.db.procore.server.environment/META-INF/MANIFEST.MF
deleted file mode 100644 (file)
index af12d59..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: ProCore Database Server Environment Checking Utilities
-Bundle-SymbolicName: org.simantics.db.procore.server.environment
-Bundle-Version: 1.1.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.simantics.db.procore.server.environment,
- org.simantics.db.procore.server.environment.windows
-Bundle-Vendor: Semantum Oy
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0"
-Bundle-NativeCode: msijni.dll;
-   processor=x86; osname=win32,
- msijni64.dll;
-   processor=x86_64; osname=win32,
- *
-Automatic-Module-Name: org.simantics.db.procore.server.environment
diff --git a/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x64.exe b/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x64.exe
deleted file mode 100644 (file)
index 5ecef5e..0000000
Binary files a/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x64.exe and /dev/null differ
diff --git a/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x86.exe b/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x86.exe
deleted file mode 100644 (file)
index 823345d..0000000
Binary files a/bundles/org.simantics.db.procore.server.environment/VC90.2008.SP1.KB2467174.redist.x86.exe and /dev/null differ
diff --git a/bundles/org.simantics.db.procore.server.environment/build.properties b/bundles/org.simantics.db.procore.server.environment/build.properties
deleted file mode 100644 (file)
index a64b63b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# 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
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .,\
-               msijni.dll,\
-               msijni64.dll,\
-               VC90.2008.SP1.KB2467174.redist.x64.exe,\
-               VC90.2008.SP1.KB2467174.redist.x86.exe
-src.includes = native/
diff --git a/bundles/org.simantics.db.procore.server.environment/msijni.dll b/bundles/org.simantics.db.procore.server.environment/msijni.dll
deleted file mode 100644 (file)
index 8009884..0000000
Binary files a/bundles/org.simantics.db.procore.server.environment/msijni.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.procore.server.environment/msijni64.dll b/bundles/org.simantics.db.procore.server.environment/msijni64.dll
deleted file mode 100644 (file)
index df74979..0000000
Binary files a/bundles/org.simantics.db.procore.server.environment/msijni64.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.procore.server.environment/native/compile.bat b/bundles/org.simantics.db.procore.server.environment/native/compile.bat
deleted file mode 100644 (file)
index 47efc2f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-@rem ***************************************************************************
-@rem Copyright (c) 2007, 2010 Association for Decentralized Information Management
-@rem in Industry THTH ry.
-@rem All rights reserved. This program and the accompanying materials
-@rem are made available under the terms of the Eclipse Public License v1.0
-@rem which accompanies this distribution, and is available at
-@rem http://www.eclipse.org/legal/epl-v10.html
-@rem
-@rem Contributors:
-@rem     VTT Technical Research Centre of Finland - initial API and implementation
-@rem ***************************************************************************
-gcc -mno-cygwin "-I%JAVA_HOME%/include" "-I%JAVA_HOME%/include/win32" -Wl,--add-stdcall-alias -shared -o ../msijni.dll msijni.c
diff --git a/bundles/org.simantics.db.procore.server.environment/native/compile.sh b/bundles/org.simantics.db.procore.server.environment/native/compile.sh
deleted file mode 100644 (file)
index aa239f6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# ***************************************************************************
-# 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
-# ***************************************************************************
-
-gcc "-I%JAVA_HOME%/include" "-I%JAVA_HOME%/include/win32" -Wl,--add-stdcall-alias -shared -o ../msijni.dll msijni.c
diff --git a/bundles/org.simantics.db.procore.server.environment/native/compile_x64.bat b/bundles/org.simantics.db.procore.server.environment/native/compile_x64.bat
deleted file mode 100644 (file)
index 0a34900..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-@rem ***************************************************************************
-@rem Copyright (c) 2007, 2010 Association for Decentralized Information Management
-@rem in Industry THTH ry.
-@rem All rights reserved. This program and the accompanying materials
-@rem are made available under the terms of the Eclipse Public License v1.0
-@rem which accompanies this distribution, and is available at
-@rem http://www.eclipse.org/legal/epl-v10.html
-@rem
-@rem Contributors:
-@rem     VTT Technical Research Centre of Finland - initial API and implementation
-@rem ***************************************************************************
-cl /O2 /Oi /GL "-I%JAVA_HOME%/include" "-I%JAVA_HOME%/include/win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MSIJNI_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /LD /FD /Gy /W3 /nologo /c /Zi /TC /errorReport:prompt /Fomsijni.obj msijni.c
-link /OUT:"..\src\msijni64.dll" /DLL /MACHINE:X64 Msi.lib msijni.obj
diff --git a/bundles/org.simantics.db.procore.server.environment/native/compile_x86.bat b/bundles/org.simantics.db.procore.server.environment/native/compile_x86.bat
deleted file mode 100644 (file)
index fab911f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-@rem ***************************************************************************
-@rem Copyright (c) 2007, 2010 Association for Decentralized Information Management
-@rem in Industry THTH ry.
-@rem All rights reserved. This program and the accompanying materials
-@rem are made available under the terms of the Eclipse Public License v1.0
-@rem which accompanies this distribution, and is available at
-@rem http://www.eclipse.org/legal/epl-v10.html
-@rem
-@rem Contributors:
-@rem     VTT Technical Research Centre of Finland - initial API and implementation
-@rem ***************************************************************************
-cl /O2 /Oi /GL "-I%JAVA_HOME%/include" "-I%JAVA_HOME%/include/win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "MSIJNI_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /LD /FD /Gy /W3 /nologo /c /Zi /TC /errorReport:prompt /Fomsijni.obj msijni.c
-link /OUT:"..\src\msijni.dll" /DLL /MACHINE:X86 Msi.lib msijni.obj
diff --git a/bundles/org.simantics.db.procore.server.environment/native/msijni.c b/bundles/org.simantics.db.procore.server.environment/native/msijni.c
deleted file mode 100644 (file)
index fe60d35..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <Msi.h>
-#include "jni.h"
-
-JNIEXPORT jint JNICALL Java_org_simantics_db_procore_server_environment_windows_Msi_MsiQueryProductState0(
-               JNIEnv* env, jclass clazz, jstring productCode
-) {
-       int result;
-       const jchar* lpProductCode;
-
-       lpProductCode = (*env)->GetStringChars(env, productCode, NULL);
-       if (lpProductCode == 0)
-               return 0;
-
-       result = MsiQueryProductState((LPCTSTR) lpProductCode);
-
-       (*env)->ReleaseStringChars(env, productCode, lpProductCode);
-
-       return (jint) result;
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.sln b/bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.sln
deleted file mode 100644 (file)
index ddbe9d1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msijni", "msijni.vcproj", "{2C249AD2-A0AE-4A88-8DCD-71F96133690E}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Win32 = Debug|Win32
-               Debug|x64 = Debug|x64
-               Release|Win32 = Release|Win32
-               Release|x64 = Release|x64
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Debug|Win32.ActiveCfg = Debug|Win32
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Debug|Win32.Build.0 = Debug|Win32
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Debug|x64.ActiveCfg = Debug|x64
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Debug|x64.Build.0 = Debug|x64
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Release|Win32.ActiveCfg = Release|Win32
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Release|Win32.Build.0 = Release|Win32
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Release|x64.ActiveCfg = Release|x64
-               {2C249AD2-A0AE-4A88-8DCD-71F96133690E}.Release|x64.Build.0 = Release|x64
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
diff --git a/bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.vcproj b/bundles/org.simantics.db.procore.server.environment/native/vs2008/msijni.vcproj
deleted file mode 100644 (file)
index cec55e0..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-       ProjectType="Visual C++"
-       Version="9,00"
-       Name="msijni"
-       ProjectGUID="{2C249AD2-A0AE-4A88-8DCD-71F96133690E}"
-       RootNamespace="msijni"
-       Keyword="Win32Proj"
-       TargetFrameworkVersion="196613"
-       >
-       <Platforms>
-               <Platform
-                       Name="Win32"
-               />
-               <Platform
-                       Name="x64"
-               />
-       </Platforms>
-       <ToolFiles>
-       </ToolFiles>
-       <Configurations>
-               <Configuration
-                       Name="Debug|Win32"
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-                       IntermediateDirectory="$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="1"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="C:\Program Files\Java\jdk1.6.0_20\include;C:\Program Files\Java\jdk1.6.0_20\include\win32"
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MSIJNI_EXPORTS"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               DebugInformationFormat="4"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="Msi.lib"
-                               LinkIncremental="2"
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                               CommandLine="copy &quot;$(TargetPath)&quot; &quot;..\..\src\msijni.dll&quot;"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Debug|x64"
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="1"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TargetEnvironment="3"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="C:\Program Files\Java\jdk1.6.0_20\include;C:\Program Files\Java\jdk1.6.0_20\include\win32"
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MSIJNI_EXPORTS"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               LinkIncremental="2"
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               TargetMachine="17"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                               CommandLine="copy &quot;$(TargetPath)&quot; &quot;..\..\src\msijni64.dll&quot;"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Release|Win32"
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-                       IntermediateDirectory="$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="1"
-                       WholeProgramOptimization="1"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="2"
-                               EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="C:\Program Files\Java\jdk1.6.0_20\include;C:\Program Files\Java\jdk1.6.0_20\include\win32"
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MSIJNI_EXPORTS"
-                               RuntimeLibrary="2"
-                               EnableFunctionLevelLinking="true"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="Msi.lib"
-                               LinkIncremental="1"
-                               AdditionalLibraryDirectories=""
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               OptimizeReferences="2"
-                               EnableCOMDATFolding="2"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                               CommandLine="copy &quot;$(TargetPath)&quot; &quot;..\..\src\msijni.dll&quot;"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Release|x64"
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
-                       ConfigurationType="2"
-                       CharacterSet="1"
-                       WholeProgramOptimization="1"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TargetEnvironment="3"
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="2"
-                               EnableIntrinsicFunctions="true"
-                               AdditionalIncludeDirectories="C:\Program Files\Java\jdk1.6.0_20\include;C:\Program Files\Java\jdk1.6.0_20\include\win32"
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MSIJNI_EXPORTS"
-                               RuntimeLibrary="2"
-                               EnableFunctionLevelLinking="true"
-                               UsePrecompiledHeader="0"
-                               WarningLevel="3"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               LinkIncremental="1"
-                               GenerateDebugInformation="true"
-                               SubSystem="2"
-                               OptimizeReferences="2"
-                               EnableCOMDATFolding="2"
-                               TargetMachine="17"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                               CommandLine="copy &quot;$(TargetPath)&quot; &quot;..\..\src\msijni64.dll&quot;"
-                       />
-               </Configuration>
-       </Configurations>
-       <References>
-       </References>
-       <Files>
-               <Filter
-                       Name="Source Files"
-                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-                       >
-                       <File
-                               RelativePath="..\msijni.c"
-                               >
-                       </File>
-               </Filter>
-               <Filter
-                       Name="Header Files"
-                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
-                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-                       >
-               </Filter>
-               <Filter
-                       Name="Resource Files"
-                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-                       >
-               </Filter>
-       </Files>
-       <Globals>
-       </Globals>
-</VisualStudioProject>
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ARCHType.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ARCHType.java
deleted file mode 100644 (file)
index 67fbee5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * 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.procore.server.environment;
-
-/**
- * @author Tuukka Lehtonen
- */
-public enum ARCHType {
-    PPC, PPC_64, SPARC, X86, X86_64, UNKNOWN
-}
\ No newline at end of file
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironment.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironment.java
deleted file mode 100644 (file)
index 1083134..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment;
-
-
-/**
- * @author Tuukka Lehtonen
- */
-public final class ExecutionEnvironment {
-
-    public final OSType os;
-    public final ARCHType arch;
-
-    private ExecutionEnvironment(OSType os, ARCHType arch) {
-        this.os = os;
-        this.arch = arch;
-    }
-
-    public static ExecutionEnvironment calculate() {
-        return new ExecutionEnvironment(calculateOS(), calculateArch());
-    }
-
-    public static ARCHType calculateArch() {
-        String osArch = System.getProperty("os.arch", "");
-        osArch = osArch.toLowerCase();
-        if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))
-            return ARCHType.X86;
-        if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))
-            return ARCHType.X86_64;
-        if (osArch.equals("ppc"))
-            return ARCHType.PPC;
-        if (osArch.startsWith("ppc"))
-            return ARCHType.PPC_64;
-        if (osArch.startsWith("sparc"))
-            return ARCHType.SPARC;
-        return ARCHType.UNKNOWN;
-    }
-
-    public static OSType calculateOS() {
-        String osName = System.getProperty("os.name", "");
-        osName = osName.toLowerCase();
-        if (osName.startsWith("mac os x"))
-            return OSType.APPLE;
-        if (osName.startsWith("windows"))
-            return OSType.WINDOWS;
-        if (osName.startsWith("linux"))
-            return OSType.LINUX;
-        if (osName.startsWith("sun"))
-            return OSType.SUN;
-        return OSType.UNKNOWN;
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironmentException.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironmentException.java
deleted file mode 100644 (file)
index 5630a09..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment;
-
-import java.util.List;
-
-import org.simantics.db.procore.server.environment.windows.Product;
-
-
-/**
- * @author Tuukka Lehtonen
- */
-public class ExecutionEnvironmentException extends Exception {
-
-    private static final long serialVersionUID = -4189715696439554271L;
-
-    public List<Product> requiredProducts;
-
-    public ExecutionEnvironmentException(List<Product> requiredProducts) {
-        super();
-        this.requiredProducts = requiredProducts;
-    }
-
-    public ExecutionEnvironmentException(String message, List<Product> requiredProducts) {
-        super(message);
-        this.requiredProducts = requiredProducts;
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/InstallException.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/InstallException.java
deleted file mode 100644 (file)
index 8dd0caa..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment;
-
-import java.util.List;
-
-import org.simantics.db.procore.server.environment.windows.Product;
-
-
-/**
- * @author Tuukka Lehtonen
- */
-public class InstallException extends Exception {
-
-    private static final long serialVersionUID = -4189715696439554271L;
-
-    public List<Product> products;
-
-    public InstallException(List<Product> products) {
-        super();
-        this.products = products;
-    }
-
-    public InstallException(String message, List<Product> products) {
-        super(message);
-        this.products = products;
-    }
-
-    public InstallException(Throwable cause, List<Product> products) {
-        super(cause);
-        this.products = products;
-    }
-
-    public InstallException(String message, Throwable cause, List<Product> products) {
-        super(message, cause);
-        this.products = products;
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/OSType.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/OSType.java
deleted file mode 100644 (file)
index 8b90095..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * 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.procore.server.environment;
-
-/**
- * @author Tuukka Lehtonen
- */
-public enum OSType {
-    APPLE, LINUX, SUN, WINDOWS, UNKNOWN
-}
\ No newline at end of file
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/RebootRequiredException.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/RebootRequiredException.java
deleted file mode 100644 (file)
index df7b0f4..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment;
-
-import java.util.List;
-
-import org.simantics.db.procore.server.environment.windows.Product;
-
-
-/**
- * @author Tuukka Lehtonen
- */
-public class RebootRequiredException extends InstallException {
-
-    private static final long serialVersionUID = -4189715696439554271L;
-
-    public RebootRequiredException(List<Product> success) {
-        super(success);
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ServerEnvironment.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ServerEnvironment.java
deleted file mode 100644 (file)
index 5de87a2..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.simantics.db.procore.server.environment.windows.Msi;
-import org.simantics.db.procore.server.environment.windows.Product;
-import org.simantics.db.procore.server.environment.windows.ProductCodes;
-
-/**
- * @author Tuukka Lehtonen
- */
-public final class ServerEnvironment {
-
-    // http://msdn.microsoft.com/en-us/library/aa368542(v=vs.85).aspx
-    private static final int ERROR_SUCCESS                 = 0;
-    private static final int ERROR_SUCCESS_REBOOT_REQUIRED = 3010;
-
-    /**
-     * Checks whether the current running environment has all the necessary
-     * components installed to run the ProCore database server.
-     * 
-     * @throws ExecutionEnvironmentException if dependencies for running the
-     *         database server are not met
-     */
-    public static void ensureServerDependenciesMet() throws ExecutionEnvironmentException {
-        ExecutionEnvironment env = ExecutionEnvironment.calculate();
-        switch (env.os) {
-            case WINDOWS: {
-                switch (env.arch) {
-                    case X86:
-                        Msi.checkOneOfProductsInstalled(ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X86_KB2467174);
-                        break;
-                    case X86_64:
-                        Msi.checkProductsInstalled(ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X86_KB2467174, ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X64_KB2467174);
-                        break;
-                }
-                break;
-            }
-        }
-    }
-
-    /**
-     * Checks whether the current running environment has all the necessary
-     * components installed to run the ProCore database server.
-     * 
-     * @throws ExecutionEnvironmentException if dependencies for running the
-     *         database server are not met
-     */
-    public static void tryInstallDependencies(IProgressMonitor monitor) throws InstallException {
-        ExecutionEnvironment env = ExecutionEnvironment.calculate();
-        switch (env.os) {
-            case WINDOWS: {
-                switch (env.arch) {
-                    case X86:
-                        runInstaller(monitor, ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X86_KB2467174, "VC90.2008.SP1.KB2467174.redist.x86.exe");
-                        break;
-                    case X86_64:
-                        runInstaller(monitor, ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X86_KB2467174, "VC90.2008.SP1.KB2467174.redist.x86.exe");
-                        runInstaller(monitor, ProductCodes.VISUAL_CPP_2008_SP1_REDIST_X64_KB2467174, "VC90.2008.SP1.KB2467174.redist.x64.exe");
-                        break;
-                }
-                break;
-            }
-        }
-    }
-
-    private static void runInstaller(IProgressMonitor monitor, Product product, String installerPath) throws InstallException {
-        try {
-            URL url = FileLocator.find(new URL("platform:/plugin/org.simantics.db.procore.server.environment/" + installerPath));
-            URL fileUrl = FileLocator.toFileURL(url);
-            final File file = new File(fileUrl.getFile());
-            System.out.println(file);
-
-            Process installer = new ProcessBuilder("cmd.exe", "/C", file.toString(), "/qb").start();
-            while (true) {
-                try {
-                    int exitValue = installer.exitValue();
-                    //System.out.println("installation done, exit code: " + exitValue);
-                    switch (exitValue) {
-                        case ERROR_SUCCESS:
-                            return;
-                        case ERROR_SUCCESS_REBOOT_REQUIRED:
-                            throw new RebootRequiredException(Arrays.asList(product));
-                    }
-                    throw new InstallException("Installation of " + product.getDescription() + " failed with error code " + exitValue, Arrays.asList(product));
-                } catch (IllegalThreadStateException e) {
-//                    if (monitor.isCanceled()) {
-//                        installer.destroy();
-//                    }
-                    // Not done yet.
-                    try {
-                        //System.out.println("sleeping");
-                        Thread.sleep(250);
-                    } catch (InterruptedException ie) {
-                    }
-                }
-            }
-        } catch (IOException e) {
-            throw new InstallException(e, Arrays.asList(product));
-        }
-    }
-
-    // -------------------------------------------------------------------------
-
-    public static void main(String[] args) {
-        try {
-            ensureServerDependenciesMet();
-        } catch (ExecutionEnvironmentException e) {
-            e.printStackTrace();
-        }
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Msi.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Msi.java
deleted file mode 100644 (file)
index 19a55c4..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * 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.procore.server.environment.windows;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-
-import org.simantics.db.procore.server.environment.ExecutionEnvironment;
-import org.simantics.db.procore.server.environment.ExecutionEnvironmentException;
-
-/**
- * Provides Java access to Windows Msi API functions:
- * <ul>
- * <li>{@link #MsiQueryProductState(String)} (see <a
- * href="http://msdn.microsoft.com/en-us/library/aa370363(VS.85).aspx">MSDN</a>)</li>
- * </ul>
- * 
- * @author Tuukka Lehtonen
- */
-public class Msi {
-
-    public static void checkOneOfProductsInstalled(Product... products) throws ExecutionEnvironmentException {
-        StringBuilder sb = new StringBuilder();
-        sb.append("None of the following products are installed properly:\n");
-        for (Product product : products) {
-            ProductState state = Msi.MsiQueryProductState(product.getCode());
-            switch (state) {
-                case DEFAULT:
-                    // One of the listed products is installed OK.
-                    return;
-                default:
-                    sb.append("\t" + product);
-                    sb.append(" - MsiQueryProductState returned ");
-                    sb.append(state);
-                    sb.append("\n");
-            }
-        }
-        throw new ExecutionEnvironmentException("Cannot run ProCore database server in this environment due to the following problems:\n" + sb.toString(), Arrays.asList(products));
-    }
-
-    public static void checkProductsInstalled(Product... products) throws ExecutionEnvironmentException {
-        StringBuilder sb = new StringBuilder();
-        for (Product product : products) {
-            ProductState state = Msi.MsiQueryProductState(product.getCode());
-            switch (state) {
-                case DEFAULT:
-                    // Installed OK
-                    continue;
-                default:
-                    sb.append("\tProduct " + product + " is not installed properly, MsiQueryProductState returned " + state);
-                    sb.append("\n");
-            }
-        }
-        if (sb.length() > 0) {
-            // Something is not installed right, throw exception
-            throw new ExecutionEnvironmentException("Cannot run ProCore database server in this environment due to the following problems:\n" + sb.toString(), Arrays.asList(products));
-        }
-    }
-
-    // -------------------------------------------------------------------------
-
-    public static ProductState MsiQueryProductState(String productCode) {
-        int result = MsiQueryProductState0(productCode);
-        return ProductState.of(result);
-    }
-
-    private static native int MsiQueryProductState0(String productCode);
-
-    // -------------------------------------------------------------------------
-
-    private static final String DLL_NAME = "msijni.dll";
-    private static final String DLL_NAME_64 = "msijni64.dll";
-
-    static {
-        initialize();
-    }
-
-    private static void initialize() {
-        ExecutionEnvironment env = ExecutionEnvironment.calculate();
-        String libName = null;
-        switch (env.arch) {
-            case X86:
-                libName = DLL_NAME;
-                break;
-            case X86_64:
-                libName = DLL_NAME_64;
-                break;
-            default:
-                return;
-        }
-
-        URL libURL = Msi.class.getResource("/" + libName);
-        if (libURL != null) {
-            try {
-                if ("file".equals(libURL.getProtocol())) {
-                    File path = new File(URLDecoder.decode(libURL.getPath(), "UTF-8"));
-                    initialize(path);
-                } else {
-                    File libFile = extractLib(libURL, libName);
-                    initialize(libFile);
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private static void initialize(File path) {
-        //System.out.println("load msijni: " + path);
-        System.load(path.toString());
-    }
-
-    /**
-     * Extracts the specified source file in the specified bundle into the
-     * specified local directory.
-     * 
-     * @param url the source URL to stream the resource from
-     * @param targetFile the target file to write the resource to
-     * @param deleteOnExit <code>true</code> to use {@link File#deleteOnExit()}
-     *        on the resulting file. Note that this does not guarantee that the
-     *        file is deleted when the JVM exits
-     * @return the resulting file
-     * @throws FileNotFoundException
-     */
-    private static File copyResource(URL url, File targetFile) throws IOException, FileNotFoundException {
-        FileOutputStream os = null;
-        InputStream is = null;
-        try {
-            if (targetFile.exists())
-                targetFile.delete();
-
-            is = url.openStream();
-            int read;
-            byte [] buffer = new byte [16384];
-            os = new FileOutputStream (targetFile);
-            while ((read = is.read (buffer)) != -1) {
-                os.write(buffer, 0, read);
-            }
-            os.close ();
-            is.close ();
-
-            return targetFile;
-        } finally {
-            uncheckedClose(os);
-            uncheckedClose(is);
-        }
-    }
-
-
-    private static void uncheckedClose(Closeable closeable) {
-        try {
-            if (closeable != null)
-                closeable.close();
-        } catch (IOException e) {
-            //ignore
-        }
-    }
-
-    private static File extractLib(URL libURL, String libName) throws FileNotFoundException, IOException {
-        String tmpDirStr = System.getProperty("java.io.tmpdir");
-        if (tmpDirStr == null)
-            throw new NullPointerException("java.io.tmpdir property is null");
-        File tmpDir = new File(tmpDirStr);
-        File libFile = new File(tmpDir, libName);
-
-        if (libFile.exists()) {
-            if (libFile.isFile()) {
-                try {
-                    byte[] origSum = computeSum(libURL);
-                    byte[] targetSum = computeSum(libFile);
-                    if (Arrays.equals(origSum, targetSum))
-                        return libFile;
-                } catch (NoSuchAlgorithmException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        return copyResource(libURL, libFile);
-    }
-
-    public static byte[] computeSum(InputStream in) throws IOException {
-        if (in == null)
-            throw new IllegalArgumentException("Input cannot be null!");
-
-        try {
-            MessageDigest md = MessageDigest.getInstance("MD5");
-            byte[] data = new byte[64 * 1024];
-
-            while (true) {
-                int read = in.read(data);
-                if (read == -1) {
-                    return md.digest();
-                }
-                md.update(data, 0, read);
-            }
-        } catch (NoSuchAlgorithmException e) {
-            // Should not be possible for MD5
-            throw new IOException(e);
-        }
-    }
-
-    public static byte[] computeSum(File f) throws IOException, NoSuchAlgorithmException {
-        InputStream in = null;
-        try {
-            in = new FileInputStream(f);
-            return computeSum(in);
-        } finally {
-            if (in != null)
-                in.close();
-        }
-    }
-
-    public static byte[] computeSum(URL url) throws IOException, NoSuchAlgorithmException {
-        InputStream in = null;
-        try {
-            in = url.openStream();
-            return computeSum(in);
-        } finally {
-            if (in != null)
-                in.close();
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Product.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/Product.java
deleted file mode 100644 (file)
index 098dd1d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment.windows;
-
-/**
- * @author Tuukka Lehtonen
- */
-public class Product {
-
-    private final String code;
-    private final String description;
-
-    public Product(String code, String description) {
-        this.code = code;
-        this.description = description;
-    }
-
-    public String getCode() {
-        return code;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    @Override
-    public String toString() {
-        return description + " - " + code;
-    }
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductCodes.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductCodes.java
deleted file mode 100644 (file)
index 493f4d4..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment.windows;
-
-/**
- * @author Tuukka Lehtonen
- */
-public final class ProductCodes {
-
-//    // Visual C++ 2008 runtime files
-//
-//    // Visual C++ 2008 Redistributable Package (x86)
-//    // {FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
-//    public static final Product VISUAL_CPP_2008_REDIST_X86      = new Product("{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}",
-//                                                                        "Visual C++ 2008 Redistributable Package (x86)");
-//
-//    // Visual C++ 2008 Redistributable Package (x64)
-//    // {350AA351-21FA-3270-8B7A-835434E766AD}
-//    public static final Product VISUAL_CPP_2008_REDIST_X64      = new Product("{350AA351-21FA-3270-8B7A-835434E766AD}",
-//                                                                        "Visual C++ 2008 Redistributable Package (x64)");
-//
-//    // Visual C++ 2008 Redistributable Package (ia64)
-//    // {2B547B43-DB50-3139-9EBE-37D419E0F5FA}
-//    public static final Product VISUAL_CPP_2008_REDIST_IA64     = new Product("{2B547B43-DB50-3139-9EBE-37D419E0F5FA}",
-//                                                                        "Visual C++ 2008 Redistributable Package (ia64)");
-
-    // Visual C++ 2008 SP1 runtime files
-
-    // THIS ONE IS CURRENTLY USED BY ProCore
-
-    // Visual C++ 2008 SP1 Redistributable Package (x86)
-    // {9A25302D-30C0-39D9-BD6F-21E6EC160475}
-    // Date Published: 9/16/2008
-    // 9.0.30729.17
-    // http://www.microsoft.com/downloads/en/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en
-    public static final Product VISUAL_CPP_2008_SP1_REDIST_X86  = new Product("{9A25302D-30C0-39D9-BD6F-21E6EC160475}",
-                                                                        "Visual C++ 2008 SP1 Redistributable Package (x86) (v9.0.30729.17)");
-
-    // Visual C++ 2008 SP1 Redistributable Package (x86) KB2467174
-    // {86CE85E6-DBAC-3FFD-B977-E4B79F83C909}
-    // Date Published: 4/12/2011
-    // 9.0.30729.5570
-    // http://support.microsoft.com/kb/2467174
-    // http://www.microsoft.com/downloads/en/details.aspx?familyid=05ce856d-8128-408b-96fa-5e1f57b097d8&displaylang=en
-    public static final Product VISUAL_CPP_2008_SP1_REDIST_X86_KB2467174  = new Product("{86CE85E6-DBAC-3FFD-B977-E4B79F83C909}",
-                                                                        "Microsoft Visual C++ 2008 Redistributable - KB2467174 - x86 9.0.30729.5570");
-
-    // Visual C++ 2008 SP1 Redistributable Package (x64)
-    // {8220EEFE-38CD-377E-8595-13398D740ACE}
-    // Date Published: 8/9/2008
-    // 9.0.30729.17
-    // http://www.microsoft.com/downloads/en/details.aspx?familyid=BA9257CA-337F-4B40-8C14-157CFDFFEE4E&displaylang=en
-    public static final Product VISUAL_CPP_2008_SP1_REDIST_X64  = new Product("{8220EEFE-38CD-377E-8595-13398D740ACE}",
-                                                                        "Visual C++ 2008 SP1 Redistributable Package (x64) (v9.0.30729.17)");
-
-    // Visual C++ 2008 SP1 Redistributable Package (x64) KB2467174
-    // {8338783A-0968-3B85-AFC7-BAAE0A63DC50}
-    // Date Published: 4/12/2011
-    // 9.0.30729.5570
-    // http://support.microsoft.com/kb/2467174
-    // http://www.microsoft.com/downloads/en/details.aspx?familyid=05ce856d-8128-408b-96fa-5e1f57b097d8&displaylang=en
-    public static final Product VISUAL_CPP_2008_SP1_REDIST_X64_KB2467174 = new Product("{8338783A-0968-3B85-AFC7-BAAE0A63DC50}",
-                                                                                 "Microsoft Visual C++ 2008 Redistributable - KB2467174 - x64 9.0.30729.5570");
-
-//    // Visual C++ 2008 SP1 Redistributable Package (ia64)
-//    // {5827ECE1-AEB0-328E-B813-6FC68622C1F9}
-//    // Date Published: 8/9/2008
-//    // 9.0.30729.17
-//    // http://www.microsoft.com/downloads/en/details.aspx?FamilyID=DCC211E6-AB82-41D6-8DEC-C79937393FE8&displaylang=en
-//    public static final Product VISUAL_CPP_2008_SP1_REDIST_IA64 = new Product("{5827ECE1-AEB0-328E-B813-6FC68622C1F9}",
-//                                                                        "Visual C++ 2008 SP1 Redistributable Package (ia64) (v9.0.30729.17)");
-
-    // Visual C++ 2010 runtime files
-
-    // Visual C++ 2010 Redistributable Package (x86)
-    // {196BB40D-1578-3D01-B289-BEFC77A11A1E}
-    public static final Product VISUAL_CPP_2010_REDIST_X86      = new Product("{196BB40D-1578-3D01-B289-BEFC77A11A1E}",
-                                                                        "Visual C++ 2010 Redistributable Package (x86)");
-
-    // Visual C++ 2010 Redistributable Package (x64)
-    // {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
-    public static final Product VISUAL_CPP_2010_REDIST_X64      = new Product("{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}",
-                                                                        "Visual C++ 2010 Redistributable Package (x64)");
-
-    // Visual C++ 2010 Redistributable Package (ia64)
-    // {C1A35166-4301-38E9-BA67-02823AD72A1B}
-    public static final Product VISUAL_CPP_2010_REDIST_IA64     = new Product("{C1A35166-4301-38E9-BA67-02823AD72A1B}",
-                                                                        "Visual C++ 2010 Redistributable Package (ia64)");
-
-    // Visual C++ 2010 SP1 runtime files
-
-    // Visual C++ 2010 SP1 Redistributable Package (x86)
-    // {F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
-    public static final Product VISUAL_CPP_2010_SP1_REDIST_X86           = new Product("{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}",
-                                                                                 "Visual C++ 2010 SP1 Redistributable Package (x86)");
-
-    // Visual C++ 2010 SP1 Redistributable Package (x64)
-    // {1D8E6291-B0D5-35EC-8441-6616F567A0F7}
-    public static final Product VISUAL_CPP_2010_SP1_REDIST_X64           = new Product("{1D8E6291-B0D5-35EC-8441-6616F567A0F7}",
-                                                                                 "Visual C++ 2010 SP1 Redistributable Package (x64)");
-
-    // Visual C++ 2010 SP1 Redistributable Package (ia64)
-    // {88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}
-    public static final Product VISUAL_CPP_2010_SP1_REDIST_IA64          = new Product("{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}",
-                                                                                 "Visual C++ 2010 SP1 Redistributable Package (ia64)");
-
-}
diff --git a/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductState.java b/bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/windows/ProductState.java
deleted file mode 100644 (file)
index d571999..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.procore.server.environment.windows;
-
-/**
- * The possible return values of Win32 API call MsiQueryProductState enumerated.
- * 
- * @author Tuukka Lehtonen
- */
-public enum ProductState {
-
-    /**
-     * An invalid parameter was passed to the function.
-     */
-    INVALIDARG(-2),
-
-    /**
-     * The product is not advertised or installed.
-     */
-    UNKNOWN(-1),
-
-    /**
-     * Indicates invocation of {@link Msi#MsiQueryProductState(String)} failed.
-     */
-    FAILED(0),
-
-    /**
-     * The product is advertised but not installed.
-     */
-    ADVERTISED(1),
-
-    /**
-     * The product is installed for a different user.
-     */
-    ABSENT(2),
-
-    /**
-     * The product is installed for a different user.
-     */
-    DEFAULT(5);
-
-    int code;
-
-    ProductState(int code) {
-        this.code = code;
-    }
-
-    public static ProductState of(int code) {
-        switch (code) {
-            case -2: return INVALIDARG;
-            case -1: return UNKNOWN;
-            case 0: return FAILED;
-            case 1: return ADVERTISED;
-            case 2: return ABSENT;
-            case 5: return DEFAULT;
-            default: throw new IllegalArgumentException("unrecognized product install state return code: " + code);
-        }
-    }
-
-    @Override
-    public String toString() {
-        return name() + "(" + code + ")";
-    }
-
-}
index 9b0a72394973975eb0e4cc089462953e8e1bf777..f69fe447bc2e0d722009f4eb704150dd3efd0f69 100644 (file)
@@ -12,7 +12,4 @@
 source.. = src/
 output.. = bin/
 bin.includes = META-INF/,\
-               .,\
-               win32.x86/,\
-               win32.x86_64/,\
-               linux.x86_64/
+               .
\ No newline at end of file
diff --git a/bundles/org.simantics.db.server/linux.x86_64/ProCoreServer b/bundles/org.simantics.db.server/linux.x86_64/ProCoreServer
deleted file mode 100644 (file)
index fdfbdc0..0000000
Binary files a/bundles/org.simantics.db.server/linux.x86_64/ProCoreServer and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/ACE.dll b/bundles/org.simantics.db.server/win32.x86/ACE.dll
deleted file mode 100644 (file)
index 5717358..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/ACE.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/ProCoreServer.exe b/bundles/org.simantics.db.server/win32.x86/ProCoreServer.exe
deleted file mode 100644 (file)
index a74c8fd..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/ProCoreServer.exe and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_chrono-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_chrono-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 7c3816f..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_chrono-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_date_time-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_date_time-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index cf0e781..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_date_time-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_filesystem-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_filesystem-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 38550ee..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_filesystem-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_regex-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_regex-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index b0caf24..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_regex-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_system-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_system-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 158ecc9..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_system-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/boost_thread-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86/boost_thread-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index c7112dc..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/boost_thread-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/msvcp110.dll b/bundles/org.simantics.db.server/win32.x86/msvcp110.dll
deleted file mode 100644 (file)
index 93fab56..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/msvcp110.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86/msvcr110.dll b/bundles/org.simantics.db.server/win32.x86/msvcr110.dll
deleted file mode 100644 (file)
index 1ce960d..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86/msvcr110.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/ACE.dll b/bundles/org.simantics.db.server/win32.x86_64/ACE.dll
deleted file mode 100644 (file)
index 58be406..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/ACE.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/ProCoreServer.exe b/bundles/org.simantics.db.server/win32.x86_64/ProCoreServer.exe
deleted file mode 100644 (file)
index 89b1f71..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/ProCoreServer.exe and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_chrono-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_chrono-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 14fb274..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_chrono-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_date_time-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_date_time-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index fc91104..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_date_time-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_filesystem-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_filesystem-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 44c8bce..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_filesystem-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_regex-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_regex-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 62938b2..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_regex-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_system-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_system-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 0e0a230..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_system-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/boost_thread-vc110-mt-1_55.dll b/bundles/org.simantics.db.server/win32.x86_64/boost_thread-vc110-mt-1_55.dll
deleted file mode 100644 (file)
index 3606c30..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/boost_thread-vc110-mt-1_55.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/lzo2.dll b/bundles/org.simantics.db.server/win32.x86_64/lzo2.dll
deleted file mode 100644 (file)
index 1c77764..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/lzo2.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/msvcp110.dll b/bundles/org.simantics.db.server/win32.x86_64/msvcp110.dll
deleted file mode 100644 (file)
index 7e27895..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/msvcp110.dll and /dev/null differ
diff --git a/bundles/org.simantics.db.server/win32.x86_64/msvcr110.dll b/bundles/org.simantics.db.server/win32.x86_64/msvcr110.dll
deleted file mode 100644 (file)
index dd484a5..0000000
Binary files a/bundles/org.simantics.db.server/win32.x86_64/msvcr110.dll and /dev/null differ
index 7403f3d7004f475e4de2bd17d7006cef5739d349..bb78bf41ee57507907c197c3fa84286e0bcded56 100644 (file)
@@ -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
index 578b42a61d885d13cfb06e20e7c31436d00a6af2..fe9bab55201f188be514d33c2d21e702586be0a1 100644 (file)
@@ -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;
             }
         });
     }
index 187fc52199a390f37b68b3a48a940d20faa4d359..42eb3d8bee0cf2cfd7fed0b8e47555665341931f 100644 (file)
@@ -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<T> implements Adapter<T, Resource> {
 
+       private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionAdapter2.class);
+
        Constructor<? extends T> constructor;
        IDynamicAdapter2[] parameters;
        
@@ -40,22 +44,20 @@ public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
 
        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<T> implements Adapter<T, Resource> {
                 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<T>() {
+                
                 @Override
-                public void run(AsyncReadGraph graph) {
-                       
+                public void perform(AsyncReadGraph graph, AsyncProcedure<T> p) {
+                    
                     Object[] args = new Object[parameters.length];
                     try {
-                       for(int i=0;i<parameters.length;++i)
-                               args[i] = parameters[i].adapt(graph, r);
-                       procedure.execute(graph, constructor.newInstance(args));
-                               } catch (IllegalArgumentException e) {
-                                   procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (InstantiationException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (IllegalAccessException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (InvocationTargetException e) {
-                        procedure.exception(g, e.getCause());
-                                       e.getCause().printStackTrace();
-                               } catch (DatabaseException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (Throwable t) {
-                                   procedure.exception(g, t);
-                                   t.printStackTrace();
-                               }
+                        for(int i=0;i<parameters.length;++i)
+                            args[i] = parameters[i].adapt(graph, r);
+                        p.execute(graph, constructor.newInstance(args));
+                    } catch (IllegalArgumentException e) {
+                        p.exception(g, e);
+                        LOGGER.error("Unexpected exception during adapter creation", e);
+                    } catch (InstantiationException e) {
+                        p.exception(g, e);
+                        LOGGER.error("Unexpected exception during adapter creation", e);
+                    } catch (IllegalAccessException e) {
+                        p.exception(g, e);
+                        LOGGER.error("Unexpected exception during adapter creation", e);
+                    } catch (InvocationTargetException e) {
+                        p.exception(g, e.getCause());
+                        LOGGER.error("Unexpected exception during adapter creation", e);
+                    } catch (DatabaseException e) {
+                        p.exception(g, e);
+                        LOGGER.error("Unexpected exception during adapter creation", e);
+                    } catch (Throwable t) {
+                        p.exception(g, t);
+                        LOGGER.error("Unexpected exception during adapter creation", t);
+                    }
+                    
                 }
                 
                 @Override
@@ -114,7 +117,7 @@ public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
                        return "ReflectionAdapter$1" + constructor + "$" + Arrays.toString(parameters);
                 }
                 
-            });
+            }, procedure);
         
        }
         
diff --git a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestHandler.java b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestHandler.java
deleted file mode 100644 (file)
index ecda4cc..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.simantics.db.testing.common;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.Platform;
-import org.simantics.db.Driver;
-import org.simantics.db.Driver.Management;
-import org.simantics.db.Manager;
-import org.simantics.db.ServerI;
-import org.simantics.db.Session;
-import org.simantics.db.SessionManager;
-import org.simantics.db.SessionReference;
-import org.simantics.db.exception.DatabaseException;
-
-import fi.vtt.simantics.procore.ProCoreServerReference;
-import fi.vtt.simantics.procore.ProCoreSessionReference;
-import fi.vtt.simantics.procore.SessionManagerSource;
-
-/**
- * ProCore specific test handler.
- *
- */
-public class TestHandler {
-//    private final TestSettings testSettings;
-    private final Driver driver;
-    private final File dbFolder;
-    TestHandler(TestSettings testSettings, String dbFolderName) throws DatabaseException {
-//        this.testSettings = testSettings;
-        driver = Manager.getDriver("procore");
-        if (null == dbFolderName)
-            dbFolder = Platform.getLocation().append("db").toFile();
-      else
-          dbFolder = new File(dbFolderName);
-    }
-    void initNew() throws DatabaseException {
-        Management m = getManagement();
-        if (m.exist())
-            m.delete();
-        m.create();
-    }
-    void initIfNeccessary() throws DatabaseException {
-        Management m = getManagement();
-        if (!m.exist())
-            m.create();
-    }
-    public Session getSession() throws DatabaseException {
-        // Note that we normally user authentication agent for user identification.
-        Properties props = new Properties();
-        props.setProperty("user", "Default User");
-        props.setProperty("password", "");
-        return driver.getSession(dbFolder.getAbsolutePath(), props);
-    }
-    public ServerI getServer() throws DatabaseException {
-        return driver.getServer(dbFolder.getAbsolutePath(), null);
-    }
-    public Management getManagement() throws DatabaseException {
-      return driver.getManagement(dbFolder.getAbsolutePath(), null);
-  }
-    public Session regSession(long sessionId) throws DatabaseException, IOException {
-        SessionManager sm = SessionManagerSource.getSessionManager();
-        ProCoreServerReference ser = new ProCoreServerReference(dbFolder.toPath());
-        SessionReference ses = new ProCoreSessionReference(ser, sessionId);
-        return sm.createSession(ses, null);
-    }
-
-}
\ No newline at end of file
index 20ba53e512451150b38ca9285fc45b985ddd404f..7f23b07b815c18988ca2aa4e58578d9822a2fa28 100644 (file)
@@ -5,6 +5,10 @@ import org.simantics.utils.Development;
 
 public class DevelopmentKeys {
 
+       final public static boolean EVERYTHING = true;
+       
+    final public static boolean  VERBOSE = false;
+
        final public static String PRINT = "Development.print";
 
        final public static String LOGGER_ECHO = trickToInitialize();
@@ -17,41 +21,69 @@ public class DevelopmentKeys {
        
        final public static String WRITELOGGER_LOG = "WriteLogger.log";
 
+       final public static String QUERYPROCESSOR_RECOMPUTE = "QueryProcessor.recompute";
+
+       final public static String QUERYPROCESSOR_LISTENERS = "QueryProcessor.listeners";
+
+       final public static String QUERYPROCESSOR_CHANGES = "QueryProcessor.changes";
+
        final public static String QUERYPROCESSOR_UPDATE = "QueryProcessor.update";
 
+       final public static String QUERYPROCESSOR_DEPENDENCIES = "QueryProcessor.dependencies";
+
        final public static String QUERYPROCESSOR_PUT = "QueryProcessor.put";
 
+       final public static String QUERYCOLLECTOR = "QueryCollector";
+
        final public static String SESSION_LOG_WRITES = "Session.logWrites";
 
        final public static String READGRAPH_COUNT = "ReadGraph.count";
 
+       final public static String L0_VALIDATION = "L0.validation";
+
+       final public static String CACHE_ENTRY_STATE = "CacheEntry.state";
+
        final public static String CLUSTERTABLE_VALIDATE_ON_LOAD = "ClusterTable.validateOnLoad";
 
        public static void initialize() {
 
                if(Development.DEVELOPMENT) {
 
-                       Development.setProperty(DevelopmentKeys.PRINT, true, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.PRINT, EVERYTHING | false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.LOGGER_ECHO, EVERYTHING | false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG, EVERYTHING | false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_NAMES, EVERYTHING | false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_STACK, EVERYTHING | false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, EVERYTHING | false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.READGRAPH_COUNT, EVERYTHING | false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.L0_VALIDATION, false, Bindings.BOOLEAN);
+
+                       Development.setProperty(DevelopmentKeys.CACHE_ENTRY_STATE, EVERYTHING | false, Bindings.BOOLEAN);
+                       
+                       Development.setProperty(DevelopmentKeys.WRITELOGGER_LOG, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.LOGGER_ECHO, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_RECOMPUTE, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG, false, Bindings.BOOLEAN);
-                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_NAMES, false, Bindings.BOOLEAN);
-                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_DEBUG_STACK, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_LISTENERS, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.READGRAPH_COUNT, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.WRITELOGGER_LOG, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, EVERYTHING | false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PUT, EVERYTHING |  false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PUT, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.QUERYCOLLECTOR, EVERYTHING |  false, Bindings.BOOLEAN);
 
-                       Development.setProperty(DevelopmentKeys.SESSION_LOG_WRITES, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.SESSION_LOG_WRITES, EVERYTHING | false, Bindings.BOOLEAN);
                        
-                       Development.setProperty(DevelopmentKeys.CLUSTERTABLE_VALIDATE_ON_LOAD, false, Bindings.BOOLEAN);
+                       Development.setProperty(DevelopmentKeys.CLUSTERTABLE_VALIDATE_ON_LOAD, EVERYTHING | false, Bindings.BOOLEAN);
                        
                        
 
index 689134b84048e39aa0a808a69796b281711538ac..9bc628d0068c65947990fdf2b03bdda9cca5ef0e 100644 (file)
@@ -1,14 +1,20 @@
 package org.simantics.desktop.ui.internal;
 
+import java.util.Collections;
+import java.util.Set;
+
+import org.simantics.project.ontology.ProjectResource;
 import org.simantics.selectionview.StandardPropertyPage;
 import org.simantics.ui.workbench.IPropertyPage;
 import org.simantics.views.swt.ModelledView;
 
 public class StandardModelledView extends ModelledView {
 
+    private static final Set<String> defaultBrowseContexts = Collections.singleton(ProjectResource.URIs.ProjectBrowseContext);
+    
     @Override
     protected IPropertyPage getPropertyPage() {
-        return new StandardPropertyPage(getSite());
+        return new StandardPropertyPage(getSite(), defaultBrowseContexts);
     }
 
 }
index 0ab824e918bf0aa3f7f7cd95540cc1ca7438bbe3..783725414778ce7cd8588a2fb72f535c458f119d 100644 (file)
@@ -17,12 +17,12 @@ import org.simantics.layer0.Layer0;
 public class NewFileDocument implements ActionFactory {
        Resource relation;
        String defaultName;
-       
+
        public NewFileDocument(ReadGraph graph, String relationUri, String defaultName) throws DatabaseException {
                relation = graph.getResource(relationUri);
                this.defaultName = defaultName;
        }
-       
+
        @Override
        public Runnable create(Object target) {
 
@@ -35,29 +35,38 @@ public class NewFileDocument implements ActionFactory {
                        @Override
                        public void run() {
                                Simantics.getSession().asyncRequest(new WriteRequest() {
-                                       
+
                                        @Override
                                        public void perform(WriteGraph graph) throws DatabaseException {
-                                           graph.markUndoPoint();
-                                           
-                                               Layer0 l0 = Layer0.getInstance(graph);
-
-                           String name = NameUtils.findFreshName(graph, defaultName, resource, relation);
-                               DocumentResource doc = DocumentResource.getInstance(graph);
-                               
-                               Resource fileResource = graph.newResource();
-                               graph.claim(fileResource, l0.InstanceOf, doc.FileDocument);
-                           graph.claimLiteral(fileResource, l0.HasName, name);
-                           graph.claim(resource, relation, fileResource);
-                           try {
-                               GraphFileUtil.writeDataToGraph(graph, new byte[0], fileResource);
-                           } catch (IOException e) {
-                               throw new DatabaseException(e);
-                           }
+                                               create(graph, resource, relation, defaultName);
                                        }
-                                       
+
                                });
                        }
                };
        }
+
+       public static Resource create(WriteGraph graph, Resource resource, Resource relation, String defaultName) throws DatabaseException {
+
+               graph.markUndoPoint();
+
+               Layer0 l0 = Layer0.getInstance(graph);
+
+               String name = NameUtils.findFreshName(graph, defaultName, resource, relation);
+               DocumentResource doc = DocumentResource.getInstance(graph);
+
+               Resource fileResource = graph.newResource();
+               graph.claim(fileResource, l0.InstanceOf, doc.FileDocument);
+               graph.claimLiteral(fileResource, l0.HasName, name);
+               graph.claim(resource, relation, fileResource);
+               try {
+                       GraphFileUtil.writeDataToGraph(graph, new byte[0], fileResource);
+               } catch (IOException e) {
+                       throw new DatabaseException(e);
+               }
+
+               return fileResource;
+
+       }
+
 }
index f9f82e4a002e3ce7f332d6bae9ab08bb86182430..36f82a01dc69cee7d9cf3b0de233753343b1b851 100644 (file)
@@ -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
index e3d00e8aa418fa57ebcacaf4da42650fc44ac3f3..d169c9684402f401abe44a54be69db6457e83cad 100644 (file)
@@ -4,6 +4,9 @@
 L0 = <http://www.simantics.org/Layer0-1.1> : 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" <R L0.HasProperty : L0.FunctionalRelation
   L0.domainProperties L0.Functions.methodsPropertyDomainProperties
index fb9d271bb141a66f35f23e78b10b817e22b82b30..afa68bbe2cbeb62dc938bba618e34c24c12366e5 100644 (file)
@@ -2,7 +2,11 @@ L0 = <http://www.simantics.org/Layer0-1.1>
 
 L0.Constraint <T L0.Entity
     >-- L0.Constraint.Validator <R L0.HasProperty : L0.FunctionalRelation
-        L0.RequiresValueType "ReadGraph => Resource -> [Issue]"
+        L0.RequiresValueType "Resource -> <ReadGraph> [Issue]"
+
+L0.SCLValidator <T L0.SCLValue
+    L0.HasValueType "Resource -> <ReadGraph> [Issue]"
+    
 L0.HasConstraint <R L0.IsRelatedTo
     L0.InverseOf L0.HasConstraint.Inverse <R L0.IsRelatedTo     
     <-- L0.Type
index ec31d0350e96b2f3c5eaa44590a643bbbea3f132..6421614359cc81df895bba4a87b157c26df3dead 100644 (file)
@@ -66,6 +66,11 @@ L0.SCLScript <T L0.Entity
     >-- L0.SCLScript.definition --> L0.String <R L0.HasProperty : L0.TotalFunction
     @L0.assert L0.SCLScript.definition ""
 
+L0.Action <T L0.Entity
+
+L0.SCLAction <T L0.Action
+  --> L0.SCLAction.action ==> "Resource -> <Proc> ()" <R L0.HasProperty : L0.TotalFunction 
+
 L0.Ontology
     >-- L0.Ontology.defaultLocalName --> L0.String <R L0.HasProperty : L0.TotalFunction
     @L0.assert L0.Ontology.defaultLocalName ""
index 74bff5f40d84e814a87eaf647273263e415b9202..ef5a587e521376e2ddc39de4af0a3e11059e3b9d 100644 (file)
@@ -40,4 +40,20 @@ L0.tag : L0.Template
         %resource %tag %resource
 L0.defTag : L0.Template
     @template %resource
-        %resource <R L0.IsWeaklyRelatedTo : L0.Tag                
\ No newline at end of file
+        %resource <R L0.IsWeaklyRelatedTo : L0.Tag
+
+L0.SCLAction.valueType = "Resource -> <Proc> ()" : L0.String
+
+L0.sclAction : L0.Template
+    @template %action %expression
+        %action : L0.SCLAction
+          L0.SCLAction.action _ : L0.SCLValue
+            L0.SCLValue.expression %expression
+            L0.HasValueType L0.SCLAction.valueType
+
+L0.sclConstraint : L0.Template
+    @template %constraint %expression
+      %constraint : L0.Constraint
+        L0.Constraint.Validator _ : L0.SCLValidator
+          L0.SCLValue.expression %expression
+
index 7c9f35bd75b511303ec430e25d9d7e85c638c94b..f192ea6fdc29b8bee6b710c0c5b1cc49c60e902b 100644 (file)
@@ -1,16 +1,14 @@
 L0 = <http://www.simantics.org/Layer0-1.1>
 
 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
index 358aaa7e914a92ad6b89e465139fa3e6f8f8559a..14aa774e8e6111642b569c2dd261121a7b686d8b 100644 (file)
@@ -1,6 +1,8 @@
 L0 = <http://www.simantics.org/Layer0-1.1>
 
-L0.Value <T L0.Entity
+L0.Value <T L0.Entity : L0.ValueType
+
+L0.ValueType <T L0.Type
     
 L0.ExternalValue <T L0.Value
 
@@ -30,7 +32,7 @@ L0.SCLValue <T L0.Value : L0.SCLValueType
     >-- L0.SCLValue.environment --> L0.SCLValue.Environment <R L0.IsRelatedTo : L0.TotalFunction
     @L0.assert L0.ConvertsToValueWith L0.Functions.sclValue
 
-L0.SCLValueType <T L0.Entity
+L0.SCLValueType <T L0.ValueType
     >-- L0.SCLValueType.validator ==> "Variable -> <ReadGraph> String" <R L0.HasProperty
 
 L0.scl : L0.Template
index 0ca3b1b04406861467b845013717710ff5c45788..c446d1c3c057f15409192b182d3dba45d6c6c668 100644 (file)
@@ -32,6 +32,7 @@ import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.DiagramHints;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ComponentUtils;
+import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.actions.NavigateToTarget;
 import org.simantics.modeling.ui.Activator;
 import org.simantics.structural.stubs.StructuralResource2;
@@ -50,8 +51,13 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA
         super(Messages.OpenDiagramFromConfigurationAdapter_DiagramEditor, Activator.COMPOSITE_ICON);
     }
 
-    protected String getEditorId() {
-        return EDITOR_ID;
+    protected String getEditorId(ReadGraph g, Resource composite) throws DatabaseException {
+        ModelingResources MOD = ModelingResources.getInstance(g);
+        String preferredEditorId = g.getPossibleRelatedValue(composite, MOD.PreferredDiagramEditorID);
+        if(preferredEditorId != null)
+            return preferredEditorId;
+        else
+            return EDITOR_ID;
     }
 
     @Override
@@ -80,7 +86,7 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA
         Simantics.getSession().asyncRequest(new ReadRequest() {
             @Override
             public void run(ReadGraph g) throws DatabaseException {
-                openEditor(g, r, getEditorId());
+                openEditor(g, r, getEditorId(g, r));
             }
         });
     }
index 253b697b9e37e9c6fde5fdaec3ba1e16de6457e5..5f3bf352be0b1471e65737e818473c20e9d430e1 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.modeling.ui.scl.scriptEditor;
 
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 import org.simantics.scl.ui.editor.SCLSourceViewerConfigurationNew;
 import org.simantics.scl.ui.editor2.SCLModuleEditor2;
 
@@ -32,5 +33,15 @@ public class SCLScriptEditor extends SCLModuleEditor2 {
         super.createPartControl(parent);
         getSite().getService(IContextService.class).activateContext("org.simantics.modeling.ui.scl.scriptEditor.context");
     }
+    
+    @Override
+    public <T> T getAdapter(Class<T> adapter) {
+        // No outline view for scripts
+        if (IContentOutlinePage.class.equals(adapter)) {
+            return null;
+        }
+        
+        return super.getAdapter(adapter);
+    }
 
 }
index 8a0b1ddbca77e0f81fd283d8445c715e8c2e5adb..09545ada8b473a45c49a2a54a1d5fc4a13b0cb6c 100644 (file)
@@ -554,8 +554,9 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
                                        if(stm != null) {
                                                if(graph.isInstanceOf(connectionPoint, L0.FunctionalRelation)) {
                                                        if(!isSynchronizedConnector(graph, templateElement, stm.getObject())) {
-                                                               messageLog.add("\t\tABORTED: tried to connect to an already connected terminal " + NameUtils.getSafeName(graph, counterPartElement) + " " + NameUtils.getSafeName(graph, connectionPoint));
-                                                               return;
+                                                               messageLog.add("\t\tWARNING: skipping addition of template connection " + NameUtils.getSafeName(graph, templateElement, true) + " into instance.");
+                                                               messageLog.add("\t\t\ttried to connect to an already connected terminal " + NameUtils.getSafeName(graph, counterPartElement, true) + " " + NameUtils.getSafeName(graph, connectionPoint));
+                                                               templateElementsAddedToTemplate.remove(templateElement);
                                                        }
                                                }
                                                }
@@ -825,7 +826,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
             Resource instanceElement = typicalInfo.bean.templateToInstance.get(changedTemplateElement);
             if (instanceElement == null) {
                 // There's an earlier problem in the sync process if this happens.
-               typicalInfo.messageLog.add("SKIPPING SYNC OF CHANGED TEMPLATE ELEMENT DUE TO MISSING INSTANCE: " + safeNameAndType(graph, getElementNameResource(graph, changedTemplateElement)));
+               typicalInfo.messageLog.add("\t\tSKIPPING SYNC OF CHANGED TEMPLATE ELEMENT DUE TO MISSING INSTANCE: " + safeNameAndType(graph, getElementNameResource(graph, changedTemplateElement)));
                 continue;
             }
             
index d7620d1336c95cc3fe99889f427e323040233cbd..e491a1b11529c780d33a141d869ae491426613dc 100644 (file)
@@ -1,6 +1,6 @@
 package org.simantics.modeling.typicals;
 
-import java.util.Collection;
+import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 
@@ -8,6 +8,6 @@ public class TypicalInfo {
 
        public TypicalInfoBean bean;
        public IProgressMonitor monitor;
-       public Collection<String> messageLog;
+       public List<String> messageLog;
        
 }
index efd050e10959b97df1d4420dde9f0140e7d9dbdd..55a1393f523e791ef1d8174e171554b4fcf0cffb 100644 (file)
@@ -8,9 +8,10 @@ Require-Bundle: org.simantics.db;bundle-version="1.1.0",
  gnu.trove3;bundle-version="3.0.0",
  org.eclipse.core.runtime;bundle-version="3.7.0",
  org.simantics.layer0;bundle-version="1.0.0",
- org.apache.log4j;bundle-version="1.2.15",
  org.simantics.db.common;bundle-version="1.1.0",
- org.simantics.structural.ontology;bundle-version="1.1.0"
+ org.simantics.structural.ontology;bundle-version="1.1.0",
+ org.slf4j.api,
+ org.simantics.db.layer0
 Export-Package: org.simantics.objmap.backward,
  org.simantics.objmap.bidirectional,
  org.simantics.objmap.exceptions,
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedList.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedList.java
new file mode 100644 (file)
index 0000000..7018a39
--- /dev/null
@@ -0,0 +1,40 @@
+package org.simantics.objmap.graph.annotations;
+
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.simantics.layer0.Layer0;
+import org.simantics.objmap.graph.annotations.meta.IsFieldRule;
+
+/**
+ * This field is a java.util.List or an array type that represents the contents
+ * of a Layer0.List entity that is the single object of the given relation. 
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@IsFieldRule
+public @interface LinkedList {
+       /**
+        * URI of a relation that has a Layer0.List as its object.
+        */
+       String value();
+       /**
+        * URI of the type of the list resource to create. 
+        */
+       String type() default Layer0.URIs.List;
+       boolean composition() default false;
+}
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListAdd.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListAdd.java
new file mode 100644 (file)
index 0000000..197579f
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An add method add(int index, T value) for a linked list mapped to the single object
+ * of a given relation.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface LinkedListAdd {
+       String value();
+}
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListGet.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListGet.java
new file mode 100644 (file)
index 0000000..a474499
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.simantics.layer0.Layer0;
+import org.simantics.objmap.graph.annotations.meta.IsCollectionRule;
+
+/**
+ * A get method that returns the contents of a linked list mapped to the single object of
+ * a given relation.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@IsCollectionRule
+@HasCollectionAdder(LinkedListAdd.class)
+@HasCollectionRemover(LinkedListRem.class)
+public @interface LinkedListGet {
+       String value();
+       String type() default Layer0.URIs.List;
+       boolean composition() default false;
+}
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListRem.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/LinkedListRem.java
new file mode 100644 (file)
index 0000000..afc834e
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Remove method for a list of objects represented by a Layer0.List as the
+ * single object of a given relation.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface LinkedListRem {
+       String value();
+}
index 1e2ff4f2d8c753c5fa11e1291705d376b7395611..d26b565b9c39d1f0a2246dc86797a7472663e784 100644 (file)
@@ -16,7 +16,7 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.simantics.objmap.graph.annotations.meta.IsFieldRule;
+import org.simantics.objmap.graph.annotations.meta.IsMethodRule;
 
 
 
@@ -27,6 +27,6 @@ import org.simantics.objmap.graph.annotations.meta.IsFieldRule;
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.METHOD)
-@IsFieldRule
+@IsMethodRule
 public @interface UpdateMethod {
 }
index ab5b1c7a9f5943c5f2e180cd6ab9eaba97a16cb0..b98961154ca4cddec50b5a2ddd8efbcc62a1f17a 100644 (file)
@@ -14,10 +14,12 @@ package org.simantics.objmap.graph.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
+import org.simantics.databoard.binding.Binding;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
-import org.simantics.layer0.Layer0;
+import org.simantics.db.layer0.request.PropertyInfo;
+import org.simantics.db.layer0.request.PropertyInfoRequest;
 import org.simantics.objmap.bidirectional.IBidirectionalMappingRule;
 import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue;
 import org.simantics.objmap.graph.annotations.CompoundRelatedSetValue;
@@ -43,6 +45,8 @@ public class CompoundRelatedGetSetValueRuleFactory<Range> implements IGetSetRule
                
 //             Class<? extends ValueAdapter> adapterClass = getterAnn.adapter();
                IRangeAccessor<Range,Object> rangeAccessor = new CompoundGetSetValueAccessor<Range,Object>(getter, setter);
+               PropertyInfo propInfo = g.syncRequest(new PropertyInfoRequest(g.getResource(getterAnn.valRelation())));
+               Binding valueBinding = propInfo.defaultBinding;
 //        Resource valueType;
 //        if (adapterClass == IdentityAdapter.class) {
 //            valueType = dataTypeOfClass(g, getter.getReturnType());
@@ -59,7 +63,8 @@ public class CompoundRelatedGetSetValueRuleFactory<Range> implements IGetSetRule
 //        }
                return new ValueRule<Resource,Range>(new CompoundValueAccessor(g.getResource(getterAnn.objRelation()),
                                                                                                                                           g.getResource(getterAnn.objType()),
-                                                                                                                                          g.getResource(getterAnn.valRelation())),
+                                                                                                                                          g.getResource(getterAnn.valRelation()),
+                                                                                                                                          valueBinding),
                                        rangeAccessor);
        }
        
@@ -69,42 +74,5 @@ public class CompoundRelatedGetSetValueRuleFactory<Range> implements IGetSetRule
                CompoundRelatedSetValue setterAnn = (CompoundRelatedSetValue)annotation;
                return getterAnn.objRelation().equals(setterAnn.value());
        }
-       
-       public static Resource dataTypeOfClass(ReadGraph g, Class<?> clazz) {
-        Layer0 b = Layer0.getInstance(g);
-        if(clazz.equals(Double.class) || clazz.equals(double.class))
-            return b.Double;
-        else if(clazz.equals(String.class))
-            return b.String;
-        else if(clazz.equals(Integer.class) || clazz.equals(int.class))
-            return b.Integer;
-        else if(clazz.equals(Float.class) || clazz.equals(float.class))
-            return b.Float;
-        else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class))
-            return b.Boolean;
-        else if(clazz.equals(Long.class) || clazz.equals(long.class))
-            return b.Long;
-        else if(clazz.equals(Byte.class) || clazz.equals(byte.class))
-            return b.Byte;
-        
-        else if(clazz.equals(double[].class))
-            return b.DoubleArray;
-        else if(clazz.equals(int[].class))
-            return b.IntegerArray;
-        else if(clazz.equals(byte[].class))
-            return b.ByteArray;
-        else if(clazz.equals(float[].class))
-            return b.FloatArray;
-        else if(clazz.equals(boolean[].class))
-            return b.BooleanArray;
-        else if(clazz.equals(String[].class))
-            return b.StringArray;
-        else if(clazz.equals(long[].class))
-            return b.LongArray;
-        else {
-               System.out.println("Couldn't find a data type for " + clazz);
-            return null;
-        }
-    }
 
 }
index cd745a5230bd97b0c7bec4631dee01d4d822a61b..6d3f33a1b23e98c1932f1a167b004b3ead6d73c2 100644 (file)
  *******************************************************************************/
 package org.simantics.objmap.graph.annotations.factories;
 
+import org.simantics.databoard.Datatypes;
+import org.simantics.databoard.binding.error.DatatypeConstructionException;
+import org.simantics.databoard.type.ArrayType;
+import org.simantics.databoard.type.BooleanType;
+import org.simantics.databoard.type.ByteType;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.type.DoubleType;
+import org.simantics.databoard.type.FloatType;
+import org.simantics.databoard.type.IntegerType;
+import org.simantics.databoard.type.LongType;
+import org.simantics.databoard.type.OptionalType;
+import org.simantics.databoard.type.StringType;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DataTypeUtils {
     
+    private static final Logger LOGGER = LoggerFactory.getLogger(DataTypeUtils.class);
+
     public static Resource dataTypeOfClass(ReadGraph g, Class<?> clazz) {
         Layer0 b = Layer0.getInstance(g);
         if(clazz.equals(Double.class) || clazz.equals(double.class))
@@ -49,9 +65,59 @@ public class DataTypeUtils {
         else if(clazz.equals(long[].class))
             return b.LongArray;
         else {
-               System.out.println("Couldn't find a data type for " + clazz);
+            try {
+                Datatype type = Datatypes.getDatatype(clazz);
+                final Resource result = dataTypeOfDatatype(g, type);
+                if (result != null)
+                    return result;
+            } catch (DatatypeConstructionException e) {
+            }
+            
+            LOGGER.error("No literal type found for class {}", clazz);
             return null;
         }
     }
-    
+
+    public static Resource dataTypeOfDatatype(ReadGraph g, Datatype type) {
+        if (type instanceof OptionalType)
+            return dataTypeOfDatatype(g, ((OptionalType) type).getComponentType());
+        
+        Layer0 b = Layer0.getInstance(g);
+        if (type instanceof DoubleType)
+            return b.Double;
+        else if(type instanceof StringType)
+            return b.String;
+        else if(type instanceof IntegerType)
+            return b.Integer;
+        else if(type instanceof FloatType)
+            return b.Float;
+        else if(type instanceof BooleanType)
+            return b.Boolean;
+        else if(type instanceof LongType)
+            return b.Long;
+        else if(type instanceof ByteType)
+            return b.Byte;
+        
+        else if (type instanceof ArrayType) {
+            type = ((ArrayType) type).componentType();
+            
+            if (type instanceof DoubleType)
+                return b.DoubleArray;
+            else if(type instanceof IntegerType)
+                return b.IntegerArray;
+            else if(type instanceof ByteType)
+                return b.ByteArray;
+            else if(type instanceof FloatType)
+                return b.FloatArray;
+            else if(type instanceof BooleanType)
+                return b.BooleanArray;
+            else if(type instanceof StringType)
+                return b.StringArray;
+            else if(type instanceof LongType)
+                return b.LongArray;
+        }
+        
+        LOGGER.error("No literal type found for data type {}", type);
+        return null;
+    }
 }
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory.java
new file mode 100644 (file)
index 0000000..072a6a2
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.annotations.factories;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.ResourceNotFoundException;
+import org.simantics.db.exception.ServiceException;
+import org.simantics.db.exception.ValidationException;
+import org.simantics.objmap.bidirectional.IBidirectionalMappingRule;
+import org.simantics.objmap.graph.annotations.LinkedList;
+import org.simantics.objmap.graph.rules.MappedElementsRule;
+import org.simantics.objmap.graph.rules.domain.LinkedListAccessor;
+import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory;
+import org.simantics.objmap.graph.rules.range.FieldAccessor;
+
+public class LinkedListRuleFactory<Range> implements IFieldRuleFactory<Resource, Range> {
+
+    @Override
+    public IBidirectionalMappingRule<Resource, Range> create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {
+        LinkedList annotation = (LinkedList)_annotation;
+        return new MappedElementsRule<Resource,Range>(
+                new LinkedListAccessor(g.getResource(annotation.value()), g.getResource(annotation.type()), annotation.composition()),
+                new FieldAccessor<Range,Collection<Range>>(field)
+            );
+    }
+
+}
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory2.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/LinkedListRuleFactory2.java
new file mode 100644 (file)
index 0000000..3ef69d9
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.annotations.factories;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.objmap.bidirectional.IBidirectionalMappingRule;
+import org.simantics.objmap.graph.annotations.LinkedListAdd;
+import org.simantics.objmap.graph.annotations.LinkedListGet;
+import org.simantics.objmap.graph.annotations.LinkedListRem;
+import org.simantics.objmap.graph.rules.MappedElementsRule;
+import org.simantics.objmap.graph.rules.domain.LinkedListAccessor;
+import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory;
+import org.simantics.objmap.graph.rules.range.CollectionAccessor;
+
+public class LinkedListRuleFactory2<Range> implements ICollectionRuleFactory<Resource,Range> {
+       
+       @Override
+       public IBidirectionalMappingRule<Resource, Range> create(ReadGraph g, Annotation annotation,
+                       Method getter, Method adder, Method remover)
+                       throws DatabaseException {
+               LinkedListGet getterAnn = (LinkedListGet)annotation;
+               return new MappedElementsRule<Resource,Range>(new LinkedListAccessor(g.getResource(getterAnn.value()), g.getResource(getterAnn.type()), getterAnn.composition()),
+                                       new CollectionAccessor<Range,Range>(getter, adder, remover));
+       }
+       
+       @Override
+       public boolean isAdder(Annotation getterAnnotation, Annotation annotation) {
+               LinkedListGet getterAnn = (LinkedListGet)getterAnnotation;
+               LinkedListAdd adderAnn = (LinkedListAdd)annotation;
+               return getterAnn.value().equals(adderAnn.value());
+       }
+       
+       @Override
+       public boolean isRemover(Annotation getterAnnotation, Annotation annotation) {
+               LinkedListGet getterAnn = (LinkedListGet)getterAnnotation;
+               LinkedListRem adderAnn = (LinkedListRem)annotation;
+               return getterAnn.value().equals(adderAnn.value());
+       }
+
+}
index 994811feef05cc85385ccce8e0d504cad3035b79..5c57a75c3c2d3279281209ffa1dfe786d33a59c9 100644 (file)
@@ -14,6 +14,10 @@ package org.simantics.objmap.graph.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingConstructionException;
+import org.simantics.databoard.binding.reflection.BindingRequest;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
@@ -47,8 +51,14 @@ public class RelatedGetSetValueRuleFactory<Range> implements IGetSetRuleFactory<
                Class<? extends ValueAdapter> adapterClass = getterAnn.adapter();
                 IRangeAccessor<Range,Object> rangeAccessor = new GetSetValueAccessor<Range,Object>(getter, setter);
         Resource valueType;
+        Binding valueBinding = null;
         if (adapterClass == IdentityAdapter.class) {
-            valueType = dataTypeOfClass(g, getter.getReturnType());
+            try {
+                valueBinding = Bindings.getBinding(BindingRequest.create(getter));
+            } catch (BindingConstructionException e) {
+                return null;
+            }
+            valueType = DataTypeUtils.dataTypeOfDatatype(g, valueBinding.type());
         } else {
                try{
                         ValueAdapter adapter = adapterClass.newInstance();
@@ -60,7 +70,7 @@ public class RelatedGetSetValueRuleFactory<Range> implements IGetSetRuleFactory<
                  throw new RuntimeException(e);
              }
         }
-               return new ValueRule<Resource,Range>(new RelatedValueAccessor(g.getResource(getterAnn.value()), valueType),
+               return new ValueRule<Resource,Range>(new RelatedValueAccessor(g.getResource(getterAnn.value()), valueType, valueBinding),
                                        rangeAccessor);
        }
        
index ca226c60554edc91a625dffa889b492acbd06dc0..adb2f6215e3a76c8d45f76a9122f5feef2ec7ec6 100644 (file)
@@ -14,12 +14,15 @@ package org.simantics.objmap.graph.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingConstructionException;
+import org.simantics.databoard.binding.reflection.BindingRequest;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.ResourceNotFoundException;
 import org.simantics.db.exception.ServiceException;
 import org.simantics.db.exception.ValidationException;
-
 import org.simantics.objmap.bidirectional.IBidirectionalMappingRule;
 import org.simantics.objmap.graph.annotations.RelatedValue;
 import org.simantics.objmap.graph.rules.ValueRule;
@@ -41,8 +44,14 @@ public class RelatedValueRuleFactory<Range> implements IFieldRuleFactory<Resourc
         Class<? extends ValueAdapter> adapterClass = annotation.adapter();
         IRangeAccessor<Range,Object> rangeAccessor = new FieldAccessor<Range,Object>(field);
         Resource valueType;
+        Binding valueBinding = null;
         if (adapterClass == IdentityAdapter.class) {
-            valueType = DataTypeUtils.dataTypeOfClass(g, field.getType());
+            try {
+                valueBinding = Bindings.getBinding(BindingRequest.create(field));
+                valueType = DataTypeUtils.dataTypeOfDatatype(g, valueBinding.type());
+            } catch (BindingConstructionException e) {
+                return null;
+            }
         } else {
             try {
                 ValueAdapter adapter = adapterClass.newInstance();
@@ -54,7 +63,7 @@ public class RelatedValueRuleFactory<Range> implements IFieldRuleFactory<Resourc
                 throw new RuntimeException(e);
             }
         }
-        return new ValueRule<Resource,Range>(new RelatedValueAccessor(g.getResource(annotation.value()), valueType), rangeAccessor);
+        return new ValueRule<Resource,Range>(new RelatedValueAccessor(g.getResource(annotation.value()), valueType, valueBinding), rangeAccessor);
     }
 
 }
index 10f64be78d5eef552a2c3a7f7fc69cb41894ceb6..e1de9f20c20c0983a4ea4c2fe15d40c0db872e04 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.graph.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -26,7 +27,7 @@ import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
 
 public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(UpdateMethodFactory.class);
     
     @Override
     public IBidirectionalMappingRule<Domain, Range> create(ReadGraph g, 
@@ -40,7 +41,7 @@ public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Do
             public boolean updateRange(ReadGraph g, IForwardMapping<Domain, Range> map,
                     Domain domainElement, Range rangeElement)
                     throws MappingException {
-                LOGGER.info("    UpdateMethodFactory.updateRange");      
+                LOGGER.trace("    UpdateMethodFactory.updateRange");      
                 try {
                     return (Boolean)method.invoke(rangeElement, g, domainElement);
                 } catch (Exception e) {
index f105a2894c42866f6ccca0cf6d8650c2dc36b406..c2ecdf1b1679fe7f9fd5bd21ed9a0cef090ea63d 100644 (file)
@@ -21,7 +21,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -42,7 +43,7 @@ import org.simantics.objmap.graph.schema.IMappingSchema;
  */
 public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
 
-       static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+       static final Logger LOGGER = LoggerFactory.getLogger(Mapping.class);
        
        
        IMappingSchema<Domain, Range> schema;
@@ -72,7 +73,7 @@ public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
        }
        
        private void createDomain(WriteGraph g, Link<Domain,Range> link) throws MappingException {
-           LOGGER.info("        createDomain for " + link.rangeElement);
+           LOGGER.trace("        createDomain for " + link.rangeElement);
                ILinkType<Domain,Range> type = schema.linkTypeOfRangeElement(link.rangeElement);
                Domain domainElement = type.createDomainElement(g, link.rangeElement);
                link.type = type;
@@ -263,11 +264,11 @@ public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
        
        @Override
        public synchronized Collection<Domain> updateDomain(WriteGraph g) throws MappingException {
-           LOGGER.info("Mapping.updateDomain");
+           LOGGER.trace("Mapping.updateDomain");
                RangeToDomain map = new RangeToDomain(g);
                ArrayList<Domain> updated = new ArrayList<Domain>();
                while(!modifiedRangeLinks.isEmpty()) {
-                   LOGGER.info("    modifiedRangeLinks.size() = " + modifiedRangeLinks.size());
+                   LOGGER.trace("    modifiedRangeLinks.size() = " + modifiedRangeLinks.size());
                    
                        Link<Domain,Range> link = modifiedRangeLinks.remove(modifiedRangeLinks.size()-1);
                        link.rangeModified = false;
@@ -279,9 +280,10 @@ public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
                        if(link.type == null) {
                                createDomain(g, link);
                        }
-                       
-                       if(link.type.updateDomain(g, map, link.domainElement, link.rangeElement))
-                               updated.add(link.domainElement);
+                       else {
+                               if(link.type.updateDomain(g, map, link.domainElement, link.rangeElement))
+                                       updated.add(link.domainElement);
+                       }
                }       
                if (listensDomain)
                        updateRange(g); //FIXME: without this listening would stop. 
@@ -290,11 +292,11 @@ public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
        
        @Override
        public synchronized Collection<Range> updateRange(ReadGraph g) throws MappingException {
-           LOGGER.info("Mapping.updateRange");
+           LOGGER.trace("Mapping.updateRange");
                DomainToRange map = new DomainToRange(g);
                ArrayList<Range> updated = new ArrayList<Range>();
                while(!modifiedDomainLinks.isEmpty()) {             
-                   LOGGER.info("    modifiedDomainLinks.size() = " + modifiedDomainLinks.size());
+                   LOGGER.trace("    modifiedDomainLinks.size() = " + modifiedDomainLinks.size());
                    
                        Link<Domain,Range> link = modifiedDomainLinks.remove(modifiedDomainLinks.size()-1);
                        link.domainModified = false;
@@ -357,7 +359,7 @@ public class Mapping<Domain, Range> implements IMapping<Domain, Range> {
        void domainModified(Link<Domain,Range> link) {
            if(!link.domainModified) {          
                synchronized(modifiedDomainLinks) {
-                   LOGGER.info("        domainModified for " + link.rangeElement);
+                   LOGGER.trace("        domainModified for " + link.rangeElement);
                 link.domainModified = true;
                 modifiedDomainLinks.add(link);
                 if(modifiedDomainLinks.size() == 1) {
index 3b6fac31d4299f9d75efb5d41a2f2391aa137b75..9761f555568fbc6b3827eaa2d6cd7ee77e9ad884 100644 (file)
@@ -11,7 +11,6 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules;
 
-import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -20,9 +19,8 @@ import org.simantics.objmap.exceptions.MappingException;
 import org.simantics.objmap.forward.IForwardMapping;
 import org.simantics.objmap.graph.rules.domain.IDomainAccessor;
 import org.simantics.objmap.graph.rules.range.IRangeAccessor;
-
-
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A rule that synchronizes collection of elements between
@@ -32,7 +30,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class MappedElementRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappedElementRule.class);
     
        IDomainAccessor<Domain,Domain> domainAccessor;
        IRangeAccessor<Range,Range> rangeAccessor;
@@ -47,7 +45,7 @@ public class MappedElementRule<Domain, Range> implements IBidirectionalMappingRu
        public boolean updateDomain(WriteGraph g, IBackwardMapping<Domain, Range> map,
                        Domain domainElement, Range rangeElement)
                        throws MappingException {
-        LOGGER.info("    MappedElementRule.updateDomain");
+        LOGGER.trace("    MappedElementRule.updateDomain");
            Range value = rangeAccessor.get(rangeElement);
            Domain mappedValue = value == null ? null : map.inverseMap(g, value);//map.inverseGet(value);
                return domainAccessor.set(g, domainElement, mappedValue);
@@ -57,7 +55,7 @@ public class MappedElementRule<Domain, Range> implements IBidirectionalMappingRu
        public boolean updateRange(ReadGraph g, IForwardMapping<Domain, Range> map,
                        Domain domainElement, Range rangeElement)
                        throws MappingException {
-        LOGGER.info("    MappedElementRule.updateRange");   
+        LOGGER.trace("    MappedElementRule.updateRange");   
            Domain value = domainAccessor.get(g, domainElement);
         Range mappedValue = value == null ? null : map.map(g, value);////map.get(value);
         return rangeAccessor.set(rangeElement, mappedValue);
index cd295e583d426b08f5fd9d163bf6b0f9c17b6564..7f3c13a106e956989fc4185353de667adad5f6e1 100644 (file)
@@ -14,7 +14,6 @@ package org.simantics.objmap.graph.rules;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -23,6 +22,8 @@ import org.simantics.objmap.exceptions.MappingException;
 import org.simantics.objmap.forward.IForwardMapping;
 import org.simantics.objmap.graph.rules.domain.IDomainAccessor;
 import org.simantics.objmap.graph.rules.range.IRangeAccessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -33,7 +34,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class MappedElementsRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappedElementsRule.class);
 
     IDomainAccessor<Domain,Collection<Domain>> domainAccessor;
     IRangeAccessor<Range,Collection<Range>> rangeAccessor;
@@ -48,7 +49,7 @@ public class MappedElementsRule<Domain, Range> implements IBidirectionalMappingR
     public boolean updateDomain(WriteGraph g, IBackwardMapping<Domain, Range> map,
             Domain domainElement, Range rangeElement)
     throws MappingException {
-        LOGGER.info("    MappedElementsRule.updateDomain");
+        LOGGER.trace("    MappedElementsRule.updateDomain");
         // Snapshot the accessed range value for concurrency safety.
         // NOTE: still assumes that the accessed collection is concurrent or
         // synchronized for toArray to be atomic.
@@ -64,7 +65,7 @@ public class MappedElementsRule<Domain, Range> implements IBidirectionalMappingR
     public boolean updateRange(ReadGraph g, IForwardMapping<Domain, Range> map,
             Domain domainElement, Range rangeElement)
     throws MappingException {
-        LOGGER.info("    MappedElementsRule.updateRange");
+        LOGGER.trace("    MappedElementsRule.updateRange");
         Collection<Domain> value = domainAccessor.get(g, domainElement);
         ArrayList<Range> mappedValue = new ArrayList<Range>(value.size());
         for(Domain r : value)
index 718bc7c2d780ec46ded879a5416cf37d6051a7a1..9ba9dba11274291b0dadb6664492542bd853951e 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.objmap.backward.IBackwardMapping;
@@ -29,7 +30,7 @@ import org.simantics.objmap.graph.rules.range.IRangeAccessor;
  */
 public class ValueRule<Domain, Range> implements IBidirectionalMappingRule<Domain, Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(ValueRule.class);
     
        IDomainAccessor<Domain,Object> domainAccessor;
        IRangeAccessor<Range,Object> rangeAccessor;
@@ -44,7 +45,7 @@ public class ValueRule<Domain, Range> implements IBidirectionalMappingRule<Domai
        public boolean updateDomain(WriteGraph g, IBackwardMapping<Domain, Range> map,
                        Domain domainElement, Range rangeElement)
                        throws MappingException {
-        LOGGER.info("    ValueRule.updateDomain");         
+        LOGGER.trace("    ValueRule.updateDomain");        
                Object value = rangeAccessor.get(rangeElement);
                return domainAccessor.set(g, domainElement, value);
        }
@@ -53,7 +54,7 @@ public class ValueRule<Domain, Range> implements IBidirectionalMappingRule<Domai
        public boolean updateRange(ReadGraph g, IForwardMapping<Domain, Range> map,
                        Domain domainElement, Range rangeElement)
                        throws MappingException {
-        LOGGER.info("    ValueRule.updateRange");
+        LOGGER.trace("    ValueRule.updateRange");
                Object value = domainAccessor.get(g, domainElement);
                return rangeAccessor.set(rangeElement, value);
        }       
index 78b48430310356fd0c4f0561aaefb0736f8f907d..39df524b270943022478f51669f2a6627cbbe03e 100644 (file)
  *******************************************************************************/
 package org.simantics.objmap.graph.rules.domain;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
+import org.simantics.databoard.binding.Binding;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.ServiceException;
 import org.simantics.layer0.Layer0;
 import org.simantics.objmap.exceptions.MappingException;
-import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory;
+import org.simantics.objmap.graph.annotations.factories.DataTypeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 
@@ -32,42 +34,46 @@ import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetVal
  */
 public class CompoundValueAccessor implements IDomainAccessor<Resource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(CompoundValueAccessor.class);
     
        Resource objRelation;
        Resource objType;
        Resource valRelation;
+       Binding valueBinding;
 
-       public CompoundValueAccessor(Resource objRelation, Resource objType, Resource valRelation) {
+       public CompoundValueAccessor(Resource objRelation, Resource objType, Resource valRelation, Binding valueBinding) {
                this.objRelation = objRelation;
                this.objType = objType;
                this.valRelation = valRelation;
+               this.valueBinding = valueBinding;
        }
 
        @Override
        public Object get(ReadGraph g, Resource element) throws MappingException {
                try {
                        Layer0 l0 = Layer0.getInstance(g);
-                   LOGGER.info("        CompoundValueAccessor.get");
+                   LOGGER.trace("        CompoundValueAccessor.get");
                    Collection<Statement> coll = g.getStatements(element, objRelation);
                    Map<String,Object> map = new HashMap<String, Object>();
                    for (Statement c : coll) {
                        String name = g.getRelatedValue(c.getObject(), l0.HasName);
-                       if (!map.containsKey(name) || !c.isAsserted(element))
-                               map.put(name, g.getRelatedValue(c.getObject(), valRelation));
+                       if (!map.containsKey(name) || !c.isAsserted(element)) {
+                                       final Object value = getValue(g, c.getObject());
+                                       map.put(name, value);
+                               }
                    }
                        return map;
                } catch (DatabaseException e) {
                        throw new MappingException(e);
                }
        }
-       
+
        @Override
        public boolean set(WriteGraph g, Resource element, Object v)
                        throws MappingException {
                try {
                        Layer0 l0 = Layer0.getInstance(g);
-                   LOGGER.info("        CompoundValueAccessor.set");
+                   LOGGER.trace("        CompoundValueAccessor.set");
                    @SuppressWarnings("unchecked")
                    Map<String,Object> values = (Map<String, Object>)v;
                    
@@ -81,6 +87,7 @@ public class CompoundValueAccessor implements IDomainAccessor<Resource,Object> {
                                valueMap.put(name, g.getRelatedValue(c.getObject(), valRelation));
                        }
                    }
+                   
                    boolean changed = false;
                    for (String key : values.keySet()) {
                        Object value = values.get(key);
@@ -97,34 +104,40 @@ public class CompoundValueAccessor implements IDomainAccessor<Resource,Object> {
                        }
                        
                        Statement valueStatement = g.getPossibleStatement(stm.getObject(), valRelation);
-                       Resource valueType = CompoundRelatedGetSetValueRuleFactory.dataTypeOfClass(g, value.getClass());
+                       Resource valueType = valueBinding != null ?
+                                       DataTypeUtils.dataTypeOfDatatype(g, valueBinding.type()) :
+                                       DataTypeUtils.dataTypeOfClass(g, value.getClass());
+                                       
                                if(valueStatement == null) {
-                                       
                                        Resource valueResource = g.newResource();
-                                       g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null,  valueType);
+                                       g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, valueType);
                                        g.claim(stm.getObject(), valRelation, valueResource);
-                                       g.claimValue(valueResource, value);                             
+                                       claimValue(g, valueResource, value);
                                } else {
-                                                                       
-                                       
                                        if (!valueStatement.isAsserted(stm.getObject()))
                                                g.claimValue(valueStatement.getObject(), value);
                                        else {
                                                Resource valueResource = g.newResource();
-                                               g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null,
-                                                               valueType);
+                                               g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null, valueType);
                                                g.claim(stm.getObject(), valRelation, valueResource);
-                                               g.claimValue(valueResource, value);
+                                               claimValue(g, valueResource, value);
                                        }
                                }
                    }
-                   return changed;
                    
+                   return changed;
                } catch (DatabaseException e) {
                        throw new MappingException(e);
                }
                
        }
+
+       private void claimValue(WriteGraph g, Resource valueResource, Object value) throws ServiceException {
+               if (valueBinding != null)
+                       g.claimValue(valueResource, value, valueBinding);
+               else
+                       g.claimValue(valueResource, value);
+       }
        
        private Statement getStatement(ReadGraph g, Resource s, Resource p, Resource o) throws DatabaseException{
                for (Statement stm : g.getStatements(s, p)) {
@@ -134,19 +147,8 @@ public class CompoundValueAccessor implements IDomainAccessor<Resource,Object> {
                return null;
        }
        
-       private boolean equals(Object o1, Object o2) {
-               if (o1 instanceof boolean[])
-                       Arrays.equals((boolean[])o1,(boolean[])o2);
-               if (o1 instanceof int[])
-                       Arrays.equals((int[])o1,(int[])o2);
-               if (o1 instanceof float[])
-                       Arrays.equals((float[])o1,(float[])o2);
-               if (o1 instanceof double[])
-                       Arrays.equals((double[])o1,(double[])o2);
-               if (o1 instanceof byte[])
-                       Arrays.equals((byte[])o1,(byte[])o2);
-               return o1.equals(o2);
-               
+       private Object getValue(ReadGraph g, final Resource object) throws DatabaseException {
+               return valueBinding != null ? g.getRelatedValue(object, valRelation, valueBinding) : g.getRelatedValue(object, valRelation);
        }
 
 }
diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/LinkedListAccessor.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/domain/LinkedListAccessor.java
new file mode 100644 (file)
index 0000000..e9104c3
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.objmap.graph.rules.domain;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.utils.ListUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.objmap.exceptions.MappingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Accesses the set of objects attached to the element by the given relation.
+ * @author Hannu Niemistö
+ */
+public class LinkedListAccessor implements IDomainAccessor<Resource,Collection<Resource>> {
+
+       static Logger LOGGER = LoggerFactory.getLogger(LinkedListAccessor.class);
+
+       Resource relation;
+       Resource listType;
+       boolean deleteExtraObjects;
+
+       public LinkedListAccessor(Resource relation, Resource listType, boolean deleteExtraObjects) {
+               super();
+               this.relation = relation;
+               this.listType = listType;
+               this.deleteExtraObjects = deleteExtraObjects;
+       }
+
+       @Override
+       public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {
+               try {
+                       LOGGER.trace("        LinkdedListAccessor.get");
+                       return ListUtils.toList(g, g.getPossibleObject(element, relation));
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+       }
+
+       @Override
+       public boolean set(WriteGraph g, Resource element, Collection<Resource> value)
+                       throws MappingException {
+               try {
+                       LOGGER.trace("        LinkdedListAccessor.set");
+                       return MappingUtils.synchronizeList(g, element, relation, listType, new ArrayList<Resource>(value), deleteExtraObjects);
+               } catch (DatabaseException e) {
+                       throw new MappingException(e);
+               }
+
+       }
+
+}
index a0d0d4dac2df176cc881fb9759f4173a911a1db1..0bb50ff5726c270d92e69cb1be1074a71e3030bd 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2013 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2013, 2019 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
@@ -8,16 +8,24 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum oy - linked list utilities
  *******************************************************************************/
 package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
+import org.simantics.db.common.utils.ListUtils;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
+import org.simantics.db.exception.NoSingleResultException;
+import org.simantics.db.exception.ServiceException;
+import org.simantics.layer0.Layer0;
 
 /**
  * Static utility methods for rule implementations.
@@ -25,7 +33,7 @@ import org.simantics.db.exception.DatabaseException;
  */
 public class MappingUtils {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(MappingUtils.class);
     
     /**
      * Adds and removes statements to/from the database so that <code>objects</code>
@@ -47,7 +55,7 @@ public class MappingUtils {
                while(true) {
                        int cmp = currentObjects[i].compareTo(objects[j]);
                        if(cmp < 0) {
-                           LOGGER.info("            remove statement");
+                           LOGGER.trace("            remove statement");
                            if(deleteExtraObjects)
                                g.deny(currentObjects[i]);
                            else
@@ -58,7 +66,7 @@ public class MappingUtils {
                                        break;
                        }
                        else if(cmp > 0) {
-                           LOGGER.info("            add statement");
+                           LOGGER.trace("            add statement");
                                g.claim(subject, predicate, objects[j]);
                                modified = true;
                                ++j;
@@ -89,4 +97,75 @@ public class MappingUtils {
                return modified;
        }
 
+       public static boolean synchronizeList(WriteGraph g, Resource element, Resource relation, Resource listType, List<Resource> value, boolean deleteExtraObjects) throws DatabaseException {
+               final Layer0 L0 = Layer0.getInstance(g);
+               
+               // Return value
+               boolean modified = false;
+               
+               // Get the list - create a new one, if necessary
+               Resource currentList = g.getPossibleObject(element, relation);
+               if (currentList == null) {
+                       currentList = ListUtils.create(g, listType);
+                       g.claim(element, relation, currentList);
+                       modified = true;
+               }
+
+               // Synchronize elements
+               List<Resource> currentNodes = ListUtils.getListNodes(g, currentList);
+               int i = 0, j = 0;
+               while (i < currentNodes.size()) {
+                       Resource node = currentNodes.get(i);
+                       Resource v = g.getSingleObject(node, L0.List_Element);
+                       if (j < value.size() && v.equals(value.get(j))) {
+                               i++;
+                               j++;
+                       }
+                       else if (value.indexOf(v) > j) {
+                               // Insert new element in the middle
+                               insertElementBefore(g, L0, node, value.get(j));
+                               modified = true;
+                               j++;
+                       }
+                       else {
+                               // Remove deleted element
+                               if (deleteExtraObjects) g.deny(v);
+                               removeNode(g, L0, node);
+                               modified = true;
+                               i++;
+                       }
+               }
+
+               // Add new elements at end
+               while (j < value.size()) {
+                       // Add tailing elements
+                       insertElementBefore(g, L0, currentList, value.get(j));
+                       modified = true;
+                       j++;
+               }
+               
+               return modified;
+       }
+
+       private static Resource insertElementBefore(WriteGraph g, final Layer0 L0, Resource node, final Resource val)
+                       throws NoSingleResultException, ManyObjectsForFunctionalRelationException, ServiceException {
+               Resource prev = g.getSingleObject(node, L0.List_Previous);
+               g.deny(prev, L0.List_Next, L0.List_Previous, node);
+               
+               Resource newNode = g.newResource();
+               g.claim(newNode, L0.InstanceOf, L0.List_Entry);
+               g.claim(prev, L0.List_Next, L0.List_Previous, newNode);
+               g.claim(newNode, L0.List_Next, L0.List_Previous, node);
+               g.claim(newNode, L0.List_Element, val);
+               return newNode;
+       }
+
+       private static void removeNode(WriteGraph g, final Layer0 L0, Resource node)
+                       throws NoSingleResultException, ManyObjectsForFunctionalRelationException, ServiceException {
+               Resource prev = g.getSingleObject(node, L0.List_Previous);
+               Resource next = g.getSingleObject(node, L0.List_Next);
+               g.claim(prev, L0.List_Next, L0.List_Previous, next);
+               g.deny(node);
+       }
+
 }
index 99253790cf0e0f0611eadcf06c9f297189882892..28000a99e7412688f7544ac392bbafa8fd868c67 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.rules.domain;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -24,7 +25,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectAccessor.class);
     
        Resource relation;
        
@@ -35,7 +36,7 @@ public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource>
        @Override
        public Resource get(ReadGraph g, Resource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectAccessor.get");
+                   LOGGER.trace("        RelatedObjectAccessor.get");
                        return g.getPossibleObject(element, relation);
                } catch (DatabaseException e) {
                        throw new MappingException(e);
@@ -46,7 +47,7 @@ public class RelatedObjectAccessor implements IDomainAccessor<Resource,Resource>
        public boolean set(WriteGraph g, Resource element, Resource value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectAccessor.set");
+                   LOGGER.trace("        RelatedObjectAccessor.set");
                    Resource resource = g.getPossibleObject(element, relation);
                        if(resource == null) {
                            if(value == null)
index 9653ab370c28f5dc058b6be7e09edd6074c02743..d2d1db99a7d78e6cc06f1d93483e3523ae376e93 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -26,7 +27,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedObjectsAccessor implements IDomainAccessor<Resource,Collection<Resource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
@@ -40,7 +41,7 @@ public class RelatedObjectsAccessor implements IDomainAccessor<Resource,Collecti
     @Override
        public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.get");
+                   LOGGER.trace("        RelatedObjectsAccessor.get");
                        return g.getObjects(element, relation);
                } catch (DatabaseException e) {
                        throw new MappingException(e);
@@ -51,7 +52,7 @@ public class RelatedObjectsAccessor implements IDomainAccessor<Resource,Collecti
        public boolean set(WriteGraph g, Resource element, Collection<Resource> value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.set");
+                   LOGGER.trace("        RelatedObjectsAccessor.set");
                        return MappingUtils.synchronizeStatements(g, element, relation, 
                                value.toArray(new Resource[value.size()]), deleteExtraObjects);
                } catch (DatabaseException e) {
index c033751e506eb7797e92918257520b8463203d6d..4d78956756a7db91ef392c6cdb1999465f2c4c0b 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Collection;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -27,7 +28,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Resource, Collection<Resource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedOrderedSetElementsAccessor.class);
     
        boolean deleteExtraObjects;
 
@@ -39,7 +40,7 @@ public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Resour
     @Override
        public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.get");
+                   LOGGER.trace("        RelatedOrderedSetElementsAccessor.get");
                        return OrderedSetUtils.toList(g, element);
                } catch (DatabaseException e) {
                        throw new MappingException(e);
@@ -50,7 +51,7 @@ public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Resour
        public boolean set(WriteGraph g, Resource element, Collection<Resource> value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.set");
+                   LOGGER.trace("        RelatedOrderedSetElementsAccessor.set");
                    return OrderedSetUtils.set(g, element, value);
                    // FIXME Implement deleteExtraObjects
                } catch (DatabaseException e) {
index d5ad40b77cd8f82f2369978872c7e967e24aac7d..9aa96d8e89ed64a1379b77d39ec762b2f83ac706 100644 (file)
@@ -13,14 +13,20 @@ package org.simantics.objmap.graph.rules.domain;
 
 import java.util.Arrays;
 
-import org.apache.log4j.Logger;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.OptionalBinding;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
 import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.BindingException;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.DoesNotContainValueException;
+import org.simantics.db.exception.ServiceException;
 import org.simantics.layer0.Layer0;
 import org.simantics.objmap.exceptions.MappingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Accesses a value attached to the element by given functional relation.
@@ -28,34 +34,36 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedValueAccessor.class);
     
        Resource relation;
        Resource valueType;
+       Binding valueBinding;
 
-       public RelatedValueAccessor(Resource relation, Resource valueType) {
+       public RelatedValueAccessor(Resource relation, Resource valueType, Binding valueBinding) {
                this.relation = relation;
                this.valueType = valueType;
+               this.valueBinding = valueBinding;
        }
 
        @Override
        public Object get(ReadGraph g, Resource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedValueAccessor.get");
+                   LOGGER.trace("        RelatedValueAccessor.get");
                        Resource valueResource = g.getPossibleObject(element, relation);
                        if(valueResource == null)
                                return null;
-                       return g.getValue(valueResource);
+                       return getValue(g, valueResource);
                } catch (DatabaseException e) {
                        throw new MappingException(e);
                }
        }
-       
+
        @Override
        public boolean set(WriteGraph g, Resource element, Object value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedValueAccessor.set");
+                   LOGGER.trace("        RelatedValueAccessor.set");
                    Statement valueStatement = g.getPossibleStatement(element, relation);
                        if(valueStatement == null) {
                                if(value == null)
@@ -64,7 +72,8 @@ public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
                                g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null,
                                                valueType);
                                g.claim(element, relation, valueResource);
-                               g.claimValue(valueResource, value);                             
+                               claimValue(g, valueResource, value);
+                               
                                return true;
                        }
                        else {
@@ -76,7 +85,7 @@ public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
                                                return false;
                                        }
                                }                               
-                               Object currentValue = g.getValue(valueStatement.getObject());
+                               Object currentValue = getValue(g, valueStatement.getObject());
                                if(equals(currentValue,value))
                                        return false;
                                if (!valueStatement.isAsserted(element))
@@ -86,7 +95,7 @@ public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
                                        g.claim(valueResource, Layer0.getInstance(g).InstanceOf, null,
                                                        valueType);
                                        g.claim(element, relation, valueResource);
-                                       g.claimValue(valueResource, value);
+                                       claimValue(g, valueResource, value);
                                }
                                return true;
                        }
@@ -95,8 +104,32 @@ public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
                }
                
        }
+
+       private Object getValue(ReadGraph g, Resource valueResource)
+                       throws DoesNotContainValueException, BindingException, ServiceException {
+               if (valueBinding != null) {
+                       return g.getValue(valueResource, getBaseBinding(valueBinding));
+               }
+               else {
+                       return g.getValue(valueResource);
+               }
+       }
+       
+       private void claimValue(WriteGraph g, Resource valueResource, Object value) throws ServiceException {
+               if (valueBinding != null)
+                       g.claimValue(valueResource, value, getBaseBinding(valueBinding));
+               else
+                       g.claimValue(valueResource, value);
+       }
+
+       private static Binding getBaseBinding(Binding binding) {
+               return binding instanceof OptionalBinding ? ((OptionalBinding)binding).getComponentBinding() : binding;
+       }
        
        private boolean equals(Object o1, Object o2) {
+               if (valueBinding != null)
+                       return valueBinding.equals(o1, o2);
+               
                if (o1 instanceof boolean[])
                        Arrays.equals((boolean[])o1,(boolean[])o2);
                if (o1 instanceof int[])
@@ -108,7 +141,6 @@ public class RelatedValueAccessor implements IDomainAccessor<Resource,Object> {
                if (o1 instanceof byte[])
                        Arrays.equals((byte[])o1,(byte[])o2);
                return o1.equals(o2);
-               
        }
 
 }
index 6615e94fb41edf507f55e646cbb9b539bca679c0..c5a35613cd07ade3454c45f76b720096ace63d4f 100644 (file)
@@ -13,8 +13,9 @@ package org.simantics.objmap.graph.rules.range;
 
 import java.lang.reflect.Field;
 
-import org.apache.log4j.Logger;
 import org.simantics.objmap.exceptions.MappingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -23,7 +24,7 @@ import org.simantics.objmap.exceptions.MappingException;
  */
 public class FieldAccessor<Range,T> implements IRangeAccessor<Range,T> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static final Logger LOGGER = LoggerFactory.getLogger(FieldAccessor.class);
     
        Field field;
 
@@ -37,8 +38,8 @@ public class FieldAccessor<Range,T> implements IRangeAccessor<Range,T> {
                    @SuppressWarnings("unchecked")
                        T result = (T)field.get(element);
                    
-               if(LOGGER.isInfoEnabled())
-                   LOGGER.info("        FieldAccessor.get " +
+               if(LOGGER.isTraceEnabled())
+                   LOGGER.trace("        FieldAccessor.get " +
                            field.getName() + " -> " + result
                    );
                
@@ -55,8 +56,8 @@ public class FieldAccessor<Range,T> implements IRangeAccessor<Range,T> {
                try {
                        Object currentValue = field.get(element);
                        
-            if(LOGGER.isInfoEnabled())
-                LOGGER.info("        FieldAccessor.set " +
+            if(LOGGER.isTraceEnabled())
+                LOGGER.trace("        FieldAccessor.set " +
                         field.getName() + " " + currentValue +  
                         " -> " + value
                 );
index 046a744cf4d332cac824bd03b2429ad959d20fc7..9b02d5d50c9bec9d4bcb77ed9a1277fd6c015267 100644 (file)
@@ -11,7 +11,7 @@
  *******************************************************************************/
 package org.simantics.objmap.graph.schema;
 
-//import org.apache.log4j.Logger;
+//import org.slf4j.Logger;
 import org.eclipse.core.runtime.IAdaptable;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
index 792813bb1020b8a524723dea76ba7bf1f7aac46d..4f44844dbbaa034afbc9d84dcf702c3cb2965ece 100644 (file)
@@ -70,8 +70,8 @@ public class DynamicSimpleLinkType<Range> extends SimpleLinkType<Range>{
             throws MappingException {
         try {
                String typeUri = (String)typeGetter.invoke(rangeElement, (Object[]) null);
-            if(LOGGER.isInfoEnabled())
-                LOGGER.info("SimpleLinkType.createDomainElement " +
+            if(LOGGER.isTraceEnabled())
+                LOGGER.trace("SimpleLinkType.createDomainElement " +
                         rangeElement.toString()
                 );
             Resource actualDomainType = g.getResource(typeUri);
@@ -95,9 +95,9 @@ public class DynamicSimpleLinkType<Range> extends SimpleLinkType<Range>{
            public Range createRangeElement(ReadGraph g, Resource domainElement)
                    throws MappingException {
                try {
-                   if(LOGGER.isInfoEnabled())
+                   if(LOGGER.isTraceEnabled())
                        try { 
-                           LOGGER.info("SimpleLinkType.createRangeElement " +
+                           LOGGER.trace("SimpleLinkType.createRangeElement " +
                                        NameUtils.getSafeName(g, domainElement)
                                    );
                        } catch(DatabaseException e) {
index 871d46bdaebce02c458098fa1b690717fc9ed741..cf2f3bf45065c5bee4951da094d67b8e94686767 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
+ * Copyright (c) 2012, 2013, 2019 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
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum oy - linked list mapping API and implementation
  *******************************************************************************/
 package org.simantics.objmap.graph.schema;
 
@@ -27,9 +28,12 @@ import org.simantics.objmap.graph.annotations.GraphType;
 import org.simantics.objmap.graph.annotations.HasCollectionAdder;
 import org.simantics.objmap.graph.annotations.HasCollectionRemover;
 import org.simantics.objmap.graph.annotations.HasSetter;
+import org.simantics.objmap.graph.annotations.LinkedListGet;
+import org.simantics.objmap.graph.annotations.LinkedList;
 import org.simantics.objmap.graph.annotations.OptionalRelatedElements;
 import org.simantics.objmap.graph.annotations.OrderedElementsGet;
 import org.simantics.objmap.graph.annotations.OrderedSetType;
+import org.simantics.objmap.graph.annotations.RelatedElement;
 import org.simantics.objmap.graph.annotations.RelatedElements;
 import org.simantics.objmap.graph.annotations.RelatedElementsGet;
 import org.simantics.objmap.graph.annotations.RelatedGetObj;
@@ -38,8 +42,11 @@ import org.simantics.objmap.graph.annotations.RelatedOrderedSetElements;
 import org.simantics.objmap.graph.annotations.RelatedValue;
 import org.simantics.objmap.graph.annotations.UpdateMethod;
 import org.simantics.objmap.graph.annotations.factories.CompoundRelatedGetSetValueRuleFactory;
+import org.simantics.objmap.graph.annotations.factories.LinkedListRuleFactory;
+import org.simantics.objmap.graph.annotations.factories.LinkedListRuleFactory2;
 import org.simantics.objmap.graph.annotations.factories.OptionalRelatedElementsRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.OrderedElementsRuleFactory;
+import org.simantics.objmap.graph.annotations.factories.RelatedElementRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory;
 import org.simantics.objmap.graph.annotations.factories.RelatedElementsRuleFactory2;
 import org.simantics.objmap.graph.annotations.factories.RelatedGetSetObjRuleFactory;
@@ -57,52 +64,60 @@ import org.simantics.objmap.graph.rules.factory.ICollectionRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IGetSetRuleFactory;
 import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class MappingSchemas {
-       /**
+    private static final Logger LOGGER = LoggerFactory.getLogger(MappingSchemas.class);
+
+    /**
      * Creates a new SimpleLinkType based on the annotations in the given class.
      * @throws IllegalAccessException 
      * @throws InstantiationException 
      * @see GraphType
      * @see RelatedValue
      */
-       public static SimpleLinkType<Object> fromAnnotations(ReadGraph g, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
-           GraphType graphType = clazz.getAnnotation(GraphType.class);
-           
-           if (graphType != null) {
-                   ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new SimpleLinkType<Object>(g.getResource(graphType.value()), clazz, rules);  
-           }
-           DynamicGraphType dynamicType = clazz.getAnnotation(DynamicGraphType.class);
-           if (dynamicType != null) {
-               ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new DynamicSimpleLinkType<Object>(g.getResource(dynamicType.value()), clazz, rules);
-           }
-           OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class);
-           if (orderedSetType != null) {
-               ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
-                   collectRulesFromAnnotations(g, clazz, rules);
-                   
-                   return new OrderedSetSimpleLinkType<Object>(g.getResource(orderedSetType.value()), clazz, rules);
-           }
-           throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations.");
-       }
-       
-       public static void collectRulesFromAnnotations(ReadGraph g, Class<?> clazz, Collection<IBidirectionalMappingRule<Resource, Object>> rules) throws DatabaseException, InstantiationException, IllegalAccessException {
-           Class<?> superclass = clazz.getSuperclass();
-           if(superclass != null)
-               collectRulesFromAnnotations(g, superclass, rules);
-               
+    public static SimpleLinkType<Object> fromAnnotations(ReadGraph g, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
+        GraphType graphType = clazz.getAnnotation(GraphType.class);
+
+        if (graphType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new SimpleLinkType<Object>(g.getResource(graphType.value()), clazz, rules);  
+        }
+        DynamicGraphType dynamicType = clazz.getAnnotation(DynamicGraphType.class);
+        if (dynamicType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new DynamicSimpleLinkType<Object>(g.getResource(dynamicType.value()), clazz, rules);
+        }
+        OrderedSetType orderedSetType = clazz.getAnnotation(OrderedSetType.class);
+        if (orderedSetType != null) {
+            ArrayList<IBidirectionalMappingRule<Resource, Object>> rules = new ArrayList<IBidirectionalMappingRule<Resource, Object>>();
+            collectRulesFromAnnotations(g, clazz, rules);
+
+            return new OrderedSetSimpleLinkType<Object>(g.getResource(orderedSetType.value()), clazz, rules);
+        }
+        throw new IllegalArgumentException("Class " + clazz.toString() + " does not contain annotations.");
+    }
+
+    public static void collectRulesFromAnnotations(ReadGraph g, Class<?> clazz, Collection<IBidirectionalMappingRule<Resource, Object>> rules) throws DatabaseException, InstantiationException, IllegalAccessException {
+        Class<?> superclass = clazz.getSuperclass();
+        if(superclass != null)
+            collectRulesFromAnnotations(g, superclass, rules);
+
         for(Annotation annotation : clazz.getAnnotations()) {
 
-               IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class);
+            IsClassRule tag = annotation.annotationType().getAnnotation(IsClassRule.class);
             if(tag!= null) {
-               rules.add(createClassRule(g, annotation, clazz).create(g, annotation, clazz));
+                final IClassRuleFactory<Resource, Object> ruleFactory = createClassRule(g, annotation, clazz);
+                if (ruleFactory != null)
+                    rules.add(ruleFactory.create(g, annotation, clazz));
+                else
+                    LOGGER.warn("No rule factory found for {}", annotation);
             }
         }
 
@@ -111,9 +126,13 @@ public class MappingSchemas {
 
             for(Annotation annotation : f.getAnnotations()) {
 
-               IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class);
+                IsFieldRule tag = annotation.annotationType().getAnnotation(IsFieldRule.class);
                 if(tag != null) {
-                    rules.add(createFieldRule(g, annotation, f).create(g, annotation, f));
+                    final IFieldRuleFactory<Resource, Object> ruleFactory = createFieldRule(g, annotation, f);
+                    if (ruleFactory != null)
+                        rules.add(ruleFactory.create(g, annotation, f));
+                    else
+                        LOGGER.warn("No rule factory found for {}", annotation);
                 }
             }
         }
@@ -122,140 +141,154 @@ public class MappingSchemas {
             m.setAccessible(true);
 
             for(Annotation annotation : m.getAnnotations()) {
-               IsMethodRule tag = 
+                IsMethodRule tag = 
                         annotation.annotationType().getAnnotation(IsMethodRule.class);
                 if(tag != null) {
-                       rules.add(createMethodRule(g, annotation, m).create(g, annotation, m));
+                    final IMethodRuleFactory<Resource, Object> ruleFactory = createMethodRule(g, annotation, m);
+                    if (ruleFactory != null)
+                        rules.add(ruleFactory.create(g, annotation, m));
+                    else
+                        LOGGER.warn("No rule factory found for {}", annotation);
                 }
             }
         }
-        
+
         for (Method m : clazz.getDeclaredMethods()) {
-               m.setAccessible(true);
-               for (Annotation annotation : m.getAnnotations()) {
-                       Class<? extends Annotation> annotationType = annotation.annotationType();
-
-                        IsGetSetRule tag = 
-                         annotationType.getAnnotation(IsGetSetRule.class);
-                        if (tag != null) {
-                                
-                                HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class);
-                                
-                                Class<? extends Annotation> setterAnn = setterAnnType.value();
-                                
-                                Method getter = m;
-                                
-                                IGetSetRuleFactory<Resource,Object> ruleFactory = createGetSetRuleFactory(g, annotation, getter);
-                                
-                                
-                                Method setter = null;
-                                
-                                for (Method m2 : clazz.getDeclaredMethods()) {
-                                        Annotation set = m2.getAnnotation(setterAnn);
-                                        if (set != null && ruleFactory.isSetter(annotation, set))
-                                                setter = m2;
-                                }
-
-                                rules.add(ruleFactory.create(g, annotation, getter, setter));
-                        }
-                
-               }
+            m.setAccessible(true);
+            for (Annotation annotation : m.getAnnotations()) {
+                Class<? extends Annotation> annotationType = annotation.annotationType();
+
+                IsGetSetRule tag = 
+                        annotationType.getAnnotation(IsGetSetRule.class);
+                if (tag != null) {
+
+                    HasSetter setterAnnType = annotationType.getAnnotation(HasSetter.class);
+
+                    Class<? extends Annotation> setterAnn = setterAnnType.value();
+
+                    Method getter = m;
+
+                    IGetSetRuleFactory<Resource,Object> ruleFactory = createGetSetRuleFactory(g, annotation, getter);
+                    if (ruleFactory != null) {
+                        Method setter = null;
+    
+                        for (Method m2 : clazz.getDeclaredMethods()) {
+                            Annotation set = m2.getAnnotation(setterAnn);
+                            if (set != null && ruleFactory.isSetter(annotation, set))
+                                setter = m2;
+                        }
+    
+                        rules.add(ruleFactory.create(g, annotation, getter, setter));
+                    }
+                    else {
+                        LOGGER.warn("No rule factory found for {}", annotation);
+                    }
+                }
+
+            }
         }
-        
+
         for (Method m : clazz.getDeclaredMethods()) {
-               m.setAccessible(true);
-               for (Annotation annotation : m.getAnnotations()) {
-                       Class<? extends Annotation> annotationType = annotation.annotationType();
-
-                        IsCollectionRule tag = 
-                         annotationType.getAnnotation(IsCollectionRule.class);
-                        if (tag != null) {
-                                
-                                HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class);
-                                HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class);
-                
-                                Class<? extends Annotation> adderAnn = adderAnnType.value();
-                                Class<? extends Annotation> removerAnn = removerAnnType.value();
-                                
-                                Method getter = m;
-                                
-                                ICollectionRuleFactory<Resource,Object> ruleFactory = createCollectionRuleFactory(g, annotation, getter);
-                                
-                                
-                                Method adder = null;
-                                Method remover = null;
-                                
-                                for (Method m2 : clazz.getDeclaredMethods()) {
-                                        Annotation add = m2.getAnnotation(adderAnn);
-                                        Annotation rem = m2.getAnnotation(removerAnn);
-                                        if (add != null && ruleFactory.isAdder(annotation, add))
-                                                adder = m2;
-                                        if (rem != null && ruleFactory.isRemover(annotation, rem))
-                                                remover = m2;
-                                }
-                                
-                                
-                                
-                                rules.add(ruleFactory.create(g, annotation, getter,adder,remover));
-                        }
-                
-               }
+            m.setAccessible(true);
+            for (Annotation annotation : m.getAnnotations()) {
+                Class<? extends Annotation> annotationType = annotation.annotationType();
+
+                IsCollectionRule tag = 
+                        annotationType.getAnnotation(IsCollectionRule.class);
+                if (tag != null) {
+
+                    HasCollectionAdder adderAnnType = annotationType.getAnnotation(HasCollectionAdder.class);
+                    HasCollectionRemover removerAnnType = annotationType.getAnnotation(HasCollectionRemover.class);
+
+                    Class<? extends Annotation> adderAnn = adderAnnType.value();
+                    Class<? extends Annotation> removerAnn = removerAnnType.value();
+
+                    Method getter = m;
+
+                    ICollectionRuleFactory<Resource,Object> ruleFactory = createCollectionRuleFactory(g, annotation, getter);
+                    if (ruleFactory != null) {
+                        Method adder = null;
+                        Method remover = null;
+    
+                        for (Method m2 : clazz.getDeclaredMethods()) {
+                            Annotation add = m2.getAnnotation(adderAnn);
+                            Annotation rem = m2.getAnnotation(removerAnn);
+                            if (add != null && ruleFactory.isAdder(annotation, add))
+                                adder = m2;
+                            if (rem != null && ruleFactory.isRemover(annotation, rem))
+                                remover = m2;
+                        }
+    
+                        rules.add(ruleFactory.create(g, annotation, getter,adder,remover));
+                    }
+                    else {
+                        LOGGER.warn("No rule factory found for {}", annotation);
+                    }
+                }
+
+            }
         }
     }
-       
-       public static IClassRuleFactory<Resource, Object> createClassRule(ReadGraph g, Annotation annotation, Class<?> clazz) {
-               return null;
-       }
-       
-       public static IFieldRuleFactory<Resource,Object> createFieldRule(ReadGraph g, Annotation annotation, Field field) {
-               if (annotation.annotationType().equals(RelatedElements.class))
-                       return new RelatedElementsRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedValue.class))
-                       return new RelatedValueRuleFactory<Object>();
-               if (annotation.annotationType().equals(OptionalRelatedElements.class))
-                       return new OptionalRelatedElementsRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedOrderedSetElements.class))
-                       return new RelatedOrderedSetElementsRuleFactory<Object>();
-               return null;
-       }
-       
-       public static IMethodRuleFactory<Resource, Object> createMethodRule(ReadGraph g, Annotation annotation, Method m) {
-               if (annotation.annotationType().equals(UpdateMethod.class))
-                       return new UpdateMethodFactory<Resource,Object>();
-               return null;
-       }
-       
-       public static IGetSetRuleFactory<Resource,Object> createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
-               if (annotation.annotationType().equals(RelatedGetValue.class))
-                       return new RelatedGetSetValueRuleFactory<Object>();
-               if (annotation.annotationType().equals(RelatedGetObj.class))
-                       return new RelatedGetSetObjRuleFactory<Object>();
-               if (annotation.annotationType().equals(CompoundRelatedGetValue.class))
-                       return new CompoundRelatedGetSetValueRuleFactory<Object>();
-               return null;
-       }
-       
-       public static ICollectionRuleFactory<Resource,Object> createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
-               if (annotation.annotationType().equals(RelatedElementsGet.class))
-                       return new RelatedElementsRuleFactory2<Object>();
-               if (annotation.annotationType().equals(OrderedElementsGet.class))
-                       return new OrderedElementsRuleFactory<Object>();
-               return null;
-       }
-       
-       /**
+
+    public static IClassRuleFactory<Resource, Object> createClassRule(ReadGraph g, Annotation annotation, Class<?> clazz) {
+        return null;
+    }
+
+    public static IFieldRuleFactory<Resource,Object> createFieldRule(ReadGraph g, Annotation annotation, Field field) {
+        if (annotation.annotationType().equals(RelatedElement.class))
+            return new RelatedElementRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedElements.class))
+            return new RelatedElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedValue.class))
+            return new RelatedValueRuleFactory<Object>();
+        if (annotation.annotationType().equals(OptionalRelatedElements.class))
+            return new OptionalRelatedElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedOrderedSetElements.class))
+            return new RelatedOrderedSetElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(LinkedList.class))
+            return new LinkedListRuleFactory<Object>();
+        return null;
+    }
+
+    public static IMethodRuleFactory<Resource, Object> createMethodRule(ReadGraph g, Annotation annotation, Method m) {
+        if (annotation.annotationType().equals(UpdateMethod.class))
+            return new UpdateMethodFactory<Resource,Object>();
+        return null;
+    }
+
+    public static IGetSetRuleFactory<Resource,Object> createGetSetRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
+        if (annotation.annotationType().equals(RelatedGetValue.class))
+            return new RelatedGetSetValueRuleFactory<Object>();
+        if (annotation.annotationType().equals(RelatedGetObj.class))
+            return new RelatedGetSetObjRuleFactory<Object>();
+        if (annotation.annotationType().equals(CompoundRelatedGetValue.class))
+            return new CompoundRelatedGetSetValueRuleFactory<Object>();
+        return null;
+    }
+
+    public static ICollectionRuleFactory<Resource,Object> createCollectionRuleFactory(ReadGraph g, Annotation annotation, Method getter) {
+        if (annotation.annotationType().equals(RelatedElementsGet.class))
+            return new RelatedElementsRuleFactory2<Object>();
+        if (annotation.annotationType().equals(OrderedElementsGet.class))
+            return new OrderedElementsRuleFactory<Object>();
+        if (annotation.annotationType().equals(LinkedListGet.class))
+            return new LinkedListRuleFactory2<>();
+        return null;
+    }
+
+    /**
      * Creates a new SimpleLinkType based on the annotations in the given class.
      * @throws IllegalAccessException 
      * @throws InstantiationException 
      * @see GraphType
      * @see RelatedValue
      */
-       
-       public static AdaptedLinkType<Object> fromAdaptable(ReadGraph g, String type, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
-           
-           
-           return new AdaptedLinkType<Object>(g.getResource(type), clazz);    
-       }
-       
-       
+
+    public static AdaptedLinkType<Object> fromAdaptable(ReadGraph g, String type, Class<?> clazz) throws DatabaseException, InstantiationException, IllegalAccessException {
+
+
+        return new AdaptedLinkType<Object>(g.getResource(type), clazz);    
+    }
+
+
 }
index bd87c074f0f4ecbe14ecddcce0b05fc4d13369d2..748422df2a5f51deebe85d421c1c4e78fdbe242d 100644 (file)
@@ -20,8 +20,8 @@ public class OrderedSetSimpleLinkType<Range> extends SimpleLinkType<Range> {
        
        public Resource createDomainElement(org.simantics.db.WriteGraph g, Range rangeElement) throws org.simantics.objmap.exceptions.MappingException {
                 try {
-            if(LOGGER.isInfoEnabled())
-                LOGGER.info("SimpleLinkType.createDomainElement " +
+            if(LOGGER.isTraceEnabled())
+                LOGGER.trace("SimpleLinkType.createDomainElement " +
                         rangeElement.toString()
                 );
             Resource result = OrderedSetUtils.create(g, domainType);
index fcfb3b012a802439398bc6d020325e9875494f38..9ddc437162e12a32720c5faefa6544ddc7e8a246 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.graph.schema;
 
 import java.util.ArrayList;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -34,7 +35,7 @@ import org.simantics.objmap.forward.IForwardMapping;
  */
 public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(SimpleLinkType.class);
     
     public Resource domainType;
     public Class<?> rangeType;
@@ -63,8 +64,8 @@ public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     public Resource createDomainElement(WriteGraph g, Range rangeElement)
             throws MappingException {
         try {
-            if(LOGGER.isInfoEnabled())
-                LOGGER.info("SimpleLinkType.createDomainElement " +
+            if(LOGGER.isTraceEnabled())
+                LOGGER.trace("SimpleLinkType.createDomainElement " +
                         rangeElement.toString()
                 );
             Resource result = g.newResource();
@@ -79,9 +80,9 @@ public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     public Range createRangeElement(ReadGraph g, Resource domainElement)
             throws MappingException {
         try {
-            if(LOGGER.isInfoEnabled())
+            if(LOGGER.isTraceEnabled())
                 try { 
-                    LOGGER.info("SimpleLinkType.createRangeElement " +
+                    LOGGER.trace("SimpleLinkType.createRangeElement " +
                                NameUtils.getSafeName(g, domainElement)
                             );
                 } catch(DatabaseException e) {
@@ -104,9 +105,9 @@ public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     };
     
     public boolean updateDomain(WriteGraph g, IBackwardMapping<Resource,Range> map, Resource domainElement, Range rangeElement) throws MappingException {
-        if(LOGGER.isInfoEnabled())
+        if(LOGGER.isTraceEnabled())
             try { 
-                LOGGER.info("SimpleLinkType.updateDomain " +
+                LOGGER.trace("SimpleLinkType.updateDomain " +
                         NameUtils.getSafeName(g, domainElement) + " " +
                         rangeElement.toString()
                         );
@@ -122,11 +123,11 @@ public class SimpleLinkType<Range> implements ILinkType<Resource,Range> {
     
     public boolean updateRange(ReadGraph g, IForwardMapping<Resource,Range> map, Resource domainElement, Range rangeElement) throws MappingException {
     
-        if(LOGGER.isInfoEnabled())
+        if(LOGGER.isTraceEnabled())
             try { 
-                LOGGER.info("SimpleLinkType.updateRange " +
+                LOGGER.trace("SimpleLinkType.updateRange " +
                                NameUtils.getSafeName(g, domainElement) + " " +
-                        rangeElement.toString()
+                        (rangeElement.getClass().getName() + "@" + Integer.toHexString(rangeElement.hashCode()))
                         );
             } catch(DatabaseException e) {
                 throw new MappingException(e);
index a5dc78f9120196e76dca9432ad3514f7d0799085..a2be5fa42bf978083642deb38b68807e46dc3329 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.structural.annotations.factories;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
@@ -26,7 +27,7 @@ import org.simantics.objmap.graph.rules.factory.IMethodRuleFactory;
 
 public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Domain, Range> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(UpdateMethodFactory.class);
     
     @Override
     public IBidirectionalMappingRule<Domain, Range> create(ReadGraph g, 
@@ -40,7 +41,7 @@ public class UpdateMethodFactory<Domain, Range> implements IMethodRuleFactory<Do
             public boolean updateRange(ReadGraph g, IForwardMapping<Domain, Range> map,
                     Domain domainElement, Range rangeElement)
                     throws MappingException {
-                LOGGER.info("    UpdateMethodFactory.updateRange");      
+                LOGGER.trace("    UpdateMethodFactory.updateRange");      
                 try {
                     return (Boolean)method.invoke(rangeElement, g, domainElement);
                 } catch (Exception e) {
index 295e60e2f29796eb96ea7ce88a90c2610018efd0..de80a9a95fdacd3ff4af5fb72166fe7e3df91ae4 100644 (file)
@@ -11,7 +11,8 @@
  *******************************************************************************/
 package org.simantics.objmap.structural.rules.domain;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -23,7 +24,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedObjectAccessor implements IDomainAccessor<StructuralResource,StructuralResource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectAccessor.class);
     
        Resource relation;
        boolean useTypeResource;
@@ -50,7 +51,7 @@ public class RelatedObjectAccessor implements IDomainAccessor<StructuralResource
        @Override
        public StructuralResource get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectAccessor.get");
+                   LOGGER.trace("        RelatedObjectAccessor.get");
                    Resource res = getServiceResource(g, element);
                    if (res == null)
                        return null;
@@ -71,7 +72,7 @@ public class RelatedObjectAccessor implements IDomainAccessor<StructuralResource
        public boolean set(WriteGraph g, StructuralResource selement, StructuralResource value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectAccessor.set");
+                   LOGGER.trace("        RelatedObjectAccessor.set");
                    Resource element = getServiceResource(g, selement);
                    if (element == null)
                        return false;
index cbd4ef3b40c9e5f1fae6b5e0159eb98e3f2e68cd..b09de09b83551a1c9d7427c6e11441d4544b0504 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -29,7 +30,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedObjectsAccessor implements IDomainAccessor<StructuralResource,Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
@@ -57,7 +58,7 @@ public class RelatedObjectsAccessor implements IDomainAccessor<StructuralResourc
     @Override
        public Collection<StructuralResource> get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.get");
+                   LOGGER.trace("        RelatedObjectsAccessor.get");
                        
                   
                    Resource res = getServiceResource(g, element);
@@ -86,7 +87,7 @@ public class RelatedObjectsAccessor implements IDomainAccessor<StructuralResourc
        public boolean set(WriteGraph g, StructuralResource element, Collection<StructuralResource> value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.set");
+                   LOGGER.trace("        RelatedObjectsAccessor.set");
                    Resource res = getServiceResource(g, element);
                    if (res == null)
                        return false;
index 6c1ed3aa2777038fbfa958ee7735c7c3441313ac..35f98994d23dd9ccb638fb493939c3b8523bdded 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -28,7 +29,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<StructuralResource, Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedOrderedSetElementsAccessor.class);
     
        boolean deleteExtraObjects;
        boolean useTypeResource;
@@ -42,7 +43,7 @@ public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Struct
     @Override
        public Collection<StructuralResource> get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.get");
+                   LOGGER.trace("        RelatedOrderedSetElementsAccessor.get");
                    Resource res = getServiceResource(g, element);
                    if (res == null)
                        return Collections.emptyList();
@@ -61,7 +62,7 @@ public class RelatedOrderedSetElementsAccessor implements IDomainAccessor<Struct
        public boolean set(WriteGraph g, StructuralResource element, Collection<StructuralResource> value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedOrderedSetElementsAccessor.set");
+                   LOGGER.trace("        RelatedOrderedSetElementsAccessor.set");
                    Resource res = getServiceResource(g, element);
                    if (res == null)
                        return false;
index 2d3a24230e88c3b6d0edd51377c75c52f1fc0903..21a6733a4b3e4938def7029fbbafa810ca6b9084 100644 (file)
@@ -13,7 +13,8 @@ package org.simantics.objmap.structural.rules.domain;
 
 import java.util.Arrays;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Statement;
@@ -27,7 +28,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class RelatedValueAccessor implements IDomainAccessor<StructuralResource,Object> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(RelatedValueAccessor.class);
     
        Resource relation;
        Resource valueType;
@@ -57,7 +58,7 @@ public class RelatedValueAccessor implements IDomainAccessor<StructuralResource,
        @Override
        public Object get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedValueAccessor.get");
+                   LOGGER.trace("        RelatedValueAccessor.get");
                    Resource res = getServiceResource(g, element);
                    if (res == null)
                        return null;
@@ -74,7 +75,7 @@ public class RelatedValueAccessor implements IDomainAccessor<StructuralResource,
        public boolean set(WriteGraph g, StructuralResource relement, Object value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedValueAccessor.set");
+                   LOGGER.trace("        RelatedValueAccessor.set");
                    
                    Resource element = getServiceResource(g, relement);
                    if (element == null)
index 32b8fd38ce0125b44b946ea29a75ce7d4c7ef75c..1b088754327511cff225e40ae690ec5c926cdec5 100644 (file)
@@ -14,7 +14,8 @@ package org.simantics.objmap.structural.rules.domain;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -26,7 +27,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class StructuralRelatedObjectAccessor implements IDomainAccessor<StructuralResource,StructuralResource> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(StructuralRelatedObjectAccessor.class);
     
        Resource relation;
        boolean useTypeResource;
@@ -54,7 +55,7 @@ public class StructuralRelatedObjectAccessor implements IDomainAccessor<Structur
        public StructuralResource get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
                        
-                       LOGGER.info("        RelatedObjectAccessor.get");
+                       LOGGER.trace("        RelatedObjectAccessor.get");
                        
                        if (!element.isStructural())
                                return null;
@@ -84,7 +85,7 @@ public class StructuralRelatedObjectAccessor implements IDomainAccessor<Structur
        public boolean set(WriteGraph g, StructuralResource element, StructuralResource value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectAccessor.set");
+                   LOGGER.trace("        RelatedObjectAccessor.set");
                    Resource instance = StructuralUtils.getContainingInstance(element);
                    Resource publicRelation = null;
                    if (instance == null)
index 730edc2696cec373b64643d8c8e632634073ec4e..aa3fdcad247a9f8e46ae0f9ef28f2bf4502aefab 100644 (file)
@@ -16,7 +16,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -29,7 +30,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class StructuralRelatedObjectsAccessor implements IDomainAccessor<StructuralResource,Collection<StructuralResource>> {
 
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(StructuralRelatedObjectsAccessor.class);
     
        Resource relation;
        boolean deleteExtraObjects;
@@ -43,7 +44,7 @@ public class StructuralRelatedObjectsAccessor implements IDomainAccessor<Structu
     @Override
        public Collection<StructuralResource> get(ReadGraph g, StructuralResource element) throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.get");
+                   LOGGER.trace("        RelatedObjectsAccessor.get");
                        
                    if (!element.isStructural())
                        return Collections.emptyList();
@@ -78,7 +79,7 @@ public class StructuralRelatedObjectsAccessor implements IDomainAccessor<Structu
        public boolean set(WriteGraph g, StructuralResource element, Collection<StructuralResource> value)
                        throws MappingException {
                try {
-                   LOGGER.info("        RelatedObjectsAccessor.set");
+                   LOGGER.trace("        RelatedObjectsAccessor.set");
                    
                    if (!element.isStructural())
                        return false;
index 4f55084861ef9413a548a9a6181b1ec9608893de..203863a6c74c61606d26e71d9c9dabf5964d675f 100644 (file)
@@ -11,7 +11,7 @@
  *******************************************************************************/
 package org.simantics.objmap.structural.schema;
 
-//import org.apache.log4j.Logger;
+//import org.slf4j.Logger;
 import org.eclipse.core.runtime.IAdaptable;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
index 8a7091fd46e828ff2774df30265d7ff719bee8e4..77b2ab094a50b6baf05c6853b3b10a7da6d91242 100644 (file)
@@ -15,7 +15,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -34,7 +35,7 @@ import org.simantics.objmap.structural.StructuralResource;
 
 public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralObject> {
     
-    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");
+    static Logger LOGGER = LoggerFactory.getLogger(SimpleLinkType.class);
     
     public Resource domainType;
     public Class<?> rangeType;
@@ -63,8 +64,8 @@ public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralO
     public StructuralResource createDomainElement(WriteGraph g, IStructuralObject rangeElement)
             throws MappingException {
         try {
-            if(LOGGER.isInfoEnabled())
-                LOGGER.info("SimpleLinkType.createDomainElement " +
+            if(LOGGER.isTraceEnabled())
+                LOGGER.trace("SimpleLinkType.createDomainElement " +
                         rangeElement.toString()
                 );
             if (rangeElement.getContext().size() == 0) {
@@ -97,9 +98,9 @@ public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralO
     public IStructuralObject createRangeElement(ReadGraph g, StructuralResource domainElement)
             throws MappingException {
         try {
-            if(LOGGER.isInfoEnabled())
+            if(LOGGER.isTraceEnabled())
                 try { 
-                    LOGGER.info("SimpleLinkType.createRangeElement " + NameUtils.getSafeName(g, domainElement.getResource()));
+                    LOGGER.trace("SimpleLinkType.createRangeElement " + NameUtils.getSafeName(g, domainElement.getResource()));
                 } catch(DatabaseException e) {
                     throw new MappingException(e);
                 }
@@ -154,9 +155,9 @@ public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralO
     }
     
     public boolean updateDomain(WriteGraph g, IBackwardMapping<StructuralResource,IStructuralObject> map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException {
-        if(LOGGER.isInfoEnabled())
+        if(LOGGER.isTraceEnabled())
             try { 
-                LOGGER.info("SimpleLinkType.updateDomain " +
+                LOGGER.trace("SimpleLinkType.updateDomain " +
                         NameUtils.getSafeName(g, domainElement.getResource()) + " " +
                         rangeElement.toString()
                         );
@@ -172,9 +173,9 @@ public class SimpleLinkType implements ILinkType<StructuralResource,IStructuralO
     
     public boolean updateRange(ReadGraph g, IForwardMapping<StructuralResource, IStructuralObject> map, StructuralResource domainElement, IStructuralObject rangeElement) throws MappingException {
     
-        if(LOGGER.isInfoEnabled())
+        if(LOGGER.isTraceEnabled())
             try { 
-                LOGGER.info("SimpleLinkType.updateRange " +
+                LOGGER.trace("SimpleLinkType.updateRange " +
                                NameUtils.getSafeName(g, domainElement.getResource()) + " " +
                         rangeElement.toString()
                         );
index 444585bbdc1463265815a479f75179393fb65b03..feec73dc909002be8c37118961a66c6c71806671 100644 (file)
  *******************************************************************************/
 package org.simantics.project.management;
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
 
 import org.simantics.db.DatabaseUserAgent;
 import org.simantics.db.Driver;
@@ -42,168 +33,5 @@ public class ServerManagerFactory {
             driver.setDatabaseUserAgent(address, agent);
         return new ServerManager(driver);
     }
-       /**
-        * Create a server manager in OSGi platform.
-        *
-        * @return
-        * @throws IOException
-        * @throws ClassNotFoundException
-        * @throws RuntimeException unexpected problem with OSGi environment
-        */
-       public static ServerManager createOSGI() throws IOException, RuntimeException {
-               try {
-                       ClassLoader cl = ServerManager.class.getClassLoader();
-
-                       // Object bundle = Platform.getBundle("org.simantics.db.build");
-                       Class<?> Platform_class = cl.loadClass("org.eclipse.core.runtime.Platform");
-                       Method Platform_getBundle = Platform_class.getMethod("getBundle", String.class);
-                       Object bundle = Platform_getBundle.invoke(null, "org.simantics.db.build");
-                       if (bundle==null) throw new RuntimeException("Bundle org.simantics.db.build not found.");
-
-                       // URL db_build_url = bundle.getEntry("/");
-                       Class<?> Bundle_class = cl.loadClass("org.osgi.framework.Bundle");
-                       Method Bundle_getEntry = Bundle_class.getMethod("getEntry", String.class);
-                       URL db_build_url = (URL) Bundle_getEntry.invoke(bundle, "/");
-
-               // URL db_build_file_url = FileLocator.toFileURL( db_build_url );
-                       Class<?> FileLocator_class = cl.loadClass("org.eclipse.core.runtime.FileLocator");
-                       Method FileLocator_toFileURL = FileLocator_class.getMethod("toFileURL", URL.class);
-                       URL db_build_file_url = (URL) FileLocator_toFileURL.invoke(null, db_build_url);
-
-                       @SuppressWarnings("unused")
-            String buildFile = URLDecoder.decode(db_build_file_url.getPath(), "UTF-8");
-
-//             File db_build_file = new File( buildFile );
-               //return new ServerManager( db_build_file );
-               throw new RuntimeException("ServerManager.createOSGI not implemented.");
-               } catch( ClassNotFoundException e ) {
-                       throw new RuntimeException(e);
-               } catch (SecurityException e) {
-                       throw new RuntimeException(e);
-               } catch (NoSuchMethodException e) {
-                       throw new RuntimeException(e);
-               } catch (IllegalArgumentException e) {
-                       throw new RuntimeException(e);
-               } catch (IllegalAccessException e) {
-                       throw new RuntimeException(e);
-               } catch (InvocationTargetException e) {
-                       throw new RuntimeException(e.getCause());
-               }
-       }
-
-       /**
-        * Create a server manager in an POJO environment.
-        *
-        * @return
-        * @throws IOException
-        */
-       public static ServerManager createPOJO() throws IOException {
-               String tempPath = System.getenv("tmp");
-               if (tempPath==null) tempPath = "c:/temp/";
-               File driverDir = new File(tempPath+"/core_drivers");
-               if (!driverDir.exists()) {
-                       System.out.println("Extracting Core drivers to "+driverDir);
-                       driverDir.mkdirs();
-                       ServerManagerFactory.extractDrivers(driverDir);
-               } else {
-                       System.out.println("Loading Core drivers from "+driverDir);
-               }
-               //return new ServerManager(driverDir);
-        throw new RuntimeException("ServerManager.createPOJO not implemented.");
-       }
-
-    public static ServerManager createPOJO(File driverDir) throws IOException {
-        //return new ServerManager(driverDir);
-        throw new RuntimeException("ServerManager.createPOJO not implemented.");
-    }
-
-    static ServerManager cached;
-
-    public static boolean isOSGi() {
-       try {
-               ServerManager.class.getClassLoader().loadClass("org.osgi.framework.Bundle");
-               return true;
-       } catch (ClassNotFoundException e) {
-               return false;
-       }
-    }
-
-    public synchronized static ServerManager getServerManager() {
-       if (cached!=null) return cached;
-       try {
-               try {
-                       return createOSGI();
-               } catch(RuntimeException e) {
-                       return createPOJO();
-               }
-       } catch (IOException e) {
-               throw new RuntimeException(e);
-       }
-    }
-
-
-    /**
-     * Extracts drivers files to a location.
-     *
-     * @param path location where to extract application files
-     * @throws IOException
-     */
-       public static void extractDrivers(File path)
-       throws IOException
-       {
-               // Extract org.simantics.db.build.zip to workspace
-               InputStream is = ServerManager.class.getResource("org.simantics.db.build.zip").openStream();
-               try {
-                       extractZip(is, path);
-               } finally {
-                       is.close();
-               }
-       }
-
-    /**
-     * Extract a zip file into a directory
-     *
-     * @param zipInput
-     * @param dst directory
-     * @throws IOException
-     */
-    private static void extractZip(InputStream zipInput, File dst) throws IOException {
-        byte[] buf = new byte[8192];
-        ZipInputStream zis = new ZipInputStream(zipInput);
-        ZipEntry entry;
-
-        entry = zis.getNextEntry();
-        while (entry != null) {
-            // for each entry to be extracted
-            String name = entry.getName();
-            LOGGER.debug("Extracting "+name);
-            File file = new File(dst, name);
-
-            if (entry.isDirectory())
-            {
-                if ( !file.exists() ) file.mkdirs();
-            } else {
-                File parent = file.getParentFile();
-                if (!parent.exists()) parent.mkdirs();
-                if (!file.exists()) file.createNewFile();
-
-                FileOutputStream fileoutputstream = new FileOutputStream(file);
-                try {
-                    int n = 0;
-                    while ((n = zis.read(buf, 0, buf.length)) > -1)
-                        fileoutputstream.write(buf, 0, n);
-                } finally {
-                    fileoutputstream.close();
-                }
-            }
-
-            zis.closeEntry();
-            entry = zis.getNextEntry();
-        }// while
-
-        zis.close();
-    }
-
-
-}
 
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/org.simantics.db.build.zip b/bundles/org.simantics.project/src/org/simantics/project/management/org.simantics.db.build.zip
deleted file mode 100644 (file)
index e31cdab..0000000
Binary files a/bundles/org.simantics.project/src/org/simantics/project/management/org.simantics.db.build.zip and /dev/null differ
diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/server_template.cnfg b/bundles/org.simantics.project/src/org/simantics/project/management/server_template.cnfg
deleted file mode 100644 (file)
index 8404378..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-# Journal options.
-# If 0 then write journal. (default)
-# If 1 then write journal with additional debug information.
-# If 2 then do not write journal.
-journal_reportFileMode=1
-
-# Log file.
-common_logFile=../server.log
-
-# Log levels.
-#common_logLevels=trace
-#common_logLevels=debug
-#common_logLevels=info
-#common_logLevels=warning
-
-# Log packages.
-#common_logPackages=main
-#common_logPackages=session
-#common_logPackages=memory
-#common_logPackages=transaction
-#common_logPackages=extension
-#common_logPackages=utility
-#common_logPackages=test
-#common_logPackages=value
-#common_logPackages=revision
-#common_logPackages=graph
-#common_logPackages=page
index d9e65e28c39208b575234aae41e3a94000702912..e719aaf8cd47e6993311d7f6b970851430087497 100644 (file)
@@ -178,7 +178,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         StringBuilder signature = new StringBuilder();
         signature.append("<div id=\"")
         .append(HtmlEscape.escape(name))
-        .append("\" class=\"code-doc-box\"><div class=\"code\">");
+        .append("\" class=\"code-doc-box\"><div class=\"code value\">");
         char firstChar = name.charAt(0);
         if(!Character.isAlphabetic(firstChar) && firstChar != '_')
             name = "(" + name + ")";
@@ -231,7 +231,9 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         
         TypeUnparsingContext tuc = new TypeUnparsingContext();
         StringBuilder signature = new StringBuilder();
-        signature.append("<div class=\"code-doc-box\"><div class=\"code\">");
+        signature.append("<div id=\"class-")
+        .append(HtmlEscape.escape(name))
+        .append("\" class=\"code-doc-box\"><div class=\"code class\">");
         signature.append("class ");
         if(typeClass.context.length > 0) {
             signature.append('(');
@@ -293,7 +295,9 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         
         TypeUnparsingContext tuc = new TypeUnparsingContext();
         StringBuilder signature = new StringBuilder();
-        signature.append("<div class=\"code-doc-box\"><div class=\"code\">");
+        signature.append("<div id=\"data-")
+        .append(HtmlEscape.escape(name))
+        .append("\" class=\"code-doc-box\"><div class=\"code data\">");
         signature.append("data ");
         signature.append(typeDescriptor.name.name);
         if(typeDescriptor instanceof TypeConstructor) {
index 27ecb48ebeb4af1ff48f18fbfc3e18f088b8fe59..7dd20434848b27777af13e2d6af193b0b8558cd3 100644 (file)
@@ -491,7 +491,6 @@ vertical-align:1px;
 .code-doc-box>.code {
   font-size: 12px;
   font-family: Consolas, "Liberation Mono", Courier, monospace;
-  background-color: #f0f0ff;
   white-space: pre;
   padding: 10px 15px;
   border-bottom: 1px solid;
@@ -500,7 +499,19 @@ vertical-align:1px;
   display: block;
 }
 
-.code-doc-box>.doc {display: block;
+.code-doc-box>.value {
+  background-color: #f0f0ff;
+}
+
+.code-doc-box>.data {
+  background-color: #f0fff0;
+}
+
+.code-doc-box>.class {
+  background-color: #fff0f0;
+}
+
+.code-doc-box>.doc {
   padding: 0px 15px ;
   display: block;
 }
index af8c194762c50810150f49f7cc9dd4b029a54c38..b69119eae0e345b65f153961cb289f85c752d63a 100644 (file)
@@ -250,13 +250,6 @@ importJava "org.simantics.db.WriteGraph" where
     @JavaName denyValue
     denyValue :: Resource -> <WriteGraph> ()
 
-claimAssertion :: Resource -> Resource -> Resource -> <WriteGraph> ()
-claimAssertion type_ predicate object = do
-    ass = newResource ()
-    claim ass L0.HasPredicate predicate
-    claim ass L0.HasObject object
-    claim type_ L0.Asserts ass
-
 "Sets the value of the literal that is an object with the given subject and predicate."
 @inline
 claimRelatedValue :: Serializable a => Resource -> Resource -> a -> <WriteGraph> ()
@@ -415,6 +408,9 @@ importJava "org.simantics.db.layer0.util.Layer0Utils" where
     addMetadataListener :: ChangeListener -> <Proc> ()
     removeMetadataListener :: ChangeListener -> <Proc> ()
 
+    @JavaName assert_
+    claimAssertion :: Resource -> Resource -> Resource -> <WriteGraph> ()
+
 copyTo :: Resource -> Resource -> <WriteGraph> Resource
 copyTo targetContainer source = do
     (collectionToList $ copyTo_ targetContainer source)!0
index f3d4c34306d71a7bce5c9779ddee01added2ec60..e20dfc471ad9ea28831463f00bc9bfc220d8704a 100644 (file)
@@ -1,6 +1,8 @@
 package org.simantics.scl.db;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.cojen.classfile.TypeDesc;
 import org.simantics.Simantics;
@@ -25,14 +27,24 @@ import org.simantics.db.service.QueryControl;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.layer0.utils.triggers.IActivationManager;
+import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
+import org.simantics.scl.compiler.errors.DoesNotExist;
 import org.simantics.scl.compiler.errors.Failable;
+import org.simantics.scl.compiler.errors.Failure;
 import org.simantics.scl.compiler.internal.codegen.types.JavaTypeTranslator;
 import org.simantics.scl.compiler.module.Module;
 import org.simantics.scl.compiler.module.repository.ImportFailureException;
 import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
+import org.simantics.scl.compiler.runtime.RuntimeModule;
+import org.simantics.scl.compiler.top.ValueNotFound;
+import org.simantics.scl.compiler.types.TCon;
 import org.simantics.scl.compiler.types.Type;
+import org.simantics.scl.compiler.types.Types;
+import org.simantics.scl.compiler.types.exceptions.MatchException;
+import org.simantics.scl.compiler.types.util.MultiFunction;
 import org.simantics.scl.osgi.SCLOsgi;
+import org.simantics.scl.reflection.ValueNotFoundException;
 import org.simantics.scl.runtime.SCLContext;
 import org.simantics.scl.runtime.function.Function;
 import org.simantics.scl.runtime.function.Function1;
@@ -58,8 +70,95 @@ public class SCLFunctions {
             return null;
         }
     }
+
+    public static Function resolveFunction(RuntimeModule rm, String function) throws ValueNotFound {
+        return (Function)rm.getValue(function);
+    }
+    
+    private static SCLValue resolveSCLValue(RuntimeModule rm, String function) throws ValueNotFound {
+        return rm.getModule().getValue(function);
+    }
+    
+    private static RuntimeModule resolveRuntimeModule(String module) throws ValueNotFound {
+        Failable<RuntimeModule> f = SCLOsgi.MODULE_REPOSITORY.getRuntimeModule(module);
+        if(f.didSucceed())
+            return f.getResult();
+        else if(f == DoesNotExist.INSTANCE)
+            throw new ValueNotFound("Didn't find module " + module);
+        else
+            throw new ValueNotFound(((Failure)f).toString());
+    }
+    
+    private static List<TCon> getEffects(SCLValue value) throws ValueNotFoundException, ValueNotFound, MatchException {
+    
+        Type type = value.getType();
+        MultiFunction mfun = Types.matchFunction(type, 1);
+        ArrayList<TCon> concreteEffects = new ArrayList<>();
+        mfun.effect.collectConcreteEffects(concreteEffects);
+        return concreteEffects;
+        
+    }
+
+    public static List<TCon> getEffects(RuntimeModule rm, String function) throws ValueNotFoundException, ValueNotFound, MatchException {
+        return getEffects(resolveSCLValue(rm, function));
+    }
+
+    public static List<TCon> getEffects(String module, String function) throws ValueNotFoundException, ValueNotFound, MatchException {
+        return getEffects(resolveSCLValue(resolveRuntimeModule(module), function));
+    }
+    
+    private static <T> T evaluate(Function function, Object ... args) {
+        return (T)function.applyArray(args);
+    }
+
+    private static <T> T evaluate(RuntimeModule rm, String function, Object ... args) throws ValueNotFound {
+        return evaluate(resolveFunction(rm, function));
+    }
+
+    public static <T> T evaluate(String module, String function, Object ... args) throws ValueNotFound {
+        return evaluate(resolveRuntimeModule(module), function, args);
+    }
+
+    public static <T> T evaluateDB(String module, String function, Object ... args) throws DatabaseException {
+        try {
+            RuntimeModule rm = resolveRuntimeModule(module);
+            List<TCon> effects = getEffects(resolveSCLValue(rm, function));
+            Function f = resolveFunction(rm, function);
+            if(effects.contains(Types.WRITE_GRAPH)) {
+                return syncWrite(f, args);
+            } else if(effects.contains(Types.READ_GRAPH)) {
+                return syncRead(f, args);
+            } else {
+                return evaluate(f, args);
+            }
+        } 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);
+        }
+    }
     
-    public static void asyncRead(final Function f) throws DatabaseException {
+    public static <T> T evaluateGraph(String module, String function, Object graph, Object ... args) throws DatabaseException {
+        final SCLContext context = SCLContext.getCurrent();
+        SCLContext.push(context);
+        Object oldGraph = context.put(GRAPH, graph);
+        try {
+            return evaluateDB(module, function, args);
+        } finally {
+            context.put(GRAPH, oldGraph);
+            SCLContext.pop();
+        }
+    }
+
+    private static Object[] NO_ARGS = new Object[] { Tuple0.INSTANCE };
+
+    public static <T> void asyncRead(final Function f) throws DatabaseException {    
+        asyncRead(f, NO_ARGS);
+    }
+
+    public static void asyncRead(final Function f, final Object ... args) throws DatabaseException {
         final SCLContext context = SCLContext.createDerivedContext();
         Simantics.getSession().asyncRequest(new ReadRequest() {
             @Override
@@ -76,10 +175,14 @@ public class SCLFunctions {
     }
     
     public static <T> T syncRead(final Function f) throws DatabaseException {
+        return syncRead(f, NO_ARGS);
+    }
+    
+    public static <T> T syncRead(final Function f, final Object ... args) throws DatabaseException {
         final SCLContext context = SCLContext.getCurrent();
         Object graph = context.get(GRAPH);
         if (graph != null) {
-            return (T)f.apply(Tuple0.INSTANCE);
+            return (T)f.applyArray(args);
         } else {
             return Simantics.getSession().syncRequest(new Read<T>() {
                 @Override
@@ -96,8 +199,12 @@ public class SCLFunctions {
             });
         }
     }
-    
+
     public static void asyncWrite(final Function f) throws DatabaseException {
+        asyncWrite(f, NO_ARGS);
+    }
+
+    public static void asyncWrite(final Function f, final Object ... args) throws DatabaseException {
         SCLContext context = SCLContext.createDerivedContext();
         if (Simantics.peekSession() != null) {
             Simantics.getSession().asyncRequest(new WriteRequest() {
@@ -106,7 +213,7 @@ public class SCLFunctions {
                     SCLContext.push(context);
                     context.put(GRAPH, graph);
                     try {
-                        f.apply(Tuple0.INSTANCE);
+                        f.apply(args);
                     } finally {
                         SCLContext.pop();
                     }
@@ -118,6 +225,10 @@ public class SCLFunctions {
     }
     
     public static <T> T syncWrite(final Function f) throws DatabaseException {
+        return syncWrite(f, NO_ARGS);
+    }
+
+    public static <T> T syncWrite(final Function f, final Object ... args) throws DatabaseException {
         final SCLContext context = SCLContext.getCurrent();
         Object graph = context.get(GRAPH);
         if (graph != null) {
@@ -131,7 +242,7 @@ public class SCLFunctions {
                     SCLReportingHandler oldPrinter = (SCLReportingHandler)context.put(SCLReportingHandler.REPORTING_HANDLER, printer);
                     ReadGraph oldGraph = (ReadGraph)context.put(GRAPH, graph);
                     try {
-                        return (T)f.apply(Tuple0.INSTANCE);
+                        return (T)f.apply(args);
                     } finally {
                         context.put(GRAPH, oldGraph);
                         context.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
@@ -144,13 +255,13 @@ public class SCLFunctions {
     
     public static <T> T delayedSyncWrite(final Function f) throws DatabaseException {
         final SCLContext context = SCLContext.getCurrent();
-       final DataContainer<T> dc = new DataContainer<T>(null);
+        final DataContainer<T> dc = new DataContainer<T>(null);
 
         DelayedWriteRequest request = new DelayedWriteRequest() {
             @Override
             public void perform(WriteGraph graph) throws DatabaseException {
-               final SCLContext context = SCLContext.getCurrent();
-               SCLContext.push(context);
+                final SCLContext context = SCLContext.getCurrent();
+                SCLContext.push(context);
                 ReadGraph oldGraph = (ReadGraph)context.put(GRAPH, graph);
                 try {
                     dc.set((T)f.apply(Tuple0.INSTANCE));
@@ -160,18 +271,18 @@ public class SCLFunctions {
                 }
             }
         };
-       
+    
         Object graph = context.get(GRAPH);
         if (graph != null) {
             if (graph instanceof WriteGraph) {
-               ((WriteGraph)graph).syncRequest(request);
+                ((WriteGraph)graph).syncRequest(request);
             } else {
-               throw new DatabaseException("Caller is inside a read transaction.");
+                throw new DatabaseException("Caller is inside a read transaction.");
             }
         } else {
             Simantics.getSession().syncRequest(request);
         }
-       return dc.get();
+        return dc.get();
     }
 
     public static <T> T virtualSyncWriteMem(WriteGraph graph, String virtualGraphId, final Function f) throws DatabaseException {
@@ -217,7 +328,7 @@ public class SCLFunctions {
             @Override
             public T perform(ReadGraph graph) throws DatabaseException {
                 return Variables.getVariable(graph, uri).getValue(graph);
-            }            
+            }
         });
     }
     
@@ -226,7 +337,7 @@ public class SCLFunctions {
             @Override
             public void perform(WriteGraph graph) throws DatabaseException {
                 Variables.getVariable(graph, uri).setValue(graph, value);
-            }            
+            }
         });
     }
     
@@ -257,23 +368,23 @@ public class SCLFunctions {
     
     public static class SCLUnaryRead extends BinaryRead<Function1<Object,Object>, Object, Object> {
 
-               public SCLUnaryRead(Function1<Object, Object> parameter1, Object parameter2) {
-                       super(parameter1, parameter2);
-               }
+        public SCLUnaryRead(Function1<Object, Object> parameter1, Object parameter2) {
+             super(parameter1, parameter2);
+        }
+
+        @Override
+        public Object perform(ReadGraph graph) throws DatabaseException {
+            return Simantics.applySCLRead(graph, parameter, parameter2);
+        }
 
-               @Override
-               public Object perform(ReadGraph graph) throws DatabaseException {
-                       return Simantics.applySCLRead(graph, parameter, parameter2);
-               }
-       
     }
     
     public static Object unaryQuery(ReadGraph graph, Function1<Object,Object> fn, Object value) throws DatabaseException {
-       return graph.syncRequest(new SCLUnaryRead(fn, value));
+        return graph.syncRequest(new SCLUnaryRead(fn, value));
     }
 
     public static Object unaryQueryCached(ReadGraph graph, Function1<Object,Object> fn, Object value) throws DatabaseException {
-       return graph.syncRequest(new SCLUnaryRead(fn, value), TransientCacheAsyncListener.<Object>instance());
+        return graph.syncRequest(new SCLUnaryRead(fn, value), TransientCacheAsyncListener.<Object>instance());
     }
     
 
@@ -318,15 +429,15 @@ public class SCLFunctions {
     }
 
     public static Object possibleFromDynamic(Type expectedType, String moduleName, Object value) {
-       
+    
         try {
 
-               
+        
             Failable<Module> failable = SCLOsgi.MODULE_REPOSITORY.getModule(moduleName);
             Module module = failable.getResult();
             
-               RuntimeEnvironment env = SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment(
-                               EnvironmentSpecification.of(moduleName, ""), module.getParentClassLoader());
+            RuntimeEnvironment env = SCLOsgi.MODULE_REPOSITORY.createRuntimeEnvironment(
+            EnvironmentSpecification.of(moduleName, ""), module.getParentClassLoader());
 
             JavaTypeTranslator tr = new JavaTypeTranslator(env.getEnvironment());
             TypeDesc desc = tr.toTypeDesc(expectedType);
@@ -342,22 +453,22 @@ public class SCLFunctions {
 
     public static void restrictQueries(ReadGraph graph, int amount, int step, int maxTimeInMs) {
 
-               QueryControl qc = graph.getService(QueryControl.class);
-               long start = System.currentTimeMillis();
-               while(true) {
-                       int current = qc.count();
-                       if(current < amount) return;
-                       qc.gc(graph, step);
-                       long duration = System.currentTimeMillis() - start;
-                       if(duration > maxTimeInMs) return;
-               }
+        QueryControl qc = graph.getService(QueryControl.class);
+        long start = System.currentTimeMillis();
+        while(true) {
+            int current = qc.count();
+            if(current < amount) return;
+            qc.gc(graph, step);
+            long duration = System.currentTimeMillis() - start;
+            if(duration > maxTimeInMs) return;
+        }
 
     }
 
     public static int countQueries(ReadGraph graph) {
 
-               QueryControl qc = graph.getService(QueryControl.class);
-               return qc.count();
+        QueryControl qc = graph.getService(QueryControl.class);
+        return qc.count();
 
     }
     
index 80e34c3746565f70cdf625cfcde5b19e5e2326a9..f19081754e71b1fc2bc034ca1be8d6345c7e9ff1 100644 (file)
@@ -30,6 +30,7 @@ import org.simantics.scl.osgi.SCLOsgi;
 import org.simantics.scl.ui.Activator;
 import org.simantics.scl.ui.editor2.SCLModuleEditor2;
 import org.simantics.scl.ui.editor2.SCLModuleEditorInput;
+import org.simantics.utils.ui.SWTUtils;
 
 public class SCLModuleOutlinePage extends ContentOutlinePage {
 
@@ -69,16 +70,20 @@ public class SCLModuleOutlinePage extends ContentOutlinePage {
 
             @Override
             public void notifyAboutUpdate() {
-                parent.getDisplay().asyncExec(() -> {
+                if (parent.isDisposed())
+                    return;
+                
+                Failable<Module> module = SCLOsgi.MODULE_REPOSITORY.getModule(moduleSource.getModuleName(), updateListener);
+                SWTUtils.asyncExec(parent, () -> {
                     if (!outlineViewer.getControl().isDisposed()) {
+                        outlineViewer.setInput(module.didSucceed() ? module.getResult() : null);
                         outlineViewer.refresh();
                     }
                 });
             }
         };
-        Failable<Module> module = SCLOsgi.MODULE_REPOSITORY.getModule(moduleSource.getModuleName(), updateListener);
-        Module result = module.getResult();
-        outlineViewer.setInput(result);
+        
+        updateListener.notifyAboutUpdate();
     }
 
     @Override
index 861f705d7a31dc8061d1848b347cb613ddcdb4ea..c38966f655f89989c94b891efeb180d8e4fd1717 100644 (file)
@@ -112,8 +112,7 @@ SEL.GenericParameterType <T L0.FunctionalRelation
       L0.readOnly true
   @L0.assert SEL.HasDisplayValue
     _ : SEL.DisplayValue
-      SEL.HasEnumerationValues _ : L0.Value
-        L0.ConvertsToValueWith SEL.Functions.getEnumerationValues
+      SEL.HasEnumerationValues SEL.Functions.getEnumerationValues
   @L0.assert SEL.HasDisplayUnit
     _ : SEL.DisplayUnit
       L0.readOnly true
index cf6f05ab2a087fcf9b2edac0178d415b97841ae4..5f7068162b6219acb8e9a1d46dde2b2c8eb34c9e 100644 (file)
@@ -309,16 +309,16 @@ STR.Property <T L0.FunctionalRelation <T L0.PropertyRelation
             L0.HasValueType "String"
 
 STR.Component
-  L0.HasConstraint STR.ConnectionConstraint : L0.Constraint
+  L0.HasConstraint STR.ConnectionValidationConstraint : L0.Constraint
     L0.Constraint.Validator
       STR.Functions.connectionValidator : L0.Function
 
-STR.ConnectionConstraint.ErrorIssue
+STR.ConnectionValidationConstraint.ErrorIssue
   @ISSUE.issue ISSUE.Severity.Error
     STR.Functions.connectionIssueDescription : L0.Function
       L0.HasValueType "String" 
   
-STR.ConnectionConstraint.Source <T ISSUE.Sources.DependencyTracker
+STR.ConnectionValidationConstraint.Source <T ISSUE.Sources.DependencyTracker
   L0.HasLabel "Structural connection validity"
   @L0.assert ISSUE.Sources.DependencyTracker.HasType STR.Component
   @L0.assert ISSUE.Sources.DependencyTracker.HasSearchType STR.Connection
index 970e6f9e813dc710545aeed3d6c0ee1c6cf234cd..e43007637ac5ca616a89f33b3cc3f62247ad8fea 100644 (file)
@@ -749,7 +749,7 @@ public class Functions {
 
                for(Resource req : requiredConnections) {
                        if(!connections.contains(req)) {
-                               result.add(new StandardIssue(sr.ConnectionConstraint_ErrorIssue, component, req));
+                               result.add(new StandardIssue(sr.ConnectionValidationConstraint_ErrorIssue, component, req));
                        }
                }
 
index 60fee19b20b9298aebe90b086d4788f445ad9b8a..11a49f01705e002a73a44c7e1d2d36aa90d4fafc 100644 (file)
@@ -624,47 +624,41 @@ public class ConnectionBrowser {
                                needDrill = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
                        needDrill.add(desc);
                } else {
+                if(relationType != null) {
+                    if(!filterByRelationType(graph, desc, relationType))
+                        continue;
+                }
                        if(result == null)
                                result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
                        result.add(desc);
                }
         }
         
-        if(needDrill == null) {
-               /*
-                * All descriptors were already flat - just take case of filtering
-                */
-            if(relationType != null) {
-                ArrayList<VariableConnectionPointDescriptor> filtered = new ArrayList<VariableConnectionPointDescriptor>(climbed.size());
-                for(VariableConnectionPointDescriptor desc : climbed)
-                    if(filterByRelationType(graph, desc, relationType))
-                        filtered.add(desc);
-                return filtered;
-            } else {
-                return climbed;
+        if(needDrill != null) {
+            /*
+             * There were some descriptors that require drill
+             */
+            for(VariableConnectionPointDescriptor top : needDrill) {
+                Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
+                if(drilled != null) {
+                    for(VariableConnectionPointDescriptor drill : drilled) {
+                        if(relationType != null) {
+                            if(!filterByRelationType(graph, drill, relationType))
+                                continue;
+                        }
+                        if(result == null)
+                            result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
+                        result.add(drill);
+                    }
+                }
             }
         }
-        
 
-        /*
-         * There were some descriptors that require drill
-         */
-        for(VariableConnectionPointDescriptor top : needDrill) {
-               Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
-            if(drilled != null) {
-               for(VariableConnectionPointDescriptor drill : drilled) {
-                       if(relationType != null) {
-                               if(!filterByRelationType(graph, drill, relationType))
-                                       continue;
-                       }
-                       if(result == null)
-                               result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
-                       result.add(drill);
-               }
-            }
+        if (result != null) {
+            return result;
+        } else {
+            return Collections.emptySet();
         }
-        return result;
-        
     }
     
     private static boolean filterByRelationType(ReadGraph graph, VariableConnectionPointDescriptor desc, Resource relationType) throws DatabaseException {
index d685b7af05d5be6605d66ca7be7c74b1f4197857..19390e5667f82c6d3c4abab2f4eae943874efee9 100644 (file)
@@ -53,7 +53,7 @@ public abstract class FileOrDirectorySelectionWidget extends Composite{
                        public void widgetSelected(SelectionEvent e) {
                                String[] name = openDialog();
                                if (name != null) {
-                                       setFilename(name);
+                                       setFilename(name,true);
                                }
                        }
                });
@@ -63,7 +63,11 @@ public abstract class FileOrDirectorySelectionWidget extends Composite{
                        @Override
                        public void modifyText(ModifyEvent e) {
                                String file = fileText.getText();
-                               setFilename(file.split(","));
+                               String files[] = file.split(",");
+                               for (int i = 0; i < files.length; i++) {
+                                       files[i] = files[i].trim();
+                               }
+                               setFilename(files, false);
                                
                        }
                });
@@ -74,14 +78,22 @@ public abstract class FileOrDirectorySelectionWidget extends Composite{
        protected abstract boolean isValid(File file);
        
        protected void setFilename(String[] filename) {
+               setFilename(filename, true);
+       }
+       
+       protected void setFilename(String[] filename, boolean update) {
                String text = "";
-               for (String s : filename) {
-                       text += s + ",";
+               if (filename.length < 6) {
+                       for (String s : filename) {
+                               text += s + ",";
+                       }
+                       if (text.length() > 2)
+                               text = text.substring(0, text.length() - 1);
+               } else {
+                       text = filename[0] + " and " + (filename.length -1) + " other files.";
                }
-               if (text.length() > 2)
-                       text = text.substring(0, text.length() - 1);
                
-               if (!text.equals(fileText.getText()))
+               if (update && !text.equals(fileText.getText()))
                        fileText.setText(text);
                
                boolean accept = true;
index 4acbf1cff206bcfcb50b6a66499e7de9b5f2bb13..ef385ba0a425dc2fd2b2328e3311f023852aa89e 100644 (file)
@@ -23,6 +23,8 @@ public class FileSelectionWidget extends FileOrDirectorySelectionWidget {
                FileDialog dialog = new FileDialog(getShell(),style);
                dialog.setFilterExtensions(getFilterExtensions());
                dialog.setFilterNames(getFilterNames());
+               if (filename != null && filename.length == 1)
+                       dialog.setFileName(filename[0]);
                String filename = dialog.open();
                if (filename == null)
                        return null;
index 5b183ad68ae104b024e766b6f29cbb4504a99fe0..47e0c5c7eb279a01ef091aa1151175b2f422d26b 100644 (file)
@@ -27,7 +27,6 @@ Require-Bundle: com.ibm.icu,
  org.simantics.layer0;bundle-version="1.0.0",
  org.simantics.graph.db;bundle-version="1.0.0",
  org.simantics.editors;bundle-version="1.0.0",
- org.simantics.db.procore.server.environment;bundle-version="1.1.0",
  org.simantics;bundle-version="1.0.0";visibility:=reexport,
  org.simantics.workbench.ontology;bundle-version="1.0.0",
  org.simantics.workbench.search;bundle-version="1.5.0",
@@ -37,7 +36,6 @@ Require-Bundle: com.ibm.icu,
  org.simantics.simulation.ui;bundle-version="1.1.0";visibility:=reexport,
  org.simantics.scenegraph.profile;bundle-version="1.0.0";visibility:=reexport,
  org.simantics.browsing.ui.model;bundle-version="1.0.0";visibility:=reexport,
- org.simantics.db.procore.ui,
  org.eclipse.ui.workbench,
  org.eclipse.e4.ui.workbench;bundle-version="1.3.0",
  org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150407-1430",
index 6f70bc56ee3a319edf5b703ff47e84eee580e9bf..cb1ee16d315c28d197016d491130a77d38c98e1c 100644 (file)
@@ -96,8 +96,6 @@ import org.simantics.application.arguments.IArguments;
 import org.simantics.application.arguments.SimanticsArguments;
 import org.simantics.db.common.Indexing;
 import org.simantics.db.indexing.DatabaseIndexing;
-import org.simantics.db.procore.server.environment.RebootRequiredException;
-import org.simantics.db.procore.server.environment.windows.Product;
 import org.simantics.project.IProject;
 import org.simantics.project.ProjectKeys;
 import org.simantics.ui.SimanticsUI;
@@ -465,19 +463,7 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
             return false;
         } catch (Exception e) {
             log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
-
-            Throwable cause = e.getCause();
-            if (cause instanceof RebootRequiredException) {
-                RebootRequiredException rre = (RebootRequiredException) cause;
-                StringBuilder msg = new StringBuilder();
-                msg.append("The application must be restarted after installing the following products:\n");
-                for (Product product : rre.products)
-                    msg.append("\t" + product + "\n");
-                msg.append("\nThe application will now close.");
-                MessageDialog.openInformation(null, "Restart Required", msg.toString());
-            } else {
-                new ShowError("Platform Startup Failed", "Simantics Platform startup failed:\n\n" + e.getMessage(), e, true);
-            }
+            new ShowError("Platform Startup Failed", "Simantics Platform startup failed:\n\n" + e.getMessage(), e, true);
             return false;
         }
 
index dcc2bf9ef39f4901e2938945520cfb21fa24de8d..1a1102e203c974462724f0c44e1a3156c3dd29bb 100644 (file)
@@ -9,7 +9,6 @@ Require-Bundle: org.eclipse.core.runtime;visibility:=reexport,
  org.simantics.db.layer0;bundle-version="1.1.0";visibility:=reexport,
  org.simantics.db.management;bundle-version="1.1.0";visibility:=reexport,
  org.simantics.project;bundle-version="1.0.1";visibility:=reexport,
- org.simantics.db.procore.server.environment;bundle-version="1.1.0",
  org.simantics.graph.db;bundle-version="1.1.5",
  org.eclipse.equinox.p2.metadata;bundle-version="2.0.0",
  org.apache.log4j;bundle-version="1.2.15",
index 2504ba62d8f9ae04f4111bfbdaafa0086409d8f1..7839ce70db31de7b0de4dc80d6725e8dc603b505 100644 (file)
@@ -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);
             }
diff --git a/bundles/org.simantics/src/org/simantics/internal/SessionUtil.java b/bundles/org.simantics/src/org/simantics/internal/SessionUtil.java
deleted file mode 100644 (file)
index 86bc764..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- *     Semantum Oy - initial API and implementation
- *******************************************************************************/
-package org.simantics.internal;
-
-import java.io.File;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.eclipse.core.runtime.IProduct;
-import org.eclipse.core.runtime.Platform;
-import org.simantics.db.ServerEx;
-import org.simantics.db.Session;
-import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.service.LifecycleSupport;
-import org.simantics.db.service.XSupport;
-import org.simantics.project.management.ServerManager;
-import org.simantics.project.management.ServerManagerFactory;
-
-/**
- * An as-simple-as-possible utility class for starting a Simantics database
- * instance and opening a connection ({@link Session}) to it.
- *
- * <p>
- * To get up and running, simply invoke:
- * <pre>
- *     SessionUtil util = new SessionUtil("my-client-id");
- *     try {
- *         File workspaceLocation = ...;
- *         Session session = util.openSession(workspaceLocation);
- *         // do something with the database session
- *     } finally {
- *         util.close();
- *     }
- * </pre>
- *
- * <p>
- * This class is a provisional utility, pending for public inclusion.
- *
- * @author Tuukka Lehtonen
- * @see Session
- */
-public class SessionUtil {
-
-       private String clientId;
-       @SuppressWarnings("unused")
-       private File workspace;
-
-       private ServerManager serverManager;
-       private ServerEx server;
-       private Session session;
-
-       public static String getApplicationClientId() {
-               IProduct product = Platform.getProduct();
-               if(product == null) return "noProduct";
-               String application = product.getApplication();
-               return application != null ? application : UUID.randomUUID().toString();
-       }
-
-       public SessionUtil() {
-               this(UUID.randomUUID().toString());
-       }
-
-       public SessionUtil(String clientId) {
-               serverManager = ServerManagerFactory.getServerManager();
-               this.clientId = clientId;
-       }
-
-       public void close() throws DatabaseException {
-               if (session != null) {
-                       session.getService(LifecycleSupport.class).close();
-               }
-               serverManager.close();
-       }
-
-//     public Session open(File workspace) throws IOException, DatabaseException {
-//             File dbDir = new File(workspace, "db");
-//             if (!dbDir.exists() || !dbDir.isDirectory())
-//                     throw new FileNotFoundException("database directory " + dbDir + " not found");
-//             server = serverManager.getServer(dbDir);
-//             server.start(null);
-//             session = openSession(server, dbDir);
-//             this.workspace = workspace;
-//             return session;
-//     }
-
-       private Session openSession(ServerEx server, File dbDir) throws DatabaseException {
-               Properties info = new Properties(ServerManager.DEFAULT);
-               session = server.createSession(info);
-               session.getService(XSupport.class).setServiceMode(true, true);
-               return session;
-       }
-
-}
index 6469aaff9dd70cfb8a1f29b941eb812a9050010c..e90980faf6073dcd02400f55fdf818752d91ba45 100644 (file)
@@ -88,7 +88,6 @@
                <module>org.simantics.db.layer0</module>
                <module>org.simantics.db.management</module>
                <module>org.simantics.db.procore</module>
-               <module>org.simantics.db.procore.server.environment</module>
                <module>org.simantics.db.procore.ui</module>
                <module>org.simantics.db.server</module>
                <module>org.simantics.db.services</module>
index 7b587321937878bd1063fb5a23dfd94aff0463e9..20c72be5fe2e9200e1976e5dbcdf3aaf2d842c42 100644 (file)
          version="0.0.0"
          unpack="false"/>
 
-   <plugin
-         id="org.simantics.db.procore.server.environment"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
    <plugin
          id="org.simantics.workbench"
          download-size="0"