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

History | View | Annotate | Download (14.3 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* gvSIG. Geographic Information System of the Valencian Government
25
*
26
* Copyright (C) 2007-2008 Infrastructures and Transports Department
27
* of the Valencian Government (CIT)
28
*
29
* This program is free software; you can redistribute it and/or
30
* modify it under the terms of the GNU General Public License
31
* as published by the Free Software Foundation; either version 2
32
* of the License, or (at your option) any later version.
33
*
34
* This program is distributed in the hope that it will be useful,
35
* but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
* GNU General Public License for more details.
38
*
39
* You should have received a copy of the GNU General Public License
40
* along with this program; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
42
* MA  02110-1301, USA.
43
*
44
*/
45

    
46
/*
47
* AUTHORS (In addition to CIT):
48
* 2009 IVER T.I   {{Task}}
49
*/
50

    
51
/**
52
 *
53
 */
54
package org.gvsig.fmap.dal.raster.impl;
55

    
56
import java.util.Collection;
57
import java.util.Iterator;
58
import java.util.Set;
59

    
60
import org.gvsig.fmap.dal.DataManager;
61
import org.gvsig.fmap.dal.DataQuery;
62
import org.gvsig.fmap.dal.DataServerExplorer;
63
import org.gvsig.fmap.dal.DataSet;
64
import org.gvsig.fmap.dal.DataStore;
65
import org.gvsig.fmap.dal.DataStoreNotification;
66
import org.gvsig.fmap.dal.DataStoreParameters;
67
import org.gvsig.fmap.dal.exception.CloseException;
68
import org.gvsig.fmap.dal.exception.DataException;
69
import org.gvsig.fmap.dal.exception.InitializeException;
70
import org.gvsig.fmap.dal.exception.OpenException;
71
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
72
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
73
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification;
74
import org.gvsig.fmap.dal.impl.DefaultDataManager;
75
import org.gvsig.fmap.dal.raster.CoverageSelection;
76
import org.gvsig.fmap.dal.raster.CoverageStore;
77
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
78
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices;
79
import org.gvsig.fmap.dal.resource.Resource;
80
import org.gvsig.fmap.dal.spi.DataStoreInitializer;
81
import org.gvsig.fmap.dal.spi.DataStoreProvider;
82
import org.gvsig.metadata.MetadataLocator;
83
import org.gvsig.timesupport.Interval;
84
import org.gvsig.timesupport.RelativeInterval;
85
import org.gvsig.tools.ToolsLocator;
86
import org.gvsig.tools.dispose.impl.AbstractDisposable;
87
import org.gvsig.tools.dynobject.DelegatedDynObject;
88
import org.gvsig.tools.dynobject.DynClass;
89
import org.gvsig.tools.dynobject.DynObject;
90
import org.gvsig.tools.dynobject.DynObjectManager;
91
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
92
import org.gvsig.tools.dynobject.exception.DynMethodException;
93
import org.gvsig.tools.exception.BaseException;
94
import org.gvsig.tools.observer.Observer;
95
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable;
96
import org.gvsig.tools.persistence.PersistentState;
97
import org.gvsig.tools.persistence.exception.PersistenceException;
98
import org.gvsig.tools.undo.command.Command;
99
import org.gvsig.tools.visitor.Visitor;
100

    
101
/**
102
 * @author jmvivo
103
 *
104
 */
105
public class DefaultCoverageStore extends AbstractDisposable implements
106
                CoverageStore, CoverageStoreProviderServices, DataStoreInitializer {
107

    
108
//        final static private Logger logger = LoggerFactory
109
//                        .getLogger(DefaultFeatureStore.class);
110

    
111
        private DataStoreParameters parameters = null;
112
        private CoverageSelection selection;
113

    
114
//        private long versionOfUpdate = 0;
115

    
116
        private DefaultDataManager dataManager = null;
117

    
118
        private CoverageStoreProvider provider = null;
119

    
120
        private DelegatedDynObject metadata;
121

    
122
        private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable(
123
                        this);
124

    
125
        public DefaultCoverageStore() {
126

    
127
        }
128

    
129
        /*
130
         * (non-Javadoc)
131
         *
132
         * @see
133
         * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase1(org.gvsig
134
         * .fmap.dal.impl.DefaultDataManager,
135
         * org.gvsig.fmap.dal.DataStoreParameters)
136
         */
137
        public void intializePhase1(DataManager dataManager,
138
                        DataStoreParameters parameters) throws InitializeException {
139
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
140

    
141
                this.metadata = (DelegatedDynObject) dynManager
142
                                .createDynObject( 
143
                                                MetadataLocator.getMetadataManager().getDefinition(DataStore.SPATIAL_METADATA_DEFINITION_NAME)
144
                                );
145
                this.dataManager = (DefaultDataManager)dataManager;
146
                this.parameters = parameters;
147

    
148
        }
149

    
150

    
151

    
152
        /*
153
         * (non-Javadoc)
154
         *
155
         * @see
156
         * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase2(org.gvsig
157
         * .fmap.dal.spi.DataStoreProvider)
158
         */
159
        public void intializePhase2(DataStoreProvider provider)
160
                        throws InitializeException {
161

    
162
                this.provider = (CoverageStoreProvider) provider;
163
                this.delegate(provider);
164

    
165
        }
166

    
167

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

    
176

    
177
        /* (non-Javadoc)
178
         * @see org.gvsig.fmap.dal.DataStore#getChildren()
179
         */
180
        public Iterator getChildren() {
181
                return this.provider.getChilds();
182
        }
183

    
184
        /* (non-Javadoc)
185
         * @see org.gvsig.fmap.dal.DataStore#getDataSet()
186
         */
187
        public DataSet getDataSet() throws DataException {
188
                // TODO Auto-generated method stub
189
                return null;
190
        }
191

    
192
        /* (non-Javadoc)
193
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery)
194
         */
195
        public DataSet getDataSet(DataQuery dataQuery) throws DataException {
196
                // TODO Auto-generated method stub
197
                return null;
198
        }
199

    
200
        public void accept(Visitor visitor) throws BaseException {
201
                // TODO Auto-generated method stub
202
        }
203

    
204
        public void accept(Visitor visitor, DataQuery dataQuery)
205
                        throws BaseException {
206
                // TODO Auto-generated method stub
207
        }
208

    
209
        /* (non-Javadoc)
210
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.tools.observer.Observer)
211
         */
212
        public void getDataSet(Observer observer) throws DataException {
213
                // TODO Auto-generated method stub
214

    
215
        }
216

    
217
        /* (non-Javadoc)
218
         * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery, org.gvsig.tools.observer.Observer)
219
         */
220
        public void getDataSet(DataQuery dataQuery, Observer observer)
221
                        throws DataException {
222
                // TODO Auto-generated method stub
223

    
224
        }
225

    
226
        /* (non-Javadoc)
227
         * @see org.gvsig.fmap.dal.DataStore#getExplorer()
228
         */
229
        public DataServerExplorer getExplorer() throws DataException,
230
                        ValidateDataParametersException {
231
                return provider.getExplorer();
232
        }
233

    
234
        /* (non-Javadoc)
235
         * @see org.gvsig.fmap.dal.DataStore#getParameters()
236
         */
237
        public DataStoreParameters getParameters() {
238
                return this.parameters;
239
        }
240

    
241
        /* (non-Javadoc)
242
         * @see org.gvsig.fmap.dal.DataStore#getSelection()
243
         */
244
        public DataSet getSelection() throws DataException {
245
                // TODO Auto-generated method stub
246
                return null;
247
        }
248

    
249
        /* (non-Javadoc)
250
         * @see org.gvsig.fmap.dal.DataStore#refresh()
251
         */
252
        public void refresh() throws DataException {
253
                // TODO Auto-generated method stub
254

    
255
        }
256

    
257
        /* (non-Javadoc)
258
         * @see org.gvsig.fmap.dal.DataStore#setSelection(org.gvsig.fmap.dal.DataSet)
259
         */
260
        public void setSelection(DataSet selection) throws DataException {
261
                // TODO Auto-generated method stub
262

    
263
        }
264

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

    
271
        }
272

    
273
        /* (non-Javadoc)
274
         * @see org.gvsig.tools.observer.ComplexObservable#disableNotifications()
275
         */
276
        public void disableNotifications() {
277
                // TODO Auto-generated method stub
278

    
279
        }
280

    
281
        /* (non-Javadoc)
282
         * @see org.gvsig.tools.observer.ComplexObservable#enableNotifications()
283
         */
284
        public void enableNotifications() {
285
                // TODO Auto-generated method stub
286

    
287
        }
288

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

    
295
        }
296

    
297
        /* (non-Javadoc)
298
         * @see org.gvsig.tools.observer.Observable#addObserver(org.gvsig.tools.observer.Observer)
299
         */
300
        public void addObserver(Observer o) {
301
                // TODO Auto-generated method stub
302

    
303
        }
304

    
305
        /* (non-Javadoc)
306
         * @see org.gvsig.tools.observer.Observable#deleteObserver(org.gvsig.tools.observer.Observer)
307
         */
308
        public void deleteObserver(Observer o) {
309
                // TODO Auto-generated method stub
310

    
311
        }
312

    
313
        /* (non-Javadoc)
314
         * @see org.gvsig.tools.observer.Observable#deleteObservers()
315
         */
316
        public void deleteObservers() {
317
                // TODO Auto-generated method stub
318

    
319
        }
320

    
321
        /* (non-Javadoc)
322
         * @see org.gvsig.tools.persistence.Persistent#getState()
323
         */
324
        public PersistentState getState() throws PersistenceException {
325
                // TODO Auto-generated method stub
326
                return null;
327
        }
328

    
329
        /* (non-Javadoc)
330
         * @see org.gvsig.tools.persistence.Persistent#loadState(org.gvsig.tools.persistence.PersistentState)
331
         */
332
        public void saveToState(PersistentState state) throws PersistenceException {
333
                // TODO Auto-generated method stub
334

    
335
        }
336

    
337
        /* (non-Javadoc)
338
         * @see org.gvsig.tools.persistence.Persistent#setState(org.gvsig.tools.persistence.PersistentState)
339
         */
340
        public void loadFromState(PersistentState state) throws PersistenceException {
341
                // TODO Auto-generated method stub
342

    
343
        }
344

    
345
        //
346
        // ====================================================================
347
        // Metadata related methods
348
        //
349

    
350
        public Object getMetadataID() {
351
                return this.provider.getSourceId();
352
        }
353

    
354
        public void delegate(DynObject dynObject) {
355
                this.metadata.delegate(dynObject);
356
        }
357

    
358
        public DynClass getDynClass() {
359
                return this.metadata.getDynClass();
360
        }
361

    
362
        public Object getDynValue(String name) throws DynFieldNotFoundException {
363
                return this.metadata.getDynValue(name);
364
        }
365

    
366
        public boolean hasDynValue(String name) {
367
                return this.metadata.hasDynValue(name);
368
        }
369

    
370
        public void implement(DynClass dynClass) {
371
                this.metadata.implement(dynClass);
372
        }
373

    
374
        public Object invokeDynMethod(String name, DynObject context)
375
                        throws DynMethodException {
376
                return this.metadata.invokeDynMethod(this, name, context);
377
        }
378

    
379
        public Object invokeDynMethod(int code, DynObject context)
380
                        throws DynMethodException {
381
                return this.metadata.invokeDynMethod(this, code, context);
382
        }
383

    
384
        public void setDynValue(String name, Object value)
385
                        throws DynFieldNotFoundException {
386
                this.metadata.setDynValue(name, value);
387

    
388
        }
389

    
390
        /*
391
         * (non-Javadoc)
392
         *
393
         * @see org.gvsig.metadata.Metadata#getMetadataChildren()
394
         */
395
        public Set getMetadataChildren() {
396
                return null;
397
        }
398

    
399
        /*
400
         * (non-Javadoc)
401
         *
402
         * @see org.gvsig.metadata.Metadata#getMetadataName()
403
         */
404
        public String getMetadataName() {
405
                return this.provider.getProviderName();
406
        }
407

    
408

    
409
        /* (non-Javadoc)
410
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#createDefaultCoverageSelection()
411
         */
412
        public CoverageSelection createDefaultCoverageSelection()
413
                        throws DataException {
414
                // TODO Auto-generated method stub
415
                return null;
416
        }
417

    
418

    
419
        /* (non-Javadoc)
420
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getManager()
421
         */
422
        public DataManager getManager() {
423
                return this.dataManager;
424
        }
425

    
426
        /* (non-Javadoc)
427
         * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getProvider()
428
         */
429
        public CoverageStoreProvider getProvider() {
430
                return this.provider;
431
        }
432

    
433
        public void notifyChange(String notification) {
434
                delegateObservable
435
                                .notifyObservers(new DefaultCoverageStoreNotification(
436
                                this, notification));
437

    
438
        }
439

    
440

    
441
        public void notifyChange(String notification, Command command) {
442
                delegateObservable
443
                                .notifyObservers(new DefaultCoverageStoreNotification(
444
                                this, notification, command));
445
        }
446

    
447

    
448
        /*
449
         * (non-Javadoc)
450
         *
451
         * @see
452
         * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
453
         * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
454
         */
455
        public void notifyChange(String notification, Resource resource) {
456
                delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
457
                                this, FeatureStoreNotification.RESOURCE_CHANGED));
458
        }
459

    
460
        public void open() throws OpenException {
461
                // TODO: Se puede hacer un open estando en edicion ?
462
                this.notifyChange(DataStoreNotification.BEFORE_OPEN);
463
                this.provider.open();
464
                this.notifyChange(DataStoreNotification.AFTER_OPEN);
465
        }
466

    
467
        public void close() throws CloseException {
468
                // TODO: Se puede hacer un close estando en edicion ?
469
                this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
470
                this.provider.close();
471
                this.notifyChange(DataStoreNotification.AFTER_CLOSE);
472
        }
473

    
474
        protected void doDispose() throws BaseException {
475
                this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
476
                this.provider.dispose();
477
                if (this.selection != null) {
478
                        this.selection.dispose();
479
                        this.selection = null;
480
                }
481

    
482
                this.parameters = null;
483
                this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
484
                this.delegateObservable.deleteObservers();
485
                this.delegateObservable = null;
486
        }
487

    
488
        public boolean allowWrite() {
489
                return this.provider.allowWrite();
490
        }
491

    
492
        public DataQuery createQuery() {
493
                // TODO Auto-generated method stub
494
                return null;
495
        }
496

    
497
        public DataStore getStore() {
498
                return this;
499
        }
500

    
501
        public CoverageStore getCoverageStore() {
502
                return this;
503
        }
504

    
505
        public void clear() {
506
                if (metadata != null) {
507
                        metadata.clear();
508
                }
509
        }
510

    
511
        public String getProviderName() {
512
                return this.provider.getProviderName();
513
        }
514
        
515
        public String getName() {
516
                return this.provider.getProviderName();
517
        }
518

    
519
        public String getFullName() {
520
                return this.provider.getFullName();
521
        }
522

    
523
    public Interval getInterval() {
524
        // TODO Auto-generated method stub
525
        return null;
526
    }
527
    
528
    public Collection getTimes() {
529
        // TODO Auto-generated method stub
530
        return null;
531
    }
532

    
533
    public Collection getTimes(Interval interval) {
534
        // TODO Auto-generated method stub
535
        return null;
536
    }   
537
}