Search in sources :

Example 41 with BeanComparator

use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.

the class PageFinderAction method searchPages.

public List<IPage> searchPages() {
    List<IPage> result = null;
    try {
        List<String> allowedGroupCodes = this.getAllowedGroupCodes();
        result = this.getPageManager().searchPages(this.getPageCodeToken(), allowedGroupCodes);
        BeanComparator comparator = new BeanComparator("code");
        Collections.sort(result, comparator);
        if (result != null) {
            if (result.size() > 0) {
                this.setFirstNode(result.get(0));
            }
            Collection<String> resultCodes = new ArrayList<>();
            for (IPage page : result) {
                resultCodes.add(page.getCode());
            }
            this.setResultCodes(resultCodes);
        }
    } catch (Throwable t) {
        _logger.error("Error on searching pages", t);
        throw new RuntimeException("Error on searching pages", t);
    }
    return result;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 42 with BeanComparator

use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.

the class BaseAction method getActualAllowedGroups.

protected List<Group> getActualAllowedGroups() {
    if (null != this._actualAllowedGroups) {
        return _actualAllowedGroups;
    }
    this._actualAllowedGroups = new ArrayList<Group>();
    UserDetails currentUser = this.getCurrentUser();
    if (null == currentUser || null == this.getRequiredPermissions()) {
        return this._actualAllowedGroups;
    }
    Iterator<String> iter = this.getRequiredPermissions().iterator();
    while (iter.hasNext()) {
        String permissionName = iter.next();
        List<Group> groupsByPermission = this.getAuthorizationManager().getGroupsByPermission(currentUser, permissionName);
        if (null != groupsByPermission) {
            for (int i = 0; i < groupsByPermission.size(); i++) {
                Group group = groupsByPermission.get(i);
                if (null != group && !this._actualAllowedGroups.contains(group)) {
                    this._actualAllowedGroups.add(group);
                }
            }
        }
    }
    Collections.sort(this._actualAllowedGroups, new BeanComparator("description"));
    return this._actualAllowedGroups;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) UserDetails(com.agiletec.aps.system.services.user.UserDetails) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 43 with BeanComparator

use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.

the class EntityTypeConfigAction method getAttributeTypes.

public List<AttributeInterface> getAttributeTypes() {
    List<AttributeInterface> attributes = null;
    try {
        IEntityManager entityManager = this.getEntityManager();
        Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
        attributes = new ArrayList<AttributeInterface>(attributeTypes.values());
        Collections.sort(attributes, new BeanComparator("type"));
    } catch (Throwable t) {
        _logger.error("Error while extracting attribute Types", t);
        // ApsSystemUtils.logThrowable(t, this, "getAttributeTypes");
        throw new RuntimeException("Error while extracting attribute Types", t);
    }
    return attributes;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) BeanComparator(org.apache.commons.beanutils.BeanComparator) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 44 with BeanComparator

use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.

the class EntityTypesAction method getEntityPrototypes.

@Override
public List<IApsEntity> getEntityPrototypes() {
    List<IApsEntity> entityPrototypes = null;
    try {
        Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
        entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
        BeanComparator comparator = new BeanComparator("typeDescr");
        Collections.sort(entityPrototypes, comparator);
    } catch (Throwable t) {
        _logger.error("Error on extracting entity prototypes", t);
        // ApsSystemUtils.logThrowable(t, this, "getEntityPrototypes");
        throw new RuntimeException("Error on extracting entity prototypes", t);
    }
    return entityPrototypes;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 45 with BeanComparator

use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.

the class HookPointTag method extractElements.

private List<HookPointElementContainer> extractElements(HttpServletRequest request) {
    WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
    String[] beanNames = wac.getBeanNamesForType(HookPointElementContainer.class);
    List<HookPointElementContainer> containers = new ArrayList<HookPointElementContainer>();
    for (int i = 0; i < beanNames.length; i++) {
        HookPointElementContainer container = (HookPointElementContainer) wac.getBean(beanNames[i]);
        if (null != container && null != container.getHookPointKey() && container.getHookPointKey().equals(this.getKey())) {
            containers.add(container);
        }
    }
    BeanComparator comparator = new BeanComparator("priority");
    Collections.sort(containers, comparator);
    return containers;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) WebApplicationContext(org.springframework.web.context.WebApplicationContext) HookPointElementContainer(com.agiletec.apsadmin.system.plugin.HookPointElementContainer)

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