Search in sources :

Example 1 with MBaseObject

use of com.pogeyan.cmis.data.mongo.MBaseObject in project copper-cms by PogeyanOSS.

the class MNavigationServiceDAOImpl method getFolderTreeIds.

@Override
public List<MBaseObject> getFolderTreeIds(String path, String[] principalIds, boolean aclPropagation) {
    if (aclPropagation) {
        Pattern exp = Pattern.compile(path, Pattern.CASE_INSENSITIVE);
        Query<MBaseObject> query = createQuery().disableValidation().filter("internalPath =", exp).field("baseId").equalIgnoreCase("cmis:folder").field("token.changeType").notEqual(TokenChangeType.DELETED.value());
        query.or(getAclCriteria(principalIds, query));
        return query.asList();
    } else {
        Pattern exp = Pattern.compile(path, Pattern.CASE_INSENSITIVE);
        Query<MBaseObject> query = createQuery().disableValidation().filter("internalPath =", exp).field("baseId").equalIgnoreCase("cmis:folder").field("token.changeType").notEqual(TokenChangeType.DELETED.value());
        return query.asList();
    }
}
Also used : Pattern(java.util.regex.Pattern) MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject)

Example 2 with MBaseObject

use of com.pogeyan.cmis.data.mongo.MBaseObject 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 3 with MBaseObject

use of com.pogeyan.cmis.data.mongo.MBaseObject 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)

Example 4 with MBaseObject

use of com.pogeyan.cmis.data.mongo.MBaseObject in project copper-cms by PogeyanOSS.

the class MBaseObjectDAOImpl method update.

@Override
public void update(String objectId, Map<String, Object> updateProps) {
    UpdateOperations<MBaseObject> update = createUpdateOperations().disableValidation();
    Query<MBaseObject> query = createQuery().disableValidation().field("id").equal(objectId).field("token.changeType").notEqual(TokenChangeType.DELETED.value());
    if (updateProps.get("acl") != null) {
        MongoAclImpl mAcl = MBaseObject.convertMongoAcl((AccessControlListImplExt) updateProps.get("acl"));
        updateProps.remove("acl");
        updateProps.put("acl", mAcl);
    }
    if (updateProps.get("token") != null) {
        MongoToken mToken = MBaseObject.convertMongoToken((TokenImpl) updateProps.get("token"));
        updateProps.remove("token");
        updateProps.put("token", mToken);
    }
    for (Map.Entry<String, Object> entry : updateProps.entrySet()) {
        update = update.set(entry.getKey(), entry.getValue());
    }
    update(query, update);
}
Also used : MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) MongoToken(com.pogeyan.cmis.data.mongo.MongoToken) IBaseObject(com.pogeyan.cmis.api.data.IBaseObject) MBaseObject(com.pogeyan.cmis.data.mongo.MBaseObject) MongoAclImpl(com.pogeyan.cmis.data.mongo.MongoAclImpl) Map(java.util.Map)

Aggregations

MBaseObject (com.pogeyan.cmis.data.mongo.MBaseObject)4 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 Pattern (java.util.regex.Pattern)2 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)1 OrderByExpression (com.pogeyan.cmis.api.uri.expression.OrderByExpression)1 MongoAclImpl (com.pogeyan.cmis.data.mongo.MongoAclImpl)1 MongoToken (com.pogeyan.cmis.data.mongo.MongoToken)1 Map (java.util.Map)1