use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class StreamRuleServiceImpl method create.
@Override
public StreamRule create(String streamId, CreateStreamRuleRequest cr) {
Map<String, Object> streamRuleData = Maps.newHashMap();
streamRuleData.put(StreamRuleImpl.FIELD_TYPE, cr.type());
streamRuleData.put(StreamRuleImpl.FIELD_VALUE, cr.value());
streamRuleData.put(StreamRuleImpl.FIELD_FIELD, cr.field());
streamRuleData.put(StreamRuleImpl.FIELD_INVERTED, cr.inverted());
streamRuleData.put(StreamRuleImpl.FIELD_STREAM_ID, new ObjectId(streamId));
streamRuleData.put(StreamRuleImpl.FIELD_DESCRIPTION, cr.description());
return new StreamRuleImpl(streamRuleData);
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class StreamServiceImpl method removeOutputFromAllStreams.
@Override
public void removeOutputFromAllStreams(Output output) {
ObjectId outputId = new ObjectId(output.getId());
DBObject match = new BasicDBObject(StreamImpl.FIELD_OUTPUTS, outputId);
DBObject modify = new BasicDBObject("$pull", new BasicDBObject(StreamImpl.FIELD_OUTPUTS, outputId));
collection(StreamImpl.class).update(match, modify, false, true);
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class MongoIndexSetService method delete.
/**
* {@inheritDoc}
*/
@Override
public int delete(ObjectId id) {
if (!isDeletable(id)) {
return 0;
}
final DBQuery.Query query = DBQuery.is("_id", id);
final WriteResult<IndexSetConfig, ObjectId> writeResult = collection.remove(query);
final int removedEntries = writeResult.getN();
if (removedEntries > 0) {
final IndexSetDeletedEvent deletedEvent = IndexSetDeletedEvent.create(id.toHexString());
clusterEventBus.post(deletedEvent);
}
return removedEntries;
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class IndexFailureServiceImpl method all.
@Override
public List<IndexFailure> all(int limit, int offset) {
final DBObject sort = new BasicDBObject("$natural", -1);
final List<DBObject> results = query(IndexFailureImpl.class, new BasicDBObject(), sort, limit, offset);
final List<IndexFailure> failures = new ArrayList<>(results.size());
for (DBObject o : results) {
failures.add(new IndexFailureImpl((ObjectId) o.get("_id"), o.toMap()));
}
return failures;
}
use of org.bson.types.ObjectId in project graylog2-server by Graylog2.
the class LegacyMongoIndexRangeServiceTest method testGetExistingIndexRange.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testGetExistingIndexRange() throws Exception {
final IndexRange indexRange = indexRangeService.get("graylog_0");
final DateTime end = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
final IndexRange expected = MongoIndexRange.create(new ObjectId("56250da2d400000000000001"), "graylog_0", EPOCH, end, end, 0);
assertThat(indexRange).isEqualTo(expected);
}
Aggregations