Revision 46517 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchpanel/SearchConditionFieldController.java
SearchConditionFieldController.java | ||
---|---|---|
33 | 33 |
import org.gvsig.fmap.dal.DALLocator; |
34 | 34 |
import org.gvsig.fmap.dal.DataManager; |
35 | 35 |
import org.gvsig.fmap.dal.DataStore; |
36 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
36 | 37 |
import org.gvsig.fmap.dal.complements.Search; |
37 | 38 |
import org.gvsig.fmap.dal.exception.DataException; |
38 | 39 |
import org.gvsig.fmap.dal.expressionevaluator.DALExpressionBuilder; |
... | ... | |
523 | 524 |
final DefaultComboBoxModel model = new DefaultComboBoxModel(); |
524 | 525 |
final FeatureStore theStore = field.getFeatureStore(); |
525 | 526 |
final FeatureQuery query; |
526 |
if (this.store == theStore) { |
|
527 |
query = parameters.getQuery().getCopy(); // theStore.createFeatureQuery(); |
|
528 |
} else { |
|
529 |
query = theStore.createFeatureQuery(); |
|
530 |
} |
|
527 |
query = theStore.createFeatureQuery(); |
|
531 | 528 |
query.addAttributeName(field.getDescriptor().getName()); |
532 | 529 |
query.setFilter(""); |
533 | 530 |
query.setLimit(updateValuesFeaturesLimit); |
... | ... | |
721 | 718 |
return; |
722 | 719 |
} |
723 | 720 |
} |
724 |
// si no lo encuentra en el modelo lo a?ade |
|
721 |
// si no lo encuentra en el modelo lo a?ade |
|
725 | 722 |
final Field field = (Field) ddnFields.getSelectedItem(); |
726 | 723 |
if (field == null) { |
727 | 724 |
return; |
... | ... | |
1043 | 1040 |
); |
1044 | 1041 |
op_composition = addNullBehavior(builder, op_composition, null_value); |
1045 | 1042 |
|
1046 |
filter = builder.exists(builder.select() |
|
1047 |
.column(parentDescriptor.getFeatureType().getPrimaryKey()[0].getName()) |
|
1048 |
.from(field.getFeatureStore().getName()) |
|
1049 |
.limit(1) |
|
1050 |
.where( |
|
1051 |
builder.expression().and( |
|
1052 |
builder.expression().eq( |
|
1053 |
builder.expression().column( |
|
1054 |
field.getFeatureStore().getName(), |
|
1055 |
getForeingKeyName(field.getFeatureStore(), this.store) |
|
1056 |
), |
|
1057 |
builder.expression().column( |
|
1058 |
this.store.getName(), |
|
1059 |
getPrimaryKeyName(this.store) |
|
1060 |
) |
|
1061 |
), |
|
1062 |
op_composition |
|
1063 |
) |
|
1064 |
) |
|
1065 |
.toValue() |
|
1066 |
); |
|
1043 |
filter = buildExists(builder, field, op_composition); |
|
1067 | 1044 |
break; |
1068 | 1045 |
} |
1069 | 1046 |
} |
... | ... | |
1072 | 1049 |
return filter; |
1073 | 1050 |
} |
1074 | 1051 |
|
1052 |
private ExpressionBuilder.Value buildExists(DALExpressionBuilder builder, Field field, ExpressionBuilder.Value op_composition) { |
|
1053 |
ExpressionBuilder.Value filter; |
|
1054 |
SQLBuilder.SelectBuilder select = builder.select(); |
|
1055 |
select.from().table().name(field.getFeatureStore().getName()); |
|
1056 |
//select.column().name(parentDescriptor.getFeatureType().getPrimaryKey()[0].getName()); |
|
1057 |
select.column().value(builder.expression().constant(1)); |
|
1058 |
select.limit(1); |
|
1059 |
select.where().value( |
|
1060 |
builder.expression().and( |
|
1061 |
builder.expression().eq( |
|
1062 |
builder.expression().column( |
|
1063 |
field.getFeatureStore().getName(), |
|
1064 |
getForeingKeyName(field.getFeatureStore(), this.store) |
|
1065 |
), |
|
1066 |
builder.expression().column( |
|
1067 |
this.store.getName(), |
|
1068 |
getPrimaryKeyName(this.store) |
|
1069 |
) |
|
1070 |
), |
|
1071 |
op_composition |
|
1072 |
) |
|
1073 |
); |
|
1074 |
filter = builder.exists(select); |
|
1075 |
return filter; |
|
1076 |
} |
|
1077 |
|
|
1075 | 1078 |
public JsonObject toJson() { |
1076 | 1079 |
JsonObjectBuilder fieldBuilder = Json.createObjectBuilder(); |
1077 | 1080 |
|
... | ... | |
1230 | 1233 |
field.getFeatureStore().getName(), |
1231 | 1234 |
descriptor.getName() |
1232 | 1235 |
)); |
1233 |
filter = builder.exists(builder.select() |
|
1234 |
.column(parentDescriptor.getFeatureType().getPrimaryKey()[0].getName()) |
|
1235 |
.from(field.getFeatureStore().getName()) |
|
1236 |
.limit(1) |
|
1237 |
.where( |
|
1238 |
builder.expression().and( |
|
1239 |
builder.expression().eq( |
|
1240 |
builder.expression().column( |
|
1241 |
field.getFeatureStore().getName(), |
|
1242 |
getForeingKeyName(field.getFeatureStore(), this.store) |
|
1243 |
), |
|
1244 |
builder.expression().column( |
|
1245 |
this.store.getName(), |
|
1246 |
getPrimaryKeyName(this.store) |
|
1247 |
) |
|
1248 |
), |
|
1249 |
op_composition |
|
1250 |
) |
|
1251 |
) |
|
1252 |
.toValue() |
|
1253 |
); |
|
1236 |
filter = buildExists(builder, field, op_composition); |
|
1254 | 1237 |
} |
1255 | 1238 |
} |
1256 | 1239 |
|
... | ... | |
1284 | 1267 |
descriptor.getName() |
1285 | 1268 |
)); |
1286 | 1269 |
|
1287 |
filter = builder.exists(builder.select() |
|
1288 |
.column(parentDescriptor.getFeatureType().getPrimaryKey()[0].getName()) |
|
1289 |
.from(field.getFeatureStore().getName()) |
|
1290 |
.limit(1) |
|
1291 |
.where( |
|
1292 |
builder.expression().and( |
|
1293 |
builder.expression().eq( |
|
1294 |
builder.expression().column( |
|
1295 |
field.getFeatureStore().getName(), |
|
1296 |
getForeingKeyName(field.getFeatureStore(), this.store) |
|
1297 |
), |
|
1298 |
builder.expression().column( |
|
1299 |
this.store.getName(), |
|
1300 |
getPrimaryKeyName(this.store) |
|
1301 |
) |
|
1302 |
), |
|
1303 |
op_composition |
|
1304 |
) |
|
1305 |
) |
|
1306 |
.toValue() |
|
1307 |
); |
|
1270 |
filter = buildExists(builder, field, op_composition); |
|
1308 | 1271 |
} |
1309 | 1272 |
} |
1310 | 1273 |
|
Also available in: Unified diff