Statistics
| Revision:

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 @ 40435

History | View | Annotate | Download (13.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.Collection;
34
import java.util.Iterator;
35
import java.util.Set;
36

    
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataQuery;
39
import org.gvsig.fmap.dal.DataServerExplorer;
40
import org.gvsig.fmap.dal.DataSet;
41
import org.gvsig.fmap.dal.DataStore;
42
import org.gvsig.fmap.dal.DataStoreNotification;
43
import org.gvsig.fmap.dal.DataStoreParameters;
44
import org.gvsig.fmap.dal.exception.CloseException;
45
import org.gvsig.fmap.dal.exception.DataException;
46
import org.gvsig.fmap.dal.exception.InitializeException;
47
import org.gvsig.fmap.dal.exception.OpenException;
48
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
49
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
50
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification;
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.DataStoreInitializer;
58
import org.gvsig.fmap.dal.spi.DataStoreProvider;
59
import org.gvsig.metadata.MetadataLocator;
60
import org.gvsig.timesupport.Interval;
61
import org.gvsig.timesupport.RelativeInterval;
62
import org.gvsig.tools.ToolsLocator;
63
import org.gvsig.tools.dispose.impl.AbstractDisposable;
64
import org.gvsig.tools.dynobject.DelegatedDynObject;
65
import org.gvsig.tools.dynobject.DynClass;
66
import org.gvsig.tools.dynobject.DynObject;
67
import org.gvsig.tools.dynobject.DynObjectManager;
68
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
69
import org.gvsig.tools.dynobject.exception.DynMethodException;
70
import org.gvsig.tools.exception.BaseException;
71
import org.gvsig.tools.observer.Observer;
72
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable;
73
import org.gvsig.tools.persistence.PersistentState;
74
import org.gvsig.tools.persistence.exception.PersistenceException;
75
import org.gvsig.tools.undo.command.Command;
76
import org.gvsig.tools.visitor.Visitor;
77

    
78
/**
79
 * @author jmvivo
80
 *
81
 */
82
public class DefaultCoverageStore extends AbstractDisposable implements
83
                CoverageStore, CoverageStoreProviderServices, DataStoreInitializer {
84

    
85
//        final static private Logger logger = LoggerFactory
86
//                        .getLogger(DefaultFeatureStore.class);
87

    
88
        private DataStoreParameters parameters = null;
89
        private CoverageSelection selection;
90

    
91
//        private long versionOfUpdate = 0;
92

    
93
        private DefaultDataManager dataManager = null;
94

    
95
        private CoverageStoreProvider provider = null;
96

    
97
        private DelegatedDynObject metadata;
98

    
99
        private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(
100
                        this);
101

    
102
        public DefaultCoverageStore() {
103

    
104
        }
105

    
106
        /*
107
         * (non-Javadoc)
108
         *
109
         * @see
110
         * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase1(org.gvsig
111
         * .fmap.dal.impl.DefaultDataManager,
112
         * org.gvsig.fmap.dal.DataStoreParameters)
113
         */
114
        public void intializePhase1(DataManager dataManager,
115
                        DataStoreParameters parameters) throws InitializeException {
116
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
117

    
118
                this.metadata = (DelegatedDynObject) dynManager
119
                                .createDynObject( 
120
                                                MetadataLocator.getMetadataManager().getDefinition(DataStore.SPATIAL_METADATA_DEFINITION_NAME)
121
                                );
122
                this.dataManager = (DefaultDataManager)dataManager;
123
                this.parameters = parameters;
124

    
125
        }
126

    
127

    
128

    
129
        /*
130
         * (non-Javadoc)
131
         *
132
         * @see
133
         * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase2(org.gvsig
134
         * .fmap.dal.spi.DataStoreProvider)
135
         */
136
        public void intializePhase2(DataStoreProvider provider)
137
                        throws InitializeException {
138

    
139
                this.provider = (CoverageStoreProvider) provider;
140
                this.delegate(provider);
141

    
142
        }
143

    
144

    
145
        /* (non-Javadoc)
146
         * @see org.gvsig.fmap.dal.DataStore#createSelection()
147
         */
148
        public DataSet createSelection() throws DataException {
149
                // TODO Auto-generated method stub
150
                return null;
151
        }
152

    
153

    
154
        /* (non-Javadoc)
155
         * @see org.gvsig.fmap.dal.DataStore#getChildren()
156
         */
157
        public Iterator getChildren() {
158
                return this.provider.getChilds();
159
        }
160

    
161
        /* (non-Javadoc)
162
         * @see org.gvsig.fmap.dal.DataStore#getDataSet()
163
         */
164
        public DataSet getDataSet() throws DataException {
165
                // TODO Auto-generated method stub
166
                return null;
167
        }
168

    
169
        /* (non-Javadoc)
170
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery)
171
         */
172
        public DataSet getDataSet(DataQuery dataQuery) throws DataException {
173
                // TODO Auto-generated method stub
174
                return null;
175
        }
176

    
177
        public void accept(Visitor visitor) throws BaseException {
178
                // TODO Auto-generated method stub
179
        }
180

    
181
        public void accept(Visitor visitor, DataQuery dataQuery)
182
                        throws BaseException {
183
                // TODO Auto-generated method stub
184
        }
185

    
186
        /* (non-Javadoc)
187
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.tools.observer.Observer)
188
         */
189
        public void getDataSet(Observer observer) throws DataException {
190
                // TODO Auto-generated method stub
191

    
192
        }
193

    
194
        /* (non-Javadoc)
195
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery, org.gvsig.tools.observer.Observer)
196
         */
197
        public void getDataSet(DataQuery dataQuery, Observer observer)
198
                        throws DataException {
199
                // TODO Auto-generated method stub
200

    
201
        }
202

    
203
        /* (non-Javadoc)
204
         * @see org.gvsig.fmap.dal.DataStore#getExplorer()
205
         */
206
        public DataServerExplorer getExplorer() throws DataException,
207
                        ValidateDataParametersException {
208
                return provider.getExplorer();
209
        }
210

    
211
        /* (non-Javadoc)
212
         * @see org.gvsig.fmap.dal.DataStore#getParameters()
213
         */
214
        public DataStoreParameters getParameters() {
215
                return this.parameters;
216
        }
217

    
218
        /* (non-Javadoc)
219
         * @see org.gvsig.fmap.dal.DataStore#getSelection()
220
         */
221
        public DataSet getSelection() throws DataException {
222
                // TODO Auto-generated method stub
223
                return null;
224
        }
225

    
226
        /* (non-Javadoc)
227
         * @see org.gvsig.fmap.dal.DataStore#refresh()
228
         */
229
        public void refresh() throws DataException {
230
                // TODO Auto-generated method stub
231

    
232
        }
233

    
234
        /* (non-Javadoc)
235
         * @see org.gvsig.fmap.dal.DataStore#setSelection(org.gvsig.fmap.dal.DataSet)
236
         */
237
        public void setSelection(DataSet selection) throws DataException {
238
                // TODO Auto-generated method stub
239

    
240
        }
241

    
242
        /* (non-Javadoc)
243
         * @see org.gvsig.tools.observer.ComplexObservable#beginComplexNotification()
244
         */
245
        public void beginComplexNotification() {
246
                // TODO Auto-generated method stub
247

    
248
        }
249

    
250
        /* (non-Javadoc)
251
         * @see org.gvsig.tools.observer.ComplexObservable#disableNotifications()
252
         */
253
        public void disableNotifications() {
254
                // TODO Auto-generated method stub
255

    
256
        }
257

    
258
        /* (non-Javadoc)
259
         * @see org.gvsig.tools.observer.ComplexObservable#enableNotifications()
260
         */
261
        public void enableNotifications() {
262
                // TODO Auto-generated method stub
263

    
264
        }
265

    
266
        /* (non-Javadoc)
267
         * @see org.gvsig.tools.observer.ComplexObservable#endComplexNotification()
268
         */
269
        public void endComplexNotification() {
270
                // TODO Auto-generated method stub
271

    
272
        }
273

    
274
        /* (non-Javadoc)
275
         * @see org.gvsig.tools.observer.Observable#addObserver(org.gvsig.tools.observer.Observer)
276
         */
277
        public void addObserver(Observer o) {
278
                // TODO Auto-generated method stub
279

    
280
        }
281

    
282
        /* (non-Javadoc)
283
         * @see org.gvsig.tools.observer.Observable#deleteObserver(org.gvsig.tools.observer.Observer)
284
         */
285
        public void deleteObserver(Observer o) {
286
                // TODO Auto-generated method stub
287

    
288
        }
289

    
290
        /* (non-Javadoc)
291
         * @see org.gvsig.tools.observer.Observable#deleteObservers()
292
         */
293
        public void deleteObservers() {
294
                // TODO Auto-generated method stub
295

    
296
        }
297

    
298
        /* (non-Javadoc)
299
         * @see org.gvsig.tools.persistence.Persistent#getState()
300
         */
301
        public PersistentState getState() throws PersistenceException {
302
                // TODO Auto-generated method stub
303
                return null;
304
        }
305

    
306
        /* (non-Javadoc)
307
         * @see org.gvsig.tools.persistence.Persistent#loadState(org.gvsig.tools.persistence.PersistentState)
308
         */
309
        public void saveToState(PersistentState state) throws PersistenceException {
310
                // TODO Auto-generated method stub
311

    
312
        }
313

    
314
        /* (non-Javadoc)
315
         * @see org.gvsig.tools.persistence.Persistent#setState(org.gvsig.tools.persistence.PersistentState)
316
         */
317
        public void loadFromState(PersistentState state) throws PersistenceException {
318
                // TODO Auto-generated method stub
319

    
320
        }
321

    
322
        //
323
        // ====================================================================
324
        // Metadata related methods
325
        //
326

    
327
        public Object getMetadataID() {
328
                return this.provider.getSourceId();
329
        }
330

    
331
        public void delegate(DynObject dynObject) {
332
                this.metadata.delegate(dynObject);
333
        }
334

    
335
        public DynClass getDynClass() {
336
                return this.metadata.getDynClass();
337
        }
338

    
339
        public Object getDynValue(String name) throws DynFieldNotFoundException {
340
                return this.metadata.getDynValue(name);
341
        }
342

    
343
        public boolean hasDynValue(String name) {
344
                return this.metadata.hasDynValue(name);
345
        }
346

    
347
        public void implement(DynClass dynClass) {
348
                this.metadata.implement(dynClass);
349
        }
350

    
351
        public Object invokeDynMethod(String name, DynObject context)
352
                        throws DynMethodException {
353
                return this.metadata.invokeDynMethod(this, name, context);
354
        }
355

    
356
        public Object invokeDynMethod(int code, DynObject context)
357
                        throws DynMethodException {
358
                return this.metadata.invokeDynMethod(this, code, context);
359
        }
360

    
361
        public void setDynValue(String name, Object value)
362
                        throws DynFieldNotFoundException {
363
                this.metadata.setDynValue(name, value);
364

    
365
        }
366

    
367
        /*
368
         * (non-Javadoc)
369
         *
370
         * @see org.gvsig.metadata.Metadata#getMetadataChildren()
371
         */
372
        public Set getMetadataChildren() {
373
                return null;
374
        }
375

    
376
        /*
377
         * (non-Javadoc)
378
         *
379
         * @see org.gvsig.metadata.Metadata#getMetadataName()
380
         */
381
        public String getMetadataName() {
382
                return this.provider.getProviderName();
383
        }
384

    
385

    
386
        /* (non-Javadoc)
387
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#createDefaultCoverageSelection()
388
         */
389
        public CoverageSelection createDefaultCoverageSelection()
390
                        throws DataException {
391
                // TODO Auto-generated method stub
392
                return null;
393
        }
394

    
395

    
396
        /* (non-Javadoc)
397
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getManager()
398
         */
399
        public DataManager getManager() {
400
                return this.dataManager;
401
        }
402

    
403
        /* (non-Javadoc)
404
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getProvider()
405
         */
406
        public CoverageStoreProvider getProvider() {
407
                return this.provider;
408
        }
409

    
410
        public void notifyChange(String notification) {
411
                delegateObservable
412
                                .notifyObservers(new DefaultCoverageStoreNotification(
413
                                this, notification));
414

    
415
        }
416

    
417

    
418
        public void notifyChange(String notification, Command command) {
419
                delegateObservable
420
                                .notifyObservers(new DefaultCoverageStoreNotification(
421
                                this, notification, command));
422
        }
423

    
424

    
425
        /*
426
         * (non-Javadoc)
427
         *
428
         * @see
429
         * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
430
         * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
431
         */
432
        public void notifyChange(String notification, Resource resource) {
433
                delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
434
                                this, FeatureStoreNotification.RESOURCE_CHANGED));
435
        }
436

    
437
        public void open() throws OpenException {
438
                // TODO: Se puede hacer un open estando en edicion ?
439
                this.notifyChange(DataStoreNotification.BEFORE_OPEN);
440
                this.provider.open();
441
                this.notifyChange(DataStoreNotification.AFTER_OPEN);
442
        }
443

    
444
        public void close() throws CloseException {
445
                // TODO: Se puede hacer un close estando en edicion ?
446
                this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
447
                this.provider.close();
448
                this.notifyChange(DataStoreNotification.AFTER_CLOSE);
449
        }
450

    
451
        protected void doDispose() throws BaseException {
452
                this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
453
                this.provider.dispose();
454
                if (this.selection != null) {
455
                        this.selection.dispose();
456
                        this.selection = null;
457
                }
458

    
459
                this.parameters = null;
460
                this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
461
                this.delegateObservable.deleteObservers();
462
                this.delegateObservable = null;
463
        }
464

    
465
        public boolean allowWrite() {
466
                return this.provider.allowWrite();
467
        }
468

    
469
        public DataQuery createQuery() {
470
                // TODO Auto-generated method stub
471
                return null;
472
        }
473

    
474
        public DataStore getStore() {
475
                return this;
476
        }
477

    
478
        public CoverageStore getCoverageStore() {
479
                return this;
480
        }
481

    
482
        public void clear() {
483
                if (metadata != null) {
484
                        metadata.clear();
485
                }
486
        }
487

    
488
        public String getProviderName() {
489
                return this.provider.getProviderName();
490
        }
491
        
492
        public String getName() {
493
                return this.provider.getProviderName();
494
        }
495

    
496
        public String getFullName() {
497
                return this.provider.getFullName();
498
        }
499

    
500
    public Interval getInterval() {
501
        // TODO Auto-generated method stub
502
        return null;
503
    }
504
    
505
    public Collection getTimes() {
506
        // TODO Auto-generated method stub
507
        return null;
508
    }
509

    
510
    public Collection getTimes(Interval interval) {
511
        // TODO Auto-generated method stub
512
        return null;
513
    }   
514
}