]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/service/ManagementSupport.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / ManagementSupport.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/ManagementSupport.java b/bundles/org.simantics.db/src/org/simantics/db/service/ManagementSupport.java
new file mode 100644 (file)
index 0000000..d7e9338
--- /dev/null
@@ -0,0 +1,125 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.service;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ChangeSet;\r
+import org.simantics.db.ChangeSetIdentifier;\r
+import org.simantics.db.Metadata;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public interface ManagementSupport {\r
+\r
+    /**\r
+     * Get change sets from server.\r
+     * IMPORTANT WARNING:\r
+     * Due to implementation deficiencies the returned collections\r
+     * changesStatements and changesValues do not implement the collection\r
+     * interface. All you can do is to iterate the collections.\r
+     * Also note that the current interface does not offer a way to access\r
+     * the changed values. (The implementation does not even store the changed\r
+     * values. The used implementation for change set is ClientChangesImpl\r
+     * because it's backed to disk and change set can be large. ClientChangeSetImpl\r
+     * would offer a better implementation of collections but is not suitable for\r
+     * large change sets.)\r
+     *\r
+     * @param graph to ensure that we have a read transaction.\r
+     * @return ChangeSets for given inclusive range [from, to].\r
+     * @throws DatabaseException\r
+     */\r
+    public Collection<ChangeSet> fetchChangeSets(ReadGraph graph, long from, long to)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Get information about change sets in server.\r
+     *\r
+     * @return ChangeSetIdentifiers for given inclusive range [from, to].\r
+     * @throws DatabaseException\r
+     */\r
+    Collection<ChangeSetIdentifier> getChangeSetIdentifiers(long from, long to)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Get information about change sets in server.\r
+     *\r
+     * @return Metadata objects for given change set for the inclusive range\r
+     *         [from, to].\r
+     * @throws DatabaseException\r
+     */\r
+    <T> Collection<T> getMetadata(long from, long to, Class<? extends Metadata> dataClass)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Get meta information about changes sets in server. This was implemented\r
+     * before the {@link #getMetadata(long, long, Class)} and was left for\r
+     * backward compatibility. Prefer {@link #getMetadata(long, long, Class)}.\r
+     *\r
+     * @return Metadata objects for given change set for the inclusive range\r
+     *         [from, to].\r
+     * @throws DatabaseException\r
+     */\r
+    <T> Collection<T> getMetadata(ReadGraph graph, long from, long to, Class<? extends Metadata> dataClass)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Create and save to file selected revision in server.\r
+     * @return\r
+     * @throws DatabaseException\r
+     */\r
+    void dumpRevision(long changeSetId)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Save change sets to file up to selected revision in server.\r
+     * @return\r
+     * @throws DatabaseException\r
+     */\r
+    void dumpChangeSets(long changeSetId)\r
+            throws DatabaseException;\r
+\r
+    /**\r
+     * Get head revision id.\r
+     * @return last revision id.\r
+     * @throws DatabaseException\r
+     */\r
+    long getHeadRevisionId()  throws DatabaseException;\r
+\r
+    /**\r
+     * Get first revision id that is or will be available when next revision is created.\r
+     *\r
+     * @return first revision id.\r
+     * @throws DatabaseException\r
+     */\r
+    long getFirstRevisionId() throws DatabaseException;\r
+\r
+    interface ChangeSetListener {\r
+        void onChanged(long headChangeSetId);\r
+    }\r
+    void subscribe(ChangeSetListener changeSetListener);\r
+    void cancel(ChangeSetListener changeSetListener);\r
+\r
+    /**\r
+     * Get information about change sets in server. This was implemented before\r
+     * {@link #getChangeSetIdentifiers(long, long)} and was left for backward\r
+     * compatibility. Prefer {@link #getChangeSetIdentifiers(long, long)}.\r
+     * This will be removed soon.\r
+     *\r
+     * @return ChangeSetIdentifiers for given inclusive range [from, to].\r
+     * @throws DatabaseException\r
+     */\r
+    @Deprecated\r
+    Collection<ChangeSetIdentifier> getChangeSets(long from, long to)\r
+            throws DatabaseException;\r
+\r
+}\r