use of org.entando.entando.web.common.model.PagedMetadata in project entando-core by entando.
the class PageModelService method getPageModels.
@Override
public PagedMetadata<PageModelDto> getPageModels(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(PageModelDto.getEntityFieldName(i.getKey())));
SearcherDaoPaginatedResult<PageModel> pageModels = this.getPageModelManager().searchPageModels(filters);
List<PageModelDto> dtoList = null;
if (null != pageModels) {
dtoList = this.getDtoBuilder().convert(pageModels.getList());
}
PagedMetadata<PageModelDto> pagedMetadata = new PagedMetadata<>(restListReq, pageModels);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in search pageModels", t);
throw new RestServerError("error in search pageModels", t);
}
}
use of org.entando.entando.web.common.model.PagedMetadata in project entando-core by entando.
the class RoleService method getRoles.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public PagedMetadata<RoleDto> getRoles(RestListRequest restRequest) {
List<Role> roles = this.getRoleManager().getRoles();
roles = sortRoleList(restRequest, roles);
if (null != restRequest.getFilter()) {
for (Filter f : restRequest.getFilter()) {
if (f.getAttributeName().equals(KEY_FILTER_ROLE_CODE)) {
roles = roles.stream().filter(i -> i.getName().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
if (f.getAttributeName().equals(KEY_FILTER_ROLE_DESCR)) {
roles = roles.stream().filter(i -> i.getDescription().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
}
}
List<Role> subList = restRequest.getSublist(roles);
List<RoleDto> dtoSlice = this.getDtoBuilder().convert(subList);
SearcherDaoPaginatedResult<RoleDto> paginatedResult = new SearcherDaoPaginatedResult(roles.size(), dtoSlice);
PagedMetadata<RoleDto> pagedMetadata = new PagedMetadata<>(restRequest, paginatedResult);
pagedMetadata.setBody(dtoSlice);
return pagedMetadata;
}
use of org.entando.entando.web.common.model.PagedMetadata in project entando-core by entando.
the class UserService method getUsers.
@Override
public PagedMetadata<UserDto> getUsers(RestListRequest requestList) {
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>(requestList.buildFieldSearchFilters());
filters.stream().filter(i -> ((i.getKey() != null) && (UserDto.getEntityFieldName(i.getKey()) != null))).forEach(i -> i.setKey(UserDto.getEntityFieldName(i.getKey())));
List<UserDetails> users = null;
if (filters.size() > 0) {
String text = (String) filters.get(0).getValue();
users = this.getUserManager().searchUsers(text);
} else {
users = this.getUserManager().getUsers();
}
List<UserDto> dtoList = dtoBuilder.convert(users);
SearcherDaoPaginatedResult<UserDetails> result = new SearcherDaoPaginatedResult<>(users.size(), users);
PagedMetadata<UserDto> pagedMetadata = new PagedMetadata<>(requestList, result);
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 org.entando.entando.web.common.model.PagedMetadata in project entando-core by entando.
the class WidgetService method getWidgets.
@SuppressWarnings("rawtypes")
@Override
public PagedMetadata<WidgetDto> getWidgets(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<>(restListReq.buildFieldSearchFilters());
filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(WidgetDto.getEntityFieldName(i.getKey())));
SearcherDaoPaginatedResult<WidgetType> widgets = this.getWidgetManager().getWidgetTypes(filters);
List<WidgetDto> dtoList = dtoBuilder.convert(widgets.getList());
for (WidgetDto widgetDto : dtoList) {
this.addFragments(widgetDto);
}
PagedMetadata<WidgetDto> pagedMetadata = new PagedMetadata<>(restListReq, widgets);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in get widgets", t);
throw new RestServerError("error in get widgets", t);
}
}
use of org.entando.entando.web.common.model.PagedMetadata in project entando-core by entando.
the class CategoryService method getCategoryReferences.
@Override
public PagedMetadata<?> getCategoryReferences(String categoryCode, String managerName, RestListRequest restListRequest) {
Category group = this.getCategoryManager().getCategory(categoryCode);
if (null == group) {
logger.warn("no category found with code {}", categoryCode);
throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_CATEGORY_NOT_FOUND, "category", categoryCode);
}
CategoryServiceUtilizer<?> utilizer = this.getCategoryServiceUtilizer(managerName);
if (null == utilizer) {
logger.warn("no references found for {}", managerName);
throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_CATEGORY_NO_REFERENCES, "reference", managerName);
}
List<?> dtoList = utilizer.getCategoryUtilizer(categoryCode);
List<?> subList = restListRequest.getSublist(dtoList);
SearcherDaoPaginatedResult<?> pagedResult = new SearcherDaoPaginatedResult(dtoList.size(), subList);
PagedMetadata<Object> pagedMetadata = new PagedMetadata<>(restListRequest, pagedResult);
pagedMetadata.setBody((List<Object>) subList);
return pagedMetadata;
}
Aggregations