1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db;
14 import org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.exception.InvalidResourceReferenceException;
16 import org.simantics.db.service.SerialisationSupport;
19 * @deprecated use {@link SerialisationSupport} instead
22 public interface ResourceSerializer {
25 * Allocates and returns an identifier that can be stored persistently over
26 * time in a client and the database will be able to give you the
27 * corresponding Resource at a later time, until all statements of the
28 * resource are removed or the identifier is released by
29 * {@link #releaseRandomAccessForResource(String)}.
32 * If random access is requested multiple times for a particular resource,
33 * the allocated ID's should be separate and each need to be released
37 * The format of the generated ID's should be such that they do not contain
41 * To retrieve the Resource for the generated ID later a read transaction is
42 * needed where {@link ReadGraph#getResource(String)} can be used.
45 * @return a persistent identifier
46 * @throws InvalidResourceReferenceException ??? does this ever need to be
49 @Deprecated // in favor of getRandomAccessId
50 String createRandomAccessId(Resource resource)
51 throws InvalidResourceReferenceException;
53 long getRandomAccessId(Resource resource) throws DatabaseException;
54 int getTransientId(Resource resource) throws DatabaseException;
60 * @throws InvalidResourceReferenceException
62 @Deprecated // in favor of getResource(long)
63 Resource getResource(String randomAccessId)
64 throws InvalidResourceReferenceException;
66 Resource getResource(long randomAccessId) throws DatabaseException;
68 Resource getResource(int transientId) throws DatabaseException;
71 * @param identifier an identifier for a previously created random access
73 * {@link #createRandomAccessForResource(Resource)}.
74 * @return <code>true</code> if the id was successfully released and
75 * <code>false</code> if the id did not exist.
76 * @throws InvalidResourceReferenceException
78 boolean disposeRandomAccessId(String randomAccessId)
79 throws InvalidResourceReferenceException;