Revision 25
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLSetProvider.java | ||
---|---|---|
82 | 82 |
protected String getSqlForEvaluator(Evaluator filter) { |
83 | 83 |
|
84 | 84 |
String resp = null; |
85 |
if (filter != null) { |
|
85 |
if (filter != null && filter.getSQL() != null) { |
|
86 |
// ================================================= |
|
86 | 87 |
EvaluatorFieldsInfo info = filter.getFieldsInfo(); |
87 | 88 |
String filterString = filter.getSQL(); |
89 |
|
|
90 |
String[] filterNames = null; |
|
91 |
String[] finalNames = null; |
|
92 |
|
|
88 | 93 |
if (info == null) { |
89 |
resp = filterString;
|
|
94 |
filterNames = getFieldNames(getFeatureType());
|
|
90 | 95 |
} else { |
91 |
String[] filterNames = info.getFieldNames(); |
|
92 |
String[] finalNames = new String[filterNames.length]; |
|
93 |
EvaluatorFieldValue[] fValues; |
|
94 |
|
|
95 |
List values = new ArrayList(); |
|
96 |
|
|
97 |
FeatureAttributeDescriptor attr; |
|
98 |
for (int i = 0; i < filterNames.length; i++) { |
|
99 |
attr = getFeatureType().getAttributeDescriptor(filterNames[i]); |
|
100 |
if (attr == null) { |
|
101 |
finalNames[i] = filterNames[i]; |
|
102 |
continue; |
|
103 |
} |
|
104 |
finalNames[i] = getEscapedFieldName(attr.getName()); |
|
105 |
|
|
96 |
filterNames = info.getFieldNames(); |
|
97 |
} |
|
98 |
|
|
99 |
finalNames = new String[filterNames.length]; |
|
100 |
FeatureAttributeDescriptor attr; |
|
101 |
for (int i = 0; i < filterNames.length; i++) { |
|
102 |
attr = getFeatureType().getAttributeDescriptor(filterNames[i]); |
|
103 |
if (attr == null) { |
|
104 |
finalNames[i] = filterNames[i]; |
|
105 |
continue; |
|
106 | 106 |
} |
107 |
finalNames[i] = getEscapedFieldName(attr.getName()); |
|
108 |
} |
|
107 | 109 |
|
108 |
for (int i = 0; i < filterNames.length; i++) { |
|
109 |
if (!filterNames[i].equals(finalNames[i])) { |
|
110 |
filterString = filterString.replaceAll( |
|
111 |
"\\b" + filterNames[i] + "\\b", |
|
112 |
finalNames[i]); |
|
113 |
} |
|
110 |
for (int i = 0; i < filterNames.length; i++) { |
|
111 |
if (!filterNames[i].equals(finalNames[i])) { |
|
112 |
filterString = filterString.replaceAll( |
|
113 |
"\\b" + filterNames[i] + "\\b", |
|
114 |
finalNames[i]); |
|
114 | 115 |
} |
115 |
resp = filterString; |
|
116 | 116 |
} |
117 |
resp = filterString; |
|
117 | 118 |
} |
118 |
// =================== |
|
119 |
// ================================ |
|
120 |
// In any case, append working area filter |
|
121 |
|
|
119 | 122 |
try { |
120 | 123 |
resp = appendWorkingAreaCondition(resp); |
121 | 124 |
} catch (Exception e) { |
... | ... | |
124 | 127 |
return resp; |
125 | 128 |
} |
126 | 129 |
|
130 |
private String[] getFieldNames(FeatureType ft) { |
|
131 |
|
|
132 |
if (ft == null) { |
|
133 |
return new String[0]; |
|
134 |
} |
|
135 |
FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors(); |
|
136 |
String[] resp = new String[atts.length]; |
|
137 |
for (int i=0; i<atts.length; i++) { |
|
138 |
resp[i] = atts[i].getName(); |
|
139 |
} |
|
140 |
return resp; |
|
141 |
} |
|
142 |
|
|
143 |
|
|
127 | 144 |
private String appendWorkingAreaCondition(String sql) throws Exception { |
128 | 145 |
|
129 | 146 |
DBStoreParameters dbParams = |
Also available in: Unified diff