use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class GroupServiceIntegrationTest method testGetGroups_filter.
@Test
public void testGetGroups_filter() throws JsonProcessingException {
RestListRequest restListRequest = new RestListRequest();
restListRequest.addFilter(new Filter("groupname", "fr"));
PagedMetadata<GroupDto> res = this.groupService.getGroups(restListRequest);
assertThat(res.getPage(), is(1));
assertThat(res.getPageSize(), is(100));
assertThat(res.getLastPage(), is(1));
assertThat(res.getTotalItems(), is(1));
}
use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class LanguageServiceTest method shouldFilterByCode.
@Test
public void shouldFilterByCode() {
RestListRequest requestList = new RestListRequest();
Filter filter = new Filter();
filter.setAttribute("code");
filter.setValue("it");
requestList.addFilter(filter);
PagedMetadata<LanguageDto> result = languageService.getLanguages(requestList);
assertThat(result.getBody()).hasSize(1);
assertThat(result.getBody().get(0).getCode()).isEqualTo("it");
}
use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class LanguageServiceTest method shouldFilterByDescription.
@Test
public void shouldFilterByDescription() {
RestListRequest requestList = new RestListRequest();
Filter filter = new Filter();
filter.setAttribute("description");
filter.setValue("English");
requestList.addFilter(filter);
PagedMetadata<LanguageDto> result = languageService.getLanguages(requestList);
assertThat(result.getBody()).hasSize(1);
assertThat(result.getBody().get(0).getCode()).isEqualTo("en");
}
use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class ActivityStreamService method buildSearchBean.
protected ActionLogRecordSearchBean buildSearchBean(RestListRequest requestList, UserDetails userDetails) {
ActionLogRecordApiSearchBean searchBean = new ActionLogRecordApiSearchBean();
// groups
if (null != requestList.getSort()) {
String direction = requestList.getDirection();
direction = (null != direction && (direction.equalsIgnoreCase("ASC") || direction.equalsIgnoreCase("DESC"))) ? direction : "DESC";
searchBean.setOrderBy(ActionLogRecordDto.getEntityFieldName(requestList.getSort()));
searchBean.setDirection(direction);
}
int offset = 0;
int page = requestList.getPage() - 1;
if (null != requestList.getPage() && requestList.getPage() != 0) {
offset = requestList.getPageSize() * page;
}
searchBean.setOffset(offset);
searchBean.setPageSize(requestList.getPageSize());
List<Group> userGroups = this.getAuthorizationManager().getUserGroups(userDetails);
searchBean.setUserGroupCodes(userGroups.stream().map(i -> i.getAuthority()).collect(Collectors.toList()));
if (null == requestList.getFilters() || requestList.getFilters().length == 0) {
return searchBean;
}
for (Filter f : requestList.getFilters()) {
// creation date range
if (f.getAttributeName().equals(KEY_FILTER_CREATION)) {
DateRange range = new DateRange(f.getValue());
searchBean.setStartCreation(range.getStart());
searchBean.setEndCreation(range.getEnd());
}
// update date range
if (f.getAttributeName().equals(KEY_FILTER_UPDATE)) {
DateRange range = new DateRange(f.getValue());
searchBean.setStartCreation(range.getStart());
searchBean.setEndCreation(range.getEnd());
}
if (f.getAttributeName().equals(KEY_FILTER_USERNAME)) {
searchBean.setUsername(f.getValue());
}
if (f.getAttributeName().equals(KEY_FILTER_NS)) {
searchBean.setNamespace(f.getValue());
}
if (f.getAttributeName().equals(KEY_FILTER_ACTIONNAME)) {
searchBean.setActionName(f.getValue());
}
if (f.getAttributeName().equals(KEY_FILTER_PARAMS)) {
searchBean.setParams(f.getValue());
}
}
return searchBean;
}
use of org.entando.entando.web.common.model.Filter in project entando-core by entando.
the class TestPageModelManager method testSearch_with_page_filter.
public void testSearch_with_page_filter() throws ApsSystemException {
RestListRequest restListRequest = new RestListRequest();
restListRequest.setPageSize(2);
restListRequest.setPage(1);
List<FieldSearchFilter> filters = restListRequest.buildFieldSearchFilters();
SearcherDaoPaginatedResult<PageModel> result = this._pageModelManager.searchPageModels(filters);
assertThat(result.getCount(), is(3));
assertThat(result.getList().size(), is(2));
restListRequest.addFilter(new Filter("descr", "modello"));
result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
assertThat(result.getCount(), is(2));
assertThat(result.getList().size(), is(2));
restListRequest.setPage(0);
result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
assertThat(result.getCount(), is(2));
assertThat(result.getList().size(), is(2));
}
Aggregations