Revision 44191 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java
JDBCSetProvider.java | ||
---|---|---|
27 | 27 |
import java.util.NoSuchElementException; |
28 | 28 |
import org.apache.commons.collections.CollectionUtils; |
29 | 29 |
import org.apache.commons.lang3.BooleanUtils; |
30 |
import org.apache.commons.lang3.StringUtils; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DataTypes; |
|
33 | 30 |
import org.gvsig.fmap.dal.exception.DataException; |
34 | 31 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
35 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember; |
|
36 | 32 |
import org.gvsig.fmap.dal.feature.FeatureType; |
37 | 33 |
|
38 | 34 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider; |
... | ... | |
48 | 44 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
49 | 45 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
50 | 46 |
import org.gvsig.tools.evaluator.Evaluator; |
51 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
52 | 47 |
import org.gvsig.tools.exception.BaseException; |
53 | 48 |
import org.slf4j.Logger; |
54 | 49 |
import org.slf4j.LoggerFactory; |
... | ... | |
138 | 133 |
|
139 | 134 |
@Override |
140 | 135 |
public boolean canFilter() { |
141 |
// No podemos filtrar si: |
|
142 |
// - Hay una subquery especificada en los parametros |
|
143 |
// - Si no soportamos geometrias y hay un filtro espacial. |
|
144 |
// |
|
145 |
if (this.getHelper().useSubquery()) { |
|
146 |
return false; |
|
147 |
} |
|
148 |
if( this.getHelper().hasSpatialFunctions() ) { |
|
149 |
// Como soportamos filtros espaciales, podremos hacer cualquier |
|
150 |
// filtro que se especifique, sea alfanumerico o espacial. |
|
151 |
return true; |
|
152 |
} |
|
153 |
|
|
154 |
// No se soportan filtros espaciales. |
|
155 |
// Si se esta filtrando por un campo Geometria, retornamos false |
|
156 |
|
|
157 |
Evaluator filter = getQuery().getFilter(); |
|
158 |
if (filter == null) { |
|
159 |
return true; |
|
160 |
} |
|
161 |
|
|
162 |
String sql = filter.getSQL(); |
|
163 |
if (StringUtils.isEmpty(sql)) { |
|
164 |
return true; |
|
165 |
} |
|
166 |
|
|
167 |
EvaluatorFieldsInfo fInfo = filter.getFieldsInfo(); |
|
168 |
if (fInfo == null ) { |
|
169 |
return true; |
|
170 |
} |
|
171 |
String[] names = fInfo.getFieldNames(); |
|
172 |
if ( names == null) { |
|
173 |
return true; |
|
174 |
} |
|
175 |
|
|
176 |
for (String name : names) { |
|
177 |
int type = this.getFeatureType() |
|
178 |
.getAttributeDescriptor(name) |
|
179 |
.getType(); |
|
180 |
if( type == DataTypes.GEOMETRY ) { |
|
181 |
return false; |
|
182 |
} |
|
183 |
} |
|
184 |
return true; |
|
136 |
return this.getHelper().supportFilter(getQuery().getFilter()); |
|
185 | 137 |
} |
186 | 138 |
|
187 | 139 |
@Override |
188 | 140 |
public boolean canOrder() { |
189 |
// No podemos ordenar si: |
|
190 |
// - Hay una subquery especificada en los parametros |
|
191 |
// - Si no soportamos geometrias y hay un filtro espacial. |
|
192 |
// |
|
193 |
if (this.getHelper().useSubquery()) { |
|
194 |
return false; |
|
195 |
} |
|
196 |
if( this.getHelper().hasSpatialFunctions() ) { |
|
197 |
// Como soportamos filtros espaciales, podremos hacer cualquier |
|
198 |
// filtro que se especifique, sea alfanumerico o espacial. |
|
199 |
return true; |
|
200 |
} |
|
201 |
|
|
202 |
FeatureQuery query = getQuery(); |
|
203 |
if (!query.hasOrder()) { |
|
204 |
return true; |
|
205 |
} |
|
206 |
for( FeatureQueryOrderMember member : query.getOrder().members() ) { |
|
207 |
if (member.hasEvaluator()) { |
|
208 |
String sql = member.getEvaluator().getSQL(); |
|
209 |
if ( StringUtils.isEmpty(sql) ) { |
|
210 |
return false; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
return true; |
|
141 |
return this.getHelper().supportOrder(getQuery().getOrder()); |
|
215 | 142 |
} |
216 | 143 |
|
217 | 144 |
public ResulSetControler getResulSetControler() { |
Also available in: Unified diff