com.arangodb.ArangoCollection Java Examples

The following examples show how to use com.arangodb.ArangoCollection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultCollectionOperations.java    From spring-data with Apache License 2.0 5 votes vote down vote up
protected DefaultCollectionOperations(final ArangoCollection collection,
	final Map<CollectionCacheKey, CollectionCacheValue> collectionCache,
	final PersistenceExceptionTranslator exceptionTranslator) {
	this.collection = collection;
	this.collectionCache = collectionCache;
	this.exceptionTranslator = exceptionTranslator;
}
 
Example #2
Source File: AQLActorsAndMoviesExample.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
private static DocumentCreateEntity<BaseDocument> saveMovie(
        final ArangoCollection movies,
        final String key,
        final String title,
        final int released,
        final String tagline) {
    final BaseDocument value = new BaseDocument();
    value.setKey(key);
    value.addAttribute("title", title);
    value.addAttribute("released", released);
    value.addAttribute("tagline", tagline);
    return movies.insertDocument(value);
}
 
Example #3
Source File: AQLActorsAndMoviesExample.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
private static DocumentCreateEntity<BaseDocument> saveActor(
        final ArangoCollection actors,
        final String key,
        final String name,
        final int born) {
    final BaseDocument value = new BaseDocument();
    value.setKey(key);
    value.addAttribute("name", name);
    value.addAttribute("born", born);
    return actors.insertDocument(value);
}
 
Example #4
Source File: AQLActorsAndMoviesExample.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
private static void saveActsIn(
        final ArangoCollection actsIn,
        final String actor,
        final String movie,
        final String[] roles,
        final int year) {
    final BaseEdgeDocument value = new BaseEdgeDocument();
    value.setFrom(actor);
    value.setTo(movie);
    value.addAttribute("roles", roles);
    value.addAttribute("year", year);
    actsIn.insertDocument(value);
}
 
Example #5
Source File: ArangoDBGraphClient.java    From arangodb-tinkerpop-provider with Apache License 2.0 5 votes vote down vote up
/**
 * Insert a ArangoDBBaseDocument in the graph. The document is updated with the id, rev and name
 * (if not * present)
 * @param document 				the document
 * @throws ArangoDBGraphException 	If there was an error inserting the document
 */

public void insertGraphVariables(ArangoDBGraphVariables document) {
	logger.debug("Insert graph variables {} in {}", document, graph.name());
	if (document.isPaired()) {
		throw new ArangoDBGraphException("Paired docuements can not be inserted, only updated");
	}
	ArangoCollection gVars = db.collection(document.collection());
	if (!gVars.exists()) {
		CollectionEntity ce = db.createCollection(document.collection());
		System.out.println(ce.getStatus());
	}
	DocumentCreateEntity<ArangoDBGraphVariables> vertexEntity;
	try {
		vertexEntity = gVars.insertDocument(document);
	} catch (ArangoDBException e) {
		logger.error("Failed to insert document: {}", e.getMessage());
		ArangoDBGraphException arangoDBException = ArangoDBExceptions.getArangoDBException(e);
		if (arangoDBException.getErrorCode() == 1210) {
			throw Graph.Exceptions.vertexWithIdAlreadyExists(document._key);
		}
		throw arangoDBException;
	}
	document._id(vertexEntity.getId());
	document._rev(vertexEntity.getRev());
	if (document._key() == null) {
		document._key(vertexEntity.getKey());
	}
	document.setPaired(true);
}
 
Example #6
Source File: ArangoDBGraphClient.java    From arangodb-tinkerpop-provider with Apache License 2.0 5 votes vote down vote up
/**
 * Delete collection.
 *
 * @param name the name
 * @return true, if successful
 */

public boolean deleteCollection(String name) {
	ArangoCollection collection = db.collection(name);
	if (collection.exists()) {
		collection.drop();
		return collection.exists();
	}
	return false;
}
 
Example #7
Source File: ArangoTemplate.java    From spring-data with Apache License 2.0 4 votes vote down vote up
private ArangoCollection _collection(final String name) {
	return _collection(name, null, null);
}
 
Example #8
Source File: ArangoTemplate.java    From spring-data with Apache License 2.0 4 votes vote down vote up
private ArangoCollection _collection(final Class<?> entityClass) {
	return _collection(entityClass, null);
}
 
Example #9
Source File: ArangoTemplate.java    From spring-data with Apache License 2.0 4 votes vote down vote up
private ArangoCollection _collection(final Class<?> entityClass, final Object id) {
	final ArangoPersistentEntity<?> persistentEntity = converter.getMappingContext()
			.getRequiredPersistentEntity(entityClass);
	final String name = determineCollectionFromId(id).orElse(persistentEntity.getCollection());
	return _collection(name, persistentEntity, persistentEntity.getCollectionOptions());
}
 
Example #10
Source File: CollectionCacheValue.java    From spring-data with Apache License 2.0 4 votes vote down vote up
public CollectionCacheValue(final ArangoCollection collection) {
	super();
	this.collection = collection;
	this.entities = new ArrayList<>();
}
 
Example #11
Source File: CollectionCacheValue.java    From spring-data with Apache License 2.0 4 votes vote down vote up
public ArangoCollection getCollection() {
	return collection;
}