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