use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class EntityAttributeConfigAction method getAllowedNestedTypes.
public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
try {
IEntityManager entityManager = this.getEntityManager();
Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
while (attributeIter.hasNext()) {
AttributeInterface attribute = attributeIter.next();
boolean simple = attribute.isSimple();
boolean multiLanguage = attribute.isMultilingual();
if ((listType instanceof ListAttribute && simple && !multiLanguage) || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
attributes.add(attribute);
}
}
Collections.sort(attributes, new BeanComparator("type"));
} catch (Throwable t) {
_logger.error("Error while extracting Allowed Nested Types", t);
// ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
throw new RuntimeException("Error while extracting Allowed Nested Types", t);
}
return attributes;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class GroupFinderAction method getGroups.
public List<Group> getGroups() {
List<Group> groups = this.getGroupManager().getGroups();
BeanComparator comparator = new BeanComparator("descr");
Collections.sort(groups, comparator);
return groups;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class CategoryAction method getAvailableNodesForMoveTreeAjax.
public List<TreeNodeWrapper> getAvailableNodesForMoveTreeAjax() {
List<TreeNodeWrapper> result = new ArrayList<TreeNodeWrapper>();
try {
String startCategoryCode = this.getSelectedNode();
if (StringUtils.isBlank(startCategoryCode)) {
_logger.warn("required parameter 'selectedNode' missing");
return result;
}
Category nodeToMove = this.getCategory(startCategoryCode);
if (null == nodeToMove) {
_logger.warn("category {} is null", startCategoryCode);
return result;
}
// XXX FIX JS
this.setCategoryCodeToken(super.getParameter("categoryCodeToken"));
List<Category> searchResult = this.getCategoryManager().searchCategories(this.getCategoryCodeToken());
if (null == searchResult || searchResult.isEmpty()) {
return result;
}
BeanComparator comparator = new BeanComparator("code");
Collections.sort(result, comparator);
int maxIndex = 30;
String maxParam = super.getParameter("max");
if (StringUtils.isNotBlank(maxParam) && StringUtils.isNumeric(maxParam)) {
maxIndex = new Integer(maxParam).intValue();
}
Iterator<Category> it = searchResult.iterator();
while (result.size() < maxIndex && it.hasNext()) {
ITreeNode candidate = it.next();
if (!candidate.isChildOf(nodeToMove.getCode()) && !candidate.getCode().equals(nodeToMove.getParentCode())) {
result.add(new TreeNodeWrapper(candidate, this.getCurrentLang().getCode()));
}
}
} catch (Throwable t) {
_logger.error("Error on searching categories ajax", t);
throw new RuntimeException("Error on searching categories ajax", t);
}
return result;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class PageTreeMenuAction method addGroup.
private void addGroup(String code, Map<String, List<SelectItem>> mapping, List<List<SelectItem>> group) {
List<SelectItem> singleGroup = mapping.get(code);
if (null != singleGroup) {
BeanComparator comparator = new BeanComparator("value");
Collections.sort(singleGroup, comparator);
group.add(singleGroup);
}
}
use of org.apache.commons.beanutils.BeanComparator in project coprhd-controller by CoprHD.
the class CreationTimeComparator method getComparator.
private ComparatorChain getComparator() {
if (COMPARATOR == null) {
COMPARATOR = new ComparatorChain();
COMPARATOR.addComparator(new BeanComparator(CREATION_TIME, new NullComparator()), reverseOrder);
}
return COMPARATOR;
}
Aggregations