com.arangodb.util.MapBuilder Java Examples

The following examples show how to use com.arangodb.util.MapBuilder. 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: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 7 votes vote down vote up
@Test
@SuppressWarnings("rawtypes")
public void aqlWithLimitQueryAsMap() {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    final ArangoCursor<Map> cursor = db.query(query, bindVars, null, Map.class);
    assertThat(cursor, is(notNullValue()));
    for (; cursor.hasNext(); ) {
        final Map map = cursor.next();
        assertThat(map.get("name"), is(notNullValue()));
        assertThat(String.valueOf(map.get("name")),
                isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
        assertThat(map.get("gender"), is(notNullValue()));
        assertThat(String.valueOf(map.get("gender")), is(Gender.FEMALE.name()));
        assertThat(map.get("age"), is(notNullValue()));
        assertThat(Long.valueOf(map.get("age").toString()), isOneOf(21L, 23L, 25L, 27L, 29L));
    }
}
 
Example #2
Source File: RelationsResolver.java    From spring-data with Apache License 2.0 6 votes vote down vote up
private ArangoCursor<?> _resolve(
	final String id,
	final Class<?> type,
	final Relations annotation,
	final boolean limit) {

	final String edges = Arrays.stream(annotation.edges()).map(e -> template.collection(e).name())
			.collect(Collectors.joining(","));

	final String query = String.format(
		"WITH @@vertex FOR v IN %d .. %d %s @start %s OPTIONS {bfs: true, uniqueVertices: \"global\"} %s RETURN v", //
		Math.max(1, annotation.minDepth()), //
		Math.max(1, annotation.maxDepth()), //
		annotation.direction(), //
		edges, //
		limit ? "LIMIT 1" : "");

	final Map<String, Object> bindVars = new MapBuilder()//
			.put("start", id) //
			.put("@vertex", type) //
			.get();

	return template.query(query, bindVars, type);
}
 
Example #3
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsList() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, List.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(list -> {
                    assertThat(list.get(0), is(notNullValue()));
                    assertThat(String.valueOf(list.get(0)),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(list.get(1), is(notNullValue()));
                    assertThat(Gender.valueOf(String.valueOf(list.get(1))), is(Gender.FEMALE));
                    assertThat(list.get(2), is(notNullValue()));
                    assertThat(Long.valueOf(String.valueOf(list.get(2))), isOneOf(21L, 23L, 25L, 27L, 29L));
                });
            })
            .get();
}
 
Example #4
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsMap() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, Map.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(map -> {
                    assertThat(map.get("name"), is(notNullValue()));
                    assertThat(String.valueOf(map.get("name")),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(map.get("gender"), is(notNullValue()));
                    assertThat(String.valueOf(map.get("gender")), is(Gender.FEMALE.name()));
                    assertThat(map.get("age"), is(notNullValue()));
                    assertThat(Long.valueOf(map.get("age").toString()), isOneOf(21L, 23L, 25L, 27L, 29L));
                });
            })
            .get();
}
 
Example #5
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackArray() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, VPackSlice.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(vpack -> {
                    assertThat(vpack.get(0).getAsString(),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(vpack.get(1).getAsString(), is(Gender.FEMALE.name()));
                    assertThat(vpack.get(2).getAsInt(), isOneOf(21, 23, 25, 27, 29));
                });
            })
            .get();
}
 
Example #6
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackObject() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, VPackSlice.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(vpack -> {
                    assertThat(vpack.get("name").getAsString(),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(vpack.get("gender").getAsString(), is(Gender.FEMALE.name()));
                    assertThat(vpack.get("age").getAsInt(), isOneOf(21, 23, 25, 27, 29));
                });
            })
            .get();
}
 
Example #7
Source File: UserAuthTest.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void readDocumentByAql() {
    try {
        arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).insertDocument(new BaseDocument("123"));
        if ((Permissions.RW.equals(param.dbPermission) || Permissions.RO.equals(param.dbPermission))
                && (Permissions.RW.equals(param.colPermission) || Permissions.RO.equals(param.colPermission))) {
            assertThat(details,
                    arangoDB.db(DB_NAME).query("FOR i IN @@col RETURN i",
                            new MapBuilder().put("@col", COLLECTION_NAME).get(), new AqlQueryOptions(), BaseDocument.class)
                            .asListRemaining().size(),
                    is(1));
        } else {
            assertThat(details,
                    arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class),
                    is(nullValue()));
        }
    } finally {
        try {
            arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).deleteDocument("123");
        } catch (final ArangoDBException e) {
        }
    }
}
 
Example #8
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("rawtypes")
public void aqlWithLimitQueryAsList() {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    final ArangoCursor<List> cursor = db.query(query, bindVars, null, List.class);
    assertThat(cursor, is(notNullValue()));
    for (; cursor.hasNext(); ) {
        final List list = cursor.next();
        assertThat(list.get(0), is(notNullValue()));
        assertThat(String.valueOf(list.get(0)),
                isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
        assertThat(list.get(1), is(notNullValue()));
        assertThat(Gender.valueOf(String.valueOf(list.get(1))), is(Gender.FEMALE));
        assertThat(list.get(2), is(notNullValue()));
        assertThat(Long.valueOf(String.valueOf(list.get(2))), isOneOf(21L, 23L, 25L, 27L, 29L));
    }
}
 
Example #9
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver-async with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsList() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, List.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(list -> {
                    assertThat(list.get(0), is(notNullValue()));
                    assertThat(String.valueOf(list.get(0)),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(list.get(1), is(notNullValue()));
                    assertThat(Gender.valueOf(String.valueOf(list.get(1))), is(Gender.FEMALE));
                    assertThat(list.get(2), is(notNullValue()));
                    assertThat(Long.valueOf(String.valueOf(list.get(2))), isOneOf(21L, 23L, 25L, 27L, 29L));
                });
            })
            .get();
}
 
Example #10
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver-async with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsMap() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, Map.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(map -> {
                    assertThat(map.get("name"), is(notNullValue()));
                    assertThat(String.valueOf(map.get("name")),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(map.get("gender"), is(notNullValue()));
                    assertThat(String.valueOf(map.get("gender")), is(Gender.FEMALE.name()));
                    assertThat(map.get("age"), is(notNullValue()));
                    assertThat(Long.valueOf(map.get("age").toString()), isOneOf(21L, 23L, 25L, 27L, 29L));
                });
            })
            .get();
}
 
Example #11
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver-async with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackArray() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, VPackSlice.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(vpack -> {
                    assertThat(vpack.get(0).getAsString(),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(vpack.get(1).getAsString(), is(Gender.FEMALE.name()));
                    assertThat(vpack.get(2).getAsInt(), isOneOf(21, 23, 25, 27, 29));
                });
            })
            .get();
}
 
Example #12
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver-async with Apache License 2.0 6 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackObject() throws InterruptedException, ExecutionException {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    db.query(query, bindVars, null, VPackSlice.class)
            .whenComplete((cursor, ex) -> {
                assertThat(cursor, is(notNullValue()));
                cursor.forEachRemaining(vpack -> {
                    assertThat(vpack.get("name").getAsString(),
                            isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
                    assertThat(vpack.get("gender").getAsString(), is(Gender.FEMALE.name()));
                    assertThat(vpack.get("age").getAsInt(), isOneOf(21, 23, 25, 27, 29));
                });
            })
            .get();
}
 
Example #13
Source File: ArangoTemplateTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Test
public void queryVPackSlice() {
	template.insert(new Customer("John", "Doe", 30));
	final ArangoCursor<VPackSlice> cursor = template.query("FOR c IN @@coll FILTER c.name == @name RETURN c",
		new MapBuilder().put("@coll", "customer").put("name", "John").get(), new AqlQueryOptions(),
		VPackSlice.class);
	assertThat(cursor, is(notNullValue()));
	final List<VPackSlice> customers = cursor.asListRemaining();
	assertThat(customers.size(), is(1));
	assertThat(customers.get(0).get("name").getAsString(), is("John"));
	assertThat(customers.get(0).get("surname").getAsString(), is("Doe"));
	assertThat(customers.get(0).get("age").getAsInt(), is(30));
}
 
Example #14
Source File: ArangoTemplate.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public <T> Iterable<T> findAll(final Class<T> entityClass) throws DataAccessException {
	final String query = "FOR entity IN @@col RETURN entity";
	final Map<String, Object> bindVars = new MapBuilder().put("@col", entityClass).get();
	return new Iterable<T>() {
		@Override
		public Iterator<T> iterator() {
			return query(query, bindVars, null, entityClass);
		}
	};
}
 
Example #15
Source File: AfterLoadEventTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Test
public void findByQueryAfterLoadEvent() {
	template.insert(customers, Customer.class);
	template.query("FOR c IN @@collection FILTER c.name == @name RETURN c",
		new MapBuilder().put("@collection", Customer.class).put("name", john.getName()).get(), Customer.class)
			.forEach(elem -> { // trigger conversion
			});
	assertThat(listener.afterLoadEvents.size(), is(1));
	for (final AfterLoadEvent<Customer> event : listener.afterLoadEvents) {
		assertThat(event.getSource(), is(john));
	}
}
 
Example #16
Source File: ArangoDatabaseTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void transactionMap() {
    final Map<String, Object> params = new MapBuilder().put("foo", "hello").put("bar", "world").get();
    final TransactionOptions options = new TransactionOptions().params(params);
    final String result = db
            .transaction("function (params) { return params['foo'] + ' ' + params['bar'];}", String.class, options);
    assertThat(result, is("hello world"));
}
 
Example #17
Source File: ArangoDatabaseTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void queryAllowDirtyRead() throws IOException {
    final ArangoCursor<BaseDocument> cursor = db.query("FOR i IN @@col FILTER i.test == @test RETURN i",
            new MapBuilder().put("@col", CNAME1).put("test", null).get(),
            new AqlQueryOptions().allowDirtyRead(true), BaseDocument.class);
    cursor.close();
}
 
Example #18
Source File: ArangoDatabaseTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void queryNoResults() throws IOException {
    final ArangoCursor<BaseDocument> cursor = db
            .query("FOR i IN @@col RETURN i", new MapBuilder().put("@col", CNAME1).get(), null,
                    BaseDocument.class);
    cursor.close();
}
 
Example #19
Source File: GeneralMappingTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Test
public void supplementKey() {
	final OnlyIdTestEntity value = new OnlyIdTestEntity();
	template.insert(value);
	final List<BasicTestEntity> result = template.query("RETURN @doc", new MapBuilder().put("doc", value).get(),
		new AqlQueryOptions(), BasicTestEntity.class).asListRemaining();
	assertThat(result.size(), is(1));
	assertThat(result.get(0).getId(), is(value.id));
	assertThat(result.get(0).getRev(), is(nullValue()));
}
 
Example #20
Source File: ArangoCollectionTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void importDocumentsJsonFromToPrefix() throws JsonProcessingException {
    String k1 = UUID.randomUUID().toString();
    String k2 = UUID.randomUUID().toString();

    final String[] keys = {k1, k2};

    final String values = mapper.writeValueAsString(Arrays.asList(
            new MapBuilder()
                    .put("_key", k1)
                    .put("_from", "from")
                    .put("_to", "to")
                    .get(),
            new MapBuilder()
                    .put("_key", k2)
                    .put("_from", "from")
                    .put("_to", "to")
                    .get()
    ));

    final DocumentImportEntity importResult = edgeCollection
            .importDocuments(values, new DocumentImportOptions().fromPrefix("foo").toPrefix("bar"));
    assertThat(importResult, is(notNullValue()));
    assertThat(importResult.getCreated(), is(2));
    for (String key : keys) {
        final BaseEdgeDocument doc = edgeCollection.getDocument(key, BaseEdgeDocument.class);
        assertThat(doc, is(notNullValue()));
        assertThat(doc.getFrom(), is("foo/from"));
        assertThat(doc.getTo(), is("bar/to"));
    }
}
 
Example #21
Source File: ArangoTemplateTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Test
public void query() {
	template.insert(new Customer("John", "Doe", 30));
	final ArangoCursor<Customer> cursor = template.query("FOR c IN @@coll FILTER c.name == @name RETURN c",
		new MapBuilder().put("@coll", "customer").put("name", "John").get(), new AqlQueryOptions(), Customer.class);
	assertThat(cursor, is(notNullValue()));
	final List<Customer> customers = cursor.asListRemaining();
	assertThat(customers.size(), is(1));
	assertThat(customers.get(0).getName(), is("John"));
	assertThat(customers.get(0).getSurname(), is("Doe"));
	assertThat(customers.get(0).getAge(), is(30));
}
 
Example #22
Source File: ArangoTemplateTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Test
public void queryMap() {
	template.insert(new Customer("John", "Doe", 30));
	final ArangoCursor<Map> cursor = template.query("FOR c IN @@coll FILTER c.name == @name RETURN c",
		new MapBuilder().put("@coll", "customer").put("name", "John").get(), new AqlQueryOptions(), Map.class);
	assertThat(cursor, is(notNullValue()));
	final List<Map> customers = cursor.asListRemaining();
	assertThat(customers.size(), is(1));
	assertThat(customers.get(0).get("name"), is("John"));
	assertThat(customers.get(0).get("surname"), is("Doe"));
	assertThat(customers.get(0).get("age"), is(30L));
}
 
Example #23
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackArray() {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN [t.name, t.gender, t.age]";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    final ArangoCursor<VPackSlice> cursor = db.query(query, bindVars, null, VPackSlice.class);
    assertThat(cursor, is(notNullValue()));
    for (; cursor.hasNext(); ) {
        final VPackSlice vpack = cursor.next();
        assertThat(vpack.get(0).getAsString(),
                isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
        assertThat(vpack.get(1).getAsString(), is(Gender.FEMALE.name()));
        assertThat(vpack.get(2).getAsInt(), isOneOf(21, 23, 25, 27, 29));
    }
}
 
Example #24
Source File: AqlQueryWithSpecialReturnTypesExample.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
@Test
public void aqlWithLimitQueryAsVPackObject() {
    final String query = "FOR t IN " + COLLECTION_NAME
            + " FILTER t.age >= 20 && t.age < 30 && t.gender == @gender RETURN t";
    final Map<String, Object> bindVars = new MapBuilder().put("gender", Gender.FEMALE).get();
    final ArangoCursor<VPackSlice> cursor = db.query(query, bindVars, null, VPackSlice.class);
    assertThat(cursor, is(notNullValue()));
    for (; cursor.hasNext(); ) {
        final VPackSlice vpack = cursor.next();
        assertThat(vpack.get("name").getAsString(),
                isOneOf("TestUser11", "TestUser13", "TestUser15", "TestUser17", "TestUser19"));
        assertThat(vpack.get("gender").getAsString(), is(Gender.FEMALE.name()));
        assertThat(vpack.get("age").getAsInt(), isOneOf(21, 23, 25, 27, 29));
    }
}
 
Example #25
Source File: ArangoTemplateTest.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Test
public void queryBaseDocument() {
	template.insert(new Customer("John", "Doe", 30));
	final ArangoCursor<BaseDocument> cursor = template.query("FOR c IN @@coll FILTER c.name == @name RETURN c",
		new MapBuilder().put("@coll", "customer").put("name", "John").get(), new AqlQueryOptions(),
		BaseDocument.class);
	assertThat(cursor, is(notNullValue()));
	final List<BaseDocument> customers = cursor.asListRemaining();
	assertThat(customers.size(), is(1));
	assertThat(customers.get(0).getAttribute("name"), is("John"));
	assertThat(customers.get(0).getAttribute("surname"), is("Doe"));
	assertThat(customers.get(0).getAttribute("age"), is(30L));
}
 
Example #26
Source File: ArangoDatabaseTest.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
@Test
public void queryWithNullBindParam() throws IOException {
    final ArangoCursor<BaseDocument> cursor = db.query("FOR i IN @@col FILTER i.test == @test RETURN i",
            new MapBuilder().put("@col", CNAME1).put("test", null).get(), null, BaseDocument.class);
    cursor.close();
}
 
Example #27
Source File: DocumentToResolver.java    From spring-data with Apache License 2.0 4 votes vote down vote up
private ArangoCursor<?> _resolve(final String id, final Class<?> type, final boolean limit) {
	final String query = String.format("FOR e IN @@edge FILTER e._to == @id RETURN e", limit ? "LIMIT 1" : "");
	return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(), new AqlQueryOptions(),
		type);
}
 
Example #28
Source File: DocumentFromResolver.java    From spring-data with Apache License 2.0 4 votes vote down vote up
private ArangoCursor<?> _resolve(final String id, final Class<?> type, final boolean limit) {
	final String query = String.format("FOR e IN @@edge FILTER e._from == @id %s RETURN e", limit ? "LIMIT 1" : "");
	return template.query(query, new MapBuilder().put("@edge", type).put("id", id).get(), new AqlQueryOptions(),
		type);
}