com.arangodb.model.CollectionCreateOptions Java Examples

The following examples show how to use com.arangodb.model.CollectionCreateOptions. 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: DefaultArangoPersistentEntity.java    From spring-data with Apache License 2.0 6 votes vote down vote up
public DefaultArangoPersistentEntity(final TypeInformation<T> information) {
	super(information);
	collection = StringUtils.uncapitalize(information.getType().getSimpleName());
	context = new StandardEvaluationContext();
	hashIndexedProperties = new ArrayList<>();
	skiplistIndexedProperties = new ArrayList<>();
	persistentIndexedProperties = new ArrayList<>();
	geoIndexedProperties = new ArrayList<>();
	fulltextIndexedProperties = new ArrayList<>();
	repeatableAnnotationCache = new HashMap<>();
	final Document document = findAnnotation(Document.class);
	final Edge edge = findAnnotation(Edge.class);
	if (edge != null) {
		collection = StringUtils.hasText(edge.value()) ? edge.value() : collection;
		collectionOptions = createCollectionOptions(edge);
	} else if (document != null) {
		collection = StringUtils.hasText(document.value()) ? document.value() : collection;
		collectionOptions = createCollectionOptions(document);
	} else {
		collectionOptions = new CollectionCreateOptions().type(CollectionType.DOCUMENT);
	}
	expression = PARSER.parseExpression(collection, ParserContext.TEMPLATE_EXPRESSION);
}
 
Example #2
Source File: DefaultArangoPersistentEntity.java    From spring-data with Apache License 2.0 5 votes vote down vote up
private static CollectionCreateOptions createCollectionOptions(final Document annotation) {
	final CollectionCreateOptions options = new CollectionCreateOptions().type(CollectionType.DOCUMENT)
			.waitForSync(annotation.waitForSync()).doCompact(annotation.doCompact())
			.isVolatile(annotation.isVolatile()).isSystem(annotation.isSystem());
	if (annotation.journalSize() > -1) {
		options.journalSize(annotation.journalSize());
	}
	if (annotation.replicationFactor() > -1) {
		options.replicationFactor(annotation.replicationFactor());
	}
	if (annotation.satellite()) {
		options.satellite(annotation.satellite());
	}
	final String[] shardKeys = annotation.shardKeys();
	if (shardKeys.length > 1 || (shardKeys.length > 0 && StringUtils.hasText(shardKeys[0]))) {
		options.shardKeys(shardKeys);
	}
	if (annotation.numberOfShards() > -1) {
		options.numberOfShards(annotation.numberOfShards());
	}
	if (annotation.indexBuckets() > -1) {
		options.indexBuckets(annotation.indexBuckets());
	}
	if (annotation.allowUserKeys()) {
		options.keyOptions(annotation.allowUserKeys(), annotation.keyType(),
			annotation.keyIncrement() > -1 ? annotation.keyIncrement() : null,
			annotation.keyOffset() > -1 ? annotation.keyOffset() : null);
	}
	return options;
}
 
Example #3
Source File: DefaultArangoPersistentEntity.java    From spring-data with Apache License 2.0 5 votes vote down vote up
private static CollectionCreateOptions createCollectionOptions(final Edge annotation) {
	final CollectionCreateOptions options = new CollectionCreateOptions().type(CollectionType.EDGES)
			.waitForSync(annotation.waitForSync()).doCompact(annotation.doCompact())
			.isVolatile(annotation.isVolatile()).isSystem(annotation.isSystem());
	if (annotation.journalSize() > -1) {
		options.journalSize(annotation.journalSize());
	}
	if (annotation.replicationFactor() > -1) {
		options.replicationFactor(annotation.replicationFactor());
	}
	final String[] shardKeys = annotation.shardKeys();
	if (shardKeys.length > 0) {
		options.shardKeys(shardKeys);
	}
	if (annotation.numberOfShards() > -1) {
		options.numberOfShards(annotation.numberOfShards());
	}
	if (annotation.indexBuckets() > -1) {
		options.indexBuckets(annotation.indexBuckets());
	}
	if (annotation.allowUserKeys()) {
		options.keyOptions(annotation.allowUserKeys(), annotation.keyType(),
			annotation.keyIncrement() > -1 ? annotation.keyIncrement() : null,
			annotation.keyOffset() > -1 ? annotation.keyOffset() : null);
	}
	return options;
}
 
Example #4
Source File: BaseTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
static void initEdgeCollections(String... collections) {
    ArangoDatabase db = initDB();
    for (String collection : collections) {
        if (db.collection(collection).exists())
            db.collection(collection).drop();
        db.createCollection(collection, new CollectionCreateOptions().type(CollectionType.EDGES));
    }
}
 
Example #5
Source File: DefaultArangoPersistentEntity.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionCreateOptions getCollectionOptions() {
	return collectionOptions;
}
 
Example #6
Source File: ArangoTemplate.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public CollectionOperations collection(final String name, final CollectionCreateOptions options)
		throws DataAccessException {
	return collection(_collection(name, null, options));
}
 
Example #7
Source File: ArangoOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the operations interface for a collection. If the collection does not exists, it is created
 * automatically.
 *
 * @param name
 *            The name of the collection
 * @param options
 *            Additional options for collection creation, can be null
 * @return {@link CollectionOperations}
 * @throws DataAccessException
 */
CollectionOperations collection(String name, CollectionCreateOptions options) throws DataAccessException;
 
Example #8
Source File: ArangoPersistentEntity.java    From spring-data with Apache License 2.0 votes vote down vote up
CollectionCreateOptions getCollectionOptions();