Search in sources :

Example 1 with WorkItemRequest

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);
}
Also used : WorkItemRequest(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) WorkItemElementOperationModel(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel) LinkedList(java.util.LinkedList)

Example 2 with WorkItemRequest

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);
    }
}
Also used : HttpServiceException(com.synopsys.integration.azure.boards.common.http.HttpServiceException) WorkItemRequest(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest) IssueMissingTransitionException(com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueMissingTransitionException) List(java.util.List) WorkItemElementOperationModel(com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel) WorkItemTypeStateResponseModel(com.synopsys.integration.azure.boards.common.service.state.WorkItemTypeStateResponseModel)

Aggregations

WorkItemElementOperationModel (com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel)2 WorkItemRequest (com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemRequest)2 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)1 IssueMissingTransitionException (com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueMissingTransitionException)1 HttpServiceException (com.synopsys.integration.azure.boards.common.http.HttpServiceException)1 WorkItemTypeStateResponseModel (com.synopsys.integration.azure.boards.common.service.state.WorkItemTypeStateResponseModel)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1