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