Search in sources :

Example 11 with BeanComparator

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;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) AbstractListAttribute(com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)

Example 12 with BeanComparator

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;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 13 with BeanComparator

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;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) TreeNodeWrapper(com.agiletec.apsadmin.system.TreeNodeWrapper) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode)

Example 14 with BeanComparator

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);
    }
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 15 with BeanComparator

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;
}
Also used : ComparatorChain(org.apache.commons.collections.comparators.ComparatorChain) NullComparator(org.apache.commons.collections.comparators.NullComparator) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Aggregations

BeanComparator (org.apache.commons.beanutils.BeanComparator)50 ArrayList (java.util.ArrayList)25 SelectItem (com.agiletec.aps.util.SelectItem)6 NullComparator (org.apache.commons.collections.comparators.NullComparator)6 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)5 Group (com.agiletec.aps.system.services.group.Group)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)3 Comparator (java.util.Comparator)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ComparatorChain (org.apache.commons.collections.comparators.ComparatorChain)3 ReverseComparator (org.apache.commons.collections.comparators.ReverseComparator)3 Role (com.agiletec.aps.system.services.role.Role)2 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 SmallEntityType (com.agiletec.aps.system.common.entity.model.SmallEntityType)1 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)1 AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)1 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)1