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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations