Search in sources :

Example 1 with RangeFilter

use of com.enonic.xp.query.filter.RangeFilter in project xp by enonic.

the class CleanUpAuditLogCommand method createQuery.

private NodeQuery createQuery() {
    final NodeQuery.Builder builder = NodeQuery.create().addQueryFilter(ValueFilter.create().fieldName(NodeIndexPath.NODE_TYPE.toString()).addValue(ValueFactory.newString(AuditLogConstants.NODE_TYPE.toString())).build());
    final RangeFilter timeToFilter = RangeFilter.create().fieldName(AuditLogConstants.TIME.toString()).to(ValueFactory.newDateTime(until)).build();
    builder.addQueryFilter(timeToFilter);
    builder.addOrderBy(FieldOrderExpr.create(AuditLogConstants.TIME, OrderExpr.Direction.ASC)).size(BATCH_SIZE);
    return builder.build();
}
Also used : NodeQuery(com.enonic.xp.node.NodeQuery) RangeFilter(com.enonic.xp.query.filter.RangeFilter)

Example 2 with RangeFilter

use of com.enonic.xp.query.filter.RangeFilter in project xp by enonic.

the class VersionTableVacuumCommand method createQuery.

private NodeVersionQuery createQuery(NodeVersionId lastVersionId) {
    final NodeVersionQuery.Builder builder = NodeVersionQuery.create();
    if (lastVersionId != null) {
        final RangeFilter versionIdFilter = RangeFilter.create().fieldName(VersionIndexPath.VERSION_ID.getPath()).gt(ValueFactory.newString(lastVersionId.toString())).build();
        builder.addQueryFilter(versionIdFilter);
    }
    final RangeFilter mustBeOlderThanFilter = RangeFilter.create().fieldName(VersionIndexPath.TIMESTAMP.getPath()).to(ValueFactory.newDateTime(until)).build();
    return builder.addQueryFilter(mustBeOlderThanFilter).addOrderBy(FieldOrderExpr.create(VersionIndexPath.VERSION_ID, OrderExpr.Direction.ASC)).size(batchSize).build();
}
Also used : NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) RangeFilter(com.enonic.xp.query.filter.RangeFilter)

Aggregations

RangeFilter (com.enonic.xp.query.filter.RangeFilter)2 NodeQuery (com.enonic.xp.node.NodeQuery)1 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)1