use of com.couchbase.client.java.view.ViewResult in project cas by apereo.
the class CouchbaseServiceRegistryDao method load.
@Override
public List<RegisteredService> load() {
try {
LOGGER.debug("Loading services");
final ViewResult allKeys = executeViewQueryForAllServices();
final List<RegisteredService> services = new LinkedList<>();
for (final ViewRow row : allKeys) {
final RawJsonDocument document = row.document(RawJsonDocument.class);
if (document != null) {
final String json = document.content();
LOGGER.debug("Found service: [{}]", json);
final StringReader stringReader = new StringReader(json);
services.add(this.registeredServiceJsonSerializer.from(stringReader));
}
}
return services;
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
return new LinkedList<>();
}
}
use of com.couchbase.client.java.view.ViewResult in project cas by apereo.
the class CouchbaseServiceRegistry method load.
@Override
public List<RegisteredService> load() {
try {
final ViewResult allKeys = executeViewQueryForAllServices();
final List<RegisteredService> services = new ArrayList<>();
for (final ViewRow row : allKeys) {
final RawJsonDocument document = row.document(RawJsonDocument.class);
if (document != null) {
final String json = document.content();
LOGGER.debug("Found service: [{}]", json);
final StringReader stringReader = new StringReader(json);
final RegisteredService service = this.registeredServiceJsonSerializer.from(stringReader);
services.add(service);
publishEvent(new CasRegisteredServiceLoadedEvent(this, service));
}
}
return services;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
throw new IllegalArgumentException(e.getMessage(), e);
}
}
use of com.couchbase.client.java.view.ViewResult in project ff4j by ff4j.
the class EventRepositoryCouchbase method queryView.
public void queryView(Bucket bucket, String design, String view) {
ViewQuery queryAllFeatures = ViewQuery.from(design, view);
ViewResult queryResult = bucket.query(queryAllFeatures);
List<ViewRow> rows = queryResult.allRows();
for (ViewRow viewRow : rows) {
System.out.println("Result view:" + viewRow.id() + ":" + viewRow.value());
}
}
use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method findTopGradesByCourse.
public List<JsonDocument> findTopGradesByCourse(String course, int limit) {
ViewQuery query = queryBuilder.findTopGradesByCourse(course, limit);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
use of com.couchbase.client.java.view.ViewResult in project tutorials by eugenp.
the class StudentGradeService method findByGradeInRange.
public List<JsonDocument> findByGradeInRange(int lower, int upper, boolean inclusiveEnd) {
ViewQuery query = queryBuilder.findByGradeInRange(lower, upper, inclusiveEnd);
ViewResult result = bucket.query(query);
return extractDocuments(result);
}
Aggregations