Package com.mongodb

Examples of com.mongodb.DBCollection


    try {

      // force connection to be established
      mongoClient.getDatabaseNames();

      DBCollection ChangedAttr = db.getCollection(ChangedAttributes);

      BasicDBObject newVal = new BasicDBObject("name", comp.getName())
          .append("time", System.currentTimeMillis())
          .append("op", "removed").append("attribute", attr)
          .append("oldValue", oldValue);

      for (Map.Entry<String, Object> e : comp.getAllProperties()
          .entrySet()) {
        newVal.append(e.getKey(), e.getValue().toString());
      }
      ChangedAttr.insert(newVal);
    } catch (MongoException e) {

      stop();
    }
  }
View Full Code Here


      // force connection to be established
      mongoClient.getDatabaseNames();

      logger.info("removing component");
      DBCollection ME = db.getCollection(Entities);

      BasicDBObject created = new BasicDBObject("name", comp.getName())
          .append("time", System.currentTimeMillis()).append("op",
              "deleted");
      ME.insert(created);

    } catch (MongoException e) {

      stop();
    }
View Full Code Here

    try {

      // force connection to be established
      mongoClient.getDatabaseNames();

      DBCollection ChangedLink = db.getCollection(Links);

      BasicDBObject newLink = new BasicDBObject("name", wire.getSource()
          .getName()).append("time", System.currentTimeMillis())
          .append("linkType", "Wire")
          .append("linkId", wire.getName())
          .append("removed", wire.getDestination().getName());

      ChangedLink.insert(newLink);

    } catch (MongoException e) {

      stop();
    }
View Full Code Here

    public SystemSetting(MongoConnection mongoConnection) {
        super(mongoConnection);
    }
   
    public boolean getBoolean(String key) {
        DBCollection coll = getCollection();
       
        DBObject query = new BasicDBObject();
        query.put("key", key);
       
        DBObject result = coll.findOne(query);
        if (result == null) {
            return false;
        }
       
        if (result.get("value").equals(true)) {
View Full Code Here

       
        return false;
    }
   
    public BasicDBList getList(String key) {
        DBCollection coll = getCollection();
        DBObject query = new BasicDBObject();
        query.put("key", key);

        DBObject result = coll.findOne(query);

        return (BasicDBList) result.get("value");
    }
View Full Code Here

        collectHistogramReports(docs, histograms, timestamp);
        collectMeterReports(docs, meters, timestamp);
        collectTimerReports(docs, timers, timestamp);

        try {
            final DBCollection collection = mongoConnection.getDatabase().getCollection("graylog2_metrics");
            // don't hang on to the data for too long.
            final BasicDBObject indexField = new BasicDBObject("timestamp", 1);
            final BasicDBObject indexOptions = new BasicDBObject("expireAfterSeconds", 5 * 60);
            collection.createIndex(indexField, indexOptions);

            collection.insert(docs, WriteConcern.UNACKNOWLEDGED);
        } catch (Exception e) {
            LOG.warn("Unable to write graylog2 metrics to mongodb. Ignoring this error.", e);
        }
    }
View Full Code Here

        if (this.messageCountsCollection != null) {
            return this.messageCountsCollection;
        }

        // Collection has not been cached yet. Do it now.
        DBCollection coll = getDatabase().getCollection("message_counts");

        coll.createIndex(new BasicDBObject("timestamp", 1));

        this.messageCountsCollection = coll;
        return coll;
    }
View Full Code Here

    public Role addRole(String roleName, int type) throws MongoException {
        if (roleName == null) {
            throw new IllegalArgumentException("Role cannot be null!");
        }
       
        DBCollection coll = getCollection();

        Role role = getRole(roleName);
        if (role != null) {
            return null;
        }

        // Role does not exist; insert it...
        DBObject data = m_helper.serialize(roleName, type);

        WriteResult result = coll.insert(data);
       
        if (result.getLastError() != null) {
            result.getLastError().throwOnError();
        }
View Full Code Here

        Filter filter = null;
        if (filterValue != null) {
            filter = FrameworkUtil.createFilter(filterValue);
        }

        DBCollection coll = getCollection();

        DBCursor cursor = coll.find();
        try {
            while (cursor.hasNext()) {
                // Hmm, there might be a more clever way of doing this...
                Role role = m_helper.deserialize(cursor.next());
                if ((filter == null) || filter.match(role.getProperties())) {
View Full Code Here

        return roles.toArray(new Role[roles.size()]);
    }

    @Override
    public Role getRole(String name) {
        DBCollection coll = getCollection();

        DBCursor cursor = coll.find(getTemplateObject(name));
        try {
            if (cursor.hasNext()) {
                return m_helper.deserialize(cursor.next());
            }
        } finally {
View Full Code Here

TOP

Related Classes of com.mongodb.DBCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.