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