use of com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest in project hub-alert by blackducksoftware.
the class AzureBoardsIssueCreator method createWorkItemCreationRequest.
private WorkItemRequest createWorkItemCreationRequest(IssueCreationModel alertIssueCreationModel) {
List<WorkItemElementOperationModel> requestElementOps = new LinkedList<>();
WorkItemElementOperationModel addTitleOp = createWorkItemAddOperation(WorkItemResponseFields.System_Title, alertIssueCreationModel.getTitle());
requestElementOps.add(addTitleOp);
WorkItemElementOperationModel addDescriptionOp = createWorkItemAddOperation(WorkItemResponseFields.System_Description, alertIssueCreationModel.getDescription());
requestElementOps.add(addDescriptionOp);
// Note: If a ProjectIssueModel is present, Alert Search Properties are assigned during issue-creation
Optional<ProjectIssueModel> issueSource = alertIssueCreationModel.getSource();
if (issueSource.isPresent()) {
List<WorkItemElementOperationModel> alertSearchFieldOps = issuePropertiesManager.createWorkItemRequestCustomFieldOperations(issueSource.get());
requestElementOps.addAll(alertSearchFieldOps);
}
return new WorkItemRequest(requestElementOps);
}
use of com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest in project hub-alert by blackducksoftware.
the class AzureBoardsIssueTransitioner method findAndPerformTransition.
@Override
protected void findAndPerformTransition(ExistingIssueDetails<Integer> existingIssueDetails, String transitionName) throws AlertException {
WorkItemElementOperationModel replaceSystemStateField = WorkItemElementOperationModel.fieldElement(WorkItemElementOperation.REPLACE, WorkItemResponseFields.System_State, transitionName);
WorkItemRequest request = new WorkItemRequest(List.of(replaceSystemStateField));
Integer issueId = existingIssueDetails.getIssueId();
try {
workItemService.updateWorkItem(organizationName, distributionDetails.getProjectNameOrId(), issueId, request);
} catch (HttpServiceException e) {
List<String> availableStates = retrieveAvailableStates(existingIssueDetails.getIssueId()).stream().map(WorkItemTypeStateResponseModel::getName).collect(Collectors.toList());
throw new IssueMissingTransitionException(existingIssueDetails.getIssueKey(), transitionName, availableStates);
}
}
Aggregations