root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / raster / impl / DefaultCoverageStore.java @ 29326
History | View | Annotate | Download (12.4 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.DefaultFeatureStore; |
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.tools.ToolsLocator; |
59 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
60 |
import org.gvsig.tools.dynobject.DynClass; |
61 |
import org.gvsig.tools.dynobject.DynObject; |
62 |
import org.gvsig.tools.dynobject.DynObjectManager; |
63 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
64 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
65 |
import org.gvsig.tools.observer.Observer; |
66 |
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable; |
67 |
import org.gvsig.tools.persistence.PersistenceException; |
68 |
import org.gvsig.tools.persistence.PersistentState; |
69 |
import org.gvsig.tools.undo.command.Command; |
70 |
import org.slf4j.Logger; |
71 |
import org.slf4j.LoggerFactory; |
72 |
|
73 |
/**
|
74 |
* @author jmvivo
|
75 |
*
|
76 |
*/
|
77 |
public class DefaultCoverageStore implements CoverageStore, |
78 |
CoverageStoreProviderServices, DataStoreImplementation { |
79 |
|
80 |
|
81 |
|
82 |
final static private Logger logger = LoggerFactory |
83 |
.getLogger(DefaultFeatureStore.class); |
84 |
|
85 |
private DataStoreParameters parameters = null; |
86 |
private CoverageSelection selection;
|
87 |
|
88 |
private long versionOfUpdate = 0; |
89 |
|
90 |
private DefaultDataManager dataManager = null; |
91 |
|
92 |
private CoverageStoreProvider provider = null; |
93 |
|
94 |
private DelegatedDynObject dynObject;
|
95 |
|
96 |
private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable( |
97 |
this);
|
98 |
|
99 |
public DefaultCoverageStore() {
|
100 |
|
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(DefaultDataManager dataManager, |
112 |
DataStoreParameters parameters) throws InitializeException {
|
113 |
DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
114 |
|
115 |
this.dynObject = (DelegatedDynObject) dynManager
|
116 |
.createDynObject(dynManager.get(DataStore.DYNCLASS_NAME)); |
117 |
this.dataManager = dataManager;
|
118 |
this.parameters = parameters;
|
119 |
|
120 |
} |
121 |
|
122 |
|
123 |
|
124 |
/*
|
125 |
* (non-Javadoc)
|
126 |
*
|
127 |
* @see
|
128 |
* org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase2(org.gvsig
|
129 |
* .fmap.dal.spi.DataStoreProvider)
|
130 |
*/
|
131 |
public void intializePhase2(DataStoreProvider provider) |
132 |
throws InitializeException {
|
133 |
|
134 |
this.provider = (CoverageStoreProvider) provider;
|
135 |
this.delegate(provider);
|
136 |
|
137 |
} |
138 |
|
139 |
|
140 |
/* (non-Javadoc)
|
141 |
* @see org.gvsig.fmap.dal.DataStore#createSelection()
|
142 |
*/
|
143 |
public DataSet createSelection() throws DataException { |
144 |
// TODO Auto-generated method stub
|
145 |
return null; |
146 |
} |
147 |
|
148 |
|
149 |
/* (non-Javadoc)
|
150 |
* @see org.gvsig.fmap.dal.DataStore#getChildren()
|
151 |
*/
|
152 |
public Iterator getChildren() { |
153 |
return this.provider.getChilds(); |
154 |
} |
155 |
|
156 |
/* (non-Javadoc)
|
157 |
* @see org.gvsig.fmap.dal.DataStore#getDataSet()
|
158 |
*/
|
159 |
public DataSet getDataSet() throws DataException { |
160 |
// TODO Auto-generated method stub
|
161 |
return null; |
162 |
} |
163 |
|
164 |
/* (non-Javadoc)
|
165 |
* @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery)
|
166 |
*/
|
167 |
public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
168 |
// TODO Auto-generated method stub
|
169 |
return null; |
170 |
} |
171 |
|
172 |
/* (non-Javadoc)
|
173 |
* @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.tools.observer.Observer)
|
174 |
*/
|
175 |
public void getDataSet(Observer observer) throws DataException { |
176 |
// TODO Auto-generated method stub
|
177 |
|
178 |
} |
179 |
|
180 |
/* (non-Javadoc)
|
181 |
* @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery, org.gvsig.tools.observer.Observer)
|
182 |
*/
|
183 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
184 |
throws DataException {
|
185 |
// TODO Auto-generated method stub
|
186 |
|
187 |
} |
188 |
|
189 |
/* (non-Javadoc)
|
190 |
* @see org.gvsig.fmap.dal.DataStore#getExplorer()
|
191 |
*/
|
192 |
public DataServerExplorer getExplorer() throws DataException, |
193 |
ValidateDataParametersException { |
194 |
return provider.getExplorer();
|
195 |
} |
196 |
|
197 |
/* (non-Javadoc)
|
198 |
* @see org.gvsig.fmap.dal.DataStore#getName()
|
199 |
*/
|
200 |
public String getName() { |
201 |
return provider.getName();
|
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.dynObject.delegate(dynObject);
|
326 |
} |
327 |
|
328 |
public DynClass getDynClass() {
|
329 |
return this.dynObject.getDynClass(); |
330 |
} |
331 |
|
332 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
333 |
return this.dynObject.getDynValue(name); |
334 |
} |
335 |
|
336 |
public boolean hasDynValue(String name) { |
337 |
return this.dynObject.hasDynValue(name); |
338 |
} |
339 |
|
340 |
public void implement(DynClass dynClass) { |
341 |
this.dynObject.implement(dynClass);
|
342 |
} |
343 |
|
344 |
public Object invokeDynMethod(String name, DynObject context) |
345 |
throws DynMethodException {
|
346 |
return this.dynObject.invokeDynMethod(this, name, context); |
347 |
} |
348 |
|
349 |
public Object invokeDynMethod(int code, DynObject context) |
350 |
throws DynMethodException {
|
351 |
return this.dynObject.invokeDynMethod(this, code, context); |
352 |
} |
353 |
|
354 |
public void setDynValue(String name, Object value) |
355 |
throws DynFieldNotFoundException {
|
356 |
this.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.getName(); |
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 DefaultDataManager 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 |
/*
|
445 |
* (non-Javadoc)
|
446 |
*
|
447 |
* @see org.gvsig.fmap.dal.DataStore#dispose()
|
448 |
*/
|
449 |
public void dispose() throws CloseException { |
450 |
this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
|
451 |
this.provider.dispose();
|
452 |
if (this.selection != null) { |
453 |
this.selection.dispose();
|
454 |
this.selection = null; |
455 |
} |
456 |
|
457 |
this.parameters = null; |
458 |
this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
|
459 |
this.delegateObservable.deleteObservers();
|
460 |
this.delegateObservable = null; |
461 |
} |
462 |
|
463 |
public boolean allowWrite() { |
464 |
return this.provider.allowWrite(); |
465 |
} |
466 |
|
467 |
public DataQuery createQuery() {
|
468 |
// TODO Auto-generated method stub
|
469 |
return null; |
470 |
} |
471 |
|
472 |
public DataStore getStore() {
|
473 |
return this; |
474 |
} |
475 |
|
476 |
public CoverageStore getCoverageStore() {
|
477 |
return this; |
478 |
} |
479 |
|
480 |
} |