Revision 41491
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/OpenDataStoreParameters.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
|
|
7 |
package org.gvsig.fmap.dal; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author usuario |
|
12 |
*/ |
|
13 |
public interface OpenDataStoreParameters extends DataStoreParameters { |
|
14 |
|
|
15 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataServerExplorerPoolEntry.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
package org.gvsig.fmap.dal; |
|
5 |
|
|
6 |
import org.gvsig.tools.persistence.Persistent; |
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
public interface DataServerExplorerPoolEntry extends Persistent { |
|
11 |
|
|
12 |
public String getName(); |
|
13 |
|
|
14 |
public DataServerExplorerParameters getExplorerParameters(); |
|
15 |
|
|
16 |
public String getDescription(); |
|
17 |
|
|
18 |
public void copyTo(DataServerExplorerPoolEntry target); |
|
19 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java | ||
---|---|---|
400 | 400 |
* if there is any error creating the object |
401 | 401 |
*/ |
402 | 402 |
public FeatureAttributeGetter createFeatureAttributeGetter(String name) throws InitializeException; |
403 |
|
|
404 |
public DataServerExplorerPool getDataServerExplorerPool(); |
|
405 |
public void setDataServerExplorerPool(DataServerExplorerPool pool); |
|
403 | 406 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataServerExplorerPool.java | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
package org.gvsig.fmap.dal; |
|
4 |
|
|
5 |
import java.util.Iterator; |
|
6 |
import org.gvsig.tools.persistence.Persistent; |
|
7 |
|
|
8 |
|
|
9 |
public interface DataServerExplorerPool extends Persistent { |
|
10 |
|
|
11 |
|
|
12 |
public void add(String name, DataServerExplorerParameters explorer); |
|
13 |
|
|
14 |
public void add(String name, String description, DataServerExplorerParameters explorer); |
|
15 |
|
|
16 |
public boolean contains(String name); |
|
17 |
|
|
18 |
public boolean contains(DataServerExplorerPoolEntry entry); |
|
19 |
|
|
20 |
public boolean isEmpty(); |
|
21 |
|
|
22 |
public void remove(DataServerExplorerPoolEntry explorer); |
|
23 |
|
|
24 |
public void remove(int explorerIndex); |
|
25 |
|
|
26 |
public void remove(String name); |
|
27 |
|
|
28 |
public int size(); |
|
29 |
|
|
30 |
public DataServerExplorerPoolEntry get(int index); |
|
31 |
|
|
32 |
public DataServerExplorerPoolEntry get(String name); |
|
33 |
|
|
34 |
public Iterator iterator(); |
|
35 |
} |
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/impl/DefaultDataManager.java | ||
---|---|---|
34 | 34 |
import org.gvsig.fmap.dal.DataManager; |
35 | 35 |
import org.gvsig.fmap.dal.DataServerExplorer; |
36 | 36 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
37 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
37 | 38 |
import org.gvsig.fmap.dal.DataStore; |
38 | 39 |
import org.gvsig.fmap.dal.DataStoreFactory; |
39 | 40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
... | ... | |
140 | 141 |
|
141 | 142 |
private OpenErrorHandler openErrorHandler; |
142 | 143 |
|
143 |
private ArrayList dataTypes; |
|
144 |
private List dataTypes; |
|
145 |
|
|
146 |
private DataServerExplorerPool dataServerExplorerPool = null; |
|
147 |
|
|
144 | 148 |
|
145 | 149 |
public DefaultDataManager() { |
146 | 150 |
/* |
... | ... | |
911 | 915 |
throw new InitializeException("FeatureAttributeGetter", e); |
912 | 916 |
} |
913 | 917 |
} |
918 |
|
|
919 |
public DataServerExplorerPool getDataServerExplorerPool() { |
|
920 |
if( this.dataServerExplorerPool==null ) { |
|
921 |
this.dataServerExplorerPool = new DefaultDataServerExplorerPool(); |
|
922 |
} |
|
923 |
return this.dataServerExplorerPool; |
|
924 |
} |
|
925 |
|
|
926 |
public void setDataServerExplorerPool(DataServerExplorerPool pool) { |
|
927 |
this.dataServerExplorerPool = pool; |
|
928 |
} |
|
929 |
|
|
930 |
|
|
914 | 931 |
} |
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/impl/DefaultDataServerExplorerPool.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
import org.apache.commons.lang3.StringUtils; |
|
7 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
8 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
9 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
10 |
import org.gvsig.tools.ToolsLocator; |
|
11 |
import org.gvsig.tools.dynobject.DynStruct; |
|
12 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
13 |
import org.gvsig.tools.persistence.PersistentState; |
|
14 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
15 |
|
|
16 |
public class DefaultDataServerExplorerPool implements DataServerExplorerPool { |
|
17 |
|
|
18 |
|
|
19 |
private static final String PERSISTENCE_DEFINITION_NAME = "DataServerExplorerPool"; |
|
20 |
|
|
21 |
private List pool; |
|
22 |
|
|
23 |
public DefaultDataServerExplorerPool() { |
|
24 |
this.pool = new ArrayList(); |
|
25 |
} |
|
26 |
|
|
27 |
public boolean contains(String name) { |
|
28 |
DataServerExplorerPoolEntry entry = this.get(name); |
|
29 |
return entry!=null; |
|
30 |
} |
|
31 |
|
|
32 |
public boolean contains(DataServerExplorerPoolEntry entry) { |
|
33 |
return contains(entry.getName()); |
|
34 |
} |
|
35 |
|
|
36 |
public boolean isEmpty() { |
|
37 |
return this.pool.isEmpty(); |
|
38 |
} |
|
39 |
|
|
40 |
public void add(String name, DataServerExplorerParameters explorer) { |
|
41 |
this.add(name, null, explorer); |
|
42 |
} |
|
43 |
|
|
44 |
public void add(String name, String description, DataServerExplorerParameters explorer) { |
|
45 |
DefaultDataServerExplorerPoolEntry newexplorer = new DefaultDataServerExplorerPoolEntry(name, description, explorer); |
|
46 |
DataServerExplorerPoolEntry existent = this.get(name); |
|
47 |
if( existent!=null ) { |
|
48 |
newexplorer.copyTo(existent); |
|
49 |
} else { |
|
50 |
this.pool.add(newexplorer); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
public void remove(DataServerExplorerPoolEntry entry) { |
|
55 |
this.remove(entry.getName()); |
|
56 |
} |
|
57 |
|
|
58 |
public void remove(int explorerIndex) { |
|
59 |
this.pool.remove(explorerIndex); |
|
60 |
} |
|
61 |
|
|
62 |
public void remove(String name) { |
|
63 |
if( StringUtils.isBlank(name) ) { |
|
64 |
return; |
|
65 |
} |
|
66 |
for( int i=0; i<this.pool.size(); i++ ) { |
|
67 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) this.pool.get(i); |
|
68 |
if( name.equalsIgnoreCase(entry.getName()) ) { |
|
69 |
this.remove(i); |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
public int size() { |
|
75 |
return this.pool.size(); |
|
76 |
} |
|
77 |
|
|
78 |
public DataServerExplorerPoolEntry get(int index) { |
|
79 |
return (DataServerExplorerPoolEntry) this.pool.get(index); |
|
80 |
} |
|
81 |
|
|
82 |
public DataServerExplorerPoolEntry get(String name) { |
|
83 |
if( StringUtils.isBlank(name) ) { |
|
84 |
return null; |
|
85 |
} |
|
86 |
for( int i=0; i<this.pool.size(); i++ ) { |
|
87 |
DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) this.pool.get(i); |
|
88 |
if( name.equalsIgnoreCase(entry.getName()) ) { |
|
89 |
return entry; |
|
90 |
} |
|
91 |
} |
|
92 |
return null; |
|
93 |
} |
|
94 |
|
|
95 |
public Iterator iterator() { |
|
96 |
return this.pool.iterator(); |
|
97 |
} |
|
98 |
|
|
99 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
100 |
state.set("pool", pool); |
|
101 |
} |
|
102 |
|
|
103 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
104 |
List l = state.getList("pool"); |
|
105 |
this.pool = new ArrayList(); |
|
106 |
this.pool.addAll(l); |
|
107 |
} |
|
108 |
|
|
109 |
public static void registerPersistenceDefinition() { |
|
110 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
111 |
if ( manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null ) { |
|
112 |
DynStruct definition |
|
113 |
= manager.addDefinition(DefaultDataServerExplorerPool.class, |
|
114 |
PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
|
115 |
+ " Persistent definition", null, null); |
|
116 |
|
|
117 |
definition.addDynFieldList("pool") |
|
118 |
.setClassOfItems(DefaultDataServerExplorerPoolEntry.class) |
|
119 |
.setMandatory(true) |
|
120 |
.setPersistent(true); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
} |
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/impl/DefaultDataServerExplorerPoolEntry.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.fmap.dal.impl; |
|
7 |
|
|
8 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
9 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
10 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
11 |
import org.gvsig.tools.ToolsLocator; |
|
12 |
import org.gvsig.tools.dynobject.DynStruct; |
|
13 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
14 |
import org.gvsig.tools.persistence.PersistentState; |
|
15 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author usuario |
|
20 |
*/ |
|
21 |
public class DefaultDataServerExplorerPoolEntry implements DataServerExplorerPoolEntry { |
|
22 |
|
|
23 |
private static final String PERSISTENCE_DEFINITION_NAME = "DataServerExplorerPoolEntry"; |
|
24 |
|
|
25 |
protected String name; |
|
26 |
protected String description; |
|
27 |
protected DataServerExplorerParameters explorer; |
|
28 |
|
|
29 |
public DefaultDataServerExplorerPoolEntry() { |
|
30 |
// Required by Persistent |
|
31 |
} |
|
32 |
|
|
33 |
public DefaultDataServerExplorerPoolEntry(String name, String description, DataServerExplorerParameters explorer) { |
|
34 |
this.name = name; |
|
35 |
this.description = description; |
|
36 |
this.explorer = explorer; |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
public String getName() { |
|
41 |
return this.name; |
|
42 |
} |
|
43 |
|
|
44 |
public void copyTo(DataServerExplorerPoolEntry target) { |
|
45 |
DefaultDataServerExplorerPoolEntry other = (DefaultDataServerExplorerPoolEntry)target; |
|
46 |
other.name = this.name; |
|
47 |
other.description = this.description; |
|
48 |
other.explorer = this.explorer; |
|
49 |
} |
|
50 |
|
|
51 |
public DataServerExplorerParameters getExplorerParameters() { |
|
52 |
return this.explorer; |
|
53 |
} |
|
54 |
|
|
55 |
public String getDescription() { |
|
56 |
return this.description; |
|
57 |
} |
|
58 |
|
|
59 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
60 |
state.set("name", this.name); |
|
61 |
state.set("description", this.description); |
|
62 |
state.set("explorer", this.explorer); |
|
63 |
} |
|
64 |
|
|
65 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
66 |
this.description = state.getString("description"); |
|
67 |
this.name = state.getString("name"); |
|
68 |
this.explorer = (DataServerExplorerParameters) state.get("explorer"); |
|
69 |
} |
|
70 |
|
|
71 |
public static void registerPersistenceDefinition() { |
|
72 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
73 |
if ( manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null ) { |
|
74 |
DynStruct definition |
|
75 |
= manager.addDefinition(DefaultDataServerExplorerPoolEntry.class, |
|
76 |
PERSISTENCE_DEFINITION_NAME, PERSISTENCE_DEFINITION_NAME |
|
77 |
+ " Persistent definition", null, null); |
|
78 |
|
|
79 |
definition.addDynFieldString("name") |
|
80 |
.setMandatory(true) |
|
81 |
.setPersistent(true); |
|
82 |
|
|
83 |
definition.addDynFieldString("description") |
|
84 |
.setMandatory(false) |
|
85 |
.setPersistent(true); |
|
86 |
|
|
87 |
definition.addDynFieldObject("explorer") |
|
88 |
.setClassOfValue(DataServerExplorerParameters.class) |
|
89 |
.setMandatory(true) |
|
90 |
.setPersistent(true); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
} |
Also available in: Unified diff