]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge remote-tracking branch 'origin/svn' 24/24/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 16 Aug 2016 11:08:02 +0000 (14:08 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 16 Aug 2016 11:10:43 +0000 (14:10 +0300)
Change-Id: Ib64bce0e85c78300c078f16a948d9db2f4872ed5

25 files changed:
bundles/org.simantics.backup.db/.classpath [new file with mode: 0644]
bundles/org.simantics.backup.db/.project [new file with mode: 0644]
bundles/org.simantics.backup.db/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.backup.db/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.backup.db/OSGI-INF/component.xml [new file with mode: 0644]
bundles/org.simantics.backup.db/build.properties [new file with mode: 0644]
bundles/org.simantics.backup.db/scl/Simantics/Backup.scl [new file with mode: 0644]
bundles/org.simantics.backup.db/src/org/simantics/backup/db/Activator.java [new file with mode: 0644]
bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackup.java [new file with mode: 0644]
bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackupProvider.java [new file with mode: 0644]
bundles/org.simantics.backup.ontology/.classpath [new file with mode: 0644]
bundles/org.simantics.backup.ontology/.project [new file with mode: 0644]
bundles/org.simantics.backup.ontology/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.backup.ontology/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.backup.ontology/build.properties [new file with mode: 0644]
bundles/org.simantics.backup.ontology/graph.tg [new file with mode: 0644]
bundles/org.simantics.backup.ontology/graph/Backup.pgraph [new file with mode: 0644]
bundles/org.simantics.backup.ontology/graph/scl/SCLMain.scl [new file with mode: 0644]
bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/Activator.java [new file with mode: 0644]
bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java [new file with mode: 0644]
features/org.jfree.feature/.project [new file with mode: 0644]
features/org.jfree.feature/build.properties [new file with mode: 0644]
features/org.jfree.feature/feature.xml [new file with mode: 0644]
features/org.simantics.desktop.feature/feature.xml
features/org.simantics.g2d.feature/feature.xml

diff --git a/bundles/org.simantics.backup.db/.classpath b/bundles/org.simantics.backup.db/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.backup.db/.project b/bundles/org.simantics.backup.db/.project
new file mode 100644 (file)
index 0000000..7dca7f1
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.backup.db</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ds.core.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.backup.db/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.backup.db/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.backup.db/META-INF/MANIFEST.MF b/bundles/org.simantics.backup.db/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..27255bf
--- /dev/null
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Modelled Backup Provider
+Bundle-SymbolicName: org.simantics.backup.db
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.backup.db.Activator
+Require-Bundle: org.simantics,
+ org.simantics.backup.ontology,
+ org.simantics.backup
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Service-Component: OSGI-INF/component.xml
diff --git a/bundles/org.simantics.backup.db/OSGI-INF/component.xml b/bundles/org.simantics.backup.db/OSGI-INF/component.xml
new file mode 100644 (file)
index 0000000..6b29980
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.simantics.backup.db.modelled">\r
+   <implementation class="org.simantics.backup.db.ModelledBackupProvider"/>\r
+   <service>\r
+      <provide interface="org.simantics.backup.IBackupProvider"/>\r
+   </service>\r
+</scr:component>\r
diff --git a/bundles/org.simantics.backup.db/build.properties b/bundles/org.simantics.backup.db/build.properties
new file mode 100644 (file)
index 0000000..5a2708a
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               scl/,\\r
+               OSGI-INF/component.xml\r
diff --git a/bundles/org.simantics.backup.db/scl/Simantics/Backup.scl b/bundles/org.simantics.backup.db/scl/Simantics/Backup.scl
new file mode 100644 (file)
index 0000000..1fafb01
--- /dev/null
@@ -0,0 +1,15 @@
+import "Simantics/DB"\r
+\r
+importJava "org.simantics.backup.IBackupProvider" where\r
+    data IBackupProvider\r
+\r
+importJava "org.simantics.backup.db.ModelledBackup" where\r
+    modelledBackup :: \r
+      (<e> ()) -> \r
+      (String -> Integer -> <e> (() -> <e> Maybe String)) -> \r
+      (<e> ()) -> \r
+      (String -> Integer -> <e> ()) -> \r
+      <Proc> IBackupProvider\r
+    \r
+importJava "org.simantics.backup.BackupProviderService" where\r
+    backup :: String -> Integer -> <Proc> ()
\ No newline at end of file
diff --git a/bundles/org.simantics.backup.db/src/org/simantics/backup/db/Activator.java b/bundles/org.simantics.backup.db/src/org/simantics/backup/db/Activator.java
new file mode 100644 (file)
index 0000000..8f87f9a
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.backup.db;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+       private static BundleContext context;\r
+\r
+       static BundleContext getContext() {\r
+               return context;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext bundleContext) throws Exception {\r
+               Activator.context = bundleContext;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext bundleContext) throws Exception {\r
+               Activator.context = null;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackup.java b/bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackup.java
new file mode 100644 (file)
index 0000000..258915c
--- /dev/null
@@ -0,0 +1,82 @@
+package org.simantics.backup.db;\r
+\r
+import java.nio.file.Path;\r
+import java.util.concurrent.Callable;\r
+import java.util.concurrent.Future;\r
+import java.util.concurrent.FutureTask;\r
+\r
+import org.simantics.backup.BackupException;\r
+import org.simantics.backup.IBackupProvider;\r
+import org.simantics.scl.runtime.function.Function1;\r
+import org.simantics.scl.runtime.function.Function2;\r
+import org.simantics.scl.runtime.tuple.Tuple0;\r
+\r
+public class ModelledBackup implements IBackupProvider {\r
+\r
+    private final Function1<Tuple0, Object> lockFunc;\r
+    private final Function2<String, Integer, Function1<Tuple0, String>> backupFunc;\r
+    private final Function1<Tuple0, Object> unlockFunc;\r
+    private final Function2<String, Integer, Object> restoreFunc;\r
+\r
+    private ModelledBackup(\r
+            Function1<Tuple0, Object> lockFunc,\r
+            Function2<String, Integer, Function1<Tuple0, String>> backupFunc,\r
+            Function1<Tuple0, Object> unlockFunc,\r
+            Function2<String, Integer, Object> restoreFunc) {\r
+        this.lockFunc = lockFunc;\r
+        this.backupFunc = backupFunc;\r
+        this.unlockFunc = unlockFunc;\r
+        this.restoreFunc = restoreFunc;\r
+    }\r
+\r
+    @Override\r
+    public void lock() {\r
+        lockFunc.apply(Tuple0.INSTANCE);\r
+    }\r
+\r
+    @Override\r
+    public Future<BackupException> backup(Path targetPath, int revision) {\r
+\r
+       final Function1<Tuple0, String> fn = backupFunc.apply(targetPath.toString(), revision);\r
+       \r
+       final FutureTask<BackupException> futureTask = new FutureTask<BackupException>(new Callable<BackupException>() {\r
+                       @Override\r
+                       public BackupException call() throws Exception {\r
+                               try {\r
+                                       String error = fn.apply(Tuple0.INSTANCE);\r
+                                       if (error != null) {\r
+                                               return new BackupException(error);\r
+                                       } else {\r
+                                               return null;\r
+                                       }\r
+                               } catch (Throwable t) {\r
+                                       return new BackupException(t);\r
+                               }\r
+                       }\r
+       });\r
+        \r
+       Thread thread = new Thread(futureTask, "Backup Provider Thread " + backupFunc.toString());\r
+       thread.start();\r
+\r
+       return futureTask;\r
+    }\r
+\r
+    @Override\r
+    public void unlock() {\r
+        unlockFunc.apply(Tuple0.INSTANCE);\r
+    }\r
+\r
+    @Override\r
+    public void restore(Path fromPath, int revision) {\r
+        restoreFunc.apply(fromPath.toString(), revision);\r
+    }\r
+\r
+    public static IBackupProvider modelledBackup(\r
+            Function1<Tuple0, Object> lockFunc,\r
+            Function2<String, Integer, Function1<Tuple0, String>> backupFunc,\r
+            Function1<Tuple0, Object> unlockFunc,\r
+            Function2<String, Integer, Object> restoreFunc) {\r
+\r
+        return new ModelledBackup(lockFunc, backupFunc, unlockFunc, restoreFunc);\r
+    }\r
+}\r
diff --git a/bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackupProvider.java b/bundles/org.simantics.backup.db/src/org/simantics/backup/db/ModelledBackupProvider.java
new file mode 100644 (file)
index 0000000..3aaefab
--- /dev/null
@@ -0,0 +1,133 @@
+package org.simantics.backup.db;\r
+\r
+import java.nio.file.Path;\r
+import java.util.ArrayList;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.concurrent.Callable;\r
+import java.util.concurrent.ExecutionException;\r
+import java.util.concurrent.Future;\r
+import java.util.concurrent.FutureTask;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.MultiStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.simantics.Simantics;\r
+import org.simantics.backup.Activator;\r
+import org.simantics.backup.BackupException;\r
+import org.simantics.backup.Backups;\r
+import org.simantics.backup.IBackupProvider;\r
+import org.simantics.backup.ontology.BackupResource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.Instances;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+\r
+public class ModelledBackupProvider implements IBackupProvider {\r
+    \r
+    List<IBackupProvider> modelledBackups = new ArrayList<>();\r
+\r
+    public ModelledBackupProvider() {\r
+       // Should this be on the constructor or can there be dynamic ontologies?\r
+       this.modelledBackups = getModelledBackups();\r
+       }\r
+    \r
+    @Override\r
+    public void lock() throws BackupException {\r
+        Backups.lock(modelledBackups);\r
+    }\r
+\r
+    @Override\r
+    public Future<BackupException> backup(Path targetPath, int revision) throws BackupException {\r
+        final List<Future<BackupException>> backups = new ArrayList<>();\r
+        final List<Exception> exceptions = new ArrayList<>(backups.size());\r
+        for (IBackupProvider modelledBackup : modelledBackups) {\r
+            try {\r
+                Future<BackupException> future = modelledBackup.backup(targetPath, revision);\r
+                backups.add(future);\r
+            } catch (BackupException e) {\r
+                exceptions.add(e);\r
+            }\r
+        }\r
+        FutureTask<BackupException> task = new FutureTask<>(new Callable<BackupException>() {\r
+\r
+            @Override\r
+            public BackupException call() throws Exception {\r
+                for (Future<BackupException> f : backups) {\r
+                    try {\r
+                        Exception exception = f.get();\r
+                        if (exception != null)\r
+                            exceptions.add(exception);\r
+                    } catch (InterruptedException | ExecutionException e) {\r
+                        exceptions.add(e);\r
+                    }\r
+                }\r
+                BackupException problem = null;\r
+                // Throw BackupException if any of the backup operations failed.\r
+                if (!exceptions.isEmpty()) {\r
+                    IStatus[] ss = exceptions.stream()\r
+                            .map(e -> new Status(IStatus.ERROR, Activator.BUNDLE_ID, e.getMessage(), e))\r
+                            .toArray(IStatus[]::new);\r
+                    problem = new BackupException(new CoreException(new MultiStatus(Activator.BUNDLE_ID, 0, ss,\r
+                            "Backup operation(s) failed to complete.", null)));\r
+                }\r
+                return problem;\r
+            }\r
+        });\r
+        new Thread(task).run();\r
+        return task;\r
+    }\r
+\r
+    @Override\r
+    public void unlock() throws BackupException {\r
+        Backups.unlock(modelledBackups);\r
+    }\r
+\r
+    @Override\r
+    public void restore(Path fromPath, int revision) throws BackupException {\r
+        for (IBackupProvider modelledBackup : modelledBackups) {\r
+            modelledBackup.restore(fromPath, revision);\r
+        }\r
+    }\r
+\r
+    \r
+    private List<IBackupProvider> getModelledBackups() {\r
+        List<IBackupProvider> modelledProviders = new ArrayList<>(0);\r
+        try {\r
+             modelledProviders = Simantics.getSession().syncRequest(new UniqueRead<List<IBackupProvider>>() {\r
+\r
+                @Override\r
+                public List<IBackupProvider> perform(ReadGraph graph) throws DatabaseException {\r
+                    BackupResource BACKUP = BackupResource.getInstance(graph);\r
+                    Instances query = graph.adapt(BACKUP.ModelledBackupProvider, Instances.class);\r
+\r
+                    HashSet<Resource> providers = new HashSet<>();\r
+                    \r
+                    List<Resource> ontologies = Layer0Utils.listOntologies(graph);\r
+                    for (Resource ontology : ontologies) {\r
+                        for(Resource provider : query.find(graph, ontology)) {\r
+                            providers.add(provider);\r
+                        }\r
+                    }\r
+                    List<IBackupProvider> modelledBackups = new ArrayList<>();\r
+                    for (Resource provider : providers) {\r
+                        Variable variable = Variables.getVariable(graph, provider);\r
+                        IBackupProvider modelledBackup = variable.getPropertyValue(graph, "instance");\r
+                        modelledBackups.add(modelledBackup);\r
+                    }\r
+                    \r
+                    return modelledBackups;\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+        return modelledProviders;\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.backup.ontology/.classpath b/bundles/org.simantics.backup.ontology/.classpath
new file mode 100644 (file)
index 0000000..b1dabee
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.backup.ontology/.project b/bundles/org.simantics.backup.ontology/.project
new file mode 100644 (file)
index 0000000..af5199b
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.backup.ontology</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.simantics.graph.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.simantics.graph.nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.backup.ontology/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.backup.ontology/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..11f6e46
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7\r
+org.eclipse.jdt.core.compiler.compliance=1.7\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.7\r
diff --git a/bundles/org.simantics.backup.ontology/META-INF/MANIFEST.MF b/bundles/org.simantics.backup.ontology/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..94a4bfa
--- /dev/null
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Backup Ontology
+Bundle-SymbolicName: org.simantics.backup.ontology
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.backup.ontology.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.simantics.layer0,
+ org.simantics.structural.ontology;bundle-version="1.2.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.backup.ontology
diff --git a/bundles/org.simantics.backup.ontology/build.properties b/bundles/org.simantics.backup.ontology/build.properties
new file mode 100644 (file)
index 0000000..022de17
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               graph.tg\r
diff --git a/bundles/org.simantics.backup.ontology/graph.tg b/bundles/org.simantics.backup.ontology/graph.tg
new file mode 100644 (file)
index 0000000..bcb6d85
Binary files /dev/null and b/bundles/org.simantics.backup.ontology/graph.tg differ
diff --git a/bundles/org.simantics.backup.ontology/graph/Backup.pgraph b/bundles/org.simantics.backup.ontology/graph/Backup.pgraph
new file mode 100644 (file)
index 0000000..aad660b
--- /dev/null
@@ -0,0 +1,21 @@
+L0 = <http://www.simantics.org/Layer0-1.1>\r
+STR = <http://www.simantics.org/Structural-1.2>\r
+\r
+BACKUP = <http://www.simantics.org/Backup-1.0> : L0.Ontology\r
+    @L0.new\r
+    L0.HasResourceClass "org.simantics.backup.ontology.BackupResource"\r
+\r
+BACKUP.SCLMain : L0.SCLModule\r
+    L0.SCLModule.definition _ : L0.String\r
+        @L0.loadString "scl/SCLMain.scl"\r
+\r
+BACKUP.ModelledBackupProvider <T L0.Entity\r
+  --> BACKUP.ModelledBackupProvider.instance ==> "IBackupProvider" <R L0.HasProperty : L0.FunctionalRelation \r
+\r
+BACKUP.modelledBackupProvider : L0.Template\r
+    @template %subject %expression\r
+        %subject : BACKUP.ModelledBackupProvider\r
+            BACKUP.ModelledBackupProvider.instance _ : STR.SCLValue\r
+                L0.SCLValue.expression %expression\r
+                L0.HasValueType "IBackupProvider"\r
+\r
diff --git a/bundles/org.simantics.backup.ontology/graph/scl/SCLMain.scl b/bundles/org.simantics.backup.ontology/graph/scl/SCLMain.scl
new file mode 100644 (file)
index 0000000..b69abd2
--- /dev/null
@@ -0,0 +1 @@
+include "Simantics/Backup"
\ No newline at end of file
diff --git a/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/Activator.java b/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/Activator.java
new file mode 100644 (file)
index 0000000..f0090a6
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.backup.ontology;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+       private static BundleContext context;\r
+\r
+       static BundleContext getContext() {\r
+               return context;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext bundleContext) throws Exception {\r
+               Activator.context = bundleContext;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext bundleContext) throws Exception {\r
+               Activator.context = null;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java b/bundles/org.simantics.backup.ontology/src/org/simantics/backup/ontology/BackupResource.java
new file mode 100644 (file)
index 0000000..215c686
--- /dev/null
@@ -0,0 +1,70 @@
+package org.simantics.backup.ontology;\r
+\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.service.QueryControl;\r
+\r
+public class BackupResource {\r
+    \r
+    public final Resource ModelledBackupProvider;\r
+    public final Resource ModelledBackupProvider_instance;\r
+    public final Resource ModelledBackupProvider_instance_Inverse;\r
+    public final Resource SCLMain;\r
+    public final Resource modelledBackupProvider;\r
+        \r
+    public static class URIs {\r
+        public static final String ModelledBackupProvider = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider";\r
+        public static final String ModelledBackupProvider_instance = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider/instance";\r
+        public static final String ModelledBackupProvider_instance_Inverse = "http://www.simantics.org/Backup-1.0/ModelledBackupProvider/instance/Inverse";\r
+        public static final String SCLMain = "http://www.simantics.org/Backup-1.0/SCLMain";\r
+        public static final String modelledBackupProvider = "http://www.simantics.org/Backup-1.0/modelledBackupProvider";\r
+    }\r
+    \r
+    public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
+        try {\r
+            return graph.getResource(uri);\r
+        } catch(DatabaseException e) {\r
+            System.err.println(e.getMessage());\r
+            return null;\r
+        }\r
+    }\r
+    \r
+    public BackupResource(ReadGraph graph) {\r
+        ModelledBackupProvider = getResourceOrNull(graph, URIs.ModelledBackupProvider);\r
+        ModelledBackupProvider_instance = getResourceOrNull(graph, URIs.ModelledBackupProvider_instance);\r
+        ModelledBackupProvider_instance_Inverse = getResourceOrNull(graph, URIs.ModelledBackupProvider_instance_Inverse);\r
+        SCLMain = getResourceOrNull(graph, URIs.SCLMain);\r
+        modelledBackupProvider = getResourceOrNull(graph, URIs.modelledBackupProvider);\r
+    }\r
+    \r
+    public static BackupResource getInstance(ReadGraph graph) {\r
+        Session session = graph.getSession();\r
+        BackupResource ret = session.peekService(BackupResource.class);\r
+        if(ret == null) {\r
+            QueryControl qc = graph.getService(QueryControl.class);\r
+            ret = new BackupResource(qc.getIndependentGraph(graph));\r
+            session.registerService(BackupResource.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+    public static BackupResource getInstance(RequestProcessor session) throws DatabaseException {\r
+        BackupResource ret = session.peekService(BackupResource.class);\r
+        if(ret == null) {\r
+            ret = session.syncRequest(new Read<BackupResource>() {\r
+                public BackupResource perform(ReadGraph graph) throws DatabaseException {\r
+                    QueryControl qc = graph.getService(QueryControl.class);\r
+                    return new BackupResource(qc.getIndependentGraph(graph));\r
+                }\r
+            });\r
+            session.registerService(BackupResource.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+}\r
+\r
diff --git a/features/org.jfree.feature/.project b/features/org.jfree.feature/.project
new file mode 100644 (file)
index 0000000..293973d
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.jfree.feature</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.FeatureBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.FeatureNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/features/org.jfree.feature/build.properties b/features/org.jfree.feature/build.properties
new file mode 100644 (file)
index 0000000..82ab19c
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = feature.xml\r
diff --git a/features/org.jfree.feature/feature.xml b/features/org.jfree.feature/feature.xml
new file mode 100644 (file)
index 0000000..c3cfc18
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<feature\r
+      id="org.jfree"\r
+      label="JFree Components"\r
+      version="1.0.0.qualifier"\r
+      provider-name="VTT Technical Research Centre of Finland">\r
+\r
+   <description url="http://www.jfree.org/">\r
+      JFree.org Java libraries.\r
+   </description>\r
+\r
+   <copyright url="http://www.jfree.org/">\r
+      Object Refinery Limited\r
+   </copyright>\r
+\r
+   <license url="http://www.gnu.org/licenses/lgpl.html">\r
+      GNU LESSER GENERAL PUBLIC LICENSE
+
+Version 3, 29 June 2007
+
+Copyright © 2007 Free Software Foundation, Inc. &lt;http://fsf.org/&gt;
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
+0. Additional Definitions.
+
+As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
+
+“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
+
+An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
+
+A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
+
+The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
+
+The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
+1. Exception to Section 3 of the GNU GPL.
+
+You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
+2. Conveying Modified Versions.
+
+If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
+
+    * a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
+    * b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
+
+3. Object Code Incorporating Material from Library Header Files.
+
+The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
+
+    * a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
+    * b) Accompany the object code with a copy of the GNU GPL and this license document.
+
+4. Combined Works.
+
+You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
+
+    * a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
+    * b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
+    * c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
+    * d) Do one of the following:
+          o 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
+          o 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user&apos;s computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
+    * e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
+
+5. Combined Libraries.
+
+You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
+
+    * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
+    * b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+
+6. Revised Versions of the GNU Lesser General Public License.
+
+The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
+
+If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy&apos;s public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.\r
+   </license>\r
+\r
+   <plugin\r
+         id="org.jfree.jchart"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.jfree.jcommon"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+</feature>\r
index d29ccac34a20301c44f3f992b24370c7734352e5..ee8db3761bf14dc5390f6b5f49166d5b4c6655e9 100644 (file)
@@ -26,7 +26,7 @@
          version="0.0.0"/>\r
 \r
    <includes\r
-         id="org.simantics.issues"\r
+         id="org.simantics.issues.feature"\r
          version="0.0.0"/>\r
 \r
    <includes\r
@@ -34,7 +34,7 @@
          version="0.0.0"/>\r
 \r
    <includes\r
-         id="org.simantics.issues.ui"\r
+         id="org.simantics.issues.ui.feature"\r
          version="0.0.0"/>\r
 \r
    <includes\r
index 00eab1cb3df85a4b46a0d68ef0f87ea6de63224f..e3e9eb0d30951352c6f82dd0c54ce88dafea4a88 100644 (file)
          id="org.simantics.views.swt.feature"\r
          version="0.0.0"/>\r
 \r
+   <includes\r
+         id="org.jfree"\r
+         version="0.0.0"/>\r
+\r
    <plugin\r
          id="org.simantics.scenegraph"\r
          download-size="0"\r