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