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