/** * Insert a record in the database. Any field/value pairs in the specified * values HashMap will be written into the record with the specified record * key. * * @param table * The name of the table * @param key * The record key of the record to insert. * @param values * A HashMap of field/value pairs to insert in the record * @return Zero on success, a non-zero error code on error. See the * {@link DB} class's description for a discussion of error codes. */ @Override public Status insert(String table, String key, Map<String, ByteIterator> values) { try { BaseDocument toInsert = new BaseDocument(key); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { toInsert.addAttribute(entry.getKey(), byteIteratorToString(entry.getValue())); } DocumentCreateOptions options = new DocumentCreateOptions().waitForSync(waitForSync); arangoDB.db(databaseName).collection(table).insertDocument(toInsert, options); return Status.OK; } catch (ArangoDBException e) { logger.error("Exception while trying insert {} {} with ex {}", table, key, e.toString()); } return Status.ERROR; }
public static CollectionType fromType(final int type) { for (final CollectionType cType : CollectionType.values()) { if (cType.type == type) { return cType; } } return null; } }
/** * @return whether the collection is a satellite collection. Only in a enterprise cluster setup. */ public Boolean getSatellite() { return this.replicationFactor.getSatellite(); }
@Override public String translateName(final Field field) { final DocumentField annotation = field.getAnnotation(DocumentField.class); if (annotation != null) { return annotation.value().getSerializeName(); } return field.getName(); } });
@Override public Collection<Warning> getWarnings() { final Extras extra = iterator.getResult().getExtra(); return extra != null ? extra.getWarnings() : null; }
/** * @param satellite * If the true the collection is created as a satellite collection. In this case * {@link #replicationFactor(Integer)} is ignored. * @return options */ public CollectionCreateOptions satellite(final Boolean satellite) { this.replicationFactor.setSatellite(satellite); return this; }
public CollectionCreateOptions() { super(); replicationFactor = new ReplicationFactor(); }
public Integer getReplicationFactor() { return replicationFactor.getReplicationFactor(); }
public static CollectionStatus fromStatus(final int status) { for (final CollectionStatus cStatus : CollectionStatus.values()) { if (cStatus.status == status) { return cStatus; } } return null; }
public static LogLevel fromLevel(final int level) { for (final LogLevel logLevel : LogLevel.values()) { if (logLevel.level == level) { return logLevel; } } return null; }
/** * @return ArangoDB exception */ public String getException() { return entity != null ? entity.getException() : null; }
/** * @return ArangoDB error message */ public String getErrorMessage() { return entity != null ? entity.getErrorMessage() : null; }
/** * @return HTTP response code */ public Integer getResponseCode() { return responseCode != null ? responseCode : entity != null ? entity.getCode() : null; }
/** * @return ArangoDB error number */ public Integer getErrorNum() { return entity != null ? entity.getErrorNum() : null; }
try { if (!transactionUpdate) { BaseDocument updateDoc = new BaseDocument(); for (Entry<String, ByteIterator> field : values.entrySet()) { updateDoc.addAttribute(field.getKey(), byteIteratorToString(field.getValue()));
public Boolean getSatellite() { return replicationFactor.getSatellite(); }
public void setSatellite(final Boolean satellite) { this.replicationFactor.setSatellite(satellite); }
public CollectionPropertiesEntity() { super(); replicationFactor = new ReplicationFactor(); }
public Integer getReplicationFactor() { return replicationFactor.getReplicationFactor(); }