]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/service/ManagementSupport.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / ManagementSupport.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.service;
13
14 import java.util.Collection;
15
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;
21
22 public interface ManagementSupport {
23
24     /**
25      * Get change sets from server.
26      * IMPORTANT WARNING:
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
35      * large change sets.)
36      *
37      * @param graph to ensure that we have a read transaction.
38      * @return ChangeSets for given inclusive range [from, to].
39      * @throws DatabaseException
40      */
41     public Collection<ChangeSet> fetchChangeSets(ReadGraph graph, long from, long to)
42             throws DatabaseException;
43
44     /**
45      * Get information about change sets in server.
46      *
47      * @return ChangeSetIdentifiers for given inclusive range [from, to].
48      * @throws DatabaseException
49      */
50     Collection<ChangeSetIdentifier> getChangeSetIdentifiers(long from, long to)
51             throws DatabaseException;
52
53     /**
54      * Get information about change sets in server.
55      *
56      * @return Metadata objects for given change set for the inclusive range
57      *         [from, to].
58      * @throws DatabaseException
59      */
60     <T> Collection<T> getMetadata(long from, long to, Class<? extends Metadata> dataClass)
61             throws DatabaseException;
62
63     /**
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)}.
67      *
68      * @return Metadata objects for given change set for the inclusive range
69      *         [from, to].
70      * @throws DatabaseException
71      */
72     <T> Collection<T> getMetadata(ReadGraph graph, long from, long to, Class<? extends Metadata> dataClass)
73             throws DatabaseException;
74
75     /**
76      * Create and save to file selected revision in server.
77      * @return
78      * @throws DatabaseException
79      */
80     void dumpRevision(long changeSetId)
81             throws DatabaseException;
82
83     /**
84      * Save change sets to file up to selected revision in server.
85      * @return
86      * @throws DatabaseException
87      */
88     void dumpChangeSets(long changeSetId)
89             throws DatabaseException;
90
91     /**
92      * Get head revision id.
93      * @return last revision id.
94      * @throws DatabaseException
95      */
96     long getHeadRevisionId()  throws DatabaseException;
97
98     /**
99      * Get first revision id that is or will be available when next revision is created.
100      *
101      * @return first revision id.
102      * @throws DatabaseException
103      */
104     long getFirstRevisionId() throws DatabaseException;
105
106     interface ChangeSetListener {
107         void onChanged(long headChangeSetId);
108     }
109     void subscribe(ChangeSetListener changeSetListener);
110     void cancel(ChangeSetListener changeSetListener);
111
112     /**
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.
117      *
118      * @return ChangeSetIdentifiers for given inclusive range [from, to].
119      * @throws DatabaseException
120      */
121     @Deprecated
122     Collection<ChangeSetIdentifier> getChangeSets(long from, long to)
123             throws DatabaseException;
124
125 }