|
com.im.df.api 5.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface DFEntityDataProvider
Data provider for a single entity. Data are not cached and are obtained directly
from data source. It is recommended to use some caching system on top of this object.
If you are interested in data changes, you should register a DFEntityDataListener
to this object.
API Status: Partly stable. This class contains a few methods which can be changed/removed in the future. These methods comments contain TODO info.
| Method Summary | |
|---|---|
void |
addDFEntityDataListener(DFEntityDataListener listener)
Register an listener to be notified about data changes in this entity data provider. |
int |
deleteIds(List<? extends Comparable<?>> ids,
DFEnvironmentRW env)
Delete these IDs |
String |
generateStatistics()
Generate a statistical summary of the information in this entity. |
Map<Comparable<?>,Map<String,Object>> |
getData(List<? extends Comparable<?>> ids,
DFEnvironmentRO env)
Fetch data for the specified IDs. |
DFEntity |
getEntity()
Get the entity which this EDP belongs to. |
DFLockable |
getLockable()
Get the lock provider only for this EDP. |
int |
getRowCount(DFEnvironmentRO env)
Get the number of rows. |
DFSchemaDataProvider |
getSchemaDataProvider()
Get parent DFSchemaDataProvider. |
Map<Comparable<?>,Map<String,Object>> |
getWrappedData(List<? extends Comparable<?>> ids,
DFEnvironmentRO env)
|
DFUpdateInfo |
insert(Map<String,Object> values,
Map<String,Object> insertOptions,
DFEnvironmentRW env)
Insert a new row with these values. |
List<? extends DFRowData> |
queryForData(DFTermExpression query,
List<? extends DFField> fields,
SortDirective sort,
DFEnvironmentRO env)
Get the values of selected fields of the entity that match the specified query |
List<? extends Comparable<?>> |
queryForIds(DFDataTree dataTree,
DFTermExpression query,
SortDirective sort,
DFEnvironmentRO env)
Get the IDs (primary key values) of the entity that match the specified query |
List<? extends Comparable<?>> |
queryForIds(DFTermExpression query,
SortDirective sort,
DFEnvironmentRO env)
Get the IDs (primary key values) of the entity that match the specified query |
List<? extends Object> |
queryForValues(DFTermExpression query,
DFField selectedField,
SortDirective sort,
DFEnvironmentRO env)
Get the values of selectedField of the entity that match the specified query |
void |
reloadData()
Reload data for this EDP. |
void |
removeDFEntityDataListener(DFEntityDataListener listener)
Unregister an listener to be notified about data changes in this entity data provider. |
List |
retrieveDistinctValuesForField(String fieldId)
Get the List of distinct values for this field. |
List<? extends Comparable<?>> |
sortIds(List<? extends Comparable<?>> ids,
SortDirective sort,
DFEnvironmentRO env)
Get these IDs for the entity in sorted order. |
Map<DFUpdateDescription,DFUpdateResult> |
update(List<DFUpdateDescription> updateDescriptors,
DFUndoConfig undoConfig,
DFEnvironmentRW env)
Update the data where certain value match the defined criteria. |
Map<DFUpdateDescription,DFUpdateResult> |
update(List<DFUpdateDescription> updateDescriptors,
DFUndoConfig undoConfig,
DFEnvironmentRW env,
boolean fireEvents)
The same as update(List, DFUndoConfig, DFEnvironmentRW) with the
possibility to turn off the firing of events. |
| Method Detail |
|---|
DFLockable getLockable()
DFSchemaDataProvider getSchemaDataProvider()
DFEntity getEntity()
int getRowCount(DFEnvironmentRO env)
List<? extends Comparable<?>> queryForIds(DFTermExpression query,
SortDirective sort,
DFEnvironmentRO env)
query - The query All elements must be present in this entity, for empty query use
DFTermExpression.ALL_DATA constant.sort - The sort directive describing how returned data should be sorted
List<? extends Object> queryForValues(DFTermExpression query,
DFField selectedField,
SortDirective sort,
DFEnvironmentRO env)
query - The query All elements must be present in this entity, for empty query use
DFTermExpression.ALL_DATA constant.selectedField - specify field which values are returned (target)sort - The sort directive describing how returned data should be sorted
List<? extends DFRowData> queryForData(DFTermExpression query,
List<? extends DFField> fields,
SortDirective sort,
DFEnvironmentRO env)
query - The query All elements must be present in this entity, for empty query use
DFTermExpression.ALL_DATA constant.fields - specify fields which values are returned (target)sort - The sort directive describing how returned data should be sorted
List<? extends Comparable<?>> queryForIds(DFDataTree dataTree,
DFTermExpression query,
SortDirective sort,
DFEnvironmentRO env)
dataTree - The DataTree that allows the different fields to be resolved to
formulate the queryquery - The query Elements can be from other entities in the DataTree, for empty query use
DFTermExpression.ALL_DATA constant.sort - The sort directivesenv -
List<? extends Comparable<?>> sortIds(List<? extends Comparable<?>> ids,
SortDirective sort,
DFEnvironmentRO env)
ids - The required IDs
Map<Comparable<?>,Map<String,Object>> getData(List<? extends Comparable<?>> ids,
DFEnvironmentRO env)
ids - The IDs
Map<Comparable<?>,Map<String,Object>> getWrappedData(List<? extends Comparable<?>> ids,
DFEnvironmentRO env)
DFUpdateInfo insert(Map<String,Object> values,
Map<String,Object> insertOptions,
DFEnvironmentRW env)
TODO P2 - getInsertOptions methods doesn't exist and currently only usage (in Import) is a hack to API. The architecture and API for insert options should be improved.
values - A Map of DFField's Id/value pairsinsertOptions - Options specific to this type of entity. Can be null.
int deleteIds(List<? extends Comparable<?>> ids,
DFEnvironmentRW env)
ids - The IDs to deleteenv -
Map<DFUpdateDescription,DFUpdateResult> update(List<DFUpdateDescription> updateDescriptors,
DFUndoConfig undoConfig,
DFEnvironmentRW env)
DFUpdateResult.isSuccessful()
method of each DFUpdateResult.
However you can update any number of rows in a single call of this method.you should rather balance it.
For example if you want to update 1000000 rows and you will call this method once for each row
then the performance won't be good. On the other hand if you call it only once with List
of 1000000 prepared DFUpdateDescriptions it will require too much memory
as whole change must be allocated and is released after operation finishes.
It's recommended that you choose some option in the middle of these two extremes. For this reason
there is defined a constant which says what is the recommended size of update batch: DIFUtilities.UPDATE_DESCRIPTORS_RECOMMENDED_LIMIT.
Then the code can look something like (it's simplified - it doesn't solve the returned results):
DFEntityDataProvider edp = ....; ListupdateDescriptors = new ArrayList (); for (int i = 0; i < rowCount; i++) { updateDescriptors.add(DFUpdateDescriptor.create(...)); if ((updateDescriptors.size() > DIFUtilities.UPDATE_DESCRIPTORS_RECOMMENDED_LIMIT) || (i == rowCount - 1)) { Map result = edp.update(updateDescriptors,...); updateDescriptors.clear(); // check results and possibly break loop if there are any errors? } }
There is a utility which can help with writing this code: BatchUpdater.
updateDescriptors - The list of descriptors what to updateenv - undoConfig - The description if and how to use undo/redo support
Map<DFUpdateDescription,DFUpdateResult> update(List<DFUpdateDescription> updateDescriptors,
DFUndoConfig undoConfig,
DFEnvironmentRW env,
boolean fireEvents)
update(List, DFUndoConfig, DFEnvironmentRW) with the
possibility to turn off the firing of events.
void reloadData()
TODO: This method may change in the future (perhaps DFEnvironmentRW will be added as parameter).
void addDFEntityDataListener(DFEntityDataListener listener)
void removeDFEntityDataListener(DFEntityDataListener listener)
List retrieveDistinctValuesForField(String fieldId)
TODO P3 - this method should probably have DFEnvironmentRO as parameter (it can take some time and 2nd reason - it should be cancellable if someone misuses "distinct values" e.g. for some field with many values in 1000000 rows table).
String generateStatistics()
|
com.im.df.api 5.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||