use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ActionLogDAO method extractRecordToDelete.
private void extractRecordToDelete(String groupName, Integer maxActivitySizeByGroup, Set<Integer> recordIds, Connection conn) {
PreparedStatement stat = null;
ResultSet result = null;
try {
List<Integer> idList = new ArrayList<Integer>();
FieldSearchFilter filter1 = new FieldSearchFilter("actiondate");
filter1.setOrder(FieldSearchFilter.Order.DESC);
FieldSearchFilter filter2 = new FieldSearchFilter("activitystreaminfo");
FieldSearchFilter[] filters = { filter1, filter2 };
List<String> groupCodes = new ArrayList<String>();
groupCodes.add(groupName);
stat = this.buildStatement(filters, groupCodes, conn);
result = stat.executeQuery();
while (result.next()) {
Integer id = result.getInt(1);
if (!idList.contains(id)) {
idList.add(id);
}
}
if (idList.size() > maxActivitySizeByGroup) {
for (int i = maxActivitySizeByGroup; i < idList.size(); i++) {
Integer id = idList.get(i);
recordIds.add(id);
}
}
} catch (Throwable t) {
_logger.error("Error while loading activity stream records to delete : group {}", groupName, t);
throw new RuntimeException("Error while loading activity stream records to delete : group '" + groupName + "'", t);
} finally {
closeDaoResources(result, stat);
}
}
use of com.agiletec.aps.system.common.FieldSearchFilter 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));
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class GuiFragmentFinderAction method getGuiFragmentsCodes.
public List<String> getGuiFragmentsCodes() {
try {
FieldSearchFilter[] filters = new FieldSearchFilter[0];
if (StringUtils.isNotBlank(this.getCode())) {
FieldSearchFilter filterToAdd = new FieldSearchFilter("code", this.getCode(), true);
filters = this.addFilter(filters, filterToAdd);
}
if (StringUtils.isNotBlank(this.getWidgetTypeCode())) {
FieldSearchFilter filterToAdd = new FieldSearchFilter("widgettypecode", this.getWidgetTypeCode(), false);
filters = this.addFilter(filters, filterToAdd);
}
if (StringUtils.isNotBlank(this.getPluginCode())) {
FieldSearchFilter filterToAdd = new FieldSearchFilter("plugincode", this.getPluginCode(), false);
filters = this.addFilter(filters, filterToAdd);
}
List<String> guiFragments = this.getGuiFragmentManager().searchGuiFragments(filters);
return guiFragments;
} catch (Throwable t) {
_logger.error("Error getting guiFragments list", t);
throw new RuntimeException("Error getting guiFragments list", t);
}
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ResourceManager method checkFilterKeys.
protected void checkFilterKeys(FieldSearchFilter[] filters) {
if (null != filters && filters.length > 0) {
String[] allowedFilterKeys = { RESOURCE_ID_FILTER_KEY, RESOURCE_TYPE_FILTER_KEY, RESOURCE_DESCR_FILTER_KEY, RESOURCE_MAIN_GROUP_FILTER_KEY, RESOURCE_FILENAME_FILTER_KEY, RESOURCE_CREATION_DATE_FILTER_KEY, RESOURCE_MODIFY_DATE_FILTER_KEY };
List<String> allowedFilterKeysList = Arrays.asList(allowedFilterKeys);
for (int i = 0; i < filters.length; i++) {
FieldSearchFilter filter = filters[i];
if (!allowedFilterKeysList.contains(filter.getKey())) {
throw new RuntimeException("Invalid filter key - '" + filter.getKey() + "'");
}
}
}
}
use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.
the class ResourceDAO method createFilters.
private FieldSearchFilter[] createFilters(String type, String text, String filename, Collection<String> groupCodes) {
FieldSearchFilter[] filters = new FieldSearchFilter[0];
if (null != type && type.trim().length() > 0) {
FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_TYPE_FILTER_KEY, type, false);
filters = super.addFilter(filters, filterToAdd);
}
if (null != text && text.trim().length() > 0) {
FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_DESCR_FILTER_KEY, text, true);
filters = super.addFilter(filters, filterToAdd);
}
if (null != filename && filename.trim().length() > 0) {
FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_FILENAME_FILTER_KEY, filename, true);
filters = super.addFilter(filters, filterToAdd);
}
if (groupCodes != null && groupCodes.size() > 0) {
List<String> allowedValues = new ArrayList<String>();
allowedValues.addAll(groupCodes);
FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_MAIN_GROUP_FILTER_KEY, allowedValues, false);
filters = super.addFilter(filters, filterToAdd);
}
if (filters.length == 0) {
return null;
}
return filters;
}
Aggregations