use of com.liferay.knowledgebase.model.impl.KBTemplateSearchDisplayImpl in project liferay-ide by liferay.
the class KBTemplateServiceImpl method getKBTemplateSearchDisplay.
@Override
public KBTemplateSearchDisplay getKBTemplateSearchDisplay(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator, int[] curStartValues, int cur, int delta, OrderByComparator orderByComparator) throws PortalException, SystemException {
// See LPS-9546
int start = 0;
if (curStartValues.length > (cur - SearchContainer.DEFAULT_CUR)) {
start = curStartValues[cur - SearchContainer.DEFAULT_CUR];
curStartValues = ArrayUtil.subset(curStartValues, 0, cur - SearchContainer.DEFAULT_CUR + 1);
} else {
cur = SearchContainer.DEFAULT_CUR;
curStartValues = new int[] { 0 };
}
int end = start + _INTERVAL;
List<KBTemplate> kbTemplates = new ArrayList<KBTemplate>();
int curStartValue = 0;
while (curStartValue == 0) {
List<KBTemplate> curKBTemplates = kbTemplateLocalService.search(groupId, title, content, startDate, endDate, andOperator, start, end, orderByComparator);
if (curKBTemplates.isEmpty()) {
break;
}
for (int i = 0; i < curKBTemplates.size(); i++) {
KBTemplate curKBTemplate = curKBTemplates.get(i);
if (!KBTemplatePermission.contains(getPermissionChecker(), curKBTemplate, ActionKeys.VIEW)) {
continue;
}
if (kbTemplates.size() == delta) {
curStartValue = start + i;
break;
}
kbTemplates.add(curKBTemplate);
}
start = start + _INTERVAL;
end = start + _INTERVAL;
}
int total = ((cur - 1) * delta) + kbTemplates.size();
if (curStartValue > 0) {
curStartValues = ArrayUtil.append(curStartValues, curStartValue);
total = total + 1;
}
return new KBTemplateSearchDisplayImpl(kbTemplates, total, curStartValues);
}
Aggregations