Revision 44159
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/main/java/org/gvsig/app/join/dal/feature/JoinTransform.java | ||
---|---|---|
30 | 30 |
import java.util.List; |
31 | 31 |
import java.util.Map; |
32 | 32 |
import java.util.Map.Entry; |
33 |
import org.apache.commons.lang3.StringUtils; |
|
33 | 34 |
import org.gvsig.fmap.dal.DataTypes; |
34 | 35 |
|
35 | 36 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
51 | 52 |
import org.gvsig.tools.evaluator.EvaluatorData; |
52 | 53 |
import org.gvsig.tools.evaluator.EvaluatorException; |
53 | 54 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
55 |
import org.gvsig.tools.observer.Observer; |
|
54 | 56 |
import org.gvsig.tools.persistence.PersistenceManager; |
55 | 57 |
import org.gvsig.tools.persistence.PersistentState; |
56 | 58 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
... | ... | |
156 | 158 |
|
157 | 159 |
} |
158 | 160 |
|
161 |
private boolean containsIgnoreCase(List<String>l, String item) { |
|
162 |
for (String x : l) { |
|
163 |
if( StringUtils.equalsIgnoreCase(item, x) ) { |
|
164 |
return true; |
|
165 |
} |
|
166 |
} |
|
167 |
return false; |
|
168 |
} |
|
169 |
|
|
159 | 170 |
@Override |
160 | 171 |
public void setUp() throws Exception { |
161 | 172 |
|
... | ... | |
201 | 212 |
addFeatureType(editableFeatureType, featureType2.getAttributeDescriptor(attrs[i]), prefix2, store2NamesMap); |
202 | 213 |
} |
203 | 214 |
|
204 |
if( this.store2NamesMap.containsKey(keyAttr2) ) { |
|
205 |
this.attrsForQuery = this.attrs; |
|
206 |
} else { |
|
207 |
List<String> list = new ArrayList<String>(this.attrs.length + 1); |
|
208 |
list.addAll(Arrays.asList(this.attrs)); |
|
209 |
list.add(keyAttr2); |
|
210 |
this.attrsForQuery = (String[]) list.toArray(new String[]{}); |
|
215 |
List<String> list1 = new ArrayList<>(); |
|
216 |
for (String attr : this.attrs) { |
|
217 |
if( !containsIgnoreCase(list1, attr) ) { |
|
218 |
list1.add(attr); |
|
219 |
} |
|
211 | 220 |
} |
221 |
if( !containsIgnoreCase(list1, keyAttr2 ) ) { |
|
222 |
list1.add(keyAttr2); |
|
223 |
} |
|
224 |
List<String> list2 = new ArrayList<>(list1); |
|
225 |
for (String attrname : list1) { |
|
226 |
FeatureAttributeDescriptor attrdesc = featureType2.getAttributeDescriptor(attrname); |
|
227 |
String[] requiredAttrs = attrdesc.getRequiredFieldNames(); |
|
228 |
if( requiredAttrs!=null ) { |
|
229 |
for (String requiredAttr : requiredAttrs) { |
|
230 |
if( !containsIgnoreCase(list2, requiredAttr) ) { |
|
231 |
list2.add(requiredAttr); |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
this.attrsForQuery = (String[]) list2.toArray(new String[]{}); |
|
237 |
// if( this.store2NamesMap.containsKey(keyAttr2) ) { |
|
238 |
// this.attrsForQuery = this.attrs; |
|
239 |
// } else { |
|
240 |
// List<String> list = new ArrayList<String>(this.attrs.length + 1); |
|
241 |
// list.addAll(Arrays.asList(this.attrs)); |
|
242 |
// list.add(keyAttr2); |
|
243 |
// this.attrsForQuery = (String[]) list.toArray(new String[]{}); |
|
244 |
// } |
|
212 | 245 |
|
213 | 246 |
// assign calculated feature type as this transform's feature type |
214 | 247 |
FeatureType[] types = new FeatureType[]{ |
215 | 248 |
editableFeatureType.getNotEditableCopy()}; |
216 | 249 |
setFeatureTypes(Arrays.asList(types), types[0]); |
250 |
|
|
251 |
if( store2.getIndexes().getFeatureIndex(keyAttr2)==null ) { |
|
252 |
store2.createIndex(featureType2, keyAttr2, keyAttr2, (Observer)null); |
|
253 |
} |
|
254 |
|
|
217 | 255 |
} |
218 | 256 |
|
219 | 257 |
private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor[] featureAttributeDescriptors, |
Also available in: Unified diff