Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / DataStore.java @ 46505

History | View | Annotate | Download (11.2 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24 40435 jjdelcerro
package org.gvsig.fmap.dal;
25
26
import java.util.Collection;
27
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
30
import org.gvsig.metadata.Metadata;
31
import org.gvsig.timesupport.Interval;
32
import org.gvsig.timesupport.Time;
33
import org.gvsig.tools.dispose.Disposable;
34 43152 fdiaz
import org.gvsig.tools.dynobject.DynObject;
35 43246 jjdelcerro
import org.gvsig.tools.dynobject.DynObject_v2;
36 40435 jjdelcerro
import org.gvsig.tools.exception.BaseException;
37
import org.gvsig.tools.observer.ComplexWeakReferencingObservable;
38
import org.gvsig.tools.observer.Observer;
39
import org.gvsig.tools.persistence.Persistent;
40 44297 jjdelcerro
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
41 43020 jjdelcerro
import org.gvsig.tools.service.spi.Services;
42 44259 jjdelcerro
import org.gvsig.tools.util.UnmodifiableBasicMap;
43 40435 jjdelcerro
import org.gvsig.tools.visitor.Visitable;
44
import org.gvsig.tools.visitor.Visitor;
45
46
/**
47
 * <p>
48
 * This is the basic interface for all data stores. Depending on the context, it
49
 * can represent a geographic layer, an alphanumeric database table or any data
50
 * file. DataStore offers generic services like:
51
 * <ul>
52
 * <li>Open and close data stores</li>
53
 * <li>Access to data sets, with the possibility of loading data in background.</li>
54
 * <li>Use of selection and locks, as well as data sets</li>
55
 * <li>Editing</li>
56
 * <li>Register event observers through the Observable interface</li>
57
 * <li>Access to embedded data stores (like GML)</li>
58
 * <li>Information about the Spatial Reference Systems used by the data store</li>
59
 * </ul>
60
 * </p>
61
 * <br>
62
 *
63
 */
64
public interface DataStore extends ComplexWeakReferencingObservable,
65 43246 jjdelcerro
                Persistent, Metadata, Disposable, Visitable, DataFactoryUnit, Services, DynObject_v2 {
66 40435 jjdelcerro
67 44669 jjdelcerro
        public static final String SHAPE_PROVIDER_NAME = "Shape";
68
        public static final String DBASE_PROVIDER_NAME = "DBF";
69
        public static final String CSV_PROVIDER_NAME = "CSV";
70
        public static final String H2SPATIAL_PROVIDER_NAME = "H2Spatial";
71 44915 omartinez
        public static final String MDB_PROVIDER_NAME = "MDB";
72 44669 jjdelcerro
73 40435 jjdelcerro
        public static final String METADATA_DEFINITION_NAME = "DataProvider";
74
75
        public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider";
76
77
        public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider";
78
79
        /**
80
         * Metadata property name for the provider name provided by the data provider.
81 43152 fdiaz
         *
82 40435 jjdelcerro
         * This metadata is provided by all data providers.
83
         */
84
        public static final String METADATA_PROVIDER = "ProviderName";
85
86
        /**
87
         * Metadata property name for Container name provided by the data provider.
88
         * By explample, in a dbf file, this is the name of dbf.
89 43152 fdiaz
         *
90 40435 jjdelcerro
         * This metadata is provided by all data providers.
91
         */
92
        public static final String METADATA_CONTAINERNAME = "ContainerName";
93
94
        /**
95
         * Metadata property name for the feature type provided by the data provider.
96 43152 fdiaz
         *
97 40435 jjdelcerro
         * This metadata is provided by all tabular data providers.
98
         */
99
        public static final String METADATA_FEATURETYPE = "FeatureType";
100
101
        /**
102
         * Metadata property name for CRS provided by the data provider.
103 43152 fdiaz
         *
104
         * This metadata is only provided by data provider with spatial
105 40435 jjdelcerro
         * information.
106
         */
107
        public static final String METADATA_CRS = "CRS";
108
109
        /**
110
         * Metadata property name for Envelope provided by the data provider
111 43152 fdiaz
         *
112
         * This metadata is only provided by data provider with spatial
113 40435 jjdelcerro
         * information.
114
         */
115
        public static final String METADATA_ENVELOPE = "Envelope";
116
117
        /**
118
         * Returns the name associated to the store.
119
         * This name is provided for informational purposes only.
120
         * Explamples:
121 43152 fdiaz
         *
122 40435 jjdelcerro
         * In a dbf the filename without the path
123 43152 fdiaz
         *
124 40435 jjdelcerro
         * In a DDBB table the name of the table
125 43152 fdiaz
         *
126 40435 jjdelcerro
         * In a WFS layer the name of the layer.
127
         *
128
         * @return String containing this store's name.
129
         */
130
        public String getName();
131 43152 fdiaz
132 40435 jjdelcerro
        /**
133
         * Returns a more descriptive name for the store that getName.
134
         * This name is provided for informational purposes only.
135
         * Explamples:
136 43152 fdiaz
         *
137 40435 jjdelcerro
         * In a file based store may return the full name of the filename, path and filename.
138 43152 fdiaz
         *
139 40435 jjdelcerro
         * In a data base based store may return "server:dbname:tablename"
140 43152 fdiaz
         *
141 40435 jjdelcerro
         * In a WFS layer based store may return "server:layername"
142 43152 fdiaz
         *
143 40435 jjdelcerro
         * @return String Containing the full name of the store
144
         */
145
        public String getFullName();
146
147
        /**
148
         * Return the of parameters of this store
149
         *
150
         * @return parameters of this store
151
         */
152
        public DataStoreParameters getParameters();
153
154
        /**
155
         * Return the provider name that use this store.
156 43152 fdiaz
         *
157 40435 jjdelcerro
         * @return provider name of this store
158
         */
159
        public String getProviderName();
160 43152 fdiaz
161 40435 jjdelcerro
        /**
162
         * Refreshes this store state.
163
         *
164
         * @throws DataException
165
         */
166
        public void refresh() throws DataException;
167
168
        /**
169
         * Returns all available data.
170
         *
171
         * @return a set of data
172
         * @throws DataException
173
         *             if there is any error while loading the data
174
         */
175
        DataSet getDataSet() throws DataException;
176
177
        /**
178
         * Returns a subset of data taking into account the properties and
179
         * restrictions of the DataQuery.
180
         *
181
         * @param dataQuery
182
         *            defines the properties of the requested data
183
         * @return a set of data
184
         * @throws DataException
185
         *             if there is any error while loading the data
186
         */
187
        DataSet getDataSet(DataQuery dataQuery) throws DataException;
188
189
    /**
190
     * Provides each value of this Store to the provided {@link Visitor}.
191
     * The values received through the {@link Visitor#visit(Object)} method
192
     * may be transient, reused or externally modifiable, so they can't
193
     * be used to be stored in any external form out of the visit method.
194 43152 fdiaz
     *
195 40435 jjdelcerro
     * If you need to store any of the values out of the
196
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
197
     * the received value in order to be stored.
198 43152 fdiaz
     *
199 40435 jjdelcerro
     * @param visitor
200
     *            the visitor to apply to each value.
201
     * @exception BaseException
202
     *                if there is an error while performing the visit
203
     */
204
    public void accept(Visitor visitor) throws BaseException;
205
206
        /**
207
     * Provides each value of this Store to the provided {@link Visitor}.
208
     * The values received through the {@link Visitor#visit(Object)} method
209
     * may be transient, reused or externally modifiable, so they can't
210
     * be used to be stored in any external form out of the visit method.
211 43152 fdiaz
     *
212 40435 jjdelcerro
     * If you need to store any of the values out of the
213
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
214
     * the received value in order to be stored.
215 43152 fdiaz
     *
216 40435 jjdelcerro
     * @param visitor
217
     *            the visitor to apply to each value.
218
     * @param dataQuery
219
     *            defines the properties of the data to visit
220
     * @exception BaseException
221
     *                if there is an error while performing the visit
222
     */
223
        public void accept(Visitor visitor, DataQuery dataQuery)
224
                        throws BaseException;
225
226
        /**
227
         * Loads all available data and notifies the observer for each loaded block of data.
228
         *
229
         * @param observer
230
         *            to be notified for each block of data loaded
231
         * @throws DataException
232
         *             if there is any error while loading the data
233
         */
234
        void getDataSet(Observer observer) throws DataException;
235
236
        /**
237
         * Loads a subset of data taking into account the properties and
238
         * restrictions of the DataQuery. Data loading is performed by calling the
239
         * Observer, once each data block is loaded.
240
         *
241
         * @param dataQuery
242
         *            defines the properties of the requested data
243
         * @param observer
244
         *            to be notified for each block of data loaded
245
         * @throws DataException
246
         *             if there is any error while loading the data
247
         */
248
        void getDataSet(DataQuery dataQuery, Observer observer) throws DataException;
249
250
        /**
251
         * Returns the selected set of data
252
         *
253
         * @return DataSet
254 44669 jjdelcerro
         * @throws org.gvsig.fmap.dal.exception.DataException
255 40435 jjdelcerro
         */
256
257
        public DataSet getSelection() throws DataException;
258
259
        /**
260
         * Sets the current data selection with the given data set.
261
         *
262 44669 jjdelcerro
         * @param selection
263 40435 jjdelcerro
         * @throws DataException
264
         */
265
        public void setSelection(DataSet selection) throws DataException;
266
267
        /**
268
         * Creates a new selection.
269
         *
270
         * @return DataSet that contains the selection
271
         *
272
         * @throws DataException
273
         */
274
        public DataSet createSelection() throws DataException;
275
276
        /**
277 44259 jjdelcerro
         * Returns an UnmodifiableBasicMap with this store children.
278
         * If do not have children, return an empty map.
279
         * Never returns null.
280 40435 jjdelcerro
         *
281 44259 jjdelcerro
         * @return an UnmodifiableBasicMap with this DataStore children
282 40435 jjdelcerro
         */
283 44259 jjdelcerro
        public UnmodifiableBasicMap<String,DataStore> getChildren();
284 44251 jjdelcerro
285 40435 jjdelcerro
286
        /**
287
         * Returns the DataServerExplorer to which this DataStore belongs, if there
288
         * is any.
289 43152 fdiaz
         *
290 40435 jjdelcerro
         * @return DataServerExplorer to which this DataStore belongs, or
291
         *         <code>null</code> if this was not accessed through any
292
         *         DataServerExplorer.
293 43152 fdiaz
         *
294 40435 jjdelcerro
         * @throws DataException
295
         * @throws ValidateDataParametersException
296
         */
297
        public DataServerExplorer getExplorer() throws DataException,
298
                        ValidateDataParametersException;
299
300
301
        /**
302
         * Returns a new instance of a {@link DataQuery}.
303
         *
304
         * @return new {@link DataQuery} instance.
305
         */
306
        public DataQuery createQuery();
307 43152 fdiaz
308 40435 jjdelcerro
        /**
309
         * Gets the {@link Interval} of the store, that means the temporal
310
         * interval where the store has valid data.
311
         * @return
312
         *         a time interval or null if there is not time support
313
         */
314
        public Interval getInterval();
315 43152 fdiaz
316 40435 jjdelcerro
        /**
317 43152 fdiaz
         * Gets all the possible values of time for which the store has data.
318 40435 jjdelcerro
         * @return
319
         *         a collection of {@link Time} objects.
320
         */
321
        public Collection getTimes();
322 43152 fdiaz
323 40435 jjdelcerro
        /**
324
         * Gets all the possible values of time for which the store has data
325
         * and intersects with an interval.
326
         * @param interval
327
         *         the interval of time
328
         * @return
329
         *         a collection of {@link Time} objects.
330
         */
331
        public Collection getTimes(Interval interval);
332 43152 fdiaz
333
        /**
334
         * @param providerName
335
         * @param parameters
336
         * @throws DataException
337
         */
338
        public void useCache(String providerName, DynObject parameters) throws DataException;
339
340 43190 jjdelcerro
        public DataStoreProviderFactory getProviderFactory();
341 43755 fdiaz
342
    /**
343
     * @return
344
     */
345
    public DataCache getCache();
346
347 44297 jjdelcerro
    public ResourcesStorage getResourcesStorage();
348
349
    public StoresRepository getStoresRepository();
350
351 40435 jjdelcerro
}