Revision 42533
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/feature/FeatureStoreProviderFactory.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
public interface FeatureStoreProviderFactory extends DataStoreProviderFactory { |
33 | 33 |
|
34 |
|
|
34 |
|
|
35 | 35 |
/** |
36 | 36 |
* Returns a list of {@link DataTypes} supported |
37 | 37 |
* by this FeatureStoreProviderFactory |
38 |
*
|
|
38 |
* |
|
39 | 39 |
* @return list of {@link DataTypes} supported |
40 | 40 |
* by this FeatureStoreProviderFactory or null |
41 | 41 |
* if it has no restrictions on data types |
42 | 42 |
*/ |
43 | 43 |
public List getSupportedDataTypes(); |
44 |
|
|
44 |
|
|
45 | 45 |
/** |
46 | 46 |
* {@link Geometry} |
47 |
*
|
|
47 |
* |
|
48 | 48 |
* Return a matrix (list of pairs) (int, int] |
49 | 49 |
* [Geometry.TYPE,GEOMETRY.SUBTYPE] |
50 | 50 |
* with types and subtypes supported by this provider. |
51 |
*
|
|
51 |
* |
|
52 | 52 |
* If the provider has not vector support |
53 | 53 |
* or has not restrictions over geometry types return null. |
54 |
*
|
|
54 |
* |
|
55 | 55 |
* @return Matrix of Geometry.TYPES, SUBTYPES or null |
56 | 56 |
*/ |
57 | 57 |
public List getSupportedGeometryTypesSubtypes(); |
58 |
|
|
58 |
|
|
59 | 59 |
/** |
60 |
*
|
|
60 |
* |
|
61 | 61 |
* @return whether this factory allows mandatory attributes |
62 |
* in the generated stores' feature types.
|
|
62 |
* in the generated stores' feature types. |
|
63 | 63 |
*/ |
64 | 64 |
public boolean allowsMandatoryAttributes(); |
65 |
|
|
65 |
|
|
66 | 66 |
/** |
67 |
*
|
|
67 |
* |
|
68 | 68 |
* @return whether this factory allows primary key attributes |
69 |
* in the generated stores' feature types.
|
|
69 |
* in the generated stores' feature types. |
|
70 | 70 |
*/ |
71 | 71 |
public boolean allowsPrimaryKeyAttributes(); |
72 |
|
|
72 |
|
|
73 | 73 |
/** |
74 |
*
|
|
74 |
* |
|
75 | 75 |
* @return a new instance of a default feature type |
76 | 76 |
* (changes to that feature type do not affect following calls) |
77 | 77 |
*/ |
78 | 78 |
public FeatureType createDefaultFeatureType(); |
79 |
|
|
79 |
|
|
80 | 80 |
/** |
81 |
*
|
|
81 |
* |
|
82 | 82 |
* @return whether stores created by this factory |
83 | 83 |
* allow several geometry types. |
84 | 84 |
* Actually redundant after adding |
85 | 85 |
* getSupportedGeometryTypesSubtypes()) |
86 | 86 |
*/ |
87 | 87 |
// public int allowMultipleGeometryTypes(); |
88 |
|
|
88 |
|
|
89 | 89 |
public int allowEditableFeatureType(); |
90 | 90 |
|
91 |
public int useLocalIndexesCanImprovePerformance(); |
|
91 |
public int useLocalIndexesCanImprovePerformance(); |
|
92 |
|
|
93 |
/** |
|
94 |
* Returns max size for attributes names |
|
95 |
* returns -1 if it is undefined |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
public int getMaxAttributeNameSize(); |
|
99 |
|
|
92 | 100 |
} |
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/DataStoreProviderFactory.java | ||
---|---|---|
28 | 28 |
import org.gvsig.tools.service.spi.ProviderFactory; |
29 | 29 |
|
30 | 30 |
public interface DataStoreProviderFactory extends ProviderFactory { |
31 |
|
|
31 |
|
|
32 | 32 |
public static final int UNKNOWN = 0; |
33 | 33 |
public static final int YES = 1; |
34 | 34 |
public static final int NO = 2; |
35 |
|
|
35 |
|
|
36 | 36 |
/** |
37 | 37 |
* Returns the name of the provider |
38 |
*
|
|
38 |
* |
|
39 | 39 |
* @return name of the provider |
40 | 40 |
*/ |
41 | 41 |
public String getName(); |
42 |
|
|
42 |
|
|
43 | 43 |
/** |
44 | 44 |
* Return a short descripion about the provider |
45 |
*
|
|
45 |
* |
|
46 | 46 |
* @return description about the provider |
47 | 47 |
*/ |
48 | 48 |
public String getDescription(); |
49 |
|
|
49 |
|
|
50 | 50 |
/** |
51 | 51 |
* The provider has read support |
52 |
*
|
|
52 |
* |
|
53 | 53 |
* @return YES if has read support |
54 | 54 |
*/ |
55 | 55 |
public int allowRead(); |
56 |
|
|
56 |
|
|
57 | 57 |
/** |
58 | 58 |
* The provider has write support |
59 |
*
|
|
59 |
* |
|
60 | 60 |
* @return YES if has write support |
61 | 61 |
*/ |
62 | 62 |
public int allowWrite(); |
63 | 63 |
|
64 | 64 |
/** |
65 | 65 |
* The provider can create new stores. |
66 |
*
|
|
66 |
* |
|
67 | 67 |
* @return YES if has creation support |
68 | 68 |
*/ |
69 | 69 |
public int allowCreate(); |
... | ... | |
71 | 71 |
/** |
72 | 72 |
* The provider has tabular support. |
73 | 73 |
* This support is the minimum requisite for a FeatureStore. |
74 |
*
|
|
74 |
* |
|
75 | 75 |
* @return YES if has write support |
76 | 76 |
*/ |
77 | 77 |
public int hasTabularSupport(); |
78 | 78 |
|
79 | 79 |
/** |
80 | 80 |
* The provider has vectorial support. |
81 |
*
|
|
81 |
* |
|
82 | 82 |
* @return YES if has vectorial support |
83 | 83 |
*/ |
84 | 84 |
public int hasVectorialSupport(); |
85 |
|
|
85 |
|
|
86 | 86 |
/** |
87 | 87 |
* The provider has raster support. |
88 |
*
|
|
88 |
* |
|
89 | 89 |
* @return YES if has raster support |
90 | 90 |
*/ |
91 | 91 |
public int hasRasterSupport(); |
92 |
|
|
92 |
|
|
93 | 93 |
/** |
94 | 94 |
* Builds a specific provider |
95 |
*
|
|
95 |
* |
|
96 | 96 |
* @return the provider |
97 | 97 |
*/ |
98 | 98 |
public DataStoreProvider createProvider(DataParameters parameters, DataStoreProviderServices providerServices) throws InitializeException; |
99 | 99 |
|
100 |
/** |
|
101 |
* Returns max size for attributes names |
|
102 |
* returns -1 if it is undefined |
|
103 |
* @return |
|
104 |
*/ |
|
105 |
public int getMaxAttributeNameSize(); |
|
106 |
|
|
100 | 107 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/AbstractFeatureStoreProviderFactory.java | ||
---|---|---|
45 | 45 |
public int allowMultipleGeometryTypes() { |
46 | 46 |
return UNKNOWN; |
47 | 47 |
} |
48 |
|
|
48 |
|
|
49 | 49 |
public int allowEditableFeatureType() { |
50 | 50 |
return UNKNOWN; |
51 | 51 |
} |
52 |
|
|
52 |
|
|
53 | 53 |
public List getSupportedDataTypes() { |
54 | 54 |
// null means all supported |
55 | 55 |
return null; |
56 | 56 |
} |
57 |
|
|
57 |
|
|
58 | 58 |
public List getSupportedGeometryTypesSubtypes() { |
59 | 59 |
// null means all supported |
60 | 60 |
return null; |
61 | 61 |
} |
62 |
|
|
62 |
|
|
63 | 63 |
public boolean allowsMandatoryAttributes() { |
64 | 64 |
return true; |
65 | 65 |
} |
66 |
|
|
66 |
|
|
67 | 67 |
public boolean allowsPrimaryKeyAttributes() { |
68 | 68 |
return true; |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
public int useLocalIndexesCanImprovePerformance() { |
72 | 72 |
return UNKNOWN; |
73 |
}
|
|
73 |
} |
|
74 | 74 |
|
75 | 75 |
/** |
76 | 76 |
* @return dummy feature type. Must be overridden by subclasses |
77 |
*
|
|
77 |
* |
|
78 | 78 |
*/ |
79 | 79 |
public FeatureType createDefaultFeatureType() { |
80 | 80 |
DataManager dm = DALLocator.getDataManager(); |
81 | 81 |
EditableFeatureType eft = dm.createFeatureType(); |
82 |
|
|
82 |
|
|
83 | 83 |
if (allowEditableFeatureType() == DataStoreProviderFactory.YES) { |
84 | 84 |
return eft; |
85 | 85 |
} else { |
... | ... | |
87 | 87 |
} |
88 | 88 |
} |
89 | 89 |
|
90 |
@Override |
|
91 |
public int getMaxAttributeNameSize() { |
|
92 |
return -1; |
|
93 |
} |
|
90 | 94 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/SHPStoreProviderFactory.java | ||
---|---|---|
43 | 43 |
import org.gvsig.fmap.dal.feature.FeatureType; |
44 | 44 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory; |
45 | 45 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
46 |
import org.gvsig.fmap.dal.store.dbf.utils.DbaseFile; |
|
46 | 47 |
import org.gvsig.fmap.geom.Geometry; |
47 | 48 |
import org.gvsig.fmap.geom.GeometryLocator; |
48 | 49 |
import org.gvsig.fmap.geom.type.GeometryType; |
... | ... | |
53 | 54 |
public class SHPStoreProviderFactory extends AbstractFeatureStoreProviderFactory implements FeatureStoreProviderFactory{ |
54 | 55 |
|
55 | 56 |
private static final Logger logger = LoggerFactory.getLogger(SHPStoreProviderFactory.class); |
56 |
|
|
57 |
|
|
57 | 58 |
public static final String DEFAULT_GEOMETRY_FIELD_NAME = "GEOMETRY"; |
58 | 59 |
public static final int DEFAULT_GEOMETRY_TYPE = Geometry.TYPES.SURFACE; |
59 | 60 |
public static final int DEFAULT_GEOMETRY_SUBTYPE = Geometry.SUBTYPES.GEOM2D; |
60 |
|
|
61 |
|
|
61 | 62 |
protected SHPStoreProviderFactory(String name, String description) { |
62 | 63 |
super(name, description); |
63 | 64 |
} |
... | ... | |
71 | 72 |
public DynObject createParameters() { |
72 | 73 |
return new SHPStoreParameters(); |
73 | 74 |
} |
74 |
|
|
75 |
|
|
75 | 76 |
public int allowCreate() { |
76 | 77 |
return YES; |
77 | 78 |
} |
78 |
|
|
79 |
|
|
79 | 80 |
public int allowWrite() { |
80 | 81 |
return YES; |
81 | 82 |
} |
... | ... | |
83 | 84 |
public int allowRead() { |
84 | 85 |
return YES; |
85 | 86 |
} |
86 |
|
|
87 |
|
|
87 | 88 |
public int hasRasterSupport() { |
88 | 89 |
return NO; |
89 | 90 |
} |
90 |
|
|
91 |
|
|
91 | 92 |
public int hasTabularSupport() { |
92 | 93 |
return YES; |
93 | 94 |
} |
94 |
|
|
95 |
|
|
95 | 96 |
public int hasVectorialSupport() { |
96 | 97 |
return YES; |
97 | 98 |
} |
... | ... | |
99 | 100 |
public int allowMultipleGeometryTypes() { |
100 | 101 |
return NO; |
101 | 102 |
} |
102 |
|
|
103 |
|
|
103 |
|
|
104 |
|
|
104 | 105 |
public int allowEditableFeatureType() { |
105 | 106 |
return YES; |
106 | 107 |
} |
... | ... | |
108 | 109 |
public int useLocalIndexesCanImprovePerformance() { |
109 | 110 |
return YES; |
110 | 111 |
} |
111 |
|
|
112 |
|
|
112 | 113 |
public List getSupportedDataTypes() { |
113 |
|
|
114 |
|
|
114 | 115 |
DataTypesManager manager = ToolsLocator.getDataTypesManager(); |
115 | 116 |
|
116 | 117 |
List resp = new ArrayList<Integer>(); |
... | ... | |
121 | 122 |
resp.add(manager.get(DataTypes.GEOMETRY)); |
122 | 123 |
return resp; |
123 | 124 |
} |
124 |
|
|
125 |
|
|
125 | 126 |
public List getSupportedGeometryTypesSubtypes() { |
126 | 127 |
// null means all supported |
127 | 128 |
int[] item = null; |
... | ... | |
131 | 132 |
item[0] = Geometry.TYPES.POINT; |
132 | 133 |
item[1] = Geometry.SUBTYPES.GEOM2D; |
133 | 134 |
resp.add(item); |
134 |
|
|
135 |
|
|
135 | 136 |
item = new int[2]; |
136 | 137 |
item[0] = Geometry.TYPES.CURVE; |
137 | 138 |
item[1] = Geometry.SUBTYPES.GEOM2D; |
138 | 139 |
resp.add(item); |
139 |
|
|
140 |
|
|
140 | 141 |
item = new int[2]; |
141 | 142 |
item[0] = Geometry.TYPES.SURFACE; |
142 | 143 |
item[1] = Geometry.SUBTYPES.GEOM2D; |
143 | 144 |
resp.add(item); |
144 |
|
|
145 |
|
|
145 | 146 |
item = new int[2]; |
146 | 147 |
item[0] = Geometry.TYPES.MULTIPOINT; |
147 | 148 |
item[1] = Geometry.SUBTYPES.GEOM2D; |
... | ... | |
151 | 152 |
item[0] = Geometry.TYPES.POINT; |
152 | 153 |
item[1] = Geometry.SUBTYPES.GEOM3D; |
153 | 154 |
resp.add(item); |
154 |
|
|
155 |
|
|
155 | 156 |
item = new int[2]; |
156 | 157 |
item[0] = Geometry.TYPES.CURVE; |
157 | 158 |
item[1] = Geometry.SUBTYPES.GEOM3D; |
158 | 159 |
resp.add(item); |
159 |
|
|
160 |
|
|
160 | 161 |
item = new int[2]; |
161 | 162 |
item[0] = Geometry.TYPES.SURFACE; |
162 | 163 |
item[1] = Geometry.SUBTYPES.GEOM3D; |
163 | 164 |
resp.add(item); |
164 |
|
|
165 |
|
|
165 | 166 |
item = new int[2]; |
166 | 167 |
item[0] = Geometry.TYPES.MULTIPOINT; |
167 | 168 |
item[1] = Geometry.SUBTYPES.GEOM3D; |
... | ... | |
171 | 172 |
item[0] = Geometry.TYPES.POINT; |
172 | 173 |
item[1] = Geometry.SUBTYPES.GEOM2DM; |
173 | 174 |
resp.add(item); |
174 |
|
|
175 |
|
|
175 | 176 |
item = new int[2]; |
176 | 177 |
item[0] = Geometry.TYPES.CURVE; |
177 | 178 |
item[1] = Geometry.SUBTYPES.GEOM2DM; |
178 | 179 |
resp.add(item); |
179 |
|
|
180 |
|
|
180 | 181 |
item = new int[2]; |
181 | 182 |
item[0] = Geometry.TYPES.SURFACE; |
182 | 183 |
item[1] = Geometry.SUBTYPES.GEOM2DM; |
183 | 184 |
resp.add(item); |
184 |
|
|
185 |
|
|
185 | 186 |
item = new int[2]; |
186 | 187 |
item[0] = Geometry.TYPES.MULTIPOINT; |
187 | 188 |
item[1] = Geometry.SUBTYPES.GEOM2DM; |
188 | 189 |
resp.add(item); |
189 | 190 |
// ====================================== |
190 |
|
|
191 |
|
|
191 | 192 |
return resp; |
192 | 193 |
} |
193 |
|
|
194 |
|
|
194 | 195 |
public boolean allowsMandatoryAttributes() { |
195 | 196 |
return false; |
196 | 197 |
} |
197 |
|
|
198 |
|
|
198 | 199 |
public boolean allowsPrimaryKeyAttributes() { |
199 | 200 |
return false; |
200 | 201 |
} |
201 | 202 |
|
202 | 203 |
/** |
203 | 204 |
* @return dummy feature type. Must be overridden by subclasses |
204 |
*
|
|
205 |
* |
|
205 | 206 |
*/ |
206 | 207 |
public FeatureType createDefaultFeatureType() { |
207 | 208 |
DataManager dm = DALLocator.getDataManager(); |
208 | 209 |
EditableFeatureType eft = dm.createFeatureType(); |
209 |
|
|
210 |
|
|
210 | 211 |
EditableFeatureAttributeDescriptor efatd = |
211 | 212 |
eft.add(DEFAULT_GEOMETRY_FIELD_NAME, DataTypes.GEOMETRY); |
212 | 213 |
|
... | ... | |
226 | 227 |
return eft.getNotEditableCopy(); |
227 | 228 |
} |
228 | 229 |
|
229 |
|
|
230 |
@Override |
|
231 |
public int getMaxAttributeNameSize() { |
|
232 |
return DbaseFile.MAX_FIELD_NAME_LENGTH; |
|
233 |
} |
|
230 | 234 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFStoreProviderFactory.java | ||
---|---|---|
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 |
package org.gvsig.fmap.dal.store.dbf; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.DataParameters; |
|
30 |
import org.gvsig.fmap.dal.DataStoreProvider; |
|
31 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
33 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory; |
|
34 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
35 |
import org.gvsig.fmap.dal.store.dbf.utils.DbaseFile; |
|
36 |
import org.gvsig.tools.ToolsLocator; |
|
37 |
import org.gvsig.tools.dataTypes.DataType; |
|
38 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
39 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
40 |
import org.gvsig.tools.dynobject.DynObject; |
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
public class DBFStoreProviderFactory extends AbstractFeatureStoreProviderFactory implements FeatureStoreProviderFactory{ |
|
45 |
|
|
46 |
private static final Logger logger = LoggerFactory.getLogger(DBFStoreProviderFactory.class); |
|
47 |
|
|
48 |
protected DBFStoreProviderFactory(String name, String description) { |
|
49 |
super(name, description); |
|
50 |
} |
|
51 |
|
|
52 |
public DataStoreProvider createProvider(DataParameters parameters, |
|
53 |
DataStoreProviderServices providerServices) |
|
54 |
throws InitializeException { |
|
55 |
return new DBFStoreProvider((DBFStoreParameters) parameters, providerServices); |
|
56 |
} |
|
57 |
|
|
58 |
public DynObject createParameters() { |
|
59 |
return new DBFStoreParameters(); |
|
60 |
} |
|
61 |
|
|
62 |
public int allowCreate() { |
|
63 |
return YES; |
|
64 |
} |
|
65 |
|
|
66 |
public int allowWrite() { |
|
67 |
return YES; |
|
68 |
} |
|
69 |
|
|
70 |
public int allowRead() { |
|
71 |
return YES; |
|
72 |
} |
|
73 |
|
|
74 |
public int hasRasterSupport() { |
|
75 |
return NO; |
|
76 |
} |
|
77 |
|
|
78 |
public int hasTabularSupport() { |
|
79 |
return YES; |
|
80 |
} |
|
81 |
|
|
82 |
public int hasVectorialSupport() { |
|
83 |
return NO; |
|
84 |
} |
|
85 |
|
|
86 |
public int allowMultipleGeometryTypes() { |
|
87 |
return NO; |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
public int allowEditableFeatureType() { |
|
92 |
return YES; |
|
93 |
} |
|
94 |
|
|
95 |
public int useLocalIndexesCanImprovePerformance() { |
|
96 |
return YES; |
|
97 |
} |
|
98 |
|
|
99 |
public List<DataType> getSupportedDataTypes() { |
|
100 |
|
|
101 |
DataTypesManager manager = ToolsLocator.getDataTypesManager(); |
|
102 |
|
|
103 |
ArrayList<DataType> resp = new ArrayList<DataType>(); |
|
104 |
resp.add(manager.get(DataTypes.STRING)); |
|
105 |
resp.add(manager.get(DataTypes.INT)); |
|
106 |
resp.add(manager.get(DataTypes.FLOAT)); |
|
107 |
resp.add(manager.get(DataTypes.DATE)); |
|
108 |
return resp; |
|
109 |
} |
|
110 |
|
|
111 |
public boolean allowsMandatoryAttributes() { |
|
112 |
return false; |
|
113 |
} |
|
114 |
|
|
115 |
public boolean allowsPrimaryKeyAttributes() { |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
public int getMaxAttributeNameSize() { |
|
120 |
return DbaseFile.MAX_FIELD_NAME_LENGTH; |
|
121 |
} |
|
122 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/DBFLibrary.java | ||
---|---|---|
92 | 92 |
|
93 | 93 |
try { |
94 | 94 |
if (!dataman.getStoreProviders().contains(DBFStoreProvider.NAME)) { |
95 |
dataman.registerStoreProvider(DBFStoreProvider.NAME, |
|
96 |
DBFStoreProvider.class, DBFStoreParameters.class); |
|
95 |
dataman.registerStoreProviderFactory(new DBFStoreProviderFactory(DBFStoreProvider.NAME, DBFStoreProvider.DESCRIPTION)); |
|
97 | 96 |
} |
98 | 97 |
} catch (RuntimeException e) { |
99 | 98 |
exs.add(e); |
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/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
36 | 36 |
import java.util.Set; |
37 | 37 |
|
38 | 38 |
import org.cresques.cts.IProjection; |
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 | 39 |
import org.gvsig.fmap.dal.DALLocator; |
43 | 40 |
import org.gvsig.fmap.dal.DataManager; |
44 | 41 |
import org.gvsig.fmap.dal.DataQuery; |
... | ... | |
145 | 142 |
import org.gvsig.tools.undo.UndoException; |
146 | 143 |
import org.gvsig.tools.undo.command.Command; |
147 | 144 |
import org.gvsig.tools.visitor.Visitor; |
145 |
import org.slf4j.Logger; |
|
146 |
import org.slf4j.LoggerFactory; |
|
148 | 147 |
|
149 | 148 |
public class DefaultFeatureStore extends AbstractDisposable implements |
150 | 149 |
DataStoreInitializer, FeatureStoreProviderServices, FeatureStore, Observer { |
... | ... | |
2189 | 2188 |
} |
2190 | 2189 |
return null; |
2191 | 2190 |
} |
2192 |
|
|
2191 |
|
|
2193 | 2192 |
public Iterator iterator() { |
2194 | 2193 |
try { |
2195 | 2194 |
return this.getFeatureSet().fastIterator(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
41 | 41 |
_Cannot_rename_geometry_field=No es posible renombrar el campo geom\u00E9trico |
42 | 42 |
_Please_insert_new_field_name=Introduzca el nombre del nuevo campo |
43 | 43 |
_Cannot_delete_geometry_field=No es posible eliminar el campo geom\u00E9trico |
44 |
_Name_too_long=Nombre demasiado largo |
|
44 | 45 |
_No_input_name=No se ha introducido un nombre |
45 | 46 |
_Find_and_select_duplicates=Detectar y seleccionar duplicados |
46 | 47 |
_No_repetitions_found=No se han encontrado repeticiones |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
41 | 41 |
_Cannot_rename_geometry_field=Renaming geometry field is not allowed |
42 | 42 |
_Please_insert_new_field_name=Insert new field name |
43 | 43 |
_Cannot_delete_geometry_field=Deleting geometry field is not allowed |
44 |
_Name_too_long=Name is too long |
|
44 | 45 |
_No_input_name=No input name |
45 | 46 |
_Find_and_select_duplicates=Find and select duplicates |
46 | 47 |
_No_repetitions_found=No repetitions found |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/CreateNewAttributePanel.java | ||
---|---|---|
51 | 51 |
|
52 | 52 |
/** |
53 | 53 |
* To create new FeatureAttributeDescriptor from the interface. |
54 |
*
|
|
54 |
* |
|
55 | 55 |
* @author Vicente Caballero Navarro |
56 |
*
|
|
56 |
* |
|
57 | 57 |
*/ |
58 | 58 |
public class CreateNewAttributePanel extends JPanel implements IWindow { |
59 | 59 |
|
60 | 60 |
/** |
61 |
*
|
|
61 |
* |
|
62 | 62 |
*/ |
63 | 63 |
private static final long serialVersionUID = 6447641307779709964L; |
64 | 64 |
private static final String DEFAULT_FIELD_LENGTH = "50"; |
... | ... | |
76 | 76 |
private JPanel jPanel = null; |
77 | 77 |
private AcceptCancelPanel jPanelOkCancel = null; |
78 | 78 |
private JPanel jPnlFields = null; |
79 |
private int maxAttributeNameSize=-1; |
|
79 | 80 |
private KeyListener checkInt = new KeyListener() { |
80 | 81 |
|
81 | 82 |
public void keyPressed(KeyEvent e) { |
... | ... | |
138 | 139 |
|
139 | 140 |
/** |
140 | 141 |
* This method initializes this |
141 |
*
|
|
142 |
* |
|
142 | 143 |
* @return void |
143 | 144 |
*/ |
144 | 145 |
private void initialize() { |
... | ... | |
151 | 152 |
|
152 | 153 |
/** |
153 | 154 |
* This method initializes jTxtFieldName |
154 |
*
|
|
155 |
* |
|
155 | 156 |
* @return javax.swing.JTextField |
156 | 157 |
*/ |
157 | 158 |
private JTextField getJTxtFieldName() { |
... | ... | |
164 | 165 |
|
165 | 166 |
/** |
166 | 167 |
* This method initializes jCboFieldType |
167 |
*
|
|
168 |
* |
|
168 | 169 |
* @return javax.swing.JComboBox |
169 | 170 |
*/ |
170 | 171 |
private JComboBox getJCboFieldType() { |
... | ... | |
219 | 220 |
|
220 | 221 |
/** |
221 | 222 |
* This method initializes jTxtFieldLength |
222 |
*
|
|
223 |
* |
|
223 | 224 |
* @return javax.swing.JTextField |
224 | 225 |
*/ |
225 | 226 |
private JTextField getJTxtFieldLength() { |
... | ... | |
234 | 235 |
|
235 | 236 |
/** |
236 | 237 |
* This method initializes jTxtFieldPrecision |
237 |
*
|
|
238 |
* |
|
238 | 239 |
* @return javax.swing.JTextField |
239 | 240 |
*/ |
240 | 241 |
private JTextField getJTxtFieldPrecision() { |
... | ... | |
250 | 251 |
|
251 | 252 |
/** |
252 | 253 |
* This method initializes jTxtDefaultValue |
253 |
*
|
|
254 |
* |
|
254 | 255 |
* @return javax.swing.JTextField |
255 | 256 |
*/ |
256 | 257 |
private JTextField getJTxtDefaultValue() { |
... | ... | |
271 | 272 |
Object defaultValueAttr = ""; |
272 | 273 |
|
273 | 274 |
nameAttr = getJTxtFieldName().getText(); |
274 |
|
|
275 |
|
|
275 | 276 |
if (nameAttr == null || nameAttr.length() == 0) { |
276 |
|
|
277 |
|
|
277 | 278 |
JOptionPane.showMessageDialog( |
278 | 279 |
this, |
279 | 280 |
Messages.getText("_No_input_name"), |
... | ... | |
281 | 282 |
JOptionPane.ERROR_MESSAGE); |
282 | 283 |
return null; |
283 | 284 |
} |
284 |
|
|
285 |
|
|
286 |
if (maxAttributeNameSize>0){ |
|
287 |
if (nameAttr.length()>maxAttributeNameSize){ |
|
288 |
JOptionPane.showMessageDialog( |
|
289 |
this, |
|
290 |
Messages.getText("_Name_too_long"), |
|
291 |
Messages.getText("_Rename_column"), |
|
292 |
JOptionPane.ERROR_MESSAGE); |
|
293 |
return null; |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
285 | 297 |
String strType = |
286 | 298 |
(String) getJCboFieldType().getModel().getSelectedItem(); |
287 | 299 |
typeAttr = ToolsLocator.getDataTypesManager().getType(strType); |
... | ... | |
323 | 335 |
|
324 | 336 |
/** |
325 | 337 |
* This method initializes jPanel |
326 |
*
|
|
338 |
* |
|
327 | 339 |
* @return javax.swing.JPanel |
328 | 340 |
*/ |
329 | 341 |
private JPanel getJPanel() { |
... | ... | |
338 | 350 |
|
339 | 351 |
/** |
340 | 352 |
* This method initializes jPanelOkCancel |
341 |
*
|
|
353 |
* |
|
342 | 354 |
* @return javax.swing.JPanel |
343 | 355 |
*/ |
344 | 356 |
private AcceptCancelPanel getJPanelOkCancel() { |
... | ... | |
358 | 370 |
|
359 | 371 |
/** |
360 | 372 |
* This method initializes jPnlFields |
361 |
*
|
|
373 |
* |
|
362 | 374 |
* @return javax.swing.JPanel |
363 | 375 |
*/ |
364 | 376 |
private JPanel getJPnlFields() { |
... | ... | |
427 | 439 |
return WindowInfo.DIALOG_PROFILE; |
428 | 440 |
} |
429 | 441 |
|
442 |
public void setMaxAttributeNameSize(int maxAttributeNameSize) { |
|
443 |
this.maxAttributeNameSize = maxAttributeNameSize; |
|
444 |
} |
|
445 |
|
|
430 | 446 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/FeatureTypeEditingPanel.java | ||
---|---|---|
52 | 52 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
53 | 53 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
54 | 54 |
import org.gvsig.app.project.documents.table.TableOperations; |
55 |
import org.gvsig.fmap.dal.DALLocator; |
|
56 |
import org.gvsig.fmap.dal.DataManager; |
|
55 | 57 |
import org.gvsig.fmap.dal.DataTypes; |
56 | 58 |
import org.gvsig.fmap.dal.exception.DataException; |
57 | 59 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
58 | 60 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
59 | 61 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
60 | 62 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
63 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
61 | 64 |
import org.gvsig.i18n.Messages; |
62 | 65 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
63 | 66 |
import org.slf4j.Logger; |
... | ... | |
65 | 68 |
|
66 | 69 |
/** |
67 | 70 |
* To modify FeatureTypes from the interface. |
68 |
*
|
|
71 |
* |
|
69 | 72 |
* @author Vicente Caballero Navarro |
70 |
*
|
|
73 |
* |
|
71 | 74 |
*/ |
72 | 75 |
public class FeatureTypeEditingPanel extends JPanel implements IWindow { |
73 | 76 |
|
... | ... | |
106 | 109 |
private class MyTableModel extends AbstractTableModel { |
107 | 110 |
|
108 | 111 |
/** |
109 |
*
|
|
112 |
* |
|
110 | 113 |
*/ |
111 | 114 |
private static final long serialVersionUID = -2847526298987536118L; |
112 | 115 |
|
... | ... | |
216 | 219 |
|
217 | 220 |
/** |
218 | 221 |
* This method initializes |
219 |
*
|
|
222 |
* |
|
220 | 223 |
* @throws DataException |
221 |
*
|
|
224 |
* |
|
222 | 225 |
*/ |
223 | 226 |
public FeatureTypeEditingPanel(FeatureStore fs) throws DataException { |
224 | 227 |
super(); |
... | ... | |
245 | 248 |
|
246 | 249 |
/** |
247 | 250 |
* This method initializes this |
248 |
*
|
|
251 |
* |
|
249 | 252 |
*/ |
250 | 253 |
private void initialize() { |
251 | 254 |
FlowLayout flowLayout = new FlowLayout(); |
... | ... | |
327 | 330 |
|
328 | 331 |
/** |
329 | 332 |
* This method initializes jScrollPane |
330 |
*
|
|
333 |
* |
|
331 | 334 |
* @return javax.swing.JScrollPane |
332 | 335 |
*/ |
333 | 336 |
private JScrollPane getJScrollPane() { |
... | ... | |
341 | 344 |
|
342 | 345 |
/** |
343 | 346 |
* This method initializes jTableFields |
344 |
*
|
|
347 |
* |
|
345 | 348 |
* @return javax.swing.JTable |
346 | 349 |
*/ |
347 | 350 |
private JTable getJTableFields() { |
... | ... | |
383 | 386 |
|
384 | 387 |
/** |
385 | 388 |
* This method initializes jBtnNewField |
386 |
*
|
|
389 |
* |
|
387 | 390 |
* @return javax.swing.JButton |
388 | 391 |
*/ |
389 | 392 |
private JButton getJBtnNewField() { |
... | ... | |
411 | 414 |
|
412 | 415 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
413 | 416 |
ActionListener okAction; |
417 |
DataManager dataManager = DALLocator.getDataManager(); |
|
418 |
FeatureStoreProviderFactory factory = |
|
419 |
(FeatureStoreProviderFactory) dataManager. |
|
420 |
getStoreProviderFactory(featureStore.getProviderName()); |
|
421 |
panelNewField.setMaxAttributeNameSize(factory.getMaxAttributeNameSize()); |
|
414 | 422 |
okAction = new java.awt.event.ActionListener() { |
415 | 423 |
|
416 | 424 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
... | ... | |
456 | 464 |
|
457 | 465 |
/** |
458 | 466 |
* This method initializes jButton |
459 |
*
|
|
467 |
* |
|
460 | 468 |
* @return javax.swing.JButton |
461 | 469 |
*/ |
462 | 470 |
private JButton getJBtnDelete() { |
... | ... | |
475 | 483 |
for (int i = selecteds.length - 1; i >= 0; i--) { |
476 | 484 |
String fieldName = |
477 | 485 |
(String) tm.getValueAt(selecteds[i], 0); |
478 |
|
|
486 |
|
|
479 | 487 |
String old_geom_fld = editableType.getDefaultGeometryAttributeName(); |
480 | 488 |
if (old_geom_fld.compareTo(fieldName) == 0) { |
481 | 489 |
JOptionPane.showMessageDialog( |
... | ... | |
498 | 506 |
|
499 | 507 |
/** |
500 | 508 |
* This method initializes jBtnRenameField |
501 |
*
|
|
509 |
* |
|
502 | 510 |
* @return javax.swing.JButton |
503 | 511 |
*/ |
504 | 512 |
private JButton getJBtnRenameField() { |
... | ... | |
517 | 525 |
for (int i = selecteds.length - 1; i >= 0; i--) { |
518 | 526 |
String fieldName = |
519 | 527 |
(String) tm.getValueAt(selecteds[i], 0); |
520 |
|
|
528 |
|
|
521 | 529 |
String old_geom_fld = editableType.getDefaultGeometryAttributeName(); |
522 | 530 |
/* |
523 | 531 |
* old_geom_fld is null if we are dealing with |
... | ... | |
541 | 549 |
if (newName == null) { |
542 | 550 |
continue; |
543 | 551 |
} |
544 |
|
|
552 |
|
|
545 | 553 |
if (newName.length() == 0) { |
546 | 554 |
JOptionPane.showMessageDialog( |
547 | 555 |
jTableFields, |
... | ... | |
550 | 558 |
JOptionPane.ERROR_MESSAGE); |
551 | 559 |
continue; |
552 | 560 |
} |
553 |
|
|
561 |
|
|
554 | 562 |
if (editableType.getIndex(newName) != -1) { |
555 | 563 |
NotificationManager.showMessageInfo( |
556 | 564 |
PluginServices.getText(this, |
557 | 565 |
"field_already_exists"), null); |
558 | 566 |
continue; |
559 | 567 |
} |
560 |
|
|
568 |
|
|
561 | 569 |
try { |
562 | 570 |
EditableFeatureAttributeDescriptor efad = |
563 | 571 |
(EditableFeatureAttributeDescriptor) |
564 | 572 |
editableType.getAttributeDescriptor(fieldName); |
565 | 573 |
efad.setName(newName); |
566 |
|
|
574 |
|
|
567 | 575 |
} catch (Exception de) { |
568 | 576 |
JOptionPane.showMessageDialog( |
569 | 577 |
jTableFields, |
... | ... | |
582 | 590 |
|
583 | 591 |
/** |
584 | 592 |
* This method initializes jBtnOK |
585 |
*
|
|
593 |
* |
|
586 | 594 |
* @return javax.swing.JButton |
587 | 595 |
*/ |
588 | 596 |
private JButton getJBtnOK() { |
... | ... | |
609 | 617 |
|
610 | 618 |
/** |
611 | 619 |
* This method initializes jButton |
612 |
*
|
|
620 |
* |
|
613 | 621 |
* @return javax.swing.JButton |
614 | 622 |
*/ |
615 | 623 |
private JButton getJBtnCancel() { |
... | ... | |
631 | 639 |
|
632 | 640 |
/** |
633 | 641 |
* This method initializes jPanelButtons |
634 |
*
|
|
642 |
* |
|
635 | 643 |
* @return javax.swing.JPanel |
636 | 644 |
*/ |
637 | 645 |
private JPanel getJPanelButtons() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableOperations.java | ||
---|---|---|
44 | 44 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
45 | 45 |
import org.gvsig.editing.EditingNotification; |
46 | 46 |
import org.gvsig.editing.EditingNotificationManager; |
47 |
import org.gvsig.fmap.dal.DALLocator; |
|
48 |
import org.gvsig.fmap.dal.DataManager; |
|
47 | 49 |
import org.gvsig.fmap.dal.DataTypes; |
48 | 50 |
import org.gvsig.fmap.dal.exception.DataException; |
49 | 51 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
... | ... | |
54 | 56 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
55 | 57 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
56 | 58 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
59 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
57 | 60 |
import org.gvsig.fmap.dal.feature.FeatureType; |
58 | 61 |
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureTypeException; |
59 | 62 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
... | ... | |
64 | 67 |
|
65 | 68 |
/** |
66 | 69 |
* Feature Table Operations. |
67 |
*
|
|
70 |
* |
|
68 | 71 |
* @author Vicente Caballero Navarro |
69 |
*
|
|
72 |
* |
|
70 | 73 |
*/ |
71 | 74 |
public class TableOperations { |
72 | 75 |
|
73 | 76 |
private static Logger logger = LoggerFactory.getLogger(TableOperations.class); |
74 |
|
|
77 |
|
|
75 | 78 |
public static final int MAX_FIELD_LENGTH = 254; |
76 | 79 |
private static TableOperations fto = null; |
77 | 80 |
private ArrayList<Feature> selectedFeatures = new ArrayList<Feature>(); |
78 | 81 |
private boolean cutting = false; |
79 |
|
|
82 |
|
|
80 | 83 |
private FeatureTableDocumentPanel tablePanel = null; |
81 | 84 |
private FeatureStore featureStore; |
82 | 85 |
|
... | ... | |
148 | 151 |
} |
149 | 152 |
|
150 | 153 |
public void deleteFeatures() throws DataException { |
151 |
|
|
154 |
|
|
152 | 155 |
FeatureTableModel _ftm = this.tablePanel.getTablePanel().getTableModel(); |
153 | 156 |
List<TableModelListener> tmll = removeTableModelListeners(_ftm); |
154 | 157 |
DisposableIterator feat_iter = null; |
155 | 158 |
Feature feat = null; |
156 | 159 |
try { |
157 |
|
|
158 |
|
|
160 |
|
|
161 |
|
|
159 | 162 |
FeatureSelection selection = featureStore.createFeatureSelection(); |
160 | 163 |
selection.select((FeatureSet) featureStore.getSelection()); |
161 | 164 |
feat_iter = selection.fastIterator(); |
... | ... | |
171 | 174 |
if (feat_iter != null) { |
172 | 175 |
feat_iter.dispose(); |
173 | 176 |
} |
174 |
|
|
177 |
|
|
175 | 178 |
addTableModelListeners(_ftm, tmll); |
176 | 179 |
} |
177 | 180 |
} |
... | ... | |
183 | 186 |
private void addTableModelListeners( |
184 | 187 |
FeatureTableModel _model, |
185 | 188 |
List<TableModelListener> _list) { |
186 |
|
|
189 |
|
|
187 | 190 |
Iterator<TableModelListener> iter = _list.iterator(); |
188 | 191 |
while (iter.hasNext()) { |
189 | 192 |
_model.addTableModelListener(iter.next()); |
... | ... | |
197 | 200 |
* @return |
198 | 201 |
*/ |
199 | 202 |
private List<TableModelListener> removeTableModelListeners(FeatureTableModel ftm) { |
200 |
|
|
203 |
|
|
201 | 204 |
TableModelListener[] ll = ftm.getListeners(TableModelListener.class); |
202 | 205 |
List<TableModelListener> resp = new ArrayList<TableModelListener>(); |
203 |
|
|
206 |
|
|
204 | 207 |
int n = ll.length; |
205 | 208 |
for (int i=0; i<n; i++) { |
206 | 209 |
resp.add(ll[i]); |
... | ... | |
264 | 267 |
feature); |
265 | 268 |
return true; |
266 | 269 |
} |
267 |
|
|
270 |
|
|
268 | 271 |
private boolean updateFeatureType(EditableFeatureType featureType) throws DataException { |
269 |
|
|
272 |
|
|
270 | 273 |
EditingNotificationManager editingNotification = MapControlLocator.getEditingNotificationManager(); |
271 | 274 |
EditingNotification notification = editingNotification.notifyObservers( |
272 | 275 |
this, |
... | ... | |
299 | 302 |
} |
300 | 303 |
|
301 | 304 |
public void insertAttributes(FeatureTable table) throws DataException { |
302 |
|
|
305 |
|
|
303 | 306 |
EditableFeatureType eft = featureStore.getDefaultFeatureType().getEditable(); |
304 | 307 |
|
305 | 308 |
List<String> tmpfnames = new ArrayList<String>(); |
... | ... | |
311 | 314 |
|
312 | 315 |
CreateNewAttributePanel panelNewField = new CreateNewAttributePanel(); |
313 | 316 |
panelNewField.setCurrentFieldNames(tmpfnames.toArray(new String[0])); |
317 |
DataManager dataManager = DALLocator.getDataManager(); |
|
318 |
FeatureStoreProviderFactory factory = |
|
319 |
(FeatureStoreProviderFactory) dataManager. |
|
320 |
getStoreProviderFactory(featureStore.getProviderName()); |
|
321 |
panelNewField.setMaxAttributeNameSize(factory.getMaxAttributeNameSize()); |
|
314 | 322 |
panelNewField.setOkAction(new NewFieldActionListener(panelNewField, eft)); |
315 | 323 |
ApplicationLocator.getManager().getUIManager().addWindow(panelNewField); |
316 | 324 |
featureStore.update(eft); |
317 | 325 |
} |
318 | 326 |
|
319 | 327 |
public void renameAttributes(FeatureTable table) throws DataException { |
320 |
|
|
328 |
|
|
321 | 329 |
FeatureType _ft = featureStore.getDefaultFeatureType(); |
322 | 330 |
|
323 | 331 |
FeatureAttributeDescriptor[] selecteds = |
... | ... | |
339 | 347 |
Messages.getText("field_already_exists"), null); |
340 | 348 |
return; |
341 | 349 |
} |
342 |
|
|
350 |
|
|
343 | 351 |
renameAttribute(featureStore, selecteds[i].getName(), newName); |
344 | 352 |
} |
345 |
|
|
353 |
|
|
346 | 354 |
// featureStore.finishEditing(); |
347 | 355 |
// featureStore.edit(FeatureStore.MODE_FULLEDIT); |
348 | 356 |
} |
349 | 357 |
|
350 | 358 |
/** |
351 | 359 |
* This method renames a field in three steps: |
352 |
*
|
|
360 |
* |
|
353 | 361 |
* (1) add new field using type and size of old field. |
354 | 362 |
* (2) copy value from old field to new field. |
355 | 363 |
* (3) remove old field. |
356 |
*
|
|
364 |
* |
|
357 | 365 |
* @param fs |
358 | 366 |
* @param name |
359 | 367 |
* @param newName |
... | ... | |
365 | 373 |
FeatureType dft = null; |
366 | 374 |
try { |
367 | 375 |
dft = fs.getDefaultFeatureType(); |
368 |
|
|
376 |
|
|
369 | 377 |
if (dft instanceof EditableFeatureType) { |
370 | 378 |
eft = (EditableFeatureType) dft; |
371 | 379 |
} else { |
372 | 380 |
eft = dft.getEditable(); |
373 | 381 |
} |
374 |
|
|
382 |
|
|
375 | 383 |
EditableFeatureAttributeDescriptor efad = |
376 | 384 |
(EditableFeatureAttributeDescriptor) eft.getAttributeDescriptor(name); |
377 | 385 |
efad.setName(newName); |
378 | 386 |
fs.update(eft); |
379 |
|
|
387 |
|
|
380 | 388 |
} catch (DataException de) { |
381 |
|
|
389 |
|
|
382 | 390 |
Component root_comp = |
383 | 391 |
ApplicationLocator.getManager().getRootComponent(); |
384 | 392 |
|
... | ... | |
407 | 415 |
// did not even add new field |
408 | 416 |
return false; |
409 | 417 |
} |
410 |
|
|
418 |
|
|
411 | 419 |
boolean error_when_inserting = false; |
412 | 420 |
try { |
413 | 421 |
// ========== copy value old field -> new field |
... | ... | |
424 | 432 |
fset.update(efeat); |
425 | 433 |
} |
426 | 434 |
diter.dispose(); |
427 |
|
|
435 |
|
|
428 | 436 |
// Closing editing to check that store admits new field |
429 | 437 |
fs.finishEditing(); |
430 | 438 |
} catch (DataException ex) { |
431 |
|
|
439 |
|
|
432 | 440 |
logger.info("Error while renaming att to: " + newName, ex); |
433 | 441 |
String final_msg = getLastMessage(ex); |
434 | 442 |
JOptionPane.showMessageDialog( |
... | ... | |
439 | 447 |
JOptionPane.ERROR_MESSAGE); |
440 | 448 |
error_when_inserting = true; |
441 | 449 |
} |
442 |
|
|
450 |
|
|
443 | 451 |
if (error_when_inserting) { |
444 | 452 |
try { |
445 | 453 |
// Trying to remove new field and leave table as it was |
... | ... | |
452 | 460 |
// Not changed |
453 | 461 |
return false; |
454 | 462 |
} |
455 |
|
|
456 | 463 |
|
464 |
|
|
457 | 465 |
try { |
458 | 466 |
// Finally reopen editing and delete old field |
459 | 467 |
fs.edit(FeatureStore.MODE_FULLEDIT); |
460 | 468 |
eft = fs.getDefaultFeatureType().getEditable(); |
461 | 469 |
eft.remove(name); |
462 | 470 |
fs.update(eft); |
463 |
|
|
471 |
|
|
464 | 472 |
} catch (DataException ex) { |
465 | 473 |
logger.info("Unable to rename attribute (" + name + " --> " + newName + ")", ex); |
466 | 474 |
ApplicationLocator.getManager().message( |
... | ... | |
472 | 480 |
*/ |
473 | 481 |
|
474 | 482 |
} |
475 |
|
|
476 | 483 |
|
477 | 484 |
|
485 |
|
|
478 | 486 |
/** |
479 | 487 |
* Renames field in feature store |
480 |
*
|
|
488 |
* |
|
481 | 489 |
* @param fs |
482 | 490 |
* @param oldname |
483 | 491 |
* @param newname |
484 |
* @return
|
|
492 |
* @return |
|
485 | 493 |
* @throws DataException |
486 | 494 |
*/ |
487 | 495 |
public static void renameColumn(FeatureStore fs, |
488 | 496 |
String oldname, String newname) throws DataException { |
489 |
|
|
497 |
|
|
490 | 498 |
FeatureType _ft = fs.getDefaultFeatureType(); |
491 | 499 |
if (_ft.getIndex(newname) != -1) { |
492 | 500 |
throw new StoreUpdateFeatureTypeException( |
... | ... | |
496 | 504 |
renameAttribute(fs, oldname, newname); |
497 | 505 |
// fs.finishEditing(); |
498 | 506 |
} |
499 |
|
|
507 |
|
|
500 | 508 |
public class NewFieldActionListener implements ActionListener { |
501 | 509 |
|
502 | 510 |
private CreateNewAttributePanel panel = null; |
503 | 511 |
private EditableFeatureType eft = null; |
504 |
|
|
512 |
|
|
505 | 513 |
public NewFieldActionListener(CreateNewAttributePanel p, EditableFeatureType t) { |
506 | 514 |
eft = t; |
507 | 515 |
panel = p; |
508 | 516 |
} |
509 |
|
|
517 |
|
|
510 | 518 |
public void actionPerformed(ActionEvent e) { |
511 | 519 |
try { |
512 | 520 |
EditableFeatureAttributeDescriptor ead = panel.loadFieldDescription(eft); |
... | ... | |
527 | 535 |
} catch (ParseException e2) { |
528 | 536 |
NotificationManager.addError(e2); |
529 | 537 |
} |
530 |
|
|
538 |
|
|
531 | 539 |
} |
532 |
|
|
540 |
|
|
533 | 541 |
} |
534 | 542 |
|
535 | 543 |
} |
Also available in: Unified diff