Search in sources :

Example 11 with UnpaginatedRequestBuilder

use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.

the class DatabaseRepositoryCloudantClient method queryForIdsAsComplexValue.

public Set<String> queryForIdsAsComplexValue(String queryName, String... keys) {
    ViewRequestBuilder query = connector.createQuery(type, queryName);
    UnpaginatedRequestBuilder reqBuild = query.newRequest(Key.Type.STRING, Object.class).keys(keys);
    return queryForIds(reqBuild);
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) UnpaginatedRequestBuilder(com.cloudant.client.api.views.UnpaginatedRequestBuilder)

Example 12 with UnpaginatedRequestBuilder

use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.

the class DatabaseRepositoryCloudantClient method queryForIdsAsComplexValues.

public Set<String> queryForIdsAsComplexValues(String queryName, Map<String, Set<String>> keys) {
    Set<String[]> complexKeys = keys.entrySet().stream().map(DatabaseRepositoryCloudantClient::createComplexKeys).flatMap(Collection::stream).collect(Collectors.toSet());
    ViewRequestBuilder query = connector.createQuery(type, queryName);
    Key.ComplexKey[] complexKys = new Key.ComplexKey[complexKeys.size()];
    int index = 0;
    for (String[] keyArr : complexKeys) {
        Key.ComplexKey key = Key.complex(keyArr);
        complexKys[index++] = key;
    }
    UnpaginatedRequestBuilder reqBuild = query.newRequest(Key.Type.COMPLEX, Object.class).keys(complexKys);
    return queryForIds(reqBuild);
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) ComplexKey(com.cloudant.client.api.views.Key.ComplexKey) ComplexKey(com.cloudant.client.api.views.Key.ComplexKey) Key(com.cloudant.client.api.views.Key) ComplexKey(com.cloudant.client.api.views.Key.ComplexKey) UnpaginatedRequestBuilder(com.cloudant.client.api.views.UnpaginatedRequestBuilder)

Example 13 with UnpaginatedRequestBuilder

use of com.cloudant.client.api.views.UnpaginatedRequestBuilder in project sw360 by eclipse.

the class DatabaseRepositoryCloudantClient method queryForIds.

public Set<String> queryForIds(String queryName, String startKey, String endKey) {
    ViewRequestBuilder query = connector.createQuery(type, queryName);
    UnpaginatedRequestBuilder req = query.newRequest(Key.Type.STRING, Object.class).startKey(startKey).endKey(endKey);
    return queryForIds(req);
}
Also used : ViewRequestBuilder(com.cloudant.client.api.views.ViewRequestBuilder) UnpaginatedRequestBuilder(com.cloudant.client.api.views.UnpaginatedRequestBuilder)

Example 14 with UnpaginatedRequestBuilder

use of com.cloudant.client.api.views.UnpaginatedRequestBuilder 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 15 with UnpaginatedRequestBuilder

use of com.cloudant.client.api.views.UnpaginatedRequestBuilder 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)

Aggregations

UnpaginatedRequestBuilder (com.cloudant.client.api.views.UnpaginatedRequestBuilder)15 ViewRequestBuilder (com.cloudant.client.api.views.ViewRequestBuilder)14 Key (com.cloudant.client.api.views.Key)2 MapReduce (com.cloudant.client.api.model.DesignDocument.MapReduce)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 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 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DatabaseConnectorCloudant (org.eclipse.sw360.datahandler.cloudantclient.DatabaseConnectorCloudant)1 DatabaseRepositoryCloudantClient (org.eclipse.sw360.datahandler.cloudantclient.DatabaseRepositoryCloudantClient)1