Search in sources :

Example 1 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class BatchLookupServiceClientProxy method getBatchDataByText.

@Override
public List<List<ILookupRow<?>>> getBatchDataByText(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByText(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByText(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 2 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class BatchLookupServiceClientProxy method getBatchDataByRec.

@Override
public List<List<ILookupRow<?>>> getBatchDataByRec(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByRec(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByRec(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 3 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class BatchLookupServiceClientProxy method getBatchDataByAll.

@Override
public List<List<ILookupRow<?>>> getBatchDataByAll(BatchLookupCall batch) {
    BatchSplit split = new BatchSplit(batch);
    if (split.getLocalCallCount() > 0) {
        BatchLookupResultCache cache = new BatchLookupResultCache();
        List<ILookupCall<?>> calls = split.getLocalCalls();
        List<List<ILookupRow<?>>> resultArray = new ArrayList<List<ILookupRow<?>>>();
        for (ILookupCall<?> call : calls) {
            resultArray.add(cache.getDataByAll(call));
        }
        split.setLocalResults(resultArray);
    }
    if (split.getRemoteCallCount() > 0) {
        List<List<ILookupRow<?>>> resultArray = getTargetService().getBatchDataByAll(new BatchLookupCall(split.getRemoteCalls()));
        split.setRemoteResults(resultArray);
    }
    return split.getCombinedResults();
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) BatchLookupResultCache(org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) BatchLookupCall(org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)

Example 4 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class AbstractContentAssistField method newByRecLookupRowProvider.

/**
 * @see LookupCall#getDataByRec()
 */
protected ILookupRowProvider<LOOKUP_KEY> newByRecLookupRowProvider(final LOOKUP_KEY parentKey, final TriState activeState) {
    return new ILookupRowProvider<LOOKUP_KEY>() {

        @SuppressWarnings("unchecked")
        @Override
        public List<ILookupRow<LOOKUP_KEY>> provide(ILookupCall<LOOKUP_KEY> lookupCall) {
            return (List<ILookupRow<LOOKUP_KEY>>) lookupCall.getDataByRec();
        }

        @Override
        public void beforeProvide(ILookupCall<LOOKUP_KEY> lookupCall) {
            prepareRecLookup(lookupCall, parentKey, activeState);
        }

        @Override
        public void afterProvide(ILookupCall<LOOKUP_KEY> lookupCall, List<ILookupRow<LOOKUP_KEY>> result) {
            interceptFilterLookupResult(lookupCall, result);
            interceptFilterRecLookupResult(lookupCall, result);
            cleanupResultList(result);
        }

        @Override
        public void provideSync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback) {
            throw new UnsupportedOperationException("Legacy calls not supported");
        }

        @Override
        public IFuture<Void> provideAsync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback, ClientRunContext clientRunContext) {
            throw new UnsupportedOperationException("Legacy calls not supported");
        }

        @Override
        public String toString() {
            ToStringBuilder sb = new ToStringBuilder(this).attr("Rec Lookup").attr("parentKey", parentKey).attr("activeState", activeState);
            return sb.toString();
        }
    };
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ToStringBuilder(org.eclipse.scout.rt.platform.util.ToStringBuilder) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Example 5 with ILookupCall

use of org.eclipse.scout.rt.shared.services.lookup.ILookupCall in project scout.rt by eclipse.

the class AbstractContentAssistField method newByTextLookupRowProvider.

/**
 * Creates a {@link ILookupRowProvider} to fetch rows matching the given text.
 *
 * @see LookupCall#getDataByText()
 * @see LookupCall#getDataByTextInBackground(ILookupRowFetchedCallback)
 */
protected ILookupRowProvider<LOOKUP_KEY> newByTextLookupRowProvider(final String text) {
    return new ILookupRowProvider<LOOKUP_KEY>() {

        @Override
        public void beforeProvide(ILookupCall<LOOKUP_KEY> lookupCall) {
            prepareTextLookup(lookupCall, text);
        }

        @Override
        public void afterProvide(ILookupCall<LOOKUP_KEY> call, List<ILookupRow<LOOKUP_KEY>> result) {
            interceptFilterLookupResult(call, result);
            interceptFilterTextLookupResult(call, result);
            cleanupResultList(result);
        }

        @Override
        public void provideSync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback) {
            callback.onSuccess(provide(lookupCall));
        }

        @Override
        public IFuture<Void> provideAsync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback, ClientRunContext clientRunContext) {
            return lookupCall.getDataByTextInBackground(clientRunContext, callback);
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<ILookupRow<LOOKUP_KEY>> provide(ILookupCall<LOOKUP_KEY> lookupCall) {
            return (List<ILookupRow<LOOKUP_KEY>>) lookupCall.getDataByText();
        }

        @Override
        public String toString() {
            ToStringBuilder sb = new ToStringBuilder(this).attr("Text Lookup").attr("text", text);
            return sb.toString();
        }
    };
}
Also used : ClientRunContext(org.eclipse.scout.rt.client.context.ClientRunContext) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ToStringBuilder(org.eclipse.scout.rt.platform.util.ToStringBuilder) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall)

Aggregations

ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)25 ArrayList (java.util.ArrayList)19 List (java.util.List)19 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)18 ClientRunContext (org.eclipse.scout.rt.client.context.ClientRunContext)8 ToStringBuilder (org.eclipse.scout.rt.platform.util.ToStringBuilder)8 BatchLookupResultCache (org.eclipse.scout.rt.shared.services.lookup.BatchLookupResultCache)8 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)8 BatchLookupCall (org.eclipse.scout.rt.shared.services.lookup.BatchLookupCall)6 Test (org.junit.Test)5 ILookupRowProvider (org.eclipse.scout.rt.client.ui.form.fields.smartfield.ILookupRowProvider)4 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)4 TestLookupCall (org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall)3 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)2 BatchLookupNormalizer (org.eclipse.scout.rt.shared.services.lookup.BatchLookupNormalizer)2 IBatchLookupService (org.eclipse.scout.rt.shared.services.lookup.IBatchLookupService)2 Before (org.junit.Before)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 IMixedSmartField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField)1