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