use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ApiGuiFragmentInterface method getGuiFragments.
public List<LinkedListItem> getGuiFragments(Properties properties) throws Throwable {
List<LinkedListItem> list = new ArrayList<LinkedListItem>();
try {
String code = properties.getProperty("code");
String widgettypecode = properties.getProperty("widgettypecode");
String plugincode = properties.getProperty("plugincode");
FieldSearchFilter[] filters = new FieldSearchFilter[0];
FieldSearchFilter codeFilterToAdd = null;
if (StringUtils.isNotBlank(code)) {
codeFilterToAdd = new FieldSearchFilter("code", code, true);
} else {
codeFilterToAdd = new FieldSearchFilter("code");
}
codeFilterToAdd.setOrder(FieldSearchFilter.Order.ASC);
filters = this.addFilter(filters, codeFilterToAdd);
if (StringUtils.isNotBlank(widgettypecode)) {
FieldSearchFilter filterToAdd = new FieldSearchFilter("widgettypecode", widgettypecode, true);
filters = this.addFilter(filters, filterToAdd);
}
if (StringUtils.isNotBlank(plugincode)) {
FieldSearchFilter filterToAdd = new FieldSearchFilter("plugincode", plugincode, true);
filters = this.addFilter(filters, filterToAdd);
}
List<String> codes = this.getGuiFragmentManager().searchGuiFragments(filters);
for (int i = 0; i < codes.size(); i++) {
String fragmantCode = codes.get(i);
String url = this.getApiResourceUrl(fragmantCode, properties.getProperty(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER), properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER), (MediaType) properties.get(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER));
LinkedListItem item = new LinkedListItem();
item.setCode(fragmantCode);
item.setUrl(url);
list.add(item);
}
} catch (Throwable t) {
_logger.error("Error extracting list of fragments", t);
throw t;
}
return list;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class RestListRequestTest method should_exclude_pagination_when_pagesize_0.
@Test
public void should_exclude_pagination_when_pagesize_0() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(0);
request.setSort("name");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("name", "jack"));
request.addFilter(new Filter("city", "rome"));
request.addFilter(new Filter("mobile", "+39"));
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(4));
assertThat(filters.get(0).getKey(), is("name"));
assertThat(filters.get(1).getKey(), is("city"));
assertThat(filters.get(2).getKey(), is("mobile"));
// sort
assertThat(filters.get(3).getKey(), is("name"));
assertThat(filters.get(3).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class RestListRequestTest method shuold_create_filters.
@Test
public void shuold_create_filters() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(25);
request.setSort("name");
request.setDirection(FieldSearchFilter.Order.ASC.name());
request.addFilter(new Filter("name", "jack"));
request.addFilter(new Filter("city", "rome"));
request.addFilter(new Filter("mobile", "+39"));
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(5));
assertThat(filters.get(0).getKey(), is("name"));
assertThat(filters.get(1).getKey(), is("city"));
assertThat(filters.get(2).getKey(), is("mobile"));
// pagination
assertThat(filters.get(3).getKey(), is(nullValue()));
assertThat(filters.get(3).getLimit(), is(not(nullValue())));
assertThat(filters.get(3).getOffset(), is(not(nullValue())));
// sort
assertThat(filters.get(4).getKey(), is("name"));
assertThat(filters.get(4).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class RestListRequestTest method should_default_direction.
@Test
public void should_default_direction() {
RestListRequest request = new RestListRequest();
request.setPage(1);
request.setPageSize(0);
request.setSort("name");
request.setDirection("wrong");
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(1));
assertThat(filters.get(0).getOrder(), is(FieldSearchFilter.Order.ASC));
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ActionLogDAO method createFilters.
protected FieldSearchFilter[] createFilters(IActionLogRecordSearchBean searchBean) {
FieldSearchFilter[] filters = new FieldSearchFilter[0];
if (null != searchBean) {
String username = searchBean.getUsername();
if (null != username && username.trim().length() > 0) {
FieldSearchFilter filter = new FieldSearchFilter("username", this.extractSearchValues(username), true);
filters = super.addFilter(filters, filter);
}
String namespace = searchBean.getNamespace();
if (null != namespace && namespace.trim().length() > 0) {
FieldSearchFilter filter = new FieldSearchFilter("namespace", this.extractSearchValues(namespace), true);
filters = super.addFilter(filters, filter);
}
String actionName = searchBean.getActionName();
if (null != actionName && actionName.trim().length() > 0) {
FieldSearchFilter filter = new FieldSearchFilter("actionname", this.extractSearchValues(actionName), true);
filters = super.addFilter(filters, filter);
}
String parameters = searchBean.getParams();
if (null != parameters && parameters.trim().length() > 0) {
FieldSearchFilter filter = new FieldSearchFilter("parameters", this.extractSearchValues(parameters), true);
filters = super.addFilter(filters, filter);
}
Date startCreation = searchBean.getStartCreation();
Date endCreation = searchBean.getEndCreation();
if (null != startCreation || null != endCreation) {
Timestamp tsStart = (null != startCreation) ? new Timestamp(startCreation.getTime()) : null;
Timestamp tsEnd = (null != endCreation) ? new Timestamp(endCreation.getTime()) : null;
FieldSearchFilter filter = new FieldSearchFilter("actiondate", tsStart, tsEnd);
filter.setOrder(FieldSearchFilter.Order.DESC);
filters = super.addFilter(filters, filter);
}
Date startUpdate = searchBean.getStartUpdate();
Date endUpdate = searchBean.getEndUpdate();
if (null != startUpdate || null != endUpdate) {
Timestamp tsStart = (null != startUpdate) ? new Timestamp(startUpdate.getTime()) : null;
Timestamp tsEnd = (null != endUpdate) ? new Timestamp(endUpdate.getTime()) : null;
FieldSearchFilter filter = new FieldSearchFilter("updatedate", tsStart, tsEnd);
filter.setOrder(FieldSearchFilter.Order.DESC);
filters = super.addFilter(filters, filter);
}
if (searchBean instanceof IActivityStreamSearchBean) {
FieldSearchFilter filter = new FieldSearchFilter("activitystreaminfo");
filters = super.addFilter(filters, filter);
}
}
return filters;
}
Aggregations