當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。