Search in sources :

Example 1 with BlackDuckQuery

use of com.synopsys.integration.blackduck.http.BlackDuckQuery in project hub-alert by blackducksoftware.

the class BlackDuckProviderDataAccessor method retrieveProjectsForProvider.

private AlertPagedModel<ProviderProject> retrieveProjectsForProvider(ConfigurationModel blackDuckConfigurationModel, int pageNumber, int pageSize, String searchTerm) throws IntegrationException {
    BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(blackDuckConfigurationModel);
    BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
    ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
    BlackDuckQuery nameQuery = new BlackDuckQuery("name", searchTerm);
    BlackDuckPageDefinition blackDuckPageDefinition = new BlackDuckPageDefinition(pageSize, pageNumber * pageSize);
    BlackDuckMultipleRequest<ProjectView> projectSpec = new BlackDuckRequestBuilder().commonGet().addBlackDuckQuery(nameQuery).setBlackDuckPageDefinition(blackDuckPageDefinition).buildBlackDuckRequest(apiDiscovery.metaProjectsLink());
    BlackDuckPageResponse<ProjectView> pageOfProjects = blackDuckApiClient.getPageResponse(projectSpec);
    List<ProviderProject> foundProjects = convertBlackDuckProjects(pageOfProjects.getItems(), blackDuckApiClient);
    int totalPageCount = computeTotalCount(pageOfProjects, pageSize);
    return new AlertPagedModel<>(totalPageCount, pageNumber, pageSize, foundProjects);
}
Also used : BlackDuckPageDefinition(com.synopsys.integration.blackduck.http.BlackDuckPageDefinition) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) AlertPagedModel(com.synopsys.integration.alert.common.rest.model.AlertPagedModel) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) BlackDuckQuery(com.synopsys.integration.blackduck.http.BlackDuckQuery) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ProviderProject(com.synopsys.integration.alert.common.persistence.model.ProviderProject)

Example 2 with BlackDuckQuery

use of com.synopsys.integration.blackduck.http.BlackDuckQuery in project hub-alert by blackducksoftware.

the class PolicyNotificationFilterCustomFunctionAction method retrievePolicyRules.

private BlackDuckPageResponse<PolicyRuleView> retrievePolicyRules(BlackDuckServicesFactory blackDuckServicesFactory, int pageNumber, int pageSize, String searchTerm) throws IntegrationException {
    ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
    BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
    BlackDuckMultipleRequest<PolicyRuleView> spec = new BlackDuckRequestBuilder().commonGet().setLimitAndOffset(pageSize, pageNumber * pageSize).addBlackDuckQuery(new BlackDuckQuery("name", searchTerm)).addBlackDuckFilter(BlackDuckRequestFilter.createFilterWithSingleValue("policyRuleEnabled", "true")).buildBlackDuckRequest(apiDiscovery.metaPolicyRulesLink());
    return blackDuckApiClient.getPageResponse(spec);
}
Also used : ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) PolicyRuleView(com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) BlackDuckQuery(com.synopsys.integration.blackduck.http.BlackDuckQuery)

Aggregations

ApiDiscovery (com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery)2 BlackDuckQuery (com.synopsys.integration.blackduck.http.BlackDuckQuery)2 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)2 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)2 ProviderProject (com.synopsys.integration.alert.common.persistence.model.ProviderProject)1 AlertPagedModel (com.synopsys.integration.alert.common.rest.model.AlertPagedModel)1 PolicyRuleView (com.synopsys.integration.blackduck.api.generated.view.PolicyRuleView)1 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)1 BlackDuckPageDefinition (com.synopsys.integration.blackduck.http.BlackDuckPageDefinition)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1