use of org.entando.entando.web.common.model.RestListRequest 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.RestListRequest 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.RestListRequest 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.RestListRequest 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 org.entando.entando.web.common.model.RestListRequest 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);
}
}
Aggregations