Search in sources :

Example 16 with ViewRequestBuilder

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);
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) Component(org.eclipse.sw360.datahandler.thrift.components.Component)

Example 17 with ViewRequestBuilder

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);
    }
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) ConfigContainer(org.eclipse.sw360.datahandler.thrift.ConfigContainer) UnpaginatedRequestBuilder(com.cloudant.client.api.views.UnpaginatedRequestBuilder)

Example 18 with ViewRequestBuilder

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);
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) UnpaginatedRequestBuilder(com.cloudant.client.api.views.UnpaginatedRequestBuilder)

Example 19 with ViewRequestBuilder

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);
}
Also used : NotNull(org.jetbrains.annotations.NotNull) ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) Key(com.cloudant.client.api.views.Key)

Aggregations

ViewRequestBuilder (com.cloudant.client.api.views.ViewRequestBuilder)19 UnpaginatedRequestBuilder (com.cloudant.client.api.views.UnpaginatedRequestBuilder)14 Key (com.cloudant.client.api.views.Key)3 PaginationData (org.eclipse.sw360.datahandler.thrift.PaginationData)2 Component (org.eclipse.sw360.datahandler.thrift.components.Component)2 NotNull (org.jetbrains.annotations.NotNull)2 MapReduce (com.cloudant.client.api.model.DesignDocument.MapReduce)1 QueryBuilder (com.cloudant.client.api.query.QueryBuilder)1 Selector (com.cloudant.client.api.query.Selector)1 ComplexKey (com.cloudant.client.api.views.Key.ComplexKey)1 MultipleRequestBuilder (com.cloudant.client.api.views.MultipleRequestBuilder)1 ViewResponse (com.cloudant.client.api.views.ViewResponse)1 TestWithDbPerTest (com.cloudant.tests.base.TestWithDbPerTest)1 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1