Search in sources :

Example 11 with ViewResult

use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.

the class StudentGradeService method sumGradePointsByStudent.

public Map<String, Long> sumGradePointsByStudent() {
    ViewQuery query = ViewQuery.from("studentGrades", "sumGradePointsByStudent").reduce().groupLevel(1);
    ViewResult result = bucket.query(query);
    Map<String, Long> gradePointsByStudent = new HashMap<>();
    for (ViewRow row : result.allRows()) {
        String course = (String) row.key();
        long sum = Long.valueOf(row.value().toString());
        gradePointsByStudent.put(course, sum);
    }
    return gradePointsByStudent;
}
Also used : HashMap(java.util.HashMap) ViewQuery(com.couchbase.client.java.view.ViewQuery) ViewResult(com.couchbase.client.java.view.ViewResult) ViewRow(com.couchbase.client.java.view.ViewRow)

Example 12 with ViewResult

use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.

the class StudentGradeService method findAll.

public List<JsonDocument> findAll() {
    ViewQuery query = queryBuilder.findAll();
    ViewResult result = bucket.query(query);
    return extractDocuments(result);
}
Also used : ViewQuery(com.couchbase.client.java.view.ViewQuery) ViewResult(com.couchbase.client.java.view.ViewResult)

Example 13 with ViewResult

use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.

the class StudentGradeService method findByCourseAndGradeInRange.

public List<JsonDocument> findByCourseAndGradeInRange(String course, int minGrade, int maxGrade, boolean inclusiveEnd) {
    ViewQuery query = queryBuilder.findByCourseAndGradeInRange(course, minGrade, maxGrade, inclusiveEnd);
    ViewResult result = bucket.query(query);
    return extractDocuments(result);
}
Also used : ViewQuery(com.couchbase.client.java.view.ViewQuery) ViewResult(com.couchbase.client.java.view.ViewResult)

Example 14 with ViewResult

use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.

the class StudentGradeService method findByGradeGreaterThan.

public List<JsonDocument> findByGradeGreaterThan(int lower) {
    ViewQuery query = queryBuilder.findByGradeGreaterThan(lower);
    ViewResult result = bucket.query(query);
    return extractDocuments(result);
}
Also used : ViewQuery(com.couchbase.client.java.view.ViewQuery) ViewResult(com.couchbase.client.java.view.ViewResult)

Aggregations

ViewResult (com.couchbase.client.java.view.ViewResult)14 ViewQuery (com.couchbase.client.java.view.ViewQuery)12 ViewRow (com.couchbase.client.java.view.ViewRow)6 HashMap (java.util.HashMap)3 RawJsonDocument (com.couchbase.client.java.document.RawJsonDocument)2 StringReader (java.io.StringReader)2 JsonArray (com.couchbase.client.java.document.json.JsonArray)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 CasRegisteredServiceLoadedEvent (org.apereo.cas.support.events.service.CasRegisteredServiceLoadedEvent)1