Search in sources :

Example 26 with BeanComparator

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

the class WidgetTypeManager method getWidgetTypes.

@Override
public List<WidgetType> getWidgetTypes() {
    List<WidgetType> types = new ArrayList<WidgetType>();
    types.addAll(this.getCacheWrapper().getWidgetTypes());
    BeanComparator comparator = new BeanComparator("code");
    Collections.sort(types, comparator);
    return types;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 27 with BeanComparator

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

the class AbstractEntityService method getShortEntityTypes.

protected PagedMetadata<EntityTypeShortDto> getShortEntityTypes(String entityManagerCode, RestListRequest requestList) {
    IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
    List<IApsEntity> entityTypes = new ArrayList<>(entityManager.getEntityPrototypes().values());
    Map<String, String> fieldMapping = this.getEntityTypeFieldNameMapping();
    entityTypes.stream().filter(i -> this.filterObjects(i, requestList.getFilter(), fieldMapping));
    Collections.sort(entityTypes, new BeanComparator(this.getFieldName(requestList.getSort(), fieldMapping)));
    if (!RestListRequest.DIRECTION_VALUE_DEFAULT.equals(requestList.getDirection())) {
        Collections.reverse(entityTypes);
    }
    List<IApsEntity> sublist = requestList.getSublist(entityTypes);
    SearcherDaoPaginatedResult<IApsEntity> result = new SearcherDaoPaginatedResult(entityTypes.size(), sublist);
    PagedMetadata<EntityTypeShortDto> pagedMetadata = new PagedMetadata<>(requestList, result);
    List<EntityTypeShortDto> body = this.getEntityTypeShortDtoBuilder().convert(sublist);
    for (EntityTypeShortDto entityTypeShortDto : body) {
        String code = entityTypeShortDto.getCode();
        entityTypeShortDto.setStatus(String.valueOf(entityManager.getStatus(code)));
    }
    pagedMetadata.setBody(body);
    return pagedMetadata;
}
Also used : PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) EntityTypeShortDto(org.entando.entando.aps.system.services.entity.model.EntityTypeShortDto) ArrayList(java.util.ArrayList) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) BeanComparator(org.apache.commons.beanutils.BeanComparator) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 28 with BeanComparator

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

the class DataSourceDumpReport method getComponentsHistory.

public List<ComponentInstallationReport> getComponentsHistory() {
    BeanComparator comparator = new BeanComparator("date");
    Collections.sort(this._componentsHistory, comparator);
    return _componentsHistory;
}
Also used : BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 29 with BeanComparator

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

the class ApiServiceInterface method getServices.

public ArrayList<ServiceInfo> getServices(Properties properties) throws ApiException {
    ArrayList<ServiceInfo> services = new ArrayList<ServiceInfo>();
    try {
        String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
        String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
        String tagParamValue = properties.getProperty("tag");
        // String myentandoParamValue = properties.getProperty("myentando");
        // Boolean myentando = (null != myentandoParamValue && myentandoParamValue.trim().length() > 0) ? Boolean.valueOf(myentandoParamValue) : null;
        langCode = (null != langCode && null != this.getLangManager().getLang(langCode)) ? langCode : defaultLangCode;
        Map<String, ApiService> masterServices = this.getApiCatalogManager().getServices(tagParamValue);
        Iterator<ApiService> iter = masterServices.values().iterator();
        while (iter.hasNext()) {
            ApiService service = (ApiService) iter.next();
            if (service.isActive() && !service.isHidden() && this.checkServiceAuthorization(service, properties, false)) {
                ServiceInfo smallService = this.createServiceInfo(service, langCode, defaultLangCode);
                services.add(smallService);
            }
        }
        BeanComparator comparator = new BeanComparator("description");
        Collections.sort(services, comparator);
    } catch (Throwable t) {
        _logger.error("Error extracting services", t);
        throw new ApiException(IApiErrorCodes.SERVER_ERROR, "Internal error");
    }
    return services;
}
Also used : ServiceInfo(org.entando.entando.aps.system.services.api.model.ServiceInfo) ApiService(org.entando.entando.aps.system.services.api.model.ApiService) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 30 with BeanComparator

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

the class ResourceFinderAction method getImageDimensions.

public List<ImageResourceDimension> getImageDimensions() {
    Map<Integer, ImageResourceDimension> master = this.getImageDimensionManager().getImageDimensions();
    List<ImageResourceDimension> dimensions = new ArrayList<ImageResourceDimension>(master.values());
    BeanComparator comparator = new BeanComparator("dimx");
    Collections.sort(dimensions, comparator);
    return dimensions;
}
Also used : ArrayList(java.util.ArrayList) ImageResourceDimension(com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResourceDimension) 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