Skip to content

Commit

Permalink
use PagedIterator.Page
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Nov 12, 2017
1 parent f96d9a2 commit eb6070e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private ViewRowIdsOrderedSelection getSelection(final List<DocumentQueryOrderBy>
private PageFetcher<Integer> huIdsPageFetcher(final List<DocumentQueryOrderBy> orderBys)
{
final ViewRowIdsOrderedSelection selection = getSelection(orderBys);
return (firstRow, maxRows) -> huEditorRepo.retrievePagedHUIds(selection, firstRow, maxRows);
return (firstRow, maxRows) -> huEditorRepo.retrieveHUIdsPage(selection, firstRow, maxRows);
}

private Stream<Integer> streamHUIdsByPage(final int firstRow, final int maxRows, final List<DocumentQueryOrderBy> orderBys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.List;
import java.util.Set;

import org.adempiere.util.collections.PagedIterator.Page;

import de.metas.ui.web.document.filter.DocumentFilter;
import de.metas.ui.web.handlingunits.HUIdsFilterHelper.HUIdsFilterData;
import de.metas.ui.web.view.ViewId;
Expand Down Expand Up @@ -47,7 +49,7 @@ public interface HUEditorViewRepository

List<Integer> retrieveHUIdsEffective(HUIdsFilterData huIdsFilter, List<DocumentFilter> filters);

Set<Integer> retrievePagedHUIds(ViewRowIdsOrderedSelection selection, int firstRow, int maxRows);
Page<Integer> retrieveHUIdsPage(ViewRowIdsOrderedSelection selection, int firstRow, int maxRows);

ViewRowIdsOrderedSelection createDefaultSelection(ViewId viewId, List<DocumentFilter> filters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.adempiere.model.PlainContextAware;
import org.adempiere.util.GuavaCollectors;
import org.adempiere.util.Services;
import org.adempiere.util.collections.PagedIterator.Page;
import org.compiere.model.I_C_UOM;
import org.compiere.model.I_M_Product;
import org.compiere.util.DB;
Expand Down Expand Up @@ -428,7 +429,7 @@ else if (huIdsFilter.getMustHUIds() != null)
}

@Override
public Set<Integer> retrievePagedHUIds(final ViewRowIdsOrderedSelection selection, final int firstRow, final int maxRows)
public Page<Integer> retrieveHUIdsPage(final ViewRowIdsOrderedSelection selection, final int firstRow, final int maxRows)
{
final int firstSeqNo = firstRow + 1; // NOTE: firstRow is 0-based while SeqNo are 1-based
final int lastSeqNo = firstRow + maxRows;
Expand Down Expand Up @@ -458,8 +459,7 @@ public Set<Integer> retrievePagedHUIds(final ViewRowIdsOrderedSelection selectio
huIds.add(huId);
}

return huIds;

return Page.ofRows(ImmutableList.copyOf(huIds));
}
catch (final SQLException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.List;
import java.util.Set;

import org.adempiere.util.collections.PagedIterator.Page;

import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;

Expand Down Expand Up @@ -83,7 +85,7 @@ public List<Integer> retrieveHUIdsEffective(final HUIdsFilterData huIdsFilter, f
}

@Override
public Set<Integer> retrievePagedHUIds(final ViewRowIdsOrderedSelection selection, final int firstRow, final int maxRows)
public Page<Integer> retrieveHUIdsPage(final ViewRowIdsOrderedSelection selection, final int firstRow, final int maxRows)
{
throw new UnsupportedOperationException("not implemented");
}
Expand Down

0 comments on commit eb6070e

Please sign in to comment.