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