public class DatasourceAwareDelegateTransformer extends java.lang.Object implements IOperationDelegate
DatasourceAwareDelegateTransformer
is an
IOperationDelegate
implementation for AbstractRestOperation
s
which also takes a IDataTransformer
into account.
It's added as IOperationDelegate
to a AbstractRestOperation
and gets notified when the REST call is finished (see
onOperationFinished(IOperation)
and
onOperationFailed(IOperation)
. It will fetch all filtered elements
(based on the given filterExpression) from the executed REST service and
attach those elements to the AbstractListDatasource
passed in the
constructor.
The optional IDataTransformer
will be used to convert each object
returned from the executed AbstractRestOperation
into an object of
the correct type for the targetDatesource.
Constructor and Description |
---|
DatasourceAwareDelegateTransformer(AbstractListDatasource targetDatasource,
IDataTransformer transformer,
java.lang.String expression)
Creates this
IOperationDelegate by passing the target datasource
as well a IDataTransformer . |
DatasourceAwareDelegateTransformer(AbstractListDatasource targetDatasource,
IDataTransformer transformer,
java.lang.String expression,
java.lang.String filterExpression)
Creates this
IOperationDelegate by passing the target datasource
as well a IDataTransformer . |
Modifier and Type | Method and Description |
---|---|
void |
onOperationFailed(IOperation operation)
notifies the targetDatasource that an exception occurred
|
void |
onOperationFinished(IOperation operation)
reads the result from the operation (takes "expression" and
"filterExpression" into account) and calls the
attachElements(AbstractListDatasource) method |
public DatasourceAwareDelegateTransformer(AbstractListDatasource targetDatasource, IDataTransformer transformer, java.lang.String expression)
IOperationDelegate
by passing the target datasource
as well a IDataTransformer
.targetDatasource
- the datasource to which the elements should be added totransformer
- might be null
; used to transform the objects from
the format of the AbstractRestOperation
into the
required format of the targetDatasourceexpression
- the JSON expression required to get the desired objects from
the returned REST result stringfilterExpression
- the JSON expression used to filter the matched elementspublic DatasourceAwareDelegateTransformer(AbstractListDatasource targetDatasource, IDataTransformer transformer, java.lang.String expression, java.lang.String filterExpression)
IOperationDelegate
by passing the target datasource
as well a IDataTransformer
.targetDatasource
- the datasource to which the elements should be added totransformer
- might be null
; used to transform the objects from
the format of the AbstractRestOperation
into the
required format of the targetDatasourceexpression
- the JSON expression required to get the desired objects from
the returned REST result stringfilterExpression
- the JSON expression used to filter the matched elementspublic void onOperationFinished(IOperation operation)
attachElements(AbstractListDatasource)
methodonOperationFinished
in interface IOperationDelegate
operation
- The watched IOperation
.public void onOperationFailed(IOperation operation)
onOperationFailed
in interface IOperationDelegate
operation
- The watched IOperation
.