public class DatasourceAwareDelegateTransformer extends AbstractOperationDelegate
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
AbstractOperationDelegate.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 filterExpression)
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 |
notifyObservers(DatasourceException exception)
Is called when the operation failed.
|
void |
onOperationFailed(IOperation operation)
Notifies this listener that the watched
IOperation failed. |
void |
onOperationSuccessful(IOperation operation)
reads the result from the operation (takes "expression" and
"filterExpression" into account) and calls the
attachElements(AbstractListDatasource) method |
onOperationFinished
public DatasourceAwareDelegateTransformer(AbstractListDatasource targetDatasource, IDataTransformer transformer, 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 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 onOperationSuccessful(IOperation operation)
attachElements(AbstractListDatasource)
methodonOperationSuccessful
in class AbstractOperationDelegate
operation
- the successful IOperation
(incl. the result string)public void onOperationFailed(IOperation operation)
IOperationDelegate
IOperation
failed. This
only indicates an exception during the execution and is independent from
the operation's result code.onOperationFailed
in interface IOperationDelegate
onOperationFailed
in class AbstractOperationDelegate
operation
- The watched IOperation
.public void notifyObservers(DatasourceException exception)
exception
- the DatasourceException
that had beed created for the
occurred error