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 @ 44669

History | View | Annotate | Download (11.2 KB)

1
/**
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
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
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.dynobject.DynObject_v2;
36
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
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
41
import org.gvsig.tools.service.spi.Services;
42
import org.gvsig.tools.util.UnmodifiableBasicMap;
43
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
                Persistent, Metadata, Disposable, Visitable, DataFactoryUnit, Services, DynObject_v2 {
66

    
67
        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
    
72
        public static final String METADATA_DEFINITION_NAME = "DataProvider";
73

    
74
        public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider";
75

    
76
        public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider";
77

    
78
        /**
79
         * Metadata property name for the provider name provided by the data provider.
80
         *
81
         * This metadata is provided by all data providers.
82
         */
83
        public static final String METADATA_PROVIDER = "ProviderName";
84

    
85
        /**
86
         * Metadata property name for Container name provided by the data provider.
87
         * By explample, in a dbf file, this is the name of dbf.
88
         *
89
         * This metadata is provided by all data providers.
90
         */
91
        public static final String METADATA_CONTAINERNAME = "ContainerName";
92

    
93
        /**
94
         * Metadata property name for the feature type provided by the data provider.
95
         *
96
         * This metadata is provided by all tabular data providers.
97
         */
98
        public static final String METADATA_FEATURETYPE = "FeatureType";
99

    
100
        /**
101
         * Metadata property name for CRS provided by the data provider.
102
         *
103
         * This metadata is only provided by data provider with spatial
104
         * information.
105
         */
106
        public static final String METADATA_CRS = "CRS";
107

    
108
        /**
109
         * Metadata property name for Envelope provided by the data provider
110
         *
111
         * This metadata is only provided by data provider with spatial
112
         * information.
113
         */
114
        public static final String METADATA_ENVELOPE = "Envelope";
115

    
116
        /**
117
         * Returns the name associated to the store.
118
         * This name is provided for informational purposes only.
119
         * Explamples:
120
         *
121
         * In a dbf the filename without the path
122
         *
123
         * In a DDBB table the name of the table
124
         *
125
         * In a WFS layer the name of the layer.
126
         *
127
         * @return String containing this store's name.
128
         */
129
        public String getName();
130

    
131
        /**
132
         * Returns a more descriptive name for the store that getName.
133
         * This name is provided for informational purposes only.
134
         * Explamples:
135
         *
136
         * In a file based store may return the full name of the filename, path and filename.
137
         *
138
         * In a data base based store may return "server:dbname:tablename"
139
         *
140
         * In a WFS layer based store may return "server:layername"
141
         *
142
         * @return String Containing the full name of the store
143
         */
144
        public String getFullName();
145

    
146
        /**
147
         * Return the of parameters of this store
148
         *
149
         * @return parameters of this store
150
         */
151
        public DataStoreParameters getParameters();
152

    
153
        /**
154
         * Return the provider name that use this store.
155
         *
156
         * @return provider name of this store
157
         */
158
        public String getProviderName();
159

    
160
        /**
161
         * Refreshes this store state.
162
         *
163
         * @throws DataException
164
         */
165
        public void refresh() throws DataException;
166

    
167
        /**
168
         * Returns all available data.
169
         *
170
         * @return a set of data
171
         * @throws DataException
172
         *             if there is any error while loading the data
173
         */
174
        DataSet getDataSet() throws DataException;
175

    
176
        /**
177
         * Returns a subset of data taking into account the properties and
178
         * restrictions of the DataQuery.
179
         *
180
         * @param dataQuery
181
         *            defines the properties of the requested data
182
         * @return a set of data
183
         * @throws DataException
184
         *             if there is any error while loading the data
185
         */
186
        DataSet getDataSet(DataQuery dataQuery) throws DataException;
187

    
188
    /**
189
     * Provides each value of this Store to the provided {@link Visitor}.
190
     * The values received through the {@link Visitor#visit(Object)} method
191
     * may be transient, reused or externally modifiable, so they can't
192
     * be used to be stored in any external form out of the visit method.
193
     *
194
     * If you need to store any of the values out of the
195
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
196
     * the received value in order to be stored.
197
     *
198
     * @param visitor
199
     *            the visitor to apply to each value.
200
     * @exception BaseException
201
     *                if there is an error while performing the visit
202
     */
203
    public void accept(Visitor visitor) throws BaseException;
204

    
205
        /**
206
     * Provides each value of this Store to the provided {@link Visitor}.
207
     * The values received through the {@link Visitor#visit(Object)} method
208
     * may be transient, reused or externally modifiable, so they can't
209
     * be used to be stored in any external form out of the visit method.
210
     *
211
     * If you need to store any of the values out of the
212
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
213
     * the received value in order to be stored.
214
     *
215
     * @param visitor
216
     *            the visitor to apply to each value.
217
     * @param dataQuery
218
     *            defines the properties of the data to visit
219
     * @exception BaseException
220
     *                if there is an error while performing the visit
221
     */
222
        public void accept(Visitor visitor, DataQuery dataQuery)
223
                        throws BaseException;
224

    
225
        /**
226
         * Loads all available data and notifies the observer for each loaded block of data.
227
         *
228
         * @param observer
229
         *            to be notified for each block of data loaded
230
         * @throws DataException
231
         *             if there is any error while loading the data
232
         */
233
        void getDataSet(Observer observer) throws DataException;
234

    
235
        /**
236
         * Loads a subset of data taking into account the properties and
237
         * restrictions of the DataQuery. Data loading is performed by calling the
238
         * Observer, once each data block is loaded.
239
         *
240
         * @param dataQuery
241
         *            defines the properties of the requested data
242
         * @param observer
243
         *            to be notified for each block of data loaded
244
         * @throws DataException
245
         *             if there is any error while loading the data
246
         */
247
        void getDataSet(DataQuery dataQuery, Observer observer) throws DataException;
248

    
249
        /**
250
         * Returns the selected set of data
251
         *
252
         * @return DataSet
253
         * @throws org.gvsig.fmap.dal.exception.DataException
254
         */
255

    
256
        public DataSet getSelection() throws DataException;
257

    
258
        /**
259
         * Sets the current data selection with the given data set.
260
         *
261
         * @param selection
262
         * @throws DataException
263
         */
264
        public void setSelection(DataSet selection) throws DataException;
265

    
266
        /**
267
         * Creates a new selection.
268
         *
269
         * @return DataSet that contains the selection
270
         *
271
         * @throws DataException
272
         */
273
        public DataSet createSelection() throws DataException;
274

    
275
        /**
276
         * Returns an UnmodifiableBasicMap with this store children.
277
         * If do not have children, return an empty map.
278
         * Never returns null.
279
         *
280
         * @return an UnmodifiableBasicMap with this DataStore children
281
         */
282
        public UnmodifiableBasicMap<String,DataStore> getChildren();
283
        
284

    
285
        /**
286
         * Returns the DataServerExplorer to which this DataStore belongs, if there
287
         * is any.
288
         *
289
         * @return DataServerExplorer to which this DataStore belongs, or
290
         *         <code>null</code> if this was not accessed through any
291
         *         DataServerExplorer.
292
         *
293
         * @throws DataException
294
         * @throws ValidateDataParametersException
295
         */
296
        public DataServerExplorer getExplorer() throws DataException,
297
                        ValidateDataParametersException;
298

    
299

    
300
        /**
301
         * Returns a new instance of a {@link DataQuery}.
302
         *
303
         * @return new {@link DataQuery} instance.
304
         */
305
        public DataQuery createQuery();
306

    
307
        /**
308
         * Gets the {@link Interval} of the store, that means the temporal
309
         * interval where the store has valid data.
310
         * @return
311
         *         a time interval or null if there is not time support
312
         */
313
        public Interval getInterval();
314

    
315
        /**
316
         * Gets all the possible values of time for which the store has data.
317
         * @return
318
         *         a collection of {@link Time} objects.
319
         */
320
        public Collection getTimes();
321

    
322
        /**
323
         * Gets all the possible values of time for which the store has data
324
         * and intersects with an interval.
325
         * @param interval
326
         *         the interval of time
327
         * @return
328
         *         a collection of {@link Time} objects.
329
         */
330
        public Collection getTimes(Interval interval);
331

    
332
        /**
333
         * @param providerName
334
         * @param parameters
335
         * @throws DataException
336
         */
337
        public void useCache(String providerName, DynObject parameters) throws DataException;
338

    
339
        public DataStoreProviderFactory getProviderFactory();
340

    
341
    /**
342
     * @return
343
     */
344
    public DataCache getCache();
345

    
346
    public ResourcesStorage getResourcesStorage();
347
    
348
    public StoresRepository getStoresRepository();
349

    
350
}
351