Revision 44376 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/DefaultForeingKey.java
DefaultForeingKey.java | ||
---|---|---|
19 | 19 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
20 | 20 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
21 | 21 |
import org.gvsig.fmap.dal.feature.FeatureType; |
22 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
22 | 23 |
import org.gvsig.tools.ToolsLocator; |
23 | 24 |
import org.gvsig.tools.dispose.DisposeUtils; |
24 | 25 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
... | ... | |
394 | 395 |
return null; |
395 | 396 |
} |
396 | 397 |
if( this.availableValues == null ) { |
397 |
context = createLocalContextIfNull(context); |
|
398 |
try { |
|
399 |
Expression labelExpression = context.getLabelExpression(); |
|
400 |
FeatureStore store = context.getFeatureStore(); |
|
401 |
if (store == null) { |
|
402 |
return null; |
|
403 |
} |
|
404 |
int count = (int) store.getFeatureCount(); |
|
405 |
DynObjectValueItem[] values = new DynObjectValueItem[Math.min(count, MAX_AVAILABLE_VALUES)]; |
|
406 |
int n = 0; |
|
407 |
for (Feature feature : store.getFeatureSet()) { |
|
408 |
Object code = feature.get(codeName); |
|
409 |
Object value; |
|
410 |
if (labelExpression == null) { |
|
411 |
value = code; |
|
412 |
} else { |
|
413 |
context.getFeatureSymbolTable().setFeature(feature); |
|
414 |
value = labelExpression.execute(context.getSymbolTable()); |
|
415 |
} |
|
416 |
values[n++] = new DynObjectValueItem(code, Objects.toString(value, Objects.toString(code, "##ERROR##"))); |
|
417 |
if( n>=MAX_AVAILABLE_VALUES ) { |
|
418 |
break; |
|
419 |
} |
|
420 |
} |
|
421 |
this.availableValues = values; |
|
422 |
} catch (Exception ex) { |
|
423 |
LOGGER.warn("Can't get values from table '" + tableName + "' of field.", ex); |
|
424 |
} finally { |
|
425 |
disposeIfLocalContext(context); |
|
398 |
DataManagerProviderServices dataManager = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
399 |
FeatureStore myStore = this.descriptor.getStore(); |
|
400 |
if( myStore!=null ) { |
|
401 |
this.availableValues = dataManager.getAvailableValues(myStore, this.descriptor); |
|
426 | 402 |
} |
427 | 403 |
} |
428 | 404 |
return this.availableValues; |
Also available in: Unified diff