]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/ResourceSerializer.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / ResourceSerializer.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/ResourceSerializer.java b/bundles/org.simantics.db/src/org/simantics/db/ResourceSerializer.java
new file mode 100644 (file)
index 0000000..7256819
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************\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;\r
+\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.InvalidResourceReferenceException;\r
+import org.simantics.db.service.SerialisationSupport;\r
+\r
+/**\r
+ * @deprecated use {@link SerialisationSupport} instead\r
+ */\r
+@Deprecated\r
+public interface ResourceSerializer {\r
+\r
+    /**\r
+     * Allocates and returns an identifier that can be stored persistently over\r
+     * time in a client and the database will be able to give you the\r
+     * corresponding Resource at a later time, until all statements of the\r
+     * resource are removed or the identifier is released by\r
+     * {@link #releaseRandomAccessForResource(String)}.\r
+     * \r
+     * <p>\r
+     * If random access is requested multiple times for a particular resource,\r
+     * the allocated ID's should be separate and each need to be released\r
+     * separately.\r
+     * \r
+     * <p>\r
+     * The format of the generated ID's should be such that they do not contain\r
+     * ':' characters.\r
+     * \r
+     * <p>\r
+     * To retrieve the Resource for the generated ID later a read transaction is\r
+     * needed where {@link ReadGraph#getResource(String)} can be used.\r
+     * \r
+     * @param resource\r
+     * @return a persistent identifier\r
+     * @throws InvalidResourceReferenceException ??? does this ever need to be\r
+     *         thrown ???\r
+     */\r
+    @Deprecated // in favor of getRandomAccessId\r
+    String createRandomAccessId(Resource resource)\r
+    throws InvalidResourceReferenceException;\r
+\r
+    long getRandomAccessId(Resource resource) throws DatabaseException;\r
+    int getTransientId(Resource resource) throws DatabaseException;\r
+\r
+    /**\r
+     * \r
+     * @param id\r
+     * @return\r
+     * @throws InvalidResourceReferenceException\r
+     */\r
+    @Deprecated // in favor of getResource(long)\r
+    Resource getResource(String randomAccessId)\r
+    throws InvalidResourceReferenceException;\r
+\r
+    Resource getResource(long randomAccessId) throws DatabaseException;\r
+\r
+    Resource getResource(int transientId) throws DatabaseException;\r
+\r
+    /**\r
+     * @param identifier an identifier for a previously created random access\r
+     *        resource id using\r
+     *        {@link #createRandomAccessForResource(Resource)}.\r
+     * @return <code>true</code> if the id was successfully released and\r
+     *         <code>false</code> if the id did not exist.\r
+     * @throws InvalidResourceReferenceException\r
+     */\r
+    boolean disposeRandomAccessId(String randomAccessId)\r
+    throws InvalidResourceReferenceException;\r
+\r
+}\r