当前位置: 首页>>代码示例>>Java>>正文


Java BasicDBList.isEmpty方法代码示例

本文整理汇总了Java中com.mongodb.BasicDBList.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBList.isEmpty方法的具体用法?Java BasicDBList.isEmpty怎么用?Java BasicDBList.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.BasicDBList的用法示例。


在下文中一共展示了BasicDBList.isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTotalCount

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private long getTotalCount() {
    AggregationResults aggregationResults = mongoTemplate.aggregate(
            Aggregation.newAggregation(
                    group("team"),
                    count().as("count")),
            Submission.class, Team.class
    );

    Object results = aggregationResults.getRawResults().get("result");

    if (results != null && results instanceof BasicDBList) {
        BasicDBList resultsList = (BasicDBList) results;

        if (resultsList.isEmpty()) {
            return 0;
        }
        BasicDBObject countResult = (BasicDBObject) resultsList.get(0);

        if (countResult.containsField("count")) {
            return countResult.getLong("count");
        }

        return 0;


    }

    return -1;
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:30,代码来源:SubmissionRepositoryCustomImpl.java

示例2: getTotalItemCountByTeam

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private long getTotalItemCountByTeam(String teamName) {
    AggregationResults aggregationResults = mongoTemplate.aggregate(
            Aggregation.newAggregation(
                    teamMatchOperation(teamName),
                    groupByAlias(),
                    group().count().as("count")
            ),
            clazz, clazz
    );

    Object results = aggregationResults.getRawResults().get("result");

    if (results != null && results instanceof BasicDBList) {
        BasicDBList resultsList = (BasicDBList) results;

        if (resultsList.isEmpty()) {
            return 0;
        }
        BasicDBObject countResult = (BasicDBObject) resultsList.get(0);

        if (countResult.containsField("count")) {
            return countResult.getLong("count");
        }

        return 0;


    }

    return -1;
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:32,代码来源:SubmittablesAggregateSupport.java

示例3: toDbo

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
public BasicDBObject toDbo() {
  String method = "toDbo";
  logger.entering(clazz, method);

  logger.fine("id: " + id);
  logger.fine("date: " + date);
  logger.fine("groupId: " + groupId);
  logger.fine("interval: " + interval);
  logger.fine("name: " + name);
  logger.fine("organizerId: " + organizerId);
  logger.fine("recipientId: " + recipientId);
  logger.fine("contributions: " + Contribution.listToString(contributions));

  // build the db object
  BasicDBObject dbo = new BasicDBObject();
  if (null != id && ObjectId.isValid(id.toString())) {
    dbo.append(OCCASION_ID_KEY, id);
  }

  if (null != date && !date.isEmpty()) {
    dbo.append(OCCASION_DATE_KEY, date);
  }

  if (null != groupId && !groupId.isEmpty()) {
    dbo.append(OCCASION_GROUP_ID_KEY, groupId);
  }

  if (null != interval && !interval.isEmpty()) {
    dbo.append(OCCASION_INTERVAL_KEY, interval);
  }

  if (null != name && !name.isEmpty()) {
    dbo.append(OCCASION_NAME_KEY, name);
  }

  if (null != organizerId && !organizerId.isEmpty()) {
    dbo.append(OCCASION_ORGANIZER_ID_KEY, organizerId);
  }

  if (null != recipientId && !recipientId.isEmpty()) {
    dbo.append(OCCASION_RECIPIENT_ID_KEY, recipientId);
  }

  BasicDBList contributionDbList = Contribution.listToDBList(contributions);
  if (null != contributionDbList && !contributionDbList.isEmpty()) {
    dbo.append(OCCASION_CONTRIBUTIONS_KEY, contributionDbList);
  }

  logger.exiting(clazz, method, dbo);
  return dbo;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:52,代码来源:Occasion.java

示例4: createIndex

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
protected void createIndex(String name, BasicDBList dbList, MongoCollection<Document> collection) {
    if (dbList.isEmpty() || name == null) {
        return;
    }

    BasicDBObject index = (BasicDBObject) dbList.get(0);
    IndexOptions options = new IndexOptions().name(name);
    if (dbList.size() > 1) {
        BasicDBObject opts = (BasicDBObject) dbList.get(1);
        if (opts.get("unique") != null && opts.get("unique") instanceof Boolean) {
            options = options.unique(opts.getBoolean("unique"));
        }
        if (opts.get("expireAfterSeconds") != null && opts.get("expireAfterSeconds") instanceof Integer) {
            options = options.expireAfter(Long.valueOf(opts.getInt("expireAfterSeconds")), TimeUnit.SECONDS);
        }
        if (opts.get("background") != null && opts.get("background") instanceof Boolean) {
            options = options.background(opts.getBoolean("background"));
        }
        if (opts.get("bits") != null && opts.get("bits") instanceof Integer) {
            options = options.bits(opts.getInt("bits"));
        }
        if (opts.get("bucketSize") != null && opts.get("bucketSize") instanceof Double) {
            options = options.bucketSize(opts.getDouble("bucketSize"));
        }
        if (opts.get("defaultLanguage") != null && opts.get("defaultLanguage") instanceof String) {
            options = options.defaultLanguage(opts.getString("defaultLanguage"));
        }
        if (opts.get("languageOverride") != null && opts.get("languageOverride") instanceof String) {
            options = options.languageOverride(opts.getString("languageOverride"));
        }
        if (opts.get("min") != null && opts.get("min") instanceof Double) {
            options = options.min(opts.getDouble("min"));
        }
        if (opts.get("max") != null && opts.get("max") instanceof Double) {
            options = options.max(opts.getDouble("max"));
        }
        if (opts.get("sparse") != null && opts.get("sparse") instanceof Boolean) {
            options = options.sparse(opts.getBoolean("sparse"));
        }
        if (opts.get("textVersion") != null && opts.get("textVersion") instanceof Integer) {
            options = options.textVersion(opts.getInt("textVersion"));
        }
        if (opts.get("version") != null && opts.get("version") instanceof Integer) {
            options = options.version(opts.getInt("version"));
        }
        if (opts.get("weights") != null && opts.get("weights") instanceof Bson) {
            options = options.weights((Bson) opts.get("weights"));
        }
    }
    collection.createIndex(new Document(index), options);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:52,代码来源:AbstractMongoProcessor.java

示例5: filterAttributes

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
protected void filterAttributes(DBObject doc, QueryOptions queryOptions) {
    if (doc == null || queryOptions == null)
        return;

    List<String> attributesToInclude = queryOptions.attributesToInclude();
    List<String> attributesToExclude = queryOptions.attributesToExclude();

    if ((attributesToInclude == null || attributesToInclude.isEmpty())
        && (attributesToExclude == null || attributesToExclude.isEmpty()))
        return;

    DBObject _attributesValues = (DBObject) doc.get(AttributeSupportColumn.ATTRIBUTES);

    if (_attributesValues == null || !(_attributesValues instanceof BasicDBList))
        return;

    BasicDBList attributesValues = (BasicDBList) _attributesValues;

    if (attributesValues.isEmpty())
        return;

    Map<Id, String> attributeIdCodeMap = attributeIdCodeMap();

    if (attributeIdCodeMap == null || attributeIdCodeMap.isEmpty())
        return;

    List<Object> objectsToRemove = new ArrayList<>();

    for (Object obj : attributesValues) {
        DBObject attrValue = (DBObject) obj;

        Id attrId = Id.valueOf(attrValue.get(AttributeValue.Col.ATTRIBUTE_ID));

        if (attrId != null) {
            String attrCode = attributeIdCodeMap.get(attrId);

            if (attributesToInclude != null && !attributesToInclude.isEmpty()
                && !attributesToInclude.contains(attrCode)) {
                objectsToRemove.add(obj);
            }

            if ((attributesToInclude == null || attributesToInclude.isEmpty()) && (attributesToExclude != null
                && !attributesToExclude.isEmpty() && attributesToInclude.contains(attrCode))) {
                objectsToRemove.add(obj);
            }
        }
    }

    if (objectsToRemove.size() > 0)
        attributesValues.removeAll(objectsToRemove);
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:52,代码来源:AbstractMongoDao.java


注:本文中的com.mongodb.BasicDBList.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。