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