类com.mongodb.AggregationOutput源码实例Demo

下面列出了怎么用com.mongodb.AggregationOutput的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    AbstractSpan activeSpan = ContextManager.activeSpan();
    CommandResult cresult = null;
    if (ret instanceof WriteResult) {
        WriteResult wresult = (WriteResult) ret;
        cresult = wresult.getCachedLastError();
    } else if (ret instanceof AggregationOutput) {
        AggregationOutput aresult = (AggregationOutput) ret;
        cresult = aresult.getCommandResult();
    }
    if (null != cresult && !cresult.ok()) {
        activeSpan.log(cresult.getException());
    }
    ContextManager.stopSpan();
    return ret;
}
 
源代码2 项目: sissi   文件: MongoRoomBuilder.java
public String reserved(JID jid) {
	// {"$match":{"jid":group.bare}}, {"$unwind":"$affiliations"}, {"$match":{"affiliations.jid":jid.bare}}, {"$project":{"nick":"$affiliations.nick"}}
	AggregationOutput output = MongoRoomBuilder.this.config.collection().aggregate(BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_JID, this.group.asStringWithBare()).get()).get(), MongoRoomBuilder.this.unwind, BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_AFFILIATIONS + "." + Dictionary.FIELD_JID, jid.asStringWithBare()).get()).get(), MongoRoomBuilder.this.project);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? null : MongoUtils.asString(DBObject.class.cast(result.get(0)), Dictionary.FIELD_NICK);
}
 
源代码3 项目: sissi   文件: MongoMucRelationContext.java
@Override
public Relation ourRelation(JID from, JID to) {
	AggregationOutput output = this.config.collection().aggregate(this.buildMatcher(to), this.unwindRoles, this.unwindAffiliation, BasicDBObjectBuilder.start().add("$match", BasicDBObjectBuilder.start().add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_JID, from.asStringWithBare()).add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_RESOURCE, from.resource()).get()).get(), this.projectRelation, this.match, this.sort, this.limit);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? new NoneRelation(from, to, this.affiliation(from, to)) : new MongoRelation(DBObject.class.cast(result.get(0)));
}
 
源代码4 项目: sissi   文件: MongoMucRelationContext.java
@Override
public Set<JID> whoSubscribedMe(JID from) {
	AggregationOutput output = this.config.collection().aggregate(this.buildMatcher(from), this.projectRoles, this.unwindRoles, this.groupSubscribe);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? this.jidset : new JIDGroup(MongoUtils.asList(DBObject.class.cast(result.get(0)), Dictionary.FIELD_ROLES));
}
 
源代码5 项目: sissi   文件: MongoMucRelationContext.java
@Override
public JIDs mapping(JID group) {
	// {"$match":{"jid":group.bare}}, {"$unwind":"$roles"}, {"$match":{"roles.nick":Xxx}}, {"$project":{"roles":"$roles"}}, {"$group":{"_id":"$roles.jid","resource":{"$push":"$roles.resource"}}}
	AggregationOutput output = this.config.collection().aggregate(this.buildMatcher(group), this.unwindRoles, BasicDBObjectBuilder.start().add("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_NICK, group.resource()).get()).get(), this.projectRoles, this.groupMapping);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? this.jids : this.extract(DBObject.class.cast(result.get(0)));
}
 
源代码6 项目: sissi   文件: MongoMucRelation4RoleContext.java
public Set<Relation> myRelations(JID from, String role) {
	// {"$match":{"jid":group.bare}}, {"$unwind":"$roles"}, {"$match":{"roles.role":Xxx}}, {"$group":{"_id":{"jid":"$jid","creator":"$creator","affiliations":"$affiliations"},"roles":{"$addToSet":"$roles"}}}, {"$project":{"jid":"$_id.jid","creator":"$_id.creator","affiliations":"$_id.affiliations","roles":"$roles"}}
	AggregationOutput output = super.config.collection().aggregate(this.buildMatcher(from), super.unwindRoles, BasicDBObjectBuilder.start().add("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_ROLE, role).get()).get(), this.group, this.projectRole);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? this.relations : new MongoRelations(DBObject.class.cast(result.get(0)));
}
 
源代码7 项目: sissi   文件: MongoMucRelationContext.java
public Set<Relation> ourRelations(JID from, JID to) {
	AggregationOutput output = this.config.collection().aggregate(this.buildMatcher(to), this.unwindRoles, BasicDBObjectBuilder.start().add("$match", BasicDBObjectBuilder.start().add(Dictionary.FIELD_ROLES + "." + Dictionary.FIELD_JID, from.asStringWithBare()).get()).get(), this.groupRelations, this.projectRelations);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? this.relations : new MongoRelations(DBObject.class.cast(result.get(0)));
}
 
public Set<Relation> myRelations(JID from, String affiliation) {
	// {"$match":{"jid":group.bare}}, {"$unwind":"$affiliations"}, {"$match":{"affiliations.affiliation":Xxx}}, {"$project":{"affiliation":"$affiliations"}}
	AggregationOutput output = super.config.collection().aggregate(super.buildMatcher(from), super.unwindAffiliation, BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_AFFILIATIONS + "." + Dictionary.FIELD_AFFILIATION, affiliation).get()).get(), this.projectAffiliation);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? super.relations : new AffiliationRelations(result);
}
 
源代码9 项目: sissi   文件: MongoProxyConfig.java
public AggregationOutput aggregate(final DBObject... ops) {
	this.log("aggregate", ops);
	return MongoProxyConfig.this.collection.aggregate(Arrays.asList(ops));
}
 
源代码10 项目: sissi   文件: MongoMucRelationContext.java
/**
 * 获取岗位
 * 
 * @param from
 * @param to
 * @param def 默认值
 * @return
 */
private ItemAffiliation affiliation(JID from, JID to, ItemAffiliation def) {
	// {"$match":{"jid":to.bare}},{"$unwind":"$affiliations"},{"$match":{"affiliations.jid":from.bare}},{"$project":{"affiliation":"$affiliations.affiliation"}}
	AggregationOutput output = this.config.collection().aggregate(BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_JID, to.asStringWithBare()).get()).get(), this.unwindAffiliation, BasicDBObjectBuilder.start("$match", BasicDBObjectBuilder.start(Dictionary.FIELD_AFFILIATIONS + "." + Dictionary.FIELD_JID, from.asStringWithBare()).get()).get(), this.projectAffiliations);
	@SuppressWarnings("deprecation")
	List<?> result = MongoUtils.asList(output.getCommandResult(), Dictionary.FIELD_RESULT);
	return result.isEmpty() ? def : ItemAffiliation.parse(MongoUtils.asString(DBObject.class.cast(result.get(0)), Dictionary.FIELD_AFFILIATION).toString());
}
 
源代码11 项目: act   文件: MongoDB.java
/**
 * Setup the ability to use MongoDB's aggregation framework.
 * This greatly greatly simplifies pulling out highly nested and unstructured data from the db.
 *
 * This method performs the query over the sequence database.
 *
 * References: https://docs.mongodb.com/manual/aggregation/
 * @param pipeline A list of DBObjects that will be sequentially applied via aggregate.
 * @return An iterator over all the matching objects.
   */
public Iterator<DBObject> applyPipelineOverSequences(List<DBObject> pipeline){
  AggregationOutput cursor = this.dbSeq.aggregate(pipeline);
  return cursor.results().iterator();
}
 
源代码12 项目: act   文件: MongoDB.java
/**
 * Setup the ability to use MongoDB's aggregation framework.
 * This greatly greatly simplifies pulling out highly nested and unstructured data from the db.
 *
 * This method performs the query over the sequence reaction.
 *
 * References: https://docs.mongodb.com/manual/aggregation/
 * @param pipeline A list of DBObjects that will be sequentially applied via aggregate.
 * @return An iterator over all the matching objects.
 */
public Iterator<DBObject> applyPipelineOverReactions(List<DBObject> pipeline){
  AggregationOutput cursor = this.dbReactions.aggregate(pipeline);
  return cursor.results().iterator();
}
 
源代码13 项目: sissi   文件: MongoCollection.java
public AggregationOutput aggregate(DBObject ... ops); 
 类所在包
 类方法
 同包方法