svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / raster / impl / DefaultCoverageStore.java @ 44259
History | View | Annotate | Download (14.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.raster.impl; |
25 | |||
26 | import java.util.Collection; |
||
27 | 44251 | jjdelcerro | import java.util.Collections; |
28 | 40435 | jjdelcerro | import java.util.Iterator; |
29 | 44251 | jjdelcerro | import java.util.List; |
30 | 40435 | jjdelcerro | import java.util.Set; |
31 | |||
32 | 43755 | fdiaz | import org.gvsig.fmap.dal.DataCache; |
33 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DataManager; |
34 | import org.gvsig.fmap.dal.DataQuery; |
||
35 | import org.gvsig.fmap.dal.DataServerExplorer; |
||
36 | import org.gvsig.fmap.dal.DataSet; |
||
37 | import org.gvsig.fmap.dal.DataStore; |
||
38 | import org.gvsig.fmap.dal.DataStoreNotification; |
||
39 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
40 | 43152 | fdiaz | import org.gvsig.fmap.dal.DataStoreProviderFactory; |
41 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.exception.CloseException; |
42 | import org.gvsig.fmap.dal.exception.DataException; |
||
43 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
44 | import org.gvsig.fmap.dal.exception.OpenException; |
||
45 | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
||
46 | import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
||
47 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification; |
||
48 | import org.gvsig.fmap.dal.impl.DefaultDataManager; |
||
49 | import org.gvsig.fmap.dal.raster.CoverageSelection; |
||
50 | import org.gvsig.fmap.dal.raster.CoverageStore; |
||
51 | import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
||
52 | import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices; |
||
53 | import org.gvsig.fmap.dal.resource.Resource; |
||
54 | import org.gvsig.fmap.dal.spi.DataStoreInitializer; |
||
55 | import org.gvsig.fmap.dal.spi.DataStoreProvider; |
||
56 | import org.gvsig.metadata.MetadataLocator; |
||
57 | import org.gvsig.timesupport.Interval; |
||
58 | import org.gvsig.timesupport.RelativeInterval; |
||
59 | import org.gvsig.tools.ToolsLocator; |
||
60 | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
||
61 | import org.gvsig.tools.dynobject.DelegatedDynObject; |
||
62 | import org.gvsig.tools.dynobject.DynClass; |
||
63 | import org.gvsig.tools.dynobject.DynObject; |
||
64 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
65 | 43246 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject_v2; |
66 | 40435 | jjdelcerro | import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
67 | import org.gvsig.tools.dynobject.exception.DynMethodException; |
||
68 | import org.gvsig.tools.exception.BaseException; |
||
69 | import org.gvsig.tools.observer.Observer; |
||
70 | import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable; |
||
71 | import org.gvsig.tools.persistence.PersistentState; |
||
72 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
73 | import org.gvsig.tools.undo.command.Command; |
||
74 | 44259 | jjdelcerro | import org.gvsig.tools.util.UnmodifiableBasicMap; |
75 | 40435 | jjdelcerro | import org.gvsig.tools.visitor.Visitor; |
76 | |||
77 | /**
|
||
78 | * @author jmvivo
|
||
79 | *
|
||
80 | */
|
||
81 | public class DefaultCoverageStore extends AbstractDisposable implements |
||
82 | CoverageStore, CoverageStoreProviderServices, DataStoreInitializer { |
||
83 | |||
84 | // final static private Logger logger = LoggerFactory
|
||
85 | // .getLogger(DefaultFeatureStore.class);
|
||
86 | |||
87 | private DataStoreParameters parameters = null; |
||
88 | private CoverageSelection selection;
|
||
89 | |||
90 | // private long versionOfUpdate = 0;
|
||
91 | |||
92 | private DefaultDataManager dataManager = null; |
||
93 | |||
94 | private CoverageStoreProvider provider = null; |
||
95 | |||
96 | private DelegatedDynObject metadata;
|
||
97 | |||
98 | private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable( |
||
99 | this);
|
||
100 | |||
101 | public DefaultCoverageStore() {
|
||
102 | |||
103 | } |
||
104 | |||
105 | /*
|
||
106 | * (non-Javadoc)
|
||
107 | *
|
||
108 | * @see
|
||
109 | * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase1(org.gvsig
|
||
110 | * .fmap.dal.impl.DefaultDataManager,
|
||
111 | * org.gvsig.fmap.dal.DataStoreParameters)
|
||
112 | */
|
||
113 | public void intializePhase1(DataManager dataManager, |
||
114 | DataStoreParameters parameters) throws InitializeException {
|
||
115 | DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
||
116 | |||
117 | this.metadata = (DelegatedDynObject) dynManager
|
||
118 | 43152 | fdiaz | .createDynObject( |
119 | 40435 | jjdelcerro | MetadataLocator.getMetadataManager().getDefinition(DataStore.SPATIAL_METADATA_DEFINITION_NAME) |
120 | ); |
||
121 | this.dataManager = (DefaultDataManager)dataManager;
|
||
122 | this.parameters = parameters;
|
||
123 | |||
124 | } |
||
125 | |||
126 | |||
127 | |||
128 | /*
|
||
129 | * (non-Javadoc)
|
||
130 | *
|
||
131 | * @see
|
||
132 | * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase2(org.gvsig
|
||
133 | * .fmap.dal.spi.DataStoreProvider)
|
||
134 | */
|
||
135 | public void intializePhase2(DataStoreProvider provider) |
||
136 | throws InitializeException {
|
||
137 | |||
138 | this.provider = (CoverageStoreProvider) provider;
|
||
139 | 43020 | jjdelcerro | this.delegate((DynObject) provider);
|
140 | 40435 | jjdelcerro | |
141 | } |
||
142 | |||
143 | |||
144 | /* (non-Javadoc)
|
||
145 | * @see org.gvsig.fmap.dal.DataStore#createSelection()
|
||
146 | */
|
||
147 | public DataSet createSelection() throws DataException { |
||
148 | // TODO Auto-generated method stub
|
||
149 | return null; |
||
150 | } |
||
151 | |||
152 | |||
153 | 44251 | jjdelcerro | @Override
|
154 | 44259 | jjdelcerro | public UnmodifiableBasicMap<String,DataStore> getChildren() { |
155 | return UnmodifiableBasicMap.EMPTY_UNMODIFIABLEBASICMAP;
|
||
156 | } |
||
157 | 44251 | jjdelcerro | |
158 | 40435 | jjdelcerro | /* (non-Javadoc)
|
159 | * @see org.gvsig.fmap.dal.DataStore#getDataSet()
|
||
160 | */
|
||
161 | public DataSet getDataSet() throws DataException { |
||
162 | // TODO Auto-generated method stub
|
||
163 | return null; |
||
164 | } |
||
165 | |||
166 | /* (non-Javadoc)
|
||
167 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery)
|
||
168 | */
|
||
169 | public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
||
170 | // TODO Auto-generated method stub
|
||
171 | return null; |
||
172 | } |
||
173 | |||
174 | public void accept(Visitor visitor) throws BaseException { |
||
175 | // TODO Auto-generated method stub
|
||
176 | } |
||
177 | |||
178 | public void accept(Visitor visitor, DataQuery dataQuery) |
||
179 | throws BaseException {
|
||
180 | // TODO Auto-generated method stub
|
||
181 | } |
||
182 | |||
183 | /* (non-Javadoc)
|
||
184 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.tools.observer.Observer)
|
||
185 | */
|
||
186 | public void getDataSet(Observer observer) throws DataException { |
||
187 | // TODO Auto-generated method stub
|
||
188 | |||
189 | } |
||
190 | |||
191 | /* (non-Javadoc)
|
||
192 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery, org.gvsig.tools.observer.Observer)
|
||
193 | */
|
||
194 | public void getDataSet(DataQuery dataQuery, Observer observer) |
||
195 | throws DataException {
|
||
196 | // TODO Auto-generated method stub
|
||
197 | |||
198 | } |
||
199 | |||
200 | /* (non-Javadoc)
|
||
201 | * @see org.gvsig.fmap.dal.DataStore#getExplorer()
|
||
202 | */
|
||
203 | public DataServerExplorer getExplorer() throws DataException, |
||
204 | ValidateDataParametersException { |
||
205 | return provider.getExplorer();
|
||
206 | } |
||
207 | |||
208 | /* (non-Javadoc)
|
||
209 | * @see org.gvsig.fmap.dal.DataStore#getParameters()
|
||
210 | */
|
||
211 | public DataStoreParameters getParameters() {
|
||
212 | return this.parameters; |
||
213 | } |
||
214 | |||
215 | /* (non-Javadoc)
|
||
216 | * @see org.gvsig.fmap.dal.DataStore#getSelection()
|
||
217 | */
|
||
218 | public DataSet getSelection() throws DataException { |
||
219 | // TODO Auto-generated method stub
|
||
220 | return null; |
||
221 | } |
||
222 | |||
223 | /* (non-Javadoc)
|
||
224 | * @see org.gvsig.fmap.dal.DataStore#refresh()
|
||
225 | */
|
||
226 | public void refresh() throws DataException { |
||
227 | // TODO Auto-generated method stub
|
||
228 | |||
229 | } |
||
230 | |||
231 | /* (non-Javadoc)
|
||
232 | * @see org.gvsig.fmap.dal.DataStore#setSelection(org.gvsig.fmap.dal.DataSet)
|
||
233 | */
|
||
234 | public void setSelection(DataSet selection) throws DataException { |
||
235 | // TODO Auto-generated method stub
|
||
236 | |||
237 | } |
||
238 | |||
239 | /* (non-Javadoc)
|
||
240 | * @see org.gvsig.tools.observer.ComplexObservable#beginComplexNotification()
|
||
241 | */
|
||
242 | public void beginComplexNotification() { |
||
243 | // TODO Auto-generated method stub
|
||
244 | |||
245 | } |
||
246 | |||
247 | /* (non-Javadoc)
|
||
248 | * @see org.gvsig.tools.observer.ComplexObservable#disableNotifications()
|
||
249 | */
|
||
250 | public void disableNotifications() { |
||
251 | // TODO Auto-generated method stub
|
||
252 | |||
253 | } |
||
254 | |||
255 | /* (non-Javadoc)
|
||
256 | * @see org.gvsig.tools.observer.ComplexObservable#enableNotifications()
|
||
257 | */
|
||
258 | public void enableNotifications() { |
||
259 | // TODO Auto-generated method stub
|
||
260 | |||
261 | } |
||
262 | |||
263 | /* (non-Javadoc)
|
||
264 | * @see org.gvsig.tools.observer.ComplexObservable#endComplexNotification()
|
||
265 | */
|
||
266 | public void endComplexNotification() { |
||
267 | // TODO Auto-generated method stub
|
||
268 | |||
269 | } |
||
270 | |||
271 | /* (non-Javadoc)
|
||
272 | * @see org.gvsig.tools.observer.Observable#addObserver(org.gvsig.tools.observer.Observer)
|
||
273 | */
|
||
274 | public void addObserver(Observer o) { |
||
275 | // TODO Auto-generated method stub
|
||
276 | |||
277 | } |
||
278 | |||
279 | /* (non-Javadoc)
|
||
280 | * @see org.gvsig.tools.observer.Observable#deleteObserver(org.gvsig.tools.observer.Observer)
|
||
281 | */
|
||
282 | public void deleteObserver(Observer o) { |
||
283 | // TODO Auto-generated method stub
|
||
284 | |||
285 | } |
||
286 | |||
287 | /* (non-Javadoc)
|
||
288 | * @see org.gvsig.tools.observer.Observable#deleteObservers()
|
||
289 | */
|
||
290 | public void deleteObservers() { |
||
291 | // TODO Auto-generated method stub
|
||
292 | |||
293 | } |
||
294 | |||
295 | /* (non-Javadoc)
|
||
296 | * @see org.gvsig.tools.persistence.Persistent#getState()
|
||
297 | */
|
||
298 | public PersistentState getState() throws PersistenceException { |
||
299 | // TODO Auto-generated method stub
|
||
300 | return null; |
||
301 | } |
||
302 | |||
303 | /* (non-Javadoc)
|
||
304 | * @see org.gvsig.tools.persistence.Persistent#loadState(org.gvsig.tools.persistence.PersistentState)
|
||
305 | */
|
||
306 | public void saveToState(PersistentState state) throws PersistenceException { |
||
307 | // TODO Auto-generated method stub
|
||
308 | |||
309 | } |
||
310 | |||
311 | /* (non-Javadoc)
|
||
312 | * @see org.gvsig.tools.persistence.Persistent#setState(org.gvsig.tools.persistence.PersistentState)
|
||
313 | */
|
||
314 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
315 | // TODO Auto-generated method stub
|
||
316 | |||
317 | } |
||
318 | |||
319 | //
|
||
320 | // ====================================================================
|
||
321 | // Metadata related methods
|
||
322 | //
|
||
323 | |||
324 | public Object getMetadataID() { |
||
325 | return this.provider.getSourceId(); |
||
326 | } |
||
327 | |||
328 | public void delegate(DynObject dynObject) { |
||
329 | this.metadata.delegate(dynObject);
|
||
330 | } |
||
331 | |||
332 | public DynClass getDynClass() {
|
||
333 | return this.metadata.getDynClass(); |
||
334 | } |
||
335 | |||
336 | public Object getDynValue(String name) throws DynFieldNotFoundException { |
||
337 | return this.metadata.getDynValue(name); |
||
338 | } |
||
339 | |||
340 | public boolean hasDynValue(String name) { |
||
341 | return this.metadata.hasDynValue(name); |
||
342 | } |
||
343 | 43755 | fdiaz | |
344 | 43246 | jjdelcerro | @Override
|
345 | public boolean hasDynMethod(String name) { |
||
346 | return ((DynObject_v2)this.metadata).hasDynMethod(name); |
||
347 | 43755 | fdiaz | } |
348 | 40435 | jjdelcerro | |
349 | public void implement(DynClass dynClass) { |
||
350 | this.metadata.implement(dynClass);
|
||
351 | } |
||
352 | |||
353 | 42775 | jjdelcerro | public Object invokeDynMethod(String name, Object[] args) |
354 | 40435 | jjdelcerro | throws DynMethodException {
|
355 | 42775 | jjdelcerro | return this.metadata.invokeDynMethod(this, name, args); |
356 | 40435 | jjdelcerro | } |
357 | |||
358 | 42775 | jjdelcerro | public Object invokeDynMethod(int code, Object[] args) |
359 | 40435 | jjdelcerro | throws DynMethodException {
|
360 | 42775 | jjdelcerro | return this.metadata.invokeDynMethod(this, code, args); |
361 | 40435 | jjdelcerro | } |
362 | |||
363 | public void setDynValue(String name, Object value) |
||
364 | throws DynFieldNotFoundException {
|
||
365 | this.metadata.setDynValue(name, value);
|
||
366 | |||
367 | } |
||
368 | |||
369 | /*
|
||
370 | * (non-Javadoc)
|
||
371 | *
|
||
372 | * @see org.gvsig.metadata.Metadata#getMetadataChildren()
|
||
373 | */
|
||
374 | public Set getMetadataChildren() { |
||
375 | return null; |
||
376 | } |
||
377 | |||
378 | /*
|
||
379 | * (non-Javadoc)
|
||
380 | *
|
||
381 | * @see org.gvsig.metadata.Metadata#getMetadataName()
|
||
382 | */
|
||
383 | public String getMetadataName() { |
||
384 | return this.provider.getProviderName(); |
||
385 | } |
||
386 | |||
387 | |||
388 | /* (non-Javadoc)
|
||
389 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#createDefaultCoverageSelection()
|
||
390 | */
|
||
391 | public CoverageSelection createDefaultCoverageSelection()
|
||
392 | throws DataException {
|
||
393 | // TODO Auto-generated method stub
|
||
394 | return null; |
||
395 | } |
||
396 | |||
397 | |||
398 | /* (non-Javadoc)
|
||
399 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getManager()
|
||
400 | */
|
||
401 | public DataManager getManager() {
|
||
402 | return this.dataManager; |
||
403 | } |
||
404 | |||
405 | /* (non-Javadoc)
|
||
406 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getProvider()
|
||
407 | */
|
||
408 | public CoverageStoreProvider getProvider() {
|
||
409 | return this.provider; |
||
410 | } |
||
411 | |||
412 | public void notifyChange(String notification) { |
||
413 | delegateObservable |
||
414 | .notifyObservers(new DefaultCoverageStoreNotification(
|
||
415 | this, notification));
|
||
416 | |||
417 | } |
||
418 | |||
419 | |||
420 | public void notifyChange(String notification, Command command) { |
||
421 | delegateObservable |
||
422 | .notifyObservers(new DefaultCoverageStoreNotification(
|
||
423 | this, notification, command));
|
||
424 | } |
||
425 | |||
426 | |||
427 | /*
|
||
428 | * (non-Javadoc)
|
||
429 | *
|
||
430 | * @see
|
||
431 | * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
|
||
432 | * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
|
||
433 | */
|
||
434 | public void notifyChange(String notification, Resource resource) { |
||
435 | delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
|
||
436 | this, FeatureStoreNotification.RESOURCE_CHANGED));
|
||
437 | } |
||
438 | |||
439 | public void open() throws OpenException { |
||
440 | // TODO: Se puede hacer un open estando en edicion ?
|
||
441 | this.notifyChange(DataStoreNotification.BEFORE_OPEN);
|
||
442 | this.provider.open();
|
||
443 | this.notifyChange(DataStoreNotification.AFTER_OPEN);
|
||
444 | } |
||
445 | |||
446 | public void close() throws CloseException { |
||
447 | // TODO: Se puede hacer un close estando en edicion ?
|
||
448 | this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
|
||
449 | this.provider.close();
|
||
450 | this.notifyChange(DataStoreNotification.AFTER_CLOSE);
|
||
451 | } |
||
452 | |||
453 | protected void doDispose() throws BaseException { |
||
454 | this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
|
||
455 | this.provider.dispose();
|
||
456 | if (this.selection != null) { |
||
457 | this.selection.dispose();
|
||
458 | this.selection = null; |
||
459 | } |
||
460 | |||
461 | this.parameters = null; |
||
462 | this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
|
||
463 | this.delegateObservable.deleteObservers();
|
||
464 | this.delegateObservable = null; |
||
465 | } |
||
466 | |||
467 | public boolean allowWrite() { |
||
468 | return this.provider.allowWrite(); |
||
469 | } |
||
470 | |||
471 | public DataQuery createQuery() {
|
||
472 | // TODO Auto-generated method stub
|
||
473 | return null; |
||
474 | } |
||
475 | |||
476 | public DataStore getStore() {
|
||
477 | return this; |
||
478 | } |
||
479 | |||
480 | public CoverageStore getCoverageStore() {
|
||
481 | return this; |
||
482 | } |
||
483 | |||
484 | public void clear() { |
||
485 | if (metadata != null) { |
||
486 | metadata.clear(); |
||
487 | } |
||
488 | } |
||
489 | |||
490 | public String getProviderName() { |
||
491 | return this.provider.getProviderName(); |
||
492 | } |
||
493 | 43152 | fdiaz | |
494 | 40435 | jjdelcerro | public String getName() { |
495 | 41739 | jjdelcerro | return this.provider.getName(); |
496 | 40435 | jjdelcerro | } |
497 | |||
498 | public String getFullName() { |
||
499 | return this.provider.getFullName(); |
||
500 | } |
||
501 | |||
502 | public Interval getInterval() {
|
||
503 | // TODO Auto-generated method stub
|
||
504 | return null; |
||
505 | } |
||
506 | 43152 | fdiaz | |
507 | 40435 | jjdelcerro | public Collection getTimes() { |
508 | // TODO Auto-generated method stub
|
||
509 | return null; |
||
510 | } |
||
511 | |||
512 | public Collection getTimes(Interval interval) { |
||
513 | // TODO Auto-generated method stub
|
||
514 | return null; |
||
515 | 43152 | fdiaz | } |
516 | |||
517 | @Override
|
||
518 | public void useCache(String providerName, DynObject parameters) throws DataException { |
||
519 | throw new UnsupportedOperationException(); |
||
520 | } |
||
521 | |||
522 | @Override
|
||
523 | 43190 | jjdelcerro | public DataStoreProviderFactory getProviderFactory() {
|
524 | 43152 | fdiaz | DataStoreProviderFactory factory = dataManager.getStoreProviderFactory(parameters.getDataStoreName()); |
525 | return factory;
|
||
526 | } |
||
527 | 43755 | fdiaz | |
528 | @Override
|
||
529 | public DataCache getCache() {
|
||
530 | // TODO Auto-generated method stub
|
||
531 | return null; |
||
532 | } |
||
533 | 40596 | jjdelcerro | } |