use of com.revolsys.ui.web.annotation.ColumnSortOrder in project com.revolsys.open by revolsys.
the class HtmlUiBuilder method initPages.
protected void initPages() {
final Class<?> clazz = getClass();
final Method[] methods = clazz.getMethods();
for (final Method method : methods) {
final String name = method.getName();
final RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
if (requestMapping != null) {
String pageName = requestMapping.name();
if (Property.isEmpty(pageName)) {
pageName = name;
}
String title = requestMapping.title();
if (Property.isEmpty(title)) {
title = CaseConverter.toCapitalizedWords(pageName);
}
final boolean secure = requestMapping.secure();
String path = null;
final String[] paths = requestMapping.value();
if (paths.length > 0) {
path = paths[0];
}
final String[] fieldNames = requestMapping.fieldNames();
if (fieldNames.length > 0) {
newView(pageName, Arrays.asList(fieldNames));
newKeyList(pageName, Arrays.asList(fieldNames));
final ColumnSortOrder[] columnSortOrder = requestMapping.columnSortOrder();
final List<List<Object>> tableSortOrder = new ArrayList<>();
for (final ColumnSortOrder sortOrder : columnSortOrder) {
int fieldIndex = -1;
final String sortFieldName = sortOrder.value();
for (int i = 0; i < fieldNames.length; i++) {
final String fieldName = fieldNames[i];
if (sortFieldName.equals(fieldName)) {
fieldIndex = i;
}
}
final boolean ascending = sortOrder.ascending();
String direction;
if (ascending) {
direction = "asc";
} else {
direction = "desc";
}
tableSortOrder.add(Arrays.asList(fieldIndex, direction));
}
if (!tableSortOrder.isEmpty()) {
setListSortOrder(pageName, tableSortOrder);
}
}
final String permission = requestMapping.permission();
final Page page = new Page(pageName, title, path, secure);
page.setPermission(permission);
addPage(page);
}
}
}
Aggregations