本文整理汇总了Java中org.alfresco.query.PageDetails.getPageDetails方法的典型用法代码示例。如果您正苦于以下问题:Java PageDetails.getPageDetails方法的具体用法?Java PageDetails.getPageDetails怎么用?Java PageDetails.getPageDetails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.query.PageDetails
的用法示例。
在下文中一共展示了PageDetails.getPageDetails方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapResult
import org.alfresco.query.PageDetails; //导入方法依赖的package包/类
protected <T> PagingResults<T> wrapResult(PagingRequest pagingRequest, List<T> result)
{
final int totalSize = result.size();
final PageDetails pageDetails = PageDetails.getPageDetails(pagingRequest, totalSize);
final List<T> page = new ArrayList<>(pageDetails.getPageSize());
Iterator<T> it = result.iterator();
for (int counter = 0; counter < pageDetails.getEnd() && it.hasNext(); counter++)
{
T element = it.next();
if (counter < pageDetails.getSkipCount())
{
continue;
}
if (counter > pageDetails.getEnd() - 1)
{
break;
}
page.add(element);
}
return new PagingResults<T>()
{
@Override
public List<T> getPage()
{
return page;
}
@Override
public boolean hasMoreItems()
{
return pageDetails.hasMoreItems();
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
Integer total = Integer.valueOf(totalSize);
return new Pair<>(total, total);
}
@Override
public String getQueryExecutionId()
{
return null;
}
};
}
示例2: wrapPagingResults
import org.alfresco.query.PageDetails; //导入方法依赖的package包/类
public static <T> PagingResults<T> wrapPagingResults(Paging paging, Collection<T> result)
{
if (paging == null)
{
throw new InvalidArgumentException("paging object can't be null.");
}
if (result == null)
{
result = Collections.emptyList();
}
PagingRequest pagingRequest = getPagingRequest(paging);
final int totalSize = result.size();
final PageDetails pageDetails = PageDetails.getPageDetails(pagingRequest, totalSize);
final List<T> page = new ArrayList<>(pageDetails.getPageSize());
Iterator<T> it = result.iterator();
for (int counter = 0, end = pageDetails.getEnd(); counter < end && it.hasNext(); counter++)
{
T element = it.next();
if (counter < pageDetails.getSkipCount())
{
continue;
}
if (counter > end - 1)
{
break;
}
page.add(element);
}
return new PagingResults<T>()
{
@Override
public List<T> getPage()
{
return page;
}
@Override
public boolean hasMoreItems()
{
return pageDetails.hasMoreItems();
}
@Override
public Pair<Integer, Integer> getTotalResultCount()
{
Integer total = totalSize;
return new Pair<>(total, total);
}
@Override
public String getQueryExecutionId()
{
return null;
}
};
}
示例3: getSites
import org.alfresco.query.PageDetails; //导入方法依赖的package包/类
public CollectionWithPagingInfo<MemberOfSite> getSites(String personId, Parameters parameters)
{
Paging paging = parameters.getPaging();
personId = people.validatePerson(personId);
PagingRequest pagingRequest = Util.getPagingRequest(paging);
// get the sorting options
List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<>(parameters.getSorting().size());
List<SortColumn> sortCols = parameters.getSorting();
if ((sortCols != null) && (sortCols.size() > 0))
{
for (SortColumn sortCol : sortCols)
{
SiteService.SortFields sortProp = SORT_SITE_MEMBERSHIP.get(sortCol.column);
if (sortProp == null)
{
throw new InvalidArgumentException("Invalid sort field: "+sortCol.column);
}
sortPairs.add(new Pair<>(sortProp, (sortCol.asc ? SortOrder.ASCENDING : SortOrder.DESCENDING)));
}
}
else
{
// default sort order
sortPairs.add(new Pair<SiteService.SortFields, SortOrder>(
SiteService.SortFields.SiteTitle,
SortOrder.ASCENDING ));
}
// get the unsorted list of site memberships
List<SiteMembership> siteMembers = siteService.listSiteMemberships(personId, 0);
// sort the list of site memberships
int totalSize = siteMembers.size();
final List<SiteMembership> sortedSiteMembers = new ArrayList<>(siteMembers);
Collections.sort(sortedSiteMembers, new SiteMembershipComparator(
sortPairs,
SiteMembershipComparator.Type.SITES));
PageDetails pageDetails = PageDetails.getPageDetails(pagingRequest, totalSize);
List<MemberOfSite> ret = new ArrayList<>(totalSize);
List<FilterProp> filterProps = getFilterPropListOfSites(parameters);
int counter;
int totalItems = 0;
Iterator<SiteMembership> it = sortedSiteMembers.iterator();
for(counter = 0; it.hasNext();)
{
SiteMembership siteMember = it.next();
if (filterProps != null && !includeFilter(siteMember, filterProps))
{
continue;
}
if(counter < pageDetails.getSkipCount())
{
totalItems++;
counter++;
continue;
}
if (counter <= pageDetails.getEnd() - 1)
{
SiteInfo siteInfo = siteMember.getSiteInfo();
MemberOfSite memberOfSite = new MemberOfSite(siteInfo.getShortName(), siteInfo.getNodeRef(), siteMember.getRole());
ret.add(memberOfSite);
counter++;
}
totalItems++;
}
return CollectionWithPagingInfo.asPaged(paging, ret, counter < totalItems, totalItems);
}
示例4: getSites
import org.alfresco.query.PageDetails; //导入方法依赖的package包/类
public CollectionWithPagingInfo<MemberOfSite> getSites(String personId, Parameters parameters)
{
Paging paging = parameters.getPaging();
personId = people.validatePerson(personId);
PagingRequest pagingRequest = Util.getPagingRequest(paging);
// get the sorting options
List<Pair<? extends Object, SortOrder>> sortPairs = new ArrayList<Pair<? extends Object, SortOrder>>(parameters.getSorting().size());
for (SortColumn sortColumn : parameters.getSorting())
{
SiteService.SortFields sortField;
try
{
sortField= SiteService.SortFields.valueOf(sortColumn.column);
}
catch (IllegalArgumentException ex)
{
// invalid sort field
continue;
}
sortPairs.add(new Pair<SiteService.SortFields, SortOrder>(
sortField,
(sortColumn.asc ? SortOrder.ASCENDING : SortOrder.DESCENDING)));
}
// if no sorting options were specify, sort by title
if(sortPairs.size() == 0)
{
sortPairs.add(new Pair<SiteService.SortFields, SortOrder>(
SiteService.SortFields.SiteTitle,
SortOrder.ASCENDING ));
}
// get the unsorted list of site memberships
List<SiteMembership> siteMembers = siteService.listSiteMemberships (personId, 0);
// sort the list of site memberships
int totalSize = siteMembers.size();
final List<SiteMembership> sortedSiteMembers = new ArrayList<>(siteMembers);
Collections.sort(sortedSiteMembers, new SiteMembershipComparator(
sortPairs,
SiteMembershipComparator.Type.SITES));
PageDetails pageDetails = PageDetails.getPageDetails(pagingRequest, totalSize);
List<MemberOfSite> ret = new ArrayList<>(totalSize);
Iterator<SiteMembership> it = sortedSiteMembers.iterator();
for(int counter = 0; counter < pageDetails.getEnd() && it.hasNext(); counter++)
{
SiteMembership siteMember = it.next();
if(counter < pageDetails.getSkipCount())
{
continue;
}
if(counter > pageDetails.getEnd() - 1)
{
break;
}
SiteInfo siteInfo = siteMember.getSiteInfo();
MemberOfSite memberOfSite = new MemberOfSite(siteInfo.getShortName(), siteInfo.getNodeRef(), siteMember.getRole());
ret.add(memberOfSite);
}
return CollectionWithPagingInfo.asPaged(paging, ret, pageDetails.hasMoreItems(), null);
}