use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class BaseFilterUtils method getFilters.
public EntitySearchFilter[] getFilters(IApsEntity entityPrototype, String filtersString, String langCode) {
if (null == entityPrototype) {
return null;
}
List<Properties> properties = getFiltersProperties(filtersString);
EntitySearchFilter[] filters = new EntitySearchFilter[properties.size()];
for (int i = 0; i < properties.size(); i++) {
Properties props = properties.get(i);
EntitySearchFilter filter = EntitySearchFilter.getInstance(entityPrototype, props);
this.attachLangFilter(entityPrototype, filter, props, langCode);
filters[i] = filter;
}
return filters;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class DataObjectActionHelper method getOrderFilter.
@Override
public EntitySearchFilter getOrderFilter(String groupBy, String order) {
String key = null;
if (null == groupBy || groupBy.trim().length() == 0 || groupBy.equals("lastModified")) {
key = IDataObjectManager.DATA_OBJECT_MODIFY_DATE_FILTER_KEY;
} else if (groupBy.equals("code")) {
key = IDataObjectManager.ENTITY_ID_FILTER_KEY;
} else if (groupBy.equals("descr")) {
key = IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY;
} else if (groupBy.equals("created")) {
key = IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY;
} else {
throw new RuntimeException("Invalid Filter '" + groupBy + "'");
}
EntitySearchFilter filter = new EntitySearchFilter(key, false);
if (null == order || order.trim().length() == 0) {
filter.setOrder(EntitySearchFilter.DESC_ORDER);
} else {
filter.setOrder(order);
}
return filter;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class ContentFinderAction method getLastUpdateContentResponse.
@SuppressWarnings("rawtypes")
public List<ContentJO> getLastUpdateContentResponse() {
List<ContentJO> response = null;
try {
EntitySearchFilter modifyOrder = new EntitySearchFilter(IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, false);
modifyOrder.setOrder(EntitySearchFilter.DESC_ORDER);
List<String> ids = this.getContentManager().searchId(new EntitySearchFilter[] { modifyOrder });
if (null != ids && !ids.isEmpty()) {
if (this.getLastUpdateResponseSize() > ids.size() - 1)
this.setLastUpdateResponseSize(ids.size() - 1);
List<String> subList = ids.subList(0, this.getLastUpdateResponseSize());
response = new ArrayList<ContentJO>();
Iterator<String> sublist = subList.iterator();
while (sublist.hasNext()) {
String contentId = sublist.next();
Content content = this.getContentManager().loadContent(contentId, false);
ContentRecordVO vo = this.getContentManager().loadContentVO(contentId);
ContentJO contentJO = new ContentJO(content, vo);
response.add(contentJO);
}
}
} catch (Throwable t) {
_logger.error("Error loading last updated content response", t);
throw new RuntimeException("Error loading last updated content response", t);
}
return response;
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class ContentFinderAction method createFilters.
/**
* Restitusce i filtri per la selezione e l'ordinamento dei contenuti
* erogati nell'interfaccia.
*
* @return Il filtri di selezione ed ordinamento dei contenuti.
*/
@SuppressWarnings("rawtypes")
protected EntitySearchFilter[] createFilters() {
ContentFinderSearchInfo searchInfo = getContentSearchInfo();
this.createBaseFilters();
if (null != this.getState() && this.getState().trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, false, this.getState(), false);
this.addFilter(filterToAdd);
searchInfo.addFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, filterToAdd);
} else {
searchInfo.removeFilter(IContentManager.CONTENT_STATUS_FILTER_KEY);
}
if (null != this.getText() && this.getText().trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, this.getText(), true);
this.addFilter(filterToAdd);
searchInfo.addFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, filterToAdd);
} else {
searchInfo.removeFilter(IContentManager.CONTENT_DESCR_FILTER_KEY);
}
if (null != this.getOwnerGroupName() && this.getOwnerGroupName().trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY, false, this.getOwnerGroupName(), false);
this.addFilter(filterToAdd);
searchInfo.addFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY, filterToAdd);
} else {
searchInfo.removeFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY);
}
if (null != this.getOnLineState() && this.getOnLineState().trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, false);
filterToAdd.setNullOption(this.getOnLineState().trim().equals("no"));
this.addFilter(filterToAdd);
searchInfo.addFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, filterToAdd);
} else {
searchInfo.removeFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY);
}
if (null != this.getContentIdToken() && this.getContentIdToken().trim().length() > 0) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.ENTITY_ID_FILTER_KEY, false, this.getContentIdToken(), true);
this.addFilter(filterToAdd);
searchInfo.addFilter(IContentManager.ENTITY_ID_FILTER_KEY, filterToAdd);
} else {
searchInfo.removeFilter(IContentManager.ENTITY_ID_FILTER_KEY);
}
this.savePagerSearchState(searchInfo);
EntitySearchFilter orderFilter = this.getContentActionHelper().getOrderFilter(this.getLastGroupBy(), this.getLastOrder());
super.addFilter(orderFilter);
searchInfo.addFilter(ContentFinderSearchInfo.ORDER_FILTER, orderFilter);
return this.getFilters();
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class ContentFinderAction method createBaseFilters.
@SuppressWarnings("rawtypes")
protected void createBaseFilters() {
try {
int initSize = this.getFilters().length;
ContentFinderSearchInfo searchInfo = getContentSearchInfo();
EntitySearchFilter[] roleFilters = this.getEntityActionHelper().getRoleFilters(this);
this.addFilters(roleFilters);
IApsEntity prototype = this.getEntityPrototype();
searchInfo.removeFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY);
searchInfo.removeFilterByPrefix(ContentFinderSearchInfo.ATTRIBUTE_FILTER);
if (null != prototype) {
EntitySearchFilter filterToAdd = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, prototype.getTypeCode(), false);
this.addFilter(filterToAdd);
searchInfo.addFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, filterToAdd);
EntitySearchFilter[] filters = this.getEntityActionHelper().getAttributeFilters(this, prototype);
this.addFilters(filters);
searchInfo.addAttributeFilters(filters);
}
this.setAddedAttributeFilter(this.getFilters().length > initSize);
} catch (Throwable t) {
_logger.error("Error while creating entity filters", t);
throw new RuntimeException("Error while creating entity filters", t);
}
}
Aggregations