use of com.liferay.portal.kernel.dao.search.ResultRow in project index-checker by jorgediaz-lr.
the class IndexCheckerOutput method generateSearchContainer.
public static SearchContainer<Comparison> generateSearchContainer(PortletConfig portletConfig, RenderRequest renderRequest, boolean groupBySite, Map<Long, List<Comparison>> resultDataMap, PortletURL serverURL) {
Locale locale = renderRequest.getLocale();
ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);
String[] headerKeys;
if (groupBySite) {
headerKeys = new String[] { "output.groupid", "output.groupname", "output.entityclass", "output.entityname", "output.errortype", "output.count", "output.primarykeys" };
} else {
headerKeys = new String[] { "output.entityclass", "output.entityname", "output.errortype", "output.count", "output.primarykeys" };
}
List<String> headerNames = OutputUtils.getHeaders(portletConfig, locale, headerKeys);
SearchContainer<Comparison> searchContainer = new SearchContainer<>(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.MAX_DELTA, serverURL, headerNames, null);
int numberOfRows = 0;
for (Map.Entry<Long, List<Comparison>> entry : resultDataMap.entrySet()) {
String groupIdOutput = null;
String groupNameOutput = null;
if (groupBySite) {
Group group = GroupLocalServiceUtil.fetchGroup(entry.getKey());
if (group == null) {
groupIdOutput = LanguageUtil.get(resourceBundle, "output.not-applicable-groupid");
groupNameOutput = LanguageUtil.get(resourceBundle, "output.not-applicable-groupname");
} else {
groupIdOutput = "" + group.getGroupId();
groupNameOutput = group.getName(locale);
}
}
List<Comparison> results = searchContainer.getResults();
if ((results == null) || results.isEmpty()) {
results = new ArrayList<>();
}
results.addAll(entry.getValue());
results = ListUtil.subList(results, searchContainer.getStart(), searchContainer.getEnd());
searchContainer.setResults(results);
List<ResultRow> resultRows = searchContainer.getResultRows();
for (Comparison comp : entry.getValue()) {
ResultRow rowError = OutputUtils.generateSearchContainerRow(resourceBundle, comp, groupIdOutput, groupNameOutput, "error", locale, numberOfRows, comp.getError());
if (rowError != null) {
numberOfRows++;
resultRows.add(rowError);
}
for (String type : comp.getOutputTypes()) {
String attribute = "pk";
if (type.contains("right")) {
attribute = Field.UID;
}
int maxSize = 0;
ResultRow row = OutputUtils.generateSearchContainerRow(resourceBundle, comp, groupIdOutput, groupNameOutput, type, attribute, locale, numberOfRows, maxSize);
if (row != null) {
numberOfRows++;
resultRows.add(row);
}
}
}
}
searchContainer.setTotal(numberOfRows);
return searchContainer;
}
use of com.liferay.portal.kernel.dao.search.ResultRow in project index-checker by jorgediaz-lr.
the class OutputUtils method generateSearchContainerRow.
public static ResultRow generateSearchContainerRow(ResourceBundle resourceBundle, Comparison comp, String groupIdOutput, String groupNameOutput, String type, Locale locale, int numberOfRows, String htmlOutput, int outputSize) {
if (Validator.isNull(htmlOutput)) {
return null;
}
ResultRow row = new com.liferay.taglib.search.ResultRow(comp, type, numberOfRows);
if ((groupIdOutput != null) && (groupNameOutput != null)) {
row.addText(groupIdOutput);
row.addText(groupNameOutput);
}
String output = HtmlUtil.escape(LanguageUtil.get(resourceBundle, "output." + type));
row.addText(HtmlUtil.escape(comp.getModelName()));
row.addText(HtmlUtil.escape(comp.getModelDisplayName(locale)));
row.addText(output.replace(" ", " "));
if (outputSize < 0) {
row.addText(StringPool.BLANK);
} else {
row.addText(StringPool.BLANK + outputSize);
}
row.addText(htmlOutput);
return row;
}
Aggregations