use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class ApiDataObjectInterface method buildSearchBean.
protected ApiDataObjectListBean buildSearchBean(Properties properties) throws ApiException, Throwable {
ApiDataObjectListBean bean = null;
try {
String dataType = properties.getProperty("dataType");
if (null == this.getDataObjectManager().getSmallDataTypesMap().get(dataType)) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "DataObject Type '" + dataType + "' does not exist", Response.Status.CONFLICT);
}
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
String filtersParam = properties.getProperty("filters");
EntitySearchFilter[] filters = this.getDataObjectListHelper().getFilters(dataType, filtersParam, langCode);
String[] categoryCodes = null;
String categoriesParam = properties.getProperty("categories");
if (null != categoriesParam && categoriesParam.trim().length() > 0) {
categoryCodes = categoriesParam.split(IDataTypeListHelper.CATEGORIES_SEPARATOR);
}
bean = new ApiDataObjectListBean(dataType, filters, categoryCodes);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in buildSearchBean", t);
throw new ApsSystemException("Error into API method", t);
}
return bean;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class DataObjectListHelper method extractContentsId.
protected List<String> extractContentsId(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
List<String> contentsId = null;
try {
List<UserFilterOptionBean> userFilters = bean.getUserFilterOptions();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == bean.getDataType() && null != config) {
bean.setContentType(config.getProperty(WIDGET_PARAM_CONTENT_TYPE));
}
if (null == bean.getDataType()) {
throw new ApsSystemException("Tipo contenuto non definito");
}
if (null == bean.getCategory() && null != config && null != config.getProperty(SHOWLET_PARAM_CATEGORY)) {
bean.setCategory(config.getProperty(SHOWLET_PARAM_CATEGORY));
}
this.addWidgetFilters(bean, config, WIDGET_PARAM_FILTERS, reqCtx);
if (null != userFilters && userFilters.size() > 0) {
for (int i = 0; i < userFilters.size(); i++) {
UserFilterOptionBean userFilter = userFilters.get(i);
EntitySearchFilter filter = userFilter.getEntityFilter();
if (null != filter) {
bean.addFilter(filter);
}
}
}
String[] categories = this.getCategories(bean.getCategories(), config, userFilters);
Collection<String> userGroupCodes = this.getAllowedGroups(reqCtx);
boolean orCategoryFilterClause = this.extractOrCategoryFilterClause(config);
contentsId = this.getDataObjectManager().loadDataObjectsId(bean.getDataType(), categories, orCategoryFilterClause, bean.getFilters(), userGroupCodes);
} catch (Throwable t) {
_logger.error("Error extracting contents id", t);
throw new ApsSystemException("Error extracting contents id", t);
}
return contentsId;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class ApiContentInterface method buildSearchBean.
protected ApiContentListBean buildSearchBean(Properties properties) throws ApiException, Throwable {
ApiContentListBean bean = null;
try {
String contentType = properties.getProperty("contentType");
if (null == this.getContentManager().getSmallContentTypesMap().get(contentType)) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type '" + contentType + "' does not exist", Response.Status.CONFLICT);
}
String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
String filtersParam = properties.getProperty("filters");
EntitySearchFilter[] filters = this.getContentListHelper().getFilters(contentType, filtersParam, langCode);
String[] categoryCodes = null;
String categoriesParam = properties.getProperty("categories");
if (null != categoriesParam && categoriesParam.trim().length() > 0) {
categoryCodes = categoriesParam.split(IContentListHelper.CATEGORIES_SEPARATOR);
}
bean = new ApiContentListBean(contentType, filters, categoryCodes);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in buildSearchBean", t);
throw new ApsSystemException("Error into API method", t);
}
return bean;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadEvents_9_a.
protected void testLoadEvents_9_a(boolean useRoleFilter) throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter filter = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(SystemConstants.DATA_TYPE_ATTRIBUTE_ROLE_TITLE, "le", true) : new EntitySearchFilter("Titolo", true, "le", true);
filter.setLangCode("it");
filter.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { filter };
List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
String[] expectedOrderedDataObjectsId2 = { "EVN25", "EVN21", "EVN23" };
assertEquals(expectedOrderedDataObjectsId2.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId2.length; i++) {
assertEquals(expectedOrderedDataObjectsId2[i], dataObjects.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testSearchDataObjects_1_2.
public void testSearchDataObjects_1_2() throws Throwable {
EntitySearchFilter versionFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CURRENT_VERSION_FILTER_KEY, false, "0.", true);
EntitySearchFilter[] filters3 = { versionFilter };
List<String> dataObjectIds = this._dataObjectManager.searchId(filters3);
assertNotNull(dataObjectIds);
String[] expected2 = { "ART179" };
assertEquals(expected2.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected2);
versionFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CURRENT_VERSION_FILTER_KEY, false, ".0", true);
EntitySearchFilter[] filters4 = { versionFilter };
dataObjectIds = this._dataObjectManager.searchId(filters4);
assertNotNull(dataObjectIds);
assertEquals(22, dataObjectIds.size());
}
Aggregations