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.service;
14 import java.util.Collection;
16 import org.simantics.db.ChangeSet;
17 import org.simantics.db.ChangeSetIdentifier;
18 import org.simantics.db.Metadata;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.exception.DatabaseException;
22 public interface ManagementSupport {
25 * Get change sets from server.
27 * Due to implementation deficiencies the returned collections
28 * changesStatements and changesValues do not implement the collection
29 * interface. All you can do is to iterate the collections.
30 * Also note that the current interface does not offer a way to access
31 * the changed values. (The implementation does not even store the changed
32 * values. The used implementation for change set is ClientChangesImpl
33 * because it's backed to disk and change set can be large. ClientChangeSetImpl
34 * would offer a better implementation of collections but is not suitable for
37 * @param graph to ensure that we have a read transaction.
38 * @return ChangeSets for given inclusive range [from, to].
39 * @throws DatabaseException
41 public Collection<ChangeSet> fetchChangeSets(ReadGraph graph, long from, long to)
42 throws DatabaseException;
45 * Get information about change sets in server.
47 * @return ChangeSetIdentifiers for given inclusive range [from, to].
48 * @throws DatabaseException
50 Collection<ChangeSetIdentifier> getChangeSetIdentifiers(long from, long to)
51 throws DatabaseException;
54 * Get information about change sets in server.
56 * @return Metadata objects for given change set for the inclusive range
58 * @throws DatabaseException
60 <T> Collection<T> getMetadata(long from, long to, Class<? extends Metadata> dataClass)
61 throws DatabaseException;
64 * Get meta information about changes sets in server. This was implemented
65 * before the {@link #getMetadata(long, long, Class)} and was left for
66 * backward compatibility. Prefer {@link #getMetadata(long, long, Class)}.
68 * @return Metadata objects for given change set for the inclusive range
70 * @throws DatabaseException
72 <T> Collection<T> getMetadata(ReadGraph graph, long from, long to, Class<? extends Metadata> dataClass)
73 throws DatabaseException;
76 * Create and save to file selected revision in server.
78 * @throws DatabaseException
80 void dumpRevision(long changeSetId)
81 throws DatabaseException;
84 * Save change sets to file up to selected revision in server.
86 * @throws DatabaseException
88 void dumpChangeSets(long changeSetId)
89 throws DatabaseException;
92 * Get head revision id.
93 * @return last revision id.
94 * @throws DatabaseException
96 long getHeadRevisionId() throws DatabaseException;
99 * Get first revision id that is or will be available when next revision is created.
101 * @return first revision id.
102 * @throws DatabaseException
104 long getFirstRevisionId() throws DatabaseException;
106 interface ChangeSetListener {
107 void onChanged(long headChangeSetId);
109 void subscribe(ChangeSetListener changeSetListener);
110 void cancel(ChangeSetListener changeSetListener);
113 * Get information about change sets in server. This was implemented before
114 * {@link #getChangeSetIdentifiers(long, long)} and was left for backward
115 * compatibility. Prefer {@link #getChangeSetIdentifiers(long, long)}.
116 * This will be removed soon.
118 * @return ChangeSetIdentifiers for given inclusive range [from, to].
119 * @throws DatabaseException
122 Collection<ChangeSetIdentifier> getChangeSets(long from, long to)
123 throws DatabaseException;