Package com.mongodb

Examples of com.mongodb.BasicDBObject


    @Override
    public List<SystemMessage> all(int page) {
        List<SystemMessage> messages = Lists.newArrayList();

        DBObject sort = new BasicDBObject();
        sort.put("timestamp", -1);

        List<DBObject> results = query(SystemMessageImpl.class, new BasicDBObject(), sort, PER_PAGE, PER_PAGE * page);
        for (DBObject o : results) {
            messages.add(new SystemMessageImpl(new ObjectId(o.get("_id").toString()), o.toMap()));
        }

        return messages;
View Full Code Here


    @Override
    @SuppressWarnings("unchecked")
    public List<SavedSearch> all() {
        List<SavedSearch> searches = Lists.newArrayList();

        List<DBObject> results = query(SavedSearchImpl.class, new BasicDBObject());
        for (DBObject o : results) {

            searches.add(new SavedSearchImpl((ObjectId) o.get("_id"), o.toMap()));
        }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public SavedSearchImpl load(String id) throws NotFoundException {
        BasicDBObject o = (BasicDBObject) get(SavedSearchImpl.class, id);

        if (o == null) {
            throw new NotFoundException();
        }

        return new SavedSearchImpl((ObjectId) o.get("_id"), o.toMap());
    }
View Full Code Here

    public String historicSingleMetric(
            @ApiParam(name = "metricName", required = true) @PathParam("metricName") String metricName,
            @ApiParam(name = "after", value = "Only values for after this UTC timestamp (1970 epoch)") @QueryParam("after") @DefaultValue("-1") long after
    ) {
        checkPermission(RestPermissions.METRICS_READHISTORY, metricName);
        BasicDBObject andQuery = new BasicDBObject();
        List<BasicDBObject> obj = new ArrayList<BasicDBObject>();
        obj.add(new BasicDBObject("name", metricName));
        if (after != -1) {
            obj.add(new BasicDBObject("$gt"new BasicDBObject("$gt", new Date(after))));
        }
        andQuery.put("$and", obj);

        final DBCursor cursor = mongoConnection.getDatabase().getCollection("graylog2_metrics")
                .find(andQuery).sort(new BasicDBObject("timestamp", 1));
        Map<String, Object> metricsData = Maps.newHashMap();
        metricsData.put("name", metricName);
        List<Object> values = Lists.newArrayList();
        metricsData.put("values", values);
View Full Code Here

        return LOG;
    }

    // TODO: Move this to the related persisted service classes
    private void verifyIndices() {
        mongoConnection.getDatabase().getCollection(getCollectionName(IndexFailureImpl.class)).createIndex(new BasicDBObject("timestamp", 1));
        mongoConnection.getDatabase().getCollection(getCollectionName(IndexFailureImpl.class)).createIndex(new BasicDBObject("letter_id", 1));

        mongoConnection.getDatabase().getCollection(getCollectionName(PersistedDeadLetterImpl.class)).createIndex(new BasicDBObject("timestamp", 1));
        mongoConnection.getDatabase().getCollection(getCollectionName(PersistedDeadLetterImpl.class)).createIndex(new BasicDBObject("letter_id", 1));
    }
View Full Code Here

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

      DBCollection ME = db.getCollection(Entities);

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

      for (Map.Entry<String, Object> e : comp.getAllProperties()
          .entrySet()) {
        created.append(e.getKey().replace('.', '_'), e.getValue()
            .toString());
      }

      ME.insert(created);
View Full Code Here

      // 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("added", wire.getDestination().getName());
View Full Code Here

      // 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", "added").append("attribute", attr)
          .append("value", newValue);
      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();

      DBCollection ChangedAttr = db.getCollection(ChangedAttributes);

      BasicDBObject newVal = new BasicDBObject("name", comp.getName())
          .append("time", System.currentTimeMillis())
          .append("op", "changed").append("attribute", attr)
          .append("value", newValue).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();

      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

TOP

Related Classes of com.mongodb.BasicDBObject

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.