use of com.cloudant.client.api.views.ViewRequestBuilder in project sw360 by eclipse.
the class ComponentRepository method getRecentComponentsSummary.
public List<Component> getRecentComponentsSummary(int limit, User user) {
ViewRequestBuilder query = getConnector().createQuery(Component.class, "byCreatedOn");
UnpaginatedRequestBuilder<String, Object> unPagnReques = query.newRequest(Key.Type.STRING, Object.class).includeDocs(true).descending(true);
if (limit >= 0) {
unPagnReques.limit(limit);
}
List<Component> components = new ArrayList<Component>(getFullDocsById(queryForIdsAsValue(unPagnReques)));
return makeSummaryWithPermissionsFromFullDocs(SummaryType.SUMMARY, components, user);
}
use of com.cloudant.client.api.views.ViewRequestBuilder in project sw360 by eclipse.
the class ConfigContainerRepository method getByConfigFor.
public ConfigContainer getByConfigFor(ConfigFor configFor) {
ViewRequestBuilder query = getConnector().createQuery(ConfigContainer.class, "byConfigFor");
UnpaginatedRequestBuilder reqBuilder = query.newRequest(Key.Type.STRING, Object.class).keys(configFor.toString()).includeDocs(true);
List<ConfigContainer> configs = queryView(reqBuilder);
if (configs.size() != 1) {
throw new IllegalStateException("There are " + configs.size() + " configuration objects in the couch db for type " + configFor + " while there should be exactly one!");
} else {
return configs.get(0);
}
}
use of com.cloudant.client.api.views.ViewRequestBuilder in project sw360 by eclipse.
the class RelationsUsageRepository method getUsedRelationsByProjectId.
public List<UsedReleaseRelations> getUsedRelationsByProjectId(String projectId) {
ViewRequestBuilder viewQuery = getConnector().createQuery(UsedReleaseRelations.class, "byProjectId");
UnpaginatedRequestBuilder req = viewQuery.newRequest(Key.Type.STRING, Object.class).includeDocs(true).reduce(false).keys(projectId);
return queryView(req);
}
use of com.cloudant.client.api.views.ViewRequestBuilder in project sw360 by eclipse.
the class AttachmentUsageRepository method getUsageForAttachments.
public List<AttachmentUsage> getUsageForAttachments(Map<String, Set<String>> attachments, String filter) {
ViewRequestBuilder viewQuery = createUsagesByAttachmentQuery(filter);
@NotNull 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;
}
MultipleRequestBuilder<com.cloudant.client.api.views.Key.ComplexKey, Object> reqBuilder = viewQuery.newMultipleRequest(Key.Type.COMPLEX, Object.class).includeDocs(true).reduce(false).keys(compexKeys);
return multiRequestqueryView(reqBuilder);
}
Aggregations