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 @ 47782
History | View | Annotate | Download (11.7 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 | 46733 | jjdelcerro | public static String getFullNameQuietly(DataStore store) { |
68 | try {
|
||
69 | return store.getFullName();
|
||
70 | } catch(Throwable th) { |
||
71 | return null; |
||
72 | } |
||
73 | } |
||
74 | 46819 | jjdelcerro | |
75 | public static String getNameQuietly(DataStore store) { |
||
76 | try {
|
||
77 | return store.getName();
|
||
78 | } catch(Throwable th) { |
||
79 | return null; |
||
80 | } |
||
81 | } |
||
82 | 44669 | jjdelcerro | public static final String SHAPE_PROVIDER_NAME = "Shape"; |
83 | public static final String DBASE_PROVIDER_NAME = "DBF"; |
||
84 | public static final String CSV_PROVIDER_NAME = "CSV"; |
||
85 | public static final String H2SPATIAL_PROVIDER_NAME = "H2Spatial"; |
||
86 | 47606 | fdiaz | public static final String GEOPACKAGE_PROVIDER_NAME = "SQLite"; |
87 | 44915 | omartinez | public static final String MDB_PROVIDER_NAME = "MDB"; |
88 | 44669 | jjdelcerro | |
89 | 40435 | jjdelcerro | public static final String METADATA_DEFINITION_NAME = "DataProvider"; |
90 | |||
91 | public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider"; |
||
92 | |||
93 | public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider"; |
||
94 | |||
95 | /**
|
||
96 | * Metadata property name for the provider name provided by the data provider.
|
||
97 | 43152 | fdiaz | *
|
98 | 40435 | jjdelcerro | * This metadata is provided by all data providers.
|
99 | */
|
||
100 | public static final String METADATA_PROVIDER = "ProviderName"; |
||
101 | |||
102 | /**
|
||
103 | * Metadata property name for Container name provided by the data provider.
|
||
104 | * By explample, in a dbf file, this is the name of dbf.
|
||
105 | 43152 | fdiaz | *
|
106 | 40435 | jjdelcerro | * This metadata is provided by all data providers.
|
107 | */
|
||
108 | public static final String METADATA_CONTAINERNAME = "ContainerName"; |
||
109 | |||
110 | /**
|
||
111 | * Metadata property name for the feature type provided by the data provider.
|
||
112 | 43152 | fdiaz | *
|
113 | 40435 | jjdelcerro | * This metadata is provided by all tabular data providers.
|
114 | */
|
||
115 | public static final String METADATA_FEATURETYPE = "FeatureType"; |
||
116 | |||
117 | /**
|
||
118 | * Metadata property name for CRS provided by the data provider.
|
||
119 | 43152 | fdiaz | *
|
120 | * This metadata is only provided by data provider with spatial
|
||
121 | 40435 | jjdelcerro | * information.
|
122 | */
|
||
123 | public static final String METADATA_CRS = "CRS"; |
||
124 | |||
125 | /**
|
||
126 | * Metadata property name for Envelope provided by the data provider
|
||
127 | 43152 | fdiaz | *
|
128 | * This metadata is only provided by data provider with spatial
|
||
129 | 40435 | jjdelcerro | * information.
|
130 | */
|
||
131 | public static final String METADATA_ENVELOPE = "Envelope"; |
||
132 | |||
133 | /**
|
||
134 | * Returns the name associated to the store.
|
||
135 | * This name is provided for informational purposes only.
|
||
136 | * Explamples:
|
||
137 | 43152 | fdiaz | *
|
138 | 40435 | jjdelcerro | * In a dbf the filename without the path
|
139 | 43152 | fdiaz | *
|
140 | 40435 | jjdelcerro | * In a DDBB table the name of the table
|
141 | 43152 | fdiaz | *
|
142 | 40435 | jjdelcerro | * In a WFS layer the name of the layer.
|
143 | *
|
||
144 | * @return String containing this store's name.
|
||
145 | */
|
||
146 | public String getName(); |
||
147 | 43152 | fdiaz | |
148 | 40435 | jjdelcerro | /**
|
149 | * Returns a more descriptive name for the store that getName.
|
||
150 | * This name is provided for informational purposes only.
|
||
151 | * Explamples:
|
||
152 | 43152 | fdiaz | *
|
153 | 40435 | jjdelcerro | * In a file based store may return the full name of the filename, path and filename.
|
154 | 43152 | fdiaz | *
|
155 | 40435 | jjdelcerro | * In a data base based store may return "server:dbname:tablename"
|
156 | 43152 | fdiaz | *
|
157 | 40435 | jjdelcerro | * In a WFS layer based store may return "server:layername"
|
158 | 43152 | fdiaz | *
|
159 | 40435 | jjdelcerro | * @return String Containing the full name of the store
|
160 | */
|
||
161 | public String getFullName(); |
||
162 | |||
163 | /**
|
||
164 | * Return the of parameters of this store
|
||
165 | *
|
||
166 | * @return parameters of this store
|
||
167 | */
|
||
168 | public DataStoreParameters getParameters();
|
||
169 | |||
170 | /**
|
||
171 | * Return the provider name that use this store.
|
||
172 | 43152 | fdiaz | *
|
173 | 40435 | jjdelcerro | * @return provider name of this store
|
174 | */
|
||
175 | public String getProviderName(); |
||
176 | 43152 | fdiaz | |
177 | 40435 | jjdelcerro | /**
|
178 | * Refreshes this store state.
|
||
179 | *
|
||
180 | * @throws DataException
|
||
181 | */
|
||
182 | public void refresh() throws DataException; |
||
183 | |||
184 | /**
|
||
185 | * Returns all available data.
|
||
186 | *
|
||
187 | * @return a set of data
|
||
188 | * @throws DataException
|
||
189 | * if there is any error while loading the data
|
||
190 | */
|
||
191 | DataSet getDataSet() throws DataException;
|
||
192 | |||
193 | /**
|
||
194 | * Returns a subset of data taking into account the properties and
|
||
195 | * restrictions of the DataQuery.
|
||
196 | *
|
||
197 | * @param dataQuery
|
||
198 | * defines the properties of the requested data
|
||
199 | * @return a set of data
|
||
200 | * @throws DataException
|
||
201 | * if there is any error while loading the data
|
||
202 | */
|
||
203 | DataSet getDataSet(DataQuery dataQuery) throws DataException;
|
||
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 | 43152 | fdiaz | *
|
211 | 40435 | jjdelcerro | * 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 | 43152 | fdiaz | *
|
215 | 40435 | jjdelcerro | * @param visitor
|
216 | * the visitor to apply to each value.
|
||
217 | * @exception BaseException
|
||
218 | * if there is an error while performing the visit
|
||
219 | */
|
||
220 | public void accept(Visitor visitor) throws BaseException; |
||
221 | |||
222 | /**
|
||
223 | * Provides each value of this Store to the provided {@link Visitor}.
|
||
224 | * The values received through the {@link Visitor#visit(Object)} method
|
||
225 | * may be transient, reused or externally modifiable, so they can't
|
||
226 | * be used to be stored in any external form out of the visit method.
|
||
227 | 43152 | fdiaz | *
|
228 | 40435 | jjdelcerro | * If you need to store any of the values out of the
|
229 | * {@link Visitor#visit(Object)} method execution, create a copy or clone
|
||
230 | * the received value in order to be stored.
|
||
231 | 43152 | fdiaz | *
|
232 | 40435 | jjdelcerro | * @param visitor
|
233 | * the visitor to apply to each value.
|
||
234 | * @param dataQuery
|
||
235 | * defines the properties of the data to visit
|
||
236 | * @exception BaseException
|
||
237 | * if there is an error while performing the visit
|
||
238 | */
|
||
239 | public void accept(Visitor visitor, DataQuery dataQuery) |
||
240 | throws BaseException;
|
||
241 | |||
242 | /**
|
||
243 | * Loads all available data and notifies the observer for each loaded block of data.
|
||
244 | *
|
||
245 | * @param observer
|
||
246 | * to be notified for each block of data loaded
|
||
247 | * @throws DataException
|
||
248 | * if there is any error while loading the data
|
||
249 | */
|
||
250 | void getDataSet(Observer observer) throws DataException; |
||
251 | |||
252 | /**
|
||
253 | * Loads a subset of data taking into account the properties and
|
||
254 | * restrictions of the DataQuery. Data loading is performed by calling the
|
||
255 | * Observer, once each data block is loaded.
|
||
256 | *
|
||
257 | * @param dataQuery
|
||
258 | * defines the properties of the requested data
|
||
259 | * @param observer
|
||
260 | * to be notified for each block of data loaded
|
||
261 | * @throws DataException
|
||
262 | * if there is any error while loading the data
|
||
263 | */
|
||
264 | void getDataSet(DataQuery dataQuery, Observer observer) throws DataException; |
||
265 | |||
266 | /**
|
||
267 | * Returns the selected set of data
|
||
268 | *
|
||
269 | * @return DataSet
|
||
270 | 44669 | jjdelcerro | * @throws org.gvsig.fmap.dal.exception.DataException
|
271 | 40435 | jjdelcerro | */
|
272 | |||
273 | public DataSet getSelection() throws DataException; |
||
274 | |||
275 | /**
|
||
276 | * Sets the current data selection with the given data set.
|
||
277 | *
|
||
278 | 44669 | jjdelcerro | * @param selection
|
279 | 40435 | jjdelcerro | * @throws DataException
|
280 | */
|
||
281 | public void setSelection(DataSet selection) throws DataException; |
||
282 | |||
283 | /**
|
||
284 | * Creates a new selection.
|
||
285 | *
|
||
286 | * @return DataSet that contains the selection
|
||
287 | *
|
||
288 | * @throws DataException
|
||
289 | */
|
||
290 | public DataSet createSelection() throws DataException; |
||
291 | |||
292 | /**
|
||
293 | 44259 | jjdelcerro | * Returns an UnmodifiableBasicMap with this store children.
|
294 | * If do not have children, return an empty map.
|
||
295 | * Never returns null.
|
||
296 | 40435 | jjdelcerro | *
|
297 | 44259 | jjdelcerro | * @return an UnmodifiableBasicMap with this DataStore children
|
298 | 40435 | jjdelcerro | */
|
299 | 44259 | jjdelcerro | public UnmodifiableBasicMap<String,DataStore> getChildren(); |
300 | 44251 | jjdelcerro | |
301 | 40435 | jjdelcerro | |
302 | /**
|
||
303 | * Returns the DataServerExplorer to which this DataStore belongs, if there
|
||
304 | * is any.
|
||
305 | 47197 | jjdelcerro | * This server explorer can be disposed.
|
306 | 43152 | fdiaz | *
|
307 | 40435 | jjdelcerro | * @return DataServerExplorer to which this DataStore belongs, or
|
308 | * <code>null</code> if this was not accessed through any
|
||
309 | * DataServerExplorer.
|
||
310 | 43152 | fdiaz | *
|
311 | 40435 | jjdelcerro | * @throws DataException
|
312 | * @throws ValidateDataParametersException
|
||
313 | */
|
||
314 | public DataServerExplorer getExplorer() throws DataException, |
||
315 | ValidateDataParametersException; |
||
316 | |||
317 | |||
318 | /**
|
||
319 | * Returns a new instance of a {@link DataQuery}.
|
||
320 | *
|
||
321 | * @return new {@link DataQuery} instance.
|
||
322 | */
|
||
323 | public DataQuery createQuery();
|
||
324 | 43152 | fdiaz | |
325 | 40435 | jjdelcerro | /**
|
326 | * Gets the {@link Interval} of the store, that means the temporal
|
||
327 | * interval where the store has valid data.
|
||
328 | * @return
|
||
329 | * a time interval or null if there is not time support
|
||
330 | */
|
||
331 | public Interval getInterval();
|
||
332 | 43152 | fdiaz | |
333 | 40435 | jjdelcerro | /**
|
334 | 43152 | fdiaz | * Gets all the possible values of time for which the store has data.
|
335 | 40435 | jjdelcerro | * @return
|
336 | * a collection of {@link Time} objects.
|
||
337 | */
|
||
338 | public Collection getTimes(); |
||
339 | 43152 | fdiaz | |
340 | 40435 | jjdelcerro | /**
|
341 | * Gets all the possible values of time for which the store has data
|
||
342 | * and intersects with an interval.
|
||
343 | * @param interval
|
||
344 | * the interval of time
|
||
345 | * @return
|
||
346 | * a collection of {@link Time} objects.
|
||
347 | */
|
||
348 | public Collection getTimes(Interval interval); |
||
349 | 43152 | fdiaz | |
350 | /**
|
||
351 | * @param providerName
|
||
352 | * @param parameters
|
||
353 | * @throws DataException
|
||
354 | */
|
||
355 | public void useCache(String providerName, DynObject parameters) throws DataException; |
||
356 | |||
357 | 43190 | jjdelcerro | public DataStoreProviderFactory getProviderFactory();
|
358 | 43755 | fdiaz | |
359 | /**
|
||
360 | * @return
|
||
361 | */
|
||
362 | public DataCache getCache();
|
||
363 | |||
364 | 44297 | jjdelcerro | public ResourcesStorage getResourcesStorage();
|
365 | |||
366 | public StoresRepository getStoresRepository();
|
||
367 | |||
368 | 40435 | jjdelcerro | } |