@Override public String save(Alert alert) throws ValidationException { checkArgument(alert instanceof AlertImpl, "Supplied argument must be of type " + AlertImpl.class + ", and not " + alert.getClass()); return this.coll.save((AlertImpl)alert).getSavedId(); }
@Override public String save(AlarmCallbackConfiguration model) throws ValidationException { return coll.save(implOrFail(model)).getSavedId(); }
@Subscribe public void publishClusterEvent(Object event) { if (event instanceof DeadEvent) { LOG.debug("Skipping DeadEvent on cluster event bus"); return; } final String className = AutoValueUtils.getCanonicalName(event.getClass()); final ClusterEvent clusterEvent = ClusterEvent.create(nodeId.toString(), className, event); try { final String id = dbCollection.save(clusterEvent, WriteConcern.JOURNALED).getSavedId(); LOG.debug("Published cluster event with ID <{}> and type <{}>", id, className); } catch (MongoException e) { LOG.error("Couldn't publish cluster event of type <" + className + ">", e); } }
@Override public String save(Alert alert) throws ValidationException { checkArgument(alert instanceof AlertImpl, "Supplied argument must be of type " + AlertImpl.class + ", and not " + alert.getClass()); return this.coll.save((AlertImpl)alert).getSavedId(); }
public K create(T entity) { return entitiesCollection.insert(entity).getSavedId(); }
public K save(T entity) { WriteResult<T, K> writeResult = entitiesCollection.save(entity); if (writeResult.getDbObjects().length != 0) { // Had an insert so we can safely reference the ID entity.setId(writeResult.getSavedId()); return writeResult.getSavedId(); } // Return the original ID (no change) return entity.getId(); }
@Override public String save(AlarmCallbackConfiguration model) throws ValidationException { return coll.save(implOrFail(model)).getSavedId(); }
@Subscribe public void publishClusterEvent(Object event) { if (event instanceof DeadEvent) { LOG.debug("Skipping DeadEvent on cluster event bus"); return; } final String className = AutoValueUtils.getCanonicalName(event.getClass()); final ClusterEvent clusterEvent = ClusterEvent.create(nodeId.toString(), className, event); try { final String id = dbCollection.save(clusterEvent, WriteConcern.JOURNALED).getSavedId(); LOG.debug("Published cluster event with ID <{}> and type <{}>", id, className); } catch (MongoException e) { LOG.error("Couldn't publish cluster event of type <" + className + ">", e); } }
public K upsert(T entity) { WriteResult<T, K> writeResult = entitiesCollection.update(findById(entity), entity, true, false); if (writeResult.getDbObjects().length != 0) { // Had an insert so we can safely reference the ID return writeResult.getSavedId(); } // Return the original ID (no change) return entity.getId(); }