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 @ 44297
History | View | Annotate | Download (17.1 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | package org.gvsig.fmap.dal.raster.impl; |
25 | |||
26 | import java.util.Collection; |
||
27 | import java.util.Iterator; |
||
28 | 44297 | jjdelcerro | import java.util.Map; |
29 | 40435 | jjdelcerro | import java.util.Set; |
30 | |||
31 | 43755 | fdiaz | import org.gvsig.fmap.dal.DataCache; |
32 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DataManager; |
33 | import org.gvsig.fmap.dal.DataQuery; |
||
34 | import org.gvsig.fmap.dal.DataServerExplorer; |
||
35 | import org.gvsig.fmap.dal.DataSet; |
||
36 | import org.gvsig.fmap.dal.DataStore; |
||
37 | import org.gvsig.fmap.dal.DataStoreNotification; |
||
38 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
39 | 43152 | fdiaz | import org.gvsig.fmap.dal.DataStoreProviderFactory; |
40 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.StoresRepository; |
41 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.exception.CloseException; |
42 | import org.gvsig.fmap.dal.exception.DataException; |
||
43 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
44 | import org.gvsig.fmap.dal.exception.OpenException; |
||
45 | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
||
46 | import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
||
47 | import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification; |
||
48 | import org.gvsig.fmap.dal.impl.DefaultDataManager; |
||
49 | import org.gvsig.fmap.dal.raster.CoverageSelection; |
||
50 | import org.gvsig.fmap.dal.raster.CoverageStore; |
||
51 | import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
||
52 | import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices; |
||
53 | import org.gvsig.fmap.dal.resource.Resource; |
||
54 | import org.gvsig.fmap.dal.spi.DataStoreInitializer; |
||
55 | import org.gvsig.fmap.dal.spi.DataStoreProvider; |
||
56 | import org.gvsig.metadata.MetadataLocator; |
||
57 | import org.gvsig.timesupport.Interval; |
||
58 | import org.gvsig.tools.ToolsLocator; |
||
59 | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
||
60 | import org.gvsig.tools.dynobject.DelegatedDynObject; |
||
61 | import org.gvsig.tools.dynobject.DynClass; |
||
62 | import org.gvsig.tools.dynobject.DynObject; |
||
63 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
64 | 43246 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject_v2; |
65 | 40435 | jjdelcerro | import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
66 | import org.gvsig.tools.dynobject.exception.DynMethodException; |
||
67 | import org.gvsig.tools.exception.BaseException; |
||
68 | import org.gvsig.tools.observer.Observer; |
||
69 | import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable; |
||
70 | import org.gvsig.tools.persistence.PersistentState; |
||
71 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
72 | 44297 | jjdelcerro | import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
73 | 40435 | jjdelcerro | import org.gvsig.tools.undo.command.Command; |
74 | 44259 | jjdelcerro | import org.gvsig.tools.util.UnmodifiableBasicMap; |
75 | 44297 | jjdelcerro | import org.gvsig.tools.util.UnmodifiableBasicSet; |
76 | import org.gvsig.tools.util.UnmodifiableBasicSetChained; |
||
77 | 40435 | jjdelcerro | import org.gvsig.tools.visitor.Visitor; |
78 | 44297 | jjdelcerro | import org.slf4j.Logger; |
79 | import org.slf4j.LoggerFactory; |
||
80 | 40435 | jjdelcerro | |
81 | /**
|
||
82 | * @author jmvivo
|
||
83 | *
|
||
84 | */
|
||
85 | public class DefaultCoverageStore extends AbstractDisposable implements |
||
86 | CoverageStore, CoverageStoreProviderServices, DataStoreInitializer { |
||
87 | |||
88 | 44297 | jjdelcerro | private static final Logger LOG = LoggerFactory.getLogger(DefaultCoverageStore.class); |
89 | 40435 | jjdelcerro | |
90 | 44297 | jjdelcerro | |
91 | 40435 | jjdelcerro | private DataStoreParameters parameters = null; |
92 | private CoverageSelection selection;
|
||
93 | |||
94 | // private long versionOfUpdate = 0;
|
||
95 | |||
96 | private DefaultDataManager dataManager = null; |
||
97 | |||
98 | private CoverageStoreProvider provider = null; |
||
99 | |||
100 | private DelegatedDynObject metadata;
|
||
101 | |||
102 | private DelegateWeakReferencingObservable delegateObservable = new DelegateWeakReferencingObservable( |
||
103 | this);
|
||
104 | |||
105 | public DefaultCoverageStore() {
|
||
106 | |||
107 | } |
||
108 | |||
109 | /*
|
||
110 | * (non-Javadoc)
|
||
111 | *
|
||
112 | * @see
|
||
113 | * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase1(org.gvsig
|
||
114 | * .fmap.dal.impl.DefaultDataManager,
|
||
115 | * org.gvsig.fmap.dal.DataStoreParameters)
|
||
116 | */
|
||
117 | public void intializePhase1(DataManager dataManager, |
||
118 | DataStoreParameters parameters) throws InitializeException {
|
||
119 | DynObjectManager dynManager = ToolsLocator.getDynObjectManager(); |
||
120 | |||
121 | this.metadata = (DelegatedDynObject) dynManager
|
||
122 | 43152 | fdiaz | .createDynObject( |
123 | 40435 | jjdelcerro | MetadataLocator.getMetadataManager().getDefinition(DataStore.SPATIAL_METADATA_DEFINITION_NAME) |
124 | ); |
||
125 | this.dataManager = (DefaultDataManager)dataManager;
|
||
126 | this.parameters = parameters;
|
||
127 | |||
128 | } |
||
129 | |||
130 | |||
131 | |||
132 | /*
|
||
133 | * (non-Javadoc)
|
||
134 | *
|
||
135 | * @see
|
||
136 | * org.gvsig.fmap.dal.impl.DataStoreImplementation#intializePhase2(org.gvsig
|
||
137 | * .fmap.dal.spi.DataStoreProvider)
|
||
138 | */
|
||
139 | public void intializePhase2(DataStoreProvider provider) |
||
140 | throws InitializeException {
|
||
141 | |||
142 | this.provider = (CoverageStoreProvider) provider;
|
||
143 | 43020 | jjdelcerro | this.delegate((DynObject) provider);
|
144 | 40435 | jjdelcerro | |
145 | } |
||
146 | |||
147 | |||
148 | /* (non-Javadoc)
|
||
149 | * @see org.gvsig.fmap.dal.DataStore#createSelection()
|
||
150 | */
|
||
151 | public DataSet createSelection() throws DataException { |
||
152 | // TODO Auto-generated method stub
|
||
153 | return null; |
||
154 | } |
||
155 | |||
156 | |||
157 | 44251 | jjdelcerro | @Override
|
158 | 44259 | jjdelcerro | public UnmodifiableBasicMap<String,DataStore> getChildren() { |
159 | return UnmodifiableBasicMap.EMPTY_UNMODIFIABLEBASICMAP;
|
||
160 | } |
||
161 | 44251 | jjdelcerro | |
162 | 40435 | jjdelcerro | /* (non-Javadoc)
|
163 | * @see org.gvsig.fmap.dal.DataStore#getDataSet()
|
||
164 | */
|
||
165 | public DataSet getDataSet() throws DataException { |
||
166 | // TODO Auto-generated method stub
|
||
167 | return null; |
||
168 | } |
||
169 | |||
170 | /* (non-Javadoc)
|
||
171 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery)
|
||
172 | */
|
||
173 | public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
||
174 | // TODO Auto-generated method stub
|
||
175 | return null; |
||
176 | } |
||
177 | |||
178 | public void accept(Visitor visitor) throws BaseException { |
||
179 | // TODO Auto-generated method stub
|
||
180 | } |
||
181 | |||
182 | public void accept(Visitor visitor, DataQuery dataQuery) |
||
183 | throws BaseException {
|
||
184 | // TODO Auto-generated method stub
|
||
185 | } |
||
186 | |||
187 | /* (non-Javadoc)
|
||
188 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.tools.observer.Observer)
|
||
189 | */
|
||
190 | public void getDataSet(Observer observer) throws DataException { |
||
191 | // TODO Auto-generated method stub
|
||
192 | |||
193 | } |
||
194 | |||
195 | /* (non-Javadoc)
|
||
196 | * @see org.gvsig.fmap.dal.DataStore#getDataSet(org.gvsig.fmap.dal.DataQuery, org.gvsig.tools.observer.Observer)
|
||
197 | */
|
||
198 | public void getDataSet(DataQuery dataQuery, Observer observer) |
||
199 | throws DataException {
|
||
200 | // TODO Auto-generated method stub
|
||
201 | |||
202 | } |
||
203 | |||
204 | /* (non-Javadoc)
|
||
205 | * @see org.gvsig.fmap.dal.DataStore#getExplorer()
|
||
206 | */
|
||
207 | public DataServerExplorer getExplorer() throws DataException, |
||
208 | ValidateDataParametersException { |
||
209 | return provider.getExplorer();
|
||
210 | } |
||
211 | |||
212 | /* (non-Javadoc)
|
||
213 | * @see org.gvsig.fmap.dal.DataStore#getParameters()
|
||
214 | */
|
||
215 | public DataStoreParameters getParameters() {
|
||
216 | return this.parameters; |
||
217 | } |
||
218 | |||
219 | /* (non-Javadoc)
|
||
220 | * @see org.gvsig.fmap.dal.DataStore#getSelection()
|
||
221 | */
|
||
222 | public DataSet getSelection() throws DataException { |
||
223 | // TODO Auto-generated method stub
|
||
224 | return null; |
||
225 | } |
||
226 | |||
227 | /* (non-Javadoc)
|
||
228 | * @see org.gvsig.fmap.dal.DataStore#refresh()
|
||
229 | */
|
||
230 | public void refresh() throws DataException { |
||
231 | // TODO Auto-generated method stub
|
||
232 | |||
233 | } |
||
234 | |||
235 | /* (non-Javadoc)
|
||
236 | * @see org.gvsig.fmap.dal.DataStore#setSelection(org.gvsig.fmap.dal.DataSet)
|
||
237 | */
|
||
238 | public void setSelection(DataSet selection) throws DataException { |
||
239 | // TODO Auto-generated method stub
|
||
240 | |||
241 | } |
||
242 | |||
243 | /* (non-Javadoc)
|
||
244 | * @see org.gvsig.tools.observer.ComplexObservable#beginComplexNotification()
|
||
245 | */
|
||
246 | public void beginComplexNotification() { |
||
247 | // TODO Auto-generated method stub
|
||
248 | |||
249 | } |
||
250 | |||
251 | /* (non-Javadoc)
|
||
252 | * @see org.gvsig.tools.observer.ComplexObservable#disableNotifications()
|
||
253 | */
|
||
254 | public void disableNotifications() { |
||
255 | // TODO Auto-generated method stub
|
||
256 | |||
257 | } |
||
258 | |||
259 | /* (non-Javadoc)
|
||
260 | * @see org.gvsig.tools.observer.ComplexObservable#enableNotifications()
|
||
261 | */
|
||
262 | public void enableNotifications() { |
||
263 | // TODO Auto-generated method stub
|
||
264 | |||
265 | } |
||
266 | |||
267 | /* (non-Javadoc)
|
||
268 | * @see org.gvsig.tools.observer.ComplexObservable#endComplexNotification()
|
||
269 | */
|
||
270 | public void endComplexNotification() { |
||
271 | // TODO Auto-generated method stub
|
||
272 | |||
273 | } |
||
274 | |||
275 | /* (non-Javadoc)
|
||
276 | * @see org.gvsig.tools.observer.Observable#addObserver(org.gvsig.tools.observer.Observer)
|
||
277 | */
|
||
278 | public void addObserver(Observer o) { |
||
279 | // TODO Auto-generated method stub
|
||
280 | |||
281 | } |
||
282 | |||
283 | /* (non-Javadoc)
|
||
284 | * @see org.gvsig.tools.observer.Observable#deleteObserver(org.gvsig.tools.observer.Observer)
|
||
285 | */
|
||
286 | public void deleteObserver(Observer o) { |
||
287 | // TODO Auto-generated method stub
|
||
288 | |||
289 | } |
||
290 | |||
291 | /* (non-Javadoc)
|
||
292 | * @see org.gvsig.tools.observer.Observable#deleteObservers()
|
||
293 | */
|
||
294 | public void deleteObservers() { |
||
295 | // TODO Auto-generated method stub
|
||
296 | |||
297 | } |
||
298 | |||
299 | /* (non-Javadoc)
|
||
300 | * @see org.gvsig.tools.persistence.Persistent#getState()
|
||
301 | */
|
||
302 | public PersistentState getState() throws PersistenceException { |
||
303 | // TODO Auto-generated method stub
|
||
304 | return null; |
||
305 | } |
||
306 | |||
307 | /* (non-Javadoc)
|
||
308 | * @see org.gvsig.tools.persistence.Persistent#loadState(org.gvsig.tools.persistence.PersistentState)
|
||
309 | */
|
||
310 | public void saveToState(PersistentState state) throws PersistenceException { |
||
311 | // TODO Auto-generated method stub
|
||
312 | |||
313 | } |
||
314 | |||
315 | /* (non-Javadoc)
|
||
316 | * @see org.gvsig.tools.persistence.Persistent#setState(org.gvsig.tools.persistence.PersistentState)
|
||
317 | */
|
||
318 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
319 | // TODO Auto-generated method stub
|
||
320 | |||
321 | } |
||
322 | |||
323 | //
|
||
324 | // ====================================================================
|
||
325 | // Metadata related methods
|
||
326 | //
|
||
327 | |||
328 | public Object getMetadataID() { |
||
329 | return this.provider.getSourceId(); |
||
330 | } |
||
331 | |||
332 | public void delegate(DynObject dynObject) { |
||
333 | this.metadata.delegate(dynObject);
|
||
334 | } |
||
335 | |||
336 | public DynClass getDynClass() {
|
||
337 | return this.metadata.getDynClass(); |
||
338 | } |
||
339 | |||
340 | public Object getDynValue(String name) throws DynFieldNotFoundException { |
||
341 | return this.metadata.getDynValue(name); |
||
342 | } |
||
343 | |||
344 | public boolean hasDynValue(String name) { |
||
345 | return this.metadata.hasDynValue(name); |
||
346 | } |
||
347 | 43755 | fdiaz | |
348 | 43246 | jjdelcerro | @Override
|
349 | public boolean hasDynMethod(String name) { |
||
350 | return ((DynObject_v2)this.metadata).hasDynMethod(name); |
||
351 | 43755 | fdiaz | } |
352 | 40435 | jjdelcerro | |
353 | public void implement(DynClass dynClass) { |
||
354 | this.metadata.implement(dynClass);
|
||
355 | } |
||
356 | |||
357 | 42775 | jjdelcerro | public Object invokeDynMethod(String name, Object[] args) |
358 | 40435 | jjdelcerro | throws DynMethodException {
|
359 | 42775 | jjdelcerro | return this.metadata.invokeDynMethod(this, name, args); |
360 | 40435 | jjdelcerro | } |
361 | |||
362 | 42775 | jjdelcerro | public Object invokeDynMethod(int code, Object[] args) |
363 | 40435 | jjdelcerro | throws DynMethodException {
|
364 | 42775 | jjdelcerro | return this.metadata.invokeDynMethod(this, code, args); |
365 | 40435 | jjdelcerro | } |
366 | |||
367 | public void setDynValue(String name, Object value) |
||
368 | throws DynFieldNotFoundException {
|
||
369 | this.metadata.setDynValue(name, value);
|
||
370 | |||
371 | } |
||
372 | |||
373 | /*
|
||
374 | * (non-Javadoc)
|
||
375 | *
|
||
376 | * @see org.gvsig.metadata.Metadata#getMetadataChildren()
|
||
377 | */
|
||
378 | public Set getMetadataChildren() { |
||
379 | return null; |
||
380 | } |
||
381 | |||
382 | /*
|
||
383 | * (non-Javadoc)
|
||
384 | *
|
||
385 | * @see org.gvsig.metadata.Metadata#getMetadataName()
|
||
386 | */
|
||
387 | public String getMetadataName() { |
||
388 | return this.provider.getProviderName(); |
||
389 | } |
||
390 | |||
391 | |||
392 | /* (non-Javadoc)
|
||
393 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#createDefaultCoverageSelection()
|
||
394 | */
|
||
395 | public CoverageSelection createDefaultCoverageSelection()
|
||
396 | throws DataException {
|
||
397 | // TODO Auto-generated method stub
|
||
398 | return null; |
||
399 | } |
||
400 | |||
401 | |||
402 | /* (non-Javadoc)
|
||
403 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getManager()
|
||
404 | */
|
||
405 | public DataManager getManager() {
|
||
406 | return this.dataManager; |
||
407 | } |
||
408 | |||
409 | /* (non-Javadoc)
|
||
410 | * @see org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices#getProvider()
|
||
411 | */
|
||
412 | public CoverageStoreProvider getProvider() {
|
||
413 | return this.provider; |
||
414 | } |
||
415 | |||
416 | public void notifyChange(String notification) { |
||
417 | delegateObservable |
||
418 | .notifyObservers(new DefaultCoverageStoreNotification(
|
||
419 | this, notification));
|
||
420 | |||
421 | } |
||
422 | |||
423 | |||
424 | public void notifyChange(String notification, Command command) { |
||
425 | delegateObservable |
||
426 | .notifyObservers(new DefaultCoverageStoreNotification(
|
||
427 | this, notification, command));
|
||
428 | } |
||
429 | |||
430 | |||
431 | /*
|
||
432 | * (non-Javadoc)
|
||
433 | *
|
||
434 | * @see
|
||
435 | * org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices#notifyChange
|
||
436 | * (java.lang.String, org.gvsig.fmap.dal.resource.Resource)
|
||
437 | */
|
||
438 | public void notifyChange(String notification, Resource resource) { |
||
439 | delegateObservable.notifyObservers(new DefaultFeatureStoreNotification(
|
||
440 | this, FeatureStoreNotification.RESOURCE_CHANGED));
|
||
441 | } |
||
442 | |||
443 | public void open() throws OpenException { |
||
444 | // TODO: Se puede hacer un open estando en edicion ?
|
||
445 | this.notifyChange(DataStoreNotification.BEFORE_OPEN);
|
||
446 | this.provider.open();
|
||
447 | this.notifyChange(DataStoreNotification.AFTER_OPEN);
|
||
448 | } |
||
449 | |||
450 | public void close() throws CloseException { |
||
451 | // TODO: Se puede hacer un close estando en edicion ?
|
||
452 | this.notifyChange(DataStoreNotification.BEFORE_CLOSE);
|
||
453 | this.provider.close();
|
||
454 | this.notifyChange(DataStoreNotification.AFTER_CLOSE);
|
||
455 | } |
||
456 | |||
457 | protected void doDispose() throws BaseException { |
||
458 | this.notifyChange(DataStoreNotification.BEFORE_DISPOSE);
|
||
459 | this.provider.dispose();
|
||
460 | if (this.selection != null) { |
||
461 | this.selection.dispose();
|
||
462 | this.selection = null; |
||
463 | } |
||
464 | |||
465 | this.parameters = null; |
||
466 | this.notifyChange(DataStoreNotification.AFTER_DISPOSE);
|
||
467 | this.delegateObservable.deleteObservers();
|
||
468 | this.delegateObservable = null; |
||
469 | } |
||
470 | |||
471 | public boolean allowWrite() { |
||
472 | return this.provider.allowWrite(); |
||
473 | } |
||
474 | |||
475 | public DataQuery createQuery() {
|
||
476 | // TODO Auto-generated method stub
|
||
477 | return null; |
||
478 | } |
||
479 | |||
480 | public DataStore getStore() {
|
||
481 | return this; |
||
482 | } |
||
483 | |||
484 | public CoverageStore getCoverageStore() {
|
||
485 | return this; |
||
486 | } |
||
487 | |||
488 | public void clear() { |
||
489 | if (metadata != null) { |
||
490 | metadata.clear(); |
||
491 | } |
||
492 | } |
||
493 | |||
494 | public String getProviderName() { |
||
495 | return this.provider.getProviderName(); |
||
496 | } |
||
497 | 43152 | fdiaz | |
498 | 40435 | jjdelcerro | public String getName() { |
499 | 41739 | jjdelcerro | return this.provider.getName(); |
500 | 40435 | jjdelcerro | } |
501 | |||
502 | public String getFullName() { |
||
503 | return this.provider.getFullName(); |
||
504 | } |
||
505 | |||
506 | public Interval getInterval() {
|
||
507 | // TODO Auto-generated method stub
|
||
508 | return null; |
||
509 | } |
||
510 | 43152 | fdiaz | |
511 | 40435 | jjdelcerro | public Collection getTimes() { |
512 | // TODO Auto-generated method stub
|
||
513 | return null; |
||
514 | } |
||
515 | |||
516 | public Collection getTimes(Interval interval) { |
||
517 | // TODO Auto-generated method stub
|
||
518 | return null; |
||
519 | 43152 | fdiaz | } |
520 | |||
521 | @Override
|
||
522 | public void useCache(String providerName, DynObject parameters) throws DataException { |
||
523 | throw new UnsupportedOperationException(); |
||
524 | } |
||
525 | |||
526 | @Override
|
||
527 | 43190 | jjdelcerro | public DataStoreProviderFactory getProviderFactory() {
|
528 | 43152 | fdiaz | DataStoreProviderFactory factory = dataManager.getStoreProviderFactory(parameters.getDataStoreName()); |
529 | return factory;
|
||
530 | } |
||
531 | 43755 | fdiaz | |
532 | @Override
|
||
533 | public DataCache getCache() {
|
||
534 | // TODO Auto-generated method stub
|
||
535 | return null; |
||
536 | } |
||
537 | 44297 | jjdelcerro | |
538 | @Override
|
||
539 | public ResourcesStorage getResourcesStorage() {
|
||
540 | try {
|
||
541 | return this.getExplorer().getResourcesStorage(this); |
||
542 | } catch (Exception ex) { |
||
543 | LOG.warn("Can't create resources storage",ex);
|
||
544 | return null; |
||
545 | } |
||
546 | } |
||
547 | |||
548 | @Override
|
||
549 | public StoresRepository getStoresRepository() {
|
||
550 | final StoresRepository mainRepository = this.dataManager.getStoresRepository(); |
||
551 | StoresRepository repository = new StoresRepository() {
|
||
552 | @Override
|
||
553 | public void add(String name, DataStoreParameters parameters) { |
||
554 | mainRepository.add(name, parameters); |
||
555 | } |
||
556 | |||
557 | @Override
|
||
558 | public void remove(String name) { |
||
559 | mainRepository.remove(name); |
||
560 | } |
||
561 | |||
562 | @Override
|
||
563 | public DataStore get(String key) { |
||
564 | DataStore store = getChildren().get(key); |
||
565 | if( store != null ) { |
||
566 | return store;
|
||
567 | } |
||
568 | return mainRepository.get(key);
|
||
569 | } |
||
570 | |||
571 | @Override
|
||
572 | public boolean isEmpty() { |
||
573 | return getChildren().isEmpty() && mainRepository.isEmpty();
|
||
574 | } |
||
575 | |||
576 | @Override
|
||
577 | public boolean containsKey(String key) { |
||
578 | return getChildren().containsKey(key) || mainRepository.containsKey(key);
|
||
579 | } |
||
580 | |||
581 | @Override
|
||
582 | public Map<String, DataStore> toMap() { |
||
583 | return null; |
||
584 | } |
||
585 | |||
586 | @Override
|
||
587 | public int size() { |
||
588 | return getChildren().size()+mainRepository.size();
|
||
589 | } |
||
590 | |||
591 | @Override
|
||
592 | public UnmodifiableBasicSet<String> keySet() { |
||
593 | UnmodifiableBasicMap<String, DataStore> children = getChildren();
|
||
594 | if( children.isEmpty() ) {
|
||
595 | return mainRepository.keySet();
|
||
596 | } |
||
597 | return new UnmodifiableBasicSetChained<>( |
||
598 | children.keySet(), |
||
599 | mainRepository.keySet() |
||
600 | ); |
||
601 | } |
||
602 | |||
603 | @Override
|
||
604 | public Iterator<DataStore> iterator() { |
||
605 | final Iterator<String> it = this.keySet().iterator(); |
||
606 | return new Iterator<DataStore>() { |
||
607 | @Override
|
||
608 | public boolean hasNext() { |
||
609 | return it.hasNext();
|
||
610 | } |
||
611 | |||
612 | @Override
|
||
613 | public DataStore next() {
|
||
614 | String name = it.next();
|
||
615 | return get(name);
|
||
616 | } |
||
617 | }; |
||
618 | } |
||
619 | }; |
||
620 | return repository;
|
||
621 | } |
||
622 | |||
623 | 40596 | jjdelcerro | } |