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