use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.
the class AttachmentContentRepository method getOnlyRemoteAttachments.
public List<AttachmentContent> getOnlyRemoteAttachments() {
ViewRequestBuilder query = getConnector().createQuery(AttachmentContent.class, "onlyRemotes");
UnpaginatedRequestBuilder req = query.newRequest(Key.Type.STRING, Object.class).includeDocs(true);
return queryView(req);
}
use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.
the class AttachmentUsageRepository method getAttachmentUsageCount.
public Map<Map<String, String>, Integer> getAttachmentUsageCount(Map<String, Set<String>> attachments, String filter) {
ViewRequestBuilder viewQuery = createUsagesByAttachmentQuery(filter);
List<String[]> complexKeysList = prepareKeys(attachments, filter);
Key.ComplexKey[] compexKeys = new Key.ComplexKey[complexKeysList.size()];
for (int i = 0; i < compexKeys.length; i++) {
Key.ComplexKey key = Key.complex(complexKeysList.get(i));
compexKeys[i] = key;
}
UnpaginatedRequestBuilder<com.cloudant.client.api.views.Key.ComplexKey, Object> reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).reduce(true).group(true).keys(compexKeys);
ViewResponse<com.cloudant.client.api.views.Key.ComplexKey, Object> result = queryViewForComplexKeys(reqBuilder);
return result.getRows().stream().collect(Collectors.toMap(key -> {
String json = key.getKey().toJson();
String replace = json.replace("[", "").replace("]", "").replaceAll("\"", "");
List<String> relIdAttachmentToUsageType = new ArrayList<String>(Arrays.asList(replace.split(",")));
return ImmutableMap.of(relIdAttachmentToUsageType.get(0), relIdAttachmentToUsageType.get(1));
}, val -> ((Double) val.getValue()).intValue()));
}
use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.
the class AttachmentUsageRepository method getUsedAttachments.
public List<AttachmentUsage> getUsedAttachments(String usedById, String filter) {
ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usedAttachmentsUsageType");
UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).includeDocs(true).reduce(false).keys(Key.complex(new String[] { usedById, filter }));
return queryView(reqBuilder);
}
use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.
the class AttachmentUsageRepository method getUsageForAttachment.
public List<AttachmentUsage> getUsageForAttachment(String ownerId, String attachmentContentId) {
ViewRequestBuilder viewQuery = getConnector().createQuery(AttachmentUsage.class, "usagesByAttachment");
UnpaginatedRequestBuilder reqBuilder = viewQuery.newRequest(Key.Type.COMPLEX, Object.class).keys(Key.complex(new String[] { ownerId, attachmentContentId })).includeDocs(true).reduce(false);
return queryView(reqBuilder);
}
use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.
the class ReleaseRepository method getRecentReleases.
public List<Release> getRecentReleases() {
ViewRequestBuilder query = getConnector().createQuery(Release.class, "byCreatedOn");
// Get the 5 last documents
UnpaginatedRequestBuilder reqBuilder = query.newRequest(Key.Type.STRING, Object.class).limit(5).descending(true).includeDocs(false);
return makeSummary(SummaryType.SHORT, queryForIds(reqBuilder));
}
Aggregations