Search in sources :

Example 1 with WorkItemQueryWhere

use of com.synopsys.integration.azure.boards.common.service.query.fluent.WorkItemQueryWhere in project hub-alert by blackducksoftware.

the class AzureBoardsWorkItemFinder method findWorkItems.

public List<WorkItemResponseModel> findWorkItems(LinkableItem provider, LinkableItem project, AzureSearchFieldMappingBuilder fieldReferenceNameToExpectedValue) throws AlertException {
    String providerKey = AzureBoardsSearchPropertiesUtils.createProviderKey(provider.getLabel(), provider.getUrl().orElse(null));
    String topicKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(project);
    String systemIdFieldName = WorkItemResponseFields.System_Id.getFieldName();
    String teamProjectFieldName = WorkItemResponseFields.System_TeamProject.getFieldName();
    WorkItemQueryWhere queryBuilder = WorkItemQuery.select(systemIdFieldName).fromWorkItems().whereGroup(teamProjectFieldName, WorkItemQueryWhereOperator.EQ, teamProjectName).and(AzureCustomFieldManager.ALERT_PROVIDER_KEY_FIELD_REFERENCE_NAME, WorkItemQueryWhereOperator.EQ, providerKey).and(AzureCustomFieldManager.ALERT_TOPIC_KEY_FIELD_REFERENCE_NAME, WorkItemQueryWhereOperator.EQ, topicKey);
    for (AzureSearchFieldMappingBuilder.ReferenceToValue refToValue : fieldReferenceNameToExpectedValue.buildAsList()) {
        queryBuilder = queryBuilder.and(refToValue.getReferenceKey(), WorkItemQueryWhereOperator.EQ, refToValue.getFieldValue());
    }
    WorkItemQuery query = queryBuilder.orderBy(systemIdFieldName).build();
    return queryManager.executeQueryAndRetrieveWorkItems(query);
}
Also used : WorkItemQuery(com.synopsys.integration.azure.boards.common.service.query.fluent.WorkItemQuery) WorkItemQueryWhere(com.synopsys.integration.azure.boards.common.service.query.fluent.WorkItemQueryWhere)

Aggregations

WorkItemQuery (com.synopsys.integration.azure.boards.common.service.query.fluent.WorkItemQuery)1 WorkItemQueryWhere (com.synopsys.integration.azure.boards.common.service.query.fluent.WorkItemQueryWhere)1