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 / feature / impl / DefaultEditableFeatureAttributeDescriptor.java @ 40559
History | View | Annotate | Download (7.49 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.feature.impl; |
25 | |||
26 | import java.util.HashMap; |
||
27 | |||
28 | import org.cresques.cts.IProjection; |
||
29 | |||
30 | import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
||
31 | import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeIntegrityException; |
||
32 | import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeSizeException; |
||
33 | import org.gvsig.fmap.geom.type.GeometryType; |
||
34 | import org.gvsig.tools.ToolsLocator; |
||
35 | import org.gvsig.tools.evaluator.Evaluator; |
||
36 | |||
37 | public class DefaultEditableFeatureAttributeDescriptor extends |
||
38 | DefaultFeatureAttributeDescriptor implements
|
||
39 | EditableFeatureAttributeDescriptor { |
||
40 | |||
41 | private DefaultFeatureAttributeDescriptor source;
|
||
42 | private boolean hasStrongChanges; |
||
43 | private String originalName = null; |
||
44 | |||
45 | protected DefaultEditableFeatureAttributeDescriptor(
|
||
46 | DefaultFeatureAttributeDescriptor other) { |
||
47 | super(other);
|
||
48 | if (other instanceof DefaultEditableFeatureAttributeDescriptor) { |
||
49 | DefaultEditableFeatureAttributeDescriptor other_edi = |
||
50 | (DefaultEditableFeatureAttributeDescriptor) other; |
||
51 | originalName = other_edi.getOriginalName(); |
||
52 | this.source = other_edi.getSource();
|
||
53 | } else {
|
||
54 | this.source = other;
|
||
55 | } |
||
56 | hasStrongChanges = false;
|
||
57 | } |
||
58 | |||
59 | public DefaultEditableFeatureAttributeDescriptor() {
|
||
60 | super();
|
||
61 | this.source = null; |
||
62 | hasStrongChanges = false;
|
||
63 | } |
||
64 | |||
65 | public DefaultFeatureAttributeDescriptor getSource() {
|
||
66 | return this.source; |
||
67 | } |
||
68 | |||
69 | public void fixAll() { |
||
70 | } |
||
71 | |||
72 | public void checkIntegrity() throws AttributeFeatureTypeIntegrityException { |
||
73 | AttributeFeatureTypeIntegrityException ex = |
||
74 | new AttributeFeatureTypeIntegrityException(getName());
|
||
75 | if (this.size < 0) { |
||
76 | ex.add(new AttributeFeatureTypeSizeException(this.size)); |
||
77 | } |
||
78 | |||
79 | // TODO: a?adir resto de comprobaciones de integridad.
|
||
80 | |||
81 | if (ex.size() > 0) { |
||
82 | throw ex;
|
||
83 | } |
||
84 | } |
||
85 | |||
86 | public EditableFeatureAttributeDescriptor setAllowNull(boolean allowNull) { |
||
87 | this.allowNull = allowNull;
|
||
88 | if (this.evaluator != null) { |
||
89 | hasStrongChanges = true;
|
||
90 | } |
||
91 | return this; |
||
92 | } |
||
93 | |||
94 | public EditableFeatureAttributeDescriptor setDataType(int type) { |
||
95 | this.dataType = ToolsLocator.getDataTypesManager().get(type);
|
||
96 | if (this.evaluator != null) { |
||
97 | hasStrongChanges = true;
|
||
98 | } |
||
99 | return this; |
||
100 | } |
||
101 | |||
102 | public EditableFeatureAttributeDescriptor setDefaultValue(
|
||
103 | Object defaultValue) {
|
||
104 | this.defaultValue = defaultValue;
|
||
105 | if (this.evaluator != null) { |
||
106 | hasStrongChanges = true;
|
||
107 | } |
||
108 | return this; |
||
109 | } |
||
110 | |||
111 | public EditableFeatureAttributeDescriptor setEvaluator(Evaluator evaluator) {
|
||
112 | if (this.evaluator != null && evaluator == null) { |
||
113 | hasStrongChanges = true;
|
||
114 | } |
||
115 | this.evaluator = evaluator;
|
||
116 | return this; |
||
117 | } |
||
118 | |||
119 | public EditableFeatureAttributeDescriptor setGeometryType(int type) { |
||
120 | this.geometryType = type;
|
||
121 | this.geomType = null; |
||
122 | return this; |
||
123 | } |
||
124 | |||
125 | public EditableFeatureAttributeDescriptor setGeometrySubType(int subType) { |
||
126 | this.geometrySubType = subType;
|
||
127 | this.geomType = null; |
||
128 | return this; |
||
129 | } |
||
130 | |||
131 | public EditableFeatureAttributeDescriptor setGeometryType(
|
||
132 | GeometryType geometryType) { |
||
133 | this.geomType = geometryType;
|
||
134 | this.geometryType = this.geomType.getType(); |
||
135 | this.geometrySubType = this.geomType.getSubType(); |
||
136 | if (this.evaluator != null) { |
||
137 | hasStrongChanges = true;
|
||
138 | } |
||
139 | return this; |
||
140 | } |
||
141 | |||
142 | public EditableFeatureAttributeDescriptor setIsPrimaryKey(
|
||
143 | boolean isPrimaryKey) {
|
||
144 | this.primaryKey = isPrimaryKey;
|
||
145 | if (this.evaluator != null) { |
||
146 | hasStrongChanges = true;
|
||
147 | } |
||
148 | return this; |
||
149 | } |
||
150 | |||
151 | public EditableFeatureAttributeDescriptor setIsReadOnly(boolean isReadOnly) { |
||
152 | this.readOnly = isReadOnly;
|
||
153 | if (this.evaluator != null) { |
||
154 | hasStrongChanges = true;
|
||
155 | } |
||
156 | return this; |
||
157 | } |
||
158 | |||
159 | public EditableFeatureAttributeDescriptor setMaximumOccurrences(
|
||
160 | int maximumOccurrences) {
|
||
161 | this.maximumOccurrences = maximumOccurrences;
|
||
162 | if (this.evaluator != null) { |
||
163 | hasStrongChanges = true;
|
||
164 | } |
||
165 | return this; |
||
166 | } |
||
167 | |||
168 | public EditableFeatureAttributeDescriptor setMinimumOccurrences(
|
||
169 | int minimumOccurrences) {
|
||
170 | this.minimumOccurrences = minimumOccurrences;
|
||
171 | if (this.evaluator != null) { |
||
172 | hasStrongChanges = true;
|
||
173 | } |
||
174 | return this; |
||
175 | } |
||
176 | |||
177 | public EditableFeatureAttributeDescriptor setName(String name) { |
||
178 | if (originalName == null) { |
||
179 | originalName = this.name;
|
||
180 | hasStrongChanges = true;
|
||
181 | } |
||
182 | this.name = name;
|
||
183 | if (this.evaluator != null) { |
||
184 | hasStrongChanges = true;
|
||
185 | } |
||
186 | return this; |
||
187 | } |
||
188 | |||
189 | public String getOriginalName() { |
||
190 | return originalName;
|
||
191 | } |
||
192 | |||
193 | public EditableFeatureAttributeDescriptor setObjectClass(Class theClass) { |
||
194 | this.objectClass = theClass;
|
||
195 | if (this.evaluator != null) { |
||
196 | hasStrongChanges = true;
|
||
197 | } |
||
198 | return this; |
||
199 | } |
||
200 | |||
201 | public EditableFeatureAttributeDescriptor setPrecision(int precision) { |
||
202 | this.precision = precision;
|
||
203 | if (this.evaluator != null) { |
||
204 | hasStrongChanges = true;
|
||
205 | } |
||
206 | return this; |
||
207 | } |
||
208 | |||
209 | public EditableFeatureAttributeDescriptor setSRS(IProjection SRS) {
|
||
210 | this.SRS = SRS;
|
||
211 | if (this.evaluator != null) { |
||
212 | hasStrongChanges = true;
|
||
213 | } |
||
214 | return this; |
||
215 | } |
||
216 | |||
217 | public EditableFeatureAttributeDescriptor setSize(int size) { |
||
218 | this.size = size;
|
||
219 | if (this.evaluator != null) { |
||
220 | hasStrongChanges = true;
|
||
221 | } |
||
222 | return this; |
||
223 | } |
||
224 | |||
225 | public boolean hasStrongChanges() { |
||
226 | return hasStrongChanges;
|
||
227 | } |
||
228 | |||
229 | public EditableFeatureAttributeDescriptor setAdditionalInfo(
|
||
230 | String infoName, Object value) { |
||
231 | if (this.additionalInfo == null) { |
||
232 | this.additionalInfo = new HashMap(); |
||
233 | } |
||
234 | this.additionalInfo.put(infoName, value);
|
||
235 | return this; |
||
236 | } |
||
237 | |||
238 | public EditableFeatureAttributeDescriptor setIsAutomatic(boolean isAutomatic) { |
||
239 | this.isAutomatic = isAutomatic;
|
||
240 | return this; |
||
241 | } |
||
242 | |||
243 | public EditableFeatureAttributeDescriptor setIsTime(boolean isTime) { |
||
244 | this.isTime = isTime;
|
||
245 | if( this.evaluator != null ) { |
||
246 | hasStrongChanges=true;
|
||
247 | } |
||
248 | return this; |
||
249 | } |
||
250 | } |