1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.service;
\r
14 import java.util.Collection;
\r
16 import org.simantics.db.ChangeSet;
\r
17 import org.simantics.db.ChangeSetIdentifier;
\r
18 import org.simantics.db.Metadata;
\r
19 import org.simantics.db.ReadGraph;
\r
20 import org.simantics.db.exception.DatabaseException;
\r
22 public interface ManagementSupport {
\r
25 * Get change sets from server.
\r
26 * IMPORTANT WARNING:
\r
27 * Due to implementation deficiencies the returned collections
\r
28 * changesStatements and changesValues do not implement the collection
\r
29 * interface. All you can do is to iterate the collections.
\r
30 * Also note that the current interface does not offer a way to access
\r
31 * the changed values. (The implementation does not even store the changed
\r
32 * values. The used implementation for change set is ClientChangesImpl
\r
33 * because it's backed to disk and change set can be large. ClientChangeSetImpl
\r
34 * would offer a better implementation of collections but is not suitable for
\r
35 * large change sets.)
\r
37 * @param graph to ensure that we have a read transaction.
\r
38 * @return ChangeSets for given inclusive range [from, to].
\r
39 * @throws DatabaseException
\r
41 public Collection<ChangeSet> fetchChangeSets(ReadGraph graph, long from, long to)
\r
42 throws DatabaseException;
\r
45 * Get information about change sets in server.
\r
47 * @return ChangeSetIdentifiers for given inclusive range [from, to].
\r
48 * @throws DatabaseException
\r
50 Collection<ChangeSetIdentifier> getChangeSetIdentifiers(long from, long to)
\r
51 throws DatabaseException;
\r
54 * Get information about change sets in server.
\r
56 * @return Metadata objects for given change set for the inclusive range
\r
58 * @throws DatabaseException
\r
60 <T> Collection<T> getMetadata(long from, long to, Class<? extends Metadata> dataClass)
\r
61 throws DatabaseException;
\r
64 * Get meta information about changes sets in server. This was implemented
\r
65 * before the {@link #getMetadata(long, long, Class)} and was left for
\r
66 * backward compatibility. Prefer {@link #getMetadata(long, long, Class)}.
\r
68 * @return Metadata objects for given change set for the inclusive range
\r
70 * @throws DatabaseException
\r
72 <T> Collection<T> getMetadata(ReadGraph graph, long from, long to, Class<? extends Metadata> dataClass)
\r
73 throws DatabaseException;
\r
76 * Create and save to file selected revision in server.
\r
78 * @throws DatabaseException
\r
80 void dumpRevision(long changeSetId)
\r
81 throws DatabaseException;
\r
84 * Save change sets to file up to selected revision in server.
\r
86 * @throws DatabaseException
\r
88 void dumpChangeSets(long changeSetId)
\r
89 throws DatabaseException;
\r
92 * Get head revision id.
\r
93 * @return last revision id.
\r
94 * @throws DatabaseException
\r
96 long getHeadRevisionId() throws DatabaseException;
\r
99 * Get first revision id that is or will be available when next revision is created.
\r
101 * @return first revision id.
\r
102 * @throws DatabaseException
\r
104 long getFirstRevisionId() throws DatabaseException;
\r
106 interface ChangeSetListener {
\r
107 void onChanged(long headChangeSetId);
\r
109 void subscribe(ChangeSetListener changeSetListener);
\r
110 void cancel(ChangeSetListener changeSetListener);
\r
113 * Get information about change sets in server. This was implemented before
\r
114 * {@link #getChangeSetIdentifiers(long, long)} and was left for backward
\r
115 * compatibility. Prefer {@link #getChangeSetIdentifiers(long, long)}.
\r
116 * This will be removed soon.
\r
118 * @return ChangeSetIdentifiers for given inclusive range [from, to].
\r
119 * @throws DatabaseException
\r
122 Collection<ChangeSetIdentifier> getChangeSets(long from, long to)
\r
123 throws DatabaseException;
\r