public ContentPackInstallation insert(final ContentPackInstallation installation) { final WriteResult<ContentPackInstallation, ObjectId> writeResult = dbCollection.insert(installation); return writeResult.getSavedObject(); }
public Optional<ContentPack> insert(final ContentPack pack) { if (findByIdAndRevision(pack.id(), pack.revision()).isPresent()) { LOG.debug("Content pack already found: id: {} revision: {}. Did not insert!", pack.id(), pack.revision()); return Optional.empty(); } final WriteResult<ContentPack, ObjectId> writeResult = dbCollection.insert(pack); return Optional.of(writeResult.getSavedObject()); }
/** * Inserts objects into the database. if the objects _id is null, one will * be generated you can get the _id that were generated by calling * getSavedObjects() or getSavedIds() on the result * * @param list * The objects to insert * @return The result * @throws MongoException * If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list) throws MongoException { return insert(list.toArray((T[]) new Object[list.size()])); }
/** * Inserts objects into the database. if the objects _id is null, one will * be generated you can get the _id that were generated by calling * getSavedObjects() or getSavedIds() on the result * * @param list * The objects to insert * @param concern * the write concern * @return The result * @throws MongoException * If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list, WriteConcern concern) throws MongoException { return insert(concern, list.toArray((T[]) new Object[list.size()])); }
public ConfigurationBundle insert(final ConfigurationBundle bundle) { final WriteResult<ConfigurationBundle, ObjectId> writeResult = dbCollection.insert(bundle); return writeResult.getSavedObject(); }
public K create(T entity) { return entitiesCollection.insert(entity).getSavedId(); }
public List<K> createAll(List<T> entities) { return entitiesCollection.insert(entities).getSavedIds(); }
@Override public <T> T create(T t) throws CompatibilityDataException { MongoClient client = null; try { client = getService().createClient(); JacksonDBCollection coll = JacksonDBCollection.wrap(client.getDB(database).getCollection(collection), t.getClass()); return (T)coll.insert(t).getSavedObject(); } catch (Exception ex) { throw new CompatibilityDataException(String.format("Failed to insert object %s", t), ex); } finally { if(client != null) { client.close(); } } }
/** * Does not update the cache, used when we know we will have a lot of save/add calls all at once, * e.g. during a convert. * * @param cause the FailureCause to add. * @param doUpdate true if a cache update should be made, false if not. * * @return the added FailureCause. * * @see MongoDBKnowledgeBase#addCause(FailureCause) */ public FailureCause addCause(FailureCause cause, boolean doUpdate) { WriteResult<FailureCause, String> result = getJacksonCollection().insert(cause); if (doUpdate) { initCache(); cache.updateCache(); } return result.getSavedObject(); }
T myobj = (T)coll.insert(t).getSavedObject(); return myobj; } catch (Exception ex) {