Search in sources :

Example 1 with ExceptionVisitExpression

use of com.pogeyan.cmis.api.uri.expression.ExceptionVisitExpression in project copper-cms by PogeyanOSS.

the class MNavigationServiceDAOImpl method getChildren.

/*
	 * (non-Javadoc) filterExpression supports eq, ne, ge, gt, le, lt, startswith,
	 * endswith. example filter:
	 * "properties.orderId eq 100 and name eq pogeyan or startswith (name::'a')"
	 * "*,modifiedAt le 123456789 and typeId eq cmis:folder" -->* represents to get
	 * all properties data in that object
	 * "properties.isRead eq false and typeId ne cmis:folder"
	 * "properties.orderId gt 100 properties.purchaseOrder ge 100"
	 * "startswith (name::'a') and properties.orderId lt 100"
	 * "properties.orderId le 100"
	 * 
	 * example order: "name asc, repositoryId" "name desc"
	 * 
	 * @see
	 * com.pogeyan.cmis.api.data.services.MNavigationServiceDAO#getChildren(java
	 * .lang.String, java.lang.String[], boolean, int, int, java.lang.String,
	 * java.lang.String[], java.lang.String)
	 */
@SuppressWarnings("unchecked")
@Override
public List<MBaseObject> getChildren(String path, String[] principalIds, boolean aclPropagation, int maxItems, int skipCount, String orderBy, String[] mappedColumns, String filterExpression) {
    Query<MBaseObject> query = createQuery().disableValidation().filter("internalPath", path).field("token.changeType").notEqual(TokenChangeType.DELETED.value());
    if (!StringUtils.isEmpty(orderBy)) {
        if (this.isOrderByParsable(orderBy)) {
            try {
                OrderByExpression orderByExpression = UriParser.parseOrderBy(orderBy);
                query = (Query<MBaseObject>) orderByExpression.accept(new MongoExpressionVisitor<MBaseObject>(query));
            } catch (ExpressionParserException | ExceptionVisitExpression e) {
            }
        } else {
            query = query.order(orderBy);
        }
    }
    if (!StringUtils.isEmpty(filterExpression)) {
        try {
            FilterExpression expression = UriParser.parseFilter(filterExpression);
            query = (Query<MBaseObject>) expression.accept(new MongoExpressionVisitor<MBaseObject>(query));
        } catch (ExpressionParserException | ExceptionVisitExpression e) {
        }
    }
    if (maxItems > 0) {
        query = query.offset(skipCount).limit(maxItems);
    }
    if (mappedColumns != null && mappedColumns.length > 0) {
        query = query.retrievedFields(true, mappedColumns);
    }
    if (aclPropagation) {
        query.or(getAclCriteria(principalIds, query));
        return query.asList();
    } else {
        return query.asList();
    }
}
Also used : MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) ExceptionVisitExpression(com.pogeyan.cmis.api.uri.expression.ExceptionVisitExpression) ExpressionParserException(com.pogeyan.cmis.api.uri.expression.ExpressionParserException) OrderByExpression(com.pogeyan.cmis.api.uri.expression.OrderByExpression) FilterExpression(com.pogeyan.cmis.api.uri.expression.FilterExpression)

Example 2 with ExceptionVisitExpression

use of com.pogeyan.cmis.api.uri.expression.ExceptionVisitExpression in project copper-cms by PogeyanOSS.

the class MNavigationServiceDAOImpl method getDescendants.

/*
	 * (non-Javadoc) filterExpression supports eq, ne, ge, gt, le, lt, startswith,
	 * endswith. example filter:
	 * "properties.orderId eq 100 and name eq pogeyan or startswith (name::'a')"
	 * "*,modifiedAt le 123456789 and typeId eq cmis:folder" -->* represents to get
	 * all properties data in that object
	 * "properties.isRead eq false and typeId ne cmis:folder"
	 * "properties.orderId gt 100 properties.purchaseOrder ge 100"
	 * "startswith (name::'a') and properties.orderId lt 100"
	 * "properties.orderId le 100"
	 * 
	 * example order: "name asc, repositoryId", "name desc"
	 * 
	 * @see com.pogeyan.cmis.api.data.services.MNavigationServiceDAO#getDescendants(
	 * java .lang.String, java.lang.String[], boolean,java.lang.String[],
	 * java.lang.String)
	 */
@SuppressWarnings("unchecked")
@Override
public List<MBaseObject> getDescendants(String path, String[] principalIds, boolean aclPropagation, String[] mappedColumns, String filterExpression) {
    Pattern exp = Pattern.compile(path, Pattern.CASE_INSENSITIVE);
    Query<MBaseObject> query = createQuery().disableValidation().filter("internalPath =", exp).field("token.changeType").notEqual(TokenChangeType.DELETED.value());
    if (!StringUtils.isEmpty(filterExpression)) {
        try {
            FilterExpression expression = UriParser.parseFilter(filterExpression);
            query = (Query<MBaseObject>) expression.accept(new MongoExpressionVisitor<MBaseObject>(query));
        } catch (ExpressionParserException | ExceptionVisitExpression e) {
        }
    }
    if (mappedColumns != null && mappedColumns.length > 0) {
        query = query.retrievedFields(true, mappedColumns);
    }
    if (aclPropagation) {
        query.or(getAclCriteria(principalIds, query));
    }
    return query.asList();
}
Also used : Pattern(java.util.regex.Pattern) MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) ExceptionVisitExpression(com.pogeyan.cmis.api.uri.expression.ExceptionVisitExpression) ExpressionParserException(com.pogeyan.cmis.api.uri.expression.ExpressionParserException) FilterExpression(com.pogeyan.cmis.api.uri.expression.FilterExpression)

Aggregations

ExceptionVisitExpression (com.pogeyan.cmis.api.uri.expression.ExceptionVisitExpression)2 ExpressionParserException (com.pogeyan.cmis.api.uri.expression.ExpressionParserException)2 FilterExpression (com.pogeyan.cmis.api.uri.expression.FilterExpression)2 MBaseObject (com.pogeyan.cmis.data.mongo.MBaseObject)2 OrderByExpression (com.pogeyan.cmis.api.uri.expression.OrderByExpression)1 Pattern (java.util.regex.Pattern)1