use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class AbstractApiAction method getPermissionAutorityOptions.
public List<SelectItem> getPermissionAutorityOptions() {
List<SelectItem> items = new ArrayList<SelectItem>();
try {
List<Permission> permissions = new ArrayList<Permission>();
permissions.addAll(this.getRoleManager().getPermissions());
BeanComparator comparator = new BeanComparator("description");
Collections.sort(permissions, comparator);
for (int i = 0; i < permissions.size(); i++) {
Permission permission = permissions.get(i);
items.add(new SelectItem(permission.getName(), this.getPermissionAutorityOptionPrefix() + permission.getDescription()));
}
} catch (Throwable t) {
_logger.error("Error extracting autority options", t);
}
return items;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class ApiServiceFinderAction method getServiceFlavours.
public Map<String, List<ApiSelectItem>> getServiceFlavours() {
Map<String, List<ApiSelectItem>> groups = new HashMap<String, List<ApiSelectItem>>();
try {
this.buildServiceGroups(groups);
Iterator<List<ApiSelectItem>> groupIter = groups.values().iterator();
while (groupIter.hasNext()) {
List<ApiSelectItem> group = groupIter.next();
BeanComparator comparator = new BeanComparator("value");
Collections.sort(group, comparator);
}
} catch (Throwable t) {
_logger.error("Error extracting Flavours services", t);
// ApsSystemUtils.logThrowable(t, this, "getServiceFlavours");
throw new RuntimeException("Error extracting Flavours services", t);
}
return groups;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class PageModelFinderAction method getPageModels.
public List<PageModel> getPageModels() {
List<PageModel> models = new ArrayList<PageModel>();
models.addAll(this.getPageModelManager().getPageModels());
BeanComparator c = new BeanComparator("description");
Collections.sort(models, c);
return models;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class EntityTypesInfoTag method getMasterObject.
@Override
protected Object getMasterObject(String keyValue) throws Throwable {
String managerNameValue = (String) super.findValue(keyValue, String.class);
try {
IEntityManager entityManager = (IEntityManager) ApsWebApplicationUtils.getBean(managerNameValue, this.pageContext);
if (null != entityManager) {
List<IApsEntity> entityTypes = new ArrayList<IApsEntity>();
Map<String, IApsEntity> typeMap = entityManager.getEntityPrototypes();
if (null != typeMap) {
BeanComparator c = new BeanComparator(this.getOrderBy());
entityTypes.addAll(typeMap.values());
Collections.sort(entityTypes, c);
}
return entityTypes;
} else {
_logger.debug("Null entity manager : service name '{}'", managerNameValue);
}
} catch (Throwable t) {
String message = "Error extracting entity types : entity manager '" + managerNameValue + "'";
_logger.error("Error extracting entity types : entity manager '{}'", managerNameValue, t);
// ApsSystemUtils.logThrowable(t, this, "getMasterObject", message);
throw new ApsSystemException(message, t);
}
return null;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class ShortcutListTag method getAllowedShortcutSelectItems.
public List<SelectItem> getAllowedShortcutSelectItems(List<Shortcut> myShortcuts, UserDetails currentUser) {
List<SelectItem> items = new ArrayList<SelectItem>();
if (null == myShortcuts || myShortcuts.isEmpty()) {
_logger.debug("shortcut list null");
return items;
}
try {
Map<String, List<SelectItem>> groups = new HashMap<String, List<SelectItem>>();
for (int i = 0; i < myShortcuts.size(); i++) {
Shortcut shortcut = myShortcuts.get(i);
String groupCode = shortcut.getSource();
String optgroup = shortcut.getSource();
if (groupCode.equals("core")) {
groupCode += " - " + shortcut.getMenuSection().getId();
String sectDescrKey = shortcut.getMenuSection().getDescriptionKey();
String sectDescr = this.getText(sectDescrKey);
if (null == sectDescrKey || sectDescrKey.equals(sectDescr)) {
sectDescr = shortcut.getMenuSection().getDescription();
}
optgroup += " - " + sectDescr;
} else {
String labelCode = optgroup + ".name";
String optgroupDescr = this.getText(labelCode);
if (!optgroupDescr.equals(labelCode)) {
optgroup = optgroupDescr;
}
}
String descrKey = shortcut.getDescriptionKey();
String descr = this.getText(descrKey);
if (null == descrKey || descrKey.equals(descr)) {
descr = shortcut.getDescription();
}
List<SelectItem> itemsByGroup = groups.get(groupCode);
if (null == itemsByGroup) {
itemsByGroup = new ArrayList<SelectItem>();
groups.put(groupCode, itemsByGroup);
}
SelectItem selectItem = new SelectItem(shortcut.getId(), descr, optgroup);
itemsByGroup.add(selectItem);
}
List<String> keys = new ArrayList<String>(groups.keySet());
Collections.sort(keys);
for (int i = 0; i < keys.size(); i++) {
List<SelectItem> itemsByGroup = groups.get(keys.get(i));
BeanComparator comparator = new BeanComparator("value");
Collections.sort(itemsByGroup, comparator);
items.addAll(itemsByGroup);
}
} catch (Throwable t) {
_logger.error("Error extracting allowed shortcut items by user {}", currentUser.getUsername(), t);
throw new RuntimeException("Error extracting allowed shortcut items by user " + currentUser.getUsername(), t);
}
return items;
}
Aggregations