use of com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper in project hub-alert by blackducksoftware.
the class AzureBoardsIssueTransitioner method isTransitionRequired.
@Override
protected boolean isTransitionRequired(ExistingIssueDetails<Integer> existingIssueDetails, IssueOperation issueOperation) throws AlertException {
Integer issueId = existingIssueDetails.getIssueId();
WorkItemResponseModel workItem = retrieveWorkItem(issueId);
List<WorkItemTypeStateResponseModel> availableStates = retrieveAvailableStates(issueId);
Map<String, String> stateNameToCategory = mapStateNameToCategory(availableStates);
WorkItemFieldsWrapper fieldsWrapper = workItem.createFieldsWrapper(gson);
Optional<String> optionalCurrentState = fieldsWrapper.getField(WorkItemResponseFields.System_State);
if (optionalCurrentState.isPresent()) {
String workItemStateCategory = stateNameToCategory.get(optionalCurrentState.get());
boolean isOpen = WORK_ITEM_STATE_CATEGORY_PROPOSED.equals(workItemStateCategory);
boolean isResolved = WORK_ITEM_STATE_CATEGORY_COMPLETED.equals(workItemStateCategory);
if (IssueOperation.OPEN.equals(issueOperation)) {
return !isOpen;
} else if (IssueOperation.RESOLVE.equals(issueOperation)) {
return !isResolved;
} else {
return true;
}
} else {
logger.warn("Could not get the work item state. Work Item ID: {}", issueId);
}
return false;
}
use of com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper in project hub-alert by blackducksoftware.
the class AzureBoardsWorkItemTypeStateRetriever method retrieveAvailableWorkItemStates.
public List<WorkItemTypeStateResponseModel> retrieveAvailableWorkItemStates(String organizationName, Integer workItemId) throws HttpServiceException {
WorkItemResponseModel workItem = azureWorkItemService.getWorkItem(organizationName, workItemId);
WorkItemFieldsWrapper fieldsWrapper = workItem.createFieldsWrapper(gson);
Optional<String> optionalWorkItemProject = fieldsWrapper.getTeamProject();
Optional<String> optionalWorkItemType = fieldsWrapper.getWorkItemType();
if (optionalWorkItemProject.isPresent() && optionalWorkItemType.isPresent()) {
AzureArrayResponseModel<WorkItemTypeStateResponseModel> workItemTypeStates = azureWorkItemTypeStateService.getStatesForProject(organizationName, optionalWorkItemProject.get(), optionalWorkItemType.get());
return workItemTypeStates.getValue();
}
return List.of();
}
use of com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper in project hub-alert by blackducksoftware.
the class AzureBoardsIssueCreator method extractIssueDetails.
private ExistingIssueDetails<Integer> extractIssueDetails(WorkItemResponseModel workItem, IssueCreationModel alertIssueCreationModel) {
WorkItemFieldsWrapper workItemFields = workItem.createFieldsWrapper(gson);
String workItemKey = Objects.toString(workItem.getId());
String workItemTitle = workItemFields.getField(WorkItemResponseFields.System_Title).orElse("Unknown Title");
String workItemUILink = AzureBoardsUILinkUtils.extractUILink(organizationName, workItem);
IssueCategory issueCategory = alertIssueCreationModel.getSource().map(issueCategoryRetriever::retrieveIssueCategoryFromProjectIssueModel).orElse(IssueCategory.BOM);
return new ExistingIssueDetails<>(workItem.getId(), workItemKey, workItemTitle, workItemUILink, IssueStatus.RESOLVABLE, issueCategory);
}
use of com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper in project hub-alert by blackducksoftware.
the class AzureBoardsProjectAndVersionIssueFinder method findWorkItemsAndConvertToSearchResults.
private List<ProjectIssueSearchResult<Integer>> findWorkItemsAndConvertToSearchResults(ProviderDetails providerDetails, LinkableItem project, @Nullable LinkableItem projectVersion, AzureSearchFieldMappingBuilder fieldReferenceNameToExpectedValue) throws AlertException {
List<WorkItemResponseModel> workItems = workItemFinder.findWorkItems(providerDetails.getProvider(), project, fieldReferenceNameToExpectedValue);
List<ProjectIssueSearchResult<Integer>> searchResults = new ArrayList<>(workItems.size());
for (WorkItemResponseModel workItem : workItems) {
WorkItemFieldsWrapper workItemFields = workItem.createFieldsWrapper(gson);
ProjectIssueModel projectIssueModel = createProjectIssueModel(providerDetails, project, projectVersion, workItemFields);
ExistingIssueDetails<Integer> issueDetails = issueDetailsCreator.createIssueDetails(workItem, workItemFields, projectIssueModel);
ProjectIssueSearchResult<Integer> searchResult = new ProjectIssueSearchResult<>(issueDetails, projectIssueModel);
searchResults.add(searchResult);
}
return searchResults;
}
Aggregations