use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class TestWidgetTypeAction method testAddNewWidgetType.
// TODO ADD MORE TESTS for add new widget
public void testAddNewWidgetType() throws Throwable {
String widgetTypeCode = "randomWidgetCode_4";
List<String> fragmantCodes = null;
try {
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
assertNull(this._guiFragmentManager.getGuiFragment(widgetTypeCode));
String result = this.executeAddWidgetType("admin", widgetTypeCode, "**GUI**");
assertEquals(Action.SUCCESS, result);
WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(addedType);
FieldSearchFilter filterByType = new FieldSearchFilter("widgettypecode", widgetTypeCode, false);
FieldSearchFilter[] filters = { filterByType };
fragmantCodes = this._guiFragmentManager.searchGuiFragments(filters);
assertNotNull(fragmantCodes);
assertEquals(1, fragmantCodes.size());
assertEquals(widgetTypeCode, fragmantCodes.get(0));
GuiFragment guiFragment = this._guiFragmentManager.getGuiFragment(fragmantCodes.get(0));
assertNotNull(guiFragment);
assertEquals(widgetTypeCode, guiFragment.getWidgetTypeCode());
assertEquals("**GUI**", guiFragment.getGui());
assertFalse(guiFragment.isLocked());
} catch (Throwable t) {
throw t;
} finally {
if (null != fragmantCodes) {
for (int i = 0; i < fragmantCodes.size(); i++) {
String code = fragmantCodes.get(i);
this._guiFragmentManager.deleteGuiFragment(code);
}
}
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ConsumerFinderAction method getSearchFilters.
private FieldSearchFilter[] getSearchFilters() {
FieldSearchFilter[] filters = new FieldSearchFilter[0];
FieldSearchFilter keyFilter = null;
if (null != this.getInsertedKey() && this.getInsertedKey().trim().length() > 0) {
keyFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_KEY_FILTER_KEY, this.getInsertedKey(), true);
} else {
keyFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_KEY_FILTER_KEY);
}
keyFilter.setOrder(FieldSearchFilter.ASC_ORDER);
filters = this.addFilter(keyFilter, filters);
if (null != this.getInsertedDescription() && this.getInsertedDescription().trim().length() > 0) {
FieldSearchFilter descrFilter = new FieldSearchFilter(IOAuthConsumerManager.CONSUMER_DESCRIPTION_FILTER_KEY, this.getInsertedDescription(), true);
filters = this.addFilter(descrFilter, filters);
}
return filters;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class RestListRequestTest method should_create_default_pagination.
@SuppressWarnings("rawtypes")
@Test
public void should_create_default_pagination() {
RestListRequest request = new RestListRequest();
// filters
List<FieldSearchFilter> filters = request.buildFieldSearchFilters();
assertThat(filters.size(), is(2));
// pagination
assertThat(filters.get(0).getKey(), is(nullValue()));
assertThat(filters.get(0).getLimit(), is(not(nullValue())));
assertThat(filters.get(0).getOffset(), is(not(nullValue())));
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class WidgetTypeManager method getGuiFragmentUtilizers.
@Override
public List getGuiFragmentUtilizers(String guiFragmentCode) throws ApsSystemException {
List<WidgetType> utilizers = new ArrayList<WidgetType>();
try {
FieldSearchFilter codeFilter = new FieldSearchFilter("code", guiFragmentCode, false);
FieldSearchFilter widgetTypeFilter = new FieldSearchFilter("widgettypecode");
FieldSearchFilter[] filters = { codeFilter, widgetTypeFilter };
List<String> widgetUtilizers = this.getGuiFragmentManager().searchGuiFragments(filters);
if (null != widgetUtilizers && !widgetUtilizers.isEmpty()) {
for (int i = 0; i < widgetUtilizers.size(); i++) {
String code = widgetUtilizers.get(i);
GuiFragment fragment = this.getGuiFragmentManager().getGuiFragment(code);
WidgetType widgetType = this.getWidgetType(fragment.getWidgetTypeCode());
if (null != widgetType) {
utilizers.add(widgetType);
}
}
}
} catch (Throwable t) {
logger.error("Error extracting utilizers", t);
throw new ApsSystemException("Error extracting utilizers", t);
}
return utilizers;
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class RestListRequest method getSublist.
public List getSublist(List master) {
if (null == master) {
return null;
}
if (0 == this.getPage()) {
return master;
}
FieldSearchFilter pagFilter = this.buildPaginationFilter();
int limit = (null != pagFilter) ? pagFilter.getLimit() : PAGE_SIZE_DEFAULT;
if (null == pagFilter) {
this.setPageSize(PAGE_SIZE_DEFAULT);
}
int offset = (null != pagFilter) ? pagFilter.getOffset() : this.getOffset();
int size = master.size();
int offsetToApply = (offset >= size) ? size : offset;
int limitToApply = ((offsetToApply + limit) > size) ? size : (offsetToApply + limit);
return master.subList(offsetToApply, limitToApply);
}
Aggregations