Search in sources :

Example 6 with SearcherDaoPaginatedResult

use of com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult in project entando-core by entando.

the class DatabaseService method getShortDumpReportDtos.

@Override
public PagedMetadata<ShortDumpReportDto> getShortDumpReportDtos(RestListRequest requestList) {
    PagedMetadata<ShortDumpReportDto> result = null;
    List<ShortDumpReportDto> dtos = new ArrayList<>();
    try {
        List<DataSourceDumpReport> reports = this.getDatabaseManager().getBackupReports();
        if (null != reports) {
            reports.stream().forEach(report -> dtos.add(new ShortDumpReportDto(report)));
        }
        List<ShortDumpReportDto> sublist = requestList.getSublist(dtos);
        int size = (null != reports) ? reports.size() : 0;
        SearcherDaoPaginatedResult searchResult = new SearcherDaoPaginatedResult(size, sublist);
        result = new PagedMetadata<>(requestList, searchResult);
        result.setBody(sublist);
    } catch (Throwable t) {
        logger.error("error extracting database reports", t);
        throw new RestServerError("error extracting database reports", t);
    }
    return result;
}
Also used : DataSourceDumpReport(org.entando.entando.aps.system.init.model.DataSourceDumpReport) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto)

Example 7 with SearcherDaoPaginatedResult

use of com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult in project entando-core by entando.

the class DataObjectModelService method getDataObjectModels.

@Override
public PagedMetadata<DataModelDto> getDataObjectModels(RestListRequest restListReq) {
    PagedMetadata<DataModelDto> pagedMetadata = null;
    try {
        List<FieldSearchFilter> filters = new ArrayList<>(restListReq.buildFieldSearchFilters());
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        filters.stream().filter(searchFilter -> searchFilter.getKey() != null).forEach(searchFilter -> {
            searchFilter.setKey(DataModelDto.getEntityFieldName(searchFilter.getKey()));
            if (searchFilter.getKey().equals("modelid") && null != searchFilter.getValue()) {
                String stringValue = searchFilter.getValue().toString();
                Long value = Long.parseLong(stringValue);
                searchFilter = new FieldSearchFilter("modelid", value, true);
            }
        });
        SearcherDaoPaginatedResult<DataObjectModel> models = this.getDataObjectModelManager().getDataObjectModels(filters);
        List<DataModelDto> dtoList = this.getDtoBuilder().convert(models.getList());
        pagedMetadata = new PagedMetadata<>(restListReq, models);
        pagedMetadata.setBody(dtoList);
    } catch (Throwable t) {
        logger.error("error in search data models", t);
        throw new RestServerError("error in search data models", t);
    }
    return pagedMetadata;
}
Also used : Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) RestServerError(org.entando.entando.aps.system.exception.RestServerError) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) GuiFragmentValidator(org.entando.entando.web.guifragment.validator.GuiFragmentValidator) DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) Map(java.util.Map) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) DataObjectModelRequest(org.entando.entando.web.dataobjectmodel.model.DataObjectModelRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 8 with SearcherDaoPaginatedResult

use of com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult in project entando-core by entando.

the class GroupService method getGroupReferences.

@Override
public PagedMetadata<?> getGroupReferences(String groupCode, String managerName, RestListRequest restRequest) {
    Group group = this.getGroupManager().getGroup(groupCode);
    if (null == group) {
        logger.warn("no group found with code {}", groupCode);
        throw new RestRourceNotFoundException(GroupValidator.ERRCODE_GROUP_NOT_FOUND, "group", groupCode);
    }
    GroupServiceUtilizer<?> utilizer = this.getGroupServiceUtilizer(managerName);
    if (null == utilizer) {
        logger.warn("no references found for {}", managerName);
        throw new RestRourceNotFoundException(GroupValidator.ERRCODE_GROUP_REFERENCES, "reference", managerName);
    }
    List<?> dtoList = utilizer.getGroupUtilizer(groupCode);
    List<?> subList = restRequest.getSublist(dtoList);
    SearcherDaoPaginatedResult<?> pagedResult = new SearcherDaoPaginatedResult(dtoList.size(), subList);
    PagedMetadata<Object> pagedMetadata = new PagedMetadata<>(restRequest, pagedResult);
    pagedMetadata.setBody((List<Object>) subList);
    return pagedMetadata;
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) Group(com.agiletec.aps.system.services.group.Group) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)

Example 9 with SearcherDaoPaginatedResult

use of com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult in project entando-core by entando.

the class GroupService method getGroups.

@SuppressWarnings("rawtypes")
@Override
public PagedMetadata<GroupDto> getGroups(RestListRequest restListReq) {
    try {
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
        filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(GroupDto.getEntityFieldName(i.getKey())));
        SearcherDaoPaginatedResult<Group> groups = this.getGroupManager().getGroups(filters);
        List<GroupDto> dtoList = dtoBuilder.convert(groups.getList());
        PagedMetadata<GroupDto> pagedMetadata = new PagedMetadata<>(restListReq, groups);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error in search groups", t);
        throw new RestServerError("error in search groups", t);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) Group(com.agiletec.aps.system.services.group.Group) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) Map(java.util.Map) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupRequest(org.entando.entando.web.group.model.GroupRequest) GroupValidator(org.entando.entando.web.group.validator.GroupValidator) Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) BeansException(org.springframework.beans.BeansException) ApplicationContext(org.springframework.context.ApplicationContext) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) Optional(java.util.Optional) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) Group(com.agiletec.aps.system.services.group.Group) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 10 with SearcherDaoPaginatedResult

use of com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult 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)

Aggregations

SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)16 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)15 ArrayList (java.util.ArrayList)9 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)8 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)7 RestListRequest (org.entando.entando.web.common.model.RestListRequest)7 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)5 List (java.util.List)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 UserDetails (com.agiletec.aps.system.services.user.UserDetails)3 Map (java.util.Map)3 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Group (com.agiletec.aps.system.services.group.Group)2 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)2 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)2