Search in sources :

Example 1 with ActionLogRecordApiSearchBean

use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordApiSearchBean in project entando-core by entando.

the class ActionLogDAO method createFilters.

protected FieldSearchFilter[] createFilters(IActionLogRecordSearchBean searchBean) {
    FieldSearchFilter[] filters = new FieldSearchFilter[0];
    if (null != searchBean) {
        if (searchBean instanceof ActionLogRecordApiSearchBean) {
            ActionLogRecordApiSearchBean apiSearchBean = (ActionLogRecordApiSearchBean) searchBean;
            String sort = apiSearchBean.getOrderBy();
            if (!StringUtils.isEmpty(sort)) {
                FieldSearchFilter filter = new FieldSearchFilter(sort);
                if (null != apiSearchBean.getDirection()) {
                    filter.setOrder(apiSearchBean.getDirection());
                }
                filters = super.addFilter(filters, filter);
            }
            Integer offset = apiSearchBean.getOffset();
            Integer pageSize = apiSearchBean.getPageSize();
            if (null != pageSize && pageSize > 0) {
                FieldSearchFilter pageFilter = new FieldSearchFilter(pageSize, offset);
                filters = super.addFilter(filters, pageFilter);
            }
        }
        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;
}
Also used : ActionLogRecordApiSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordApiSearchBean) IActivityStreamSearchBean(org.entando.entando.aps.system.services.actionlog.model.IActivityStreamSearchBean) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with ActionLogRecordApiSearchBean

use of org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordApiSearchBean in project entando-core by entando.

the class ActivityStreamService method buildSearchBean.

protected ActionLogRecordSearchBean buildSearchBean(RestListRequest requestList, UserDetails userDetails) {
    ActionLogRecordApiSearchBean searchBean = new ActionLogRecordApiSearchBean();
    // groups
    if (null != requestList.getSort()) {
        String direction = requestList.getDirection();
        direction = (null != direction && (direction.equalsIgnoreCase("ASC") || direction.equalsIgnoreCase("DESC"))) ? direction : "DESC";
        searchBean.setOrderBy(ActionLogRecordDto.getEntityFieldName(requestList.getSort()));
        searchBean.setDirection(direction);
    }
    int offset = 0;
    int page = requestList.getPage() - 1;
    if (null != requestList.getPage() && requestList.getPage() != 0) {
        offset = requestList.getPageSize() * page;
    }
    searchBean.setOffset(offset);
    searchBean.setPageSize(requestList.getPageSize());
    List<Group> userGroups = this.getAuthorizationManager().getUserGroups(userDetails);
    searchBean.setUserGroupCodes(userGroups.stream().map(i -> i.getAuthority()).collect(Collectors.toList()));
    if (null == requestList.getFilters() || requestList.getFilters().length == 0) {
        return searchBean;
    }
    for (Filter f : requestList.getFilters()) {
        // creation date range
        if (f.getAttributeName().equals(KEY_FILTER_CREATION)) {
            DateRange range = new DateRange(f.getValue());
            searchBean.setStartCreation(range.getStart());
            searchBean.setEndCreation(range.getEnd());
        }
        // update date range
        if (f.getAttributeName().equals(KEY_FILTER_UPDATE)) {
            DateRange range = new DateRange(f.getValue());
            searchBean.setStartCreation(range.getStart());
            searchBean.setEndCreation(range.getEnd());
        }
        if (f.getAttributeName().equals(KEY_FILTER_USERNAME)) {
            searchBean.setUsername(f.getValue());
        }
        if (f.getAttributeName().equals(KEY_FILTER_NS)) {
            searchBean.setNamespace(f.getValue());
        }
        if (f.getAttributeName().equals(KEY_FILTER_ACTIONNAME)) {
            searchBean.setActionName(f.getValue());
        }
        if (f.getAttributeName().equals(KEY_FILTER_PARAMS)) {
            searchBean.setParams(f.getValue());
        }
    }
    return searchBean;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) DateRange(org.entando.entando.web.common.model.DateRange) Filter(org.entando.entando.web.common.model.Filter) ActionLogRecordApiSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordApiSearchBean)

Aggregations

ActionLogRecordApiSearchBean (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordApiSearchBean)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 Group (com.agiletec.aps.system.services.group.Group)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 IActivityStreamSearchBean (org.entando.entando.aps.system.services.actionlog.model.IActivityStreamSearchBean)1 DateRange (org.entando.entando.web.common.model.DateRange)1 Filter (org.entando.entando.web.common.model.Filter)1