Search in sources :

Example 1 with ProjectWorkItemFieldModel

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

the class AzureCustomFieldManager method findOrCreateAlertCustomProjectField.

private ProjectWorkItemFieldModel findOrCreateAlertCustomProjectField(String projectName, String fieldName, String fieldReferenceName, String fieldDescription) throws AlertException {
    ProjectWorkItemFieldModel fieldRequestModel = ProjectWorkItemFieldModel.workItemStringField(fieldName, fieldReferenceName, fieldDescription);
    Optional<ProjectWorkItemFieldModel> customField = getAlertCustomProjectField(projectName, fieldRequestModel.getReferenceName());
    if (customField.isPresent()) {
        return customField.get();
    }
    // custom field not found so create it
    try {
        return projectService.createProjectField(organizationName, projectName, fieldRequestModel);
    } catch (IOException e) {
        throw new AlertException(String.format("There was a problem creating the request to create the Alert Custom Field (%s) in the Azure project: %s", fieldReferenceName, projectName), e);
    } catch (HttpServiceException e) {
        throw new AlertException(String.format("There was a problem creating the Alert Custom Field (%s) in the Azure project: %s", fieldReferenceName, projectName), e);
    }
}
Also used : HttpServiceException(com.synopsys.integration.azure.boards.common.http.HttpServiceException) ProjectWorkItemFieldModel(com.synopsys.integration.azure.boards.common.service.project.ProjectWorkItemFieldModel) IOException(java.io.IOException) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Example 2 with ProjectWorkItemFieldModel

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

the class AzureCustomFieldManager method installCustomFields.

public void installCustomFields(String projectName, String workItemTypeName) throws AlertException {
    List<Future<ProjectWorkItemFieldModel>> projectFieldFindOrCreateHolders = new ArrayList<>(7);
    for (AzureCustomFieldDescriptor fieldDesc : AZURE_CUSTOM_FIELDS) {
        Future<ProjectWorkItemFieldModel> fieldFindOrCreateHolder = executorService.submit(() -> findOrCreateAlertCustomProjectField(projectName, fieldDesc.getFieldName(), fieldDesc.getFieldReferenceName(), fieldDesc.getFieldDescription()));
        projectFieldFindOrCreateHolders.add(fieldFindOrCreateHolder);
    }
    TeamProjectReferenceResponseModel project = getProject(projectName);
    String processId = getProjectPropertyValue(project, ProjectPropertyResponseModel.COMMON_PROPERTIES_PROCESS_ID);
    String workItemTypeRefName = getWorkItemTypeRefName(processId, workItemTypeName);
    List<Future<ProcessFieldResponseModel>> processFieldAdditionHolders = new ArrayList<>(7);
    for (Future<ProjectWorkItemFieldModel> projectFieldFuture : projectFieldFindOrCreateHolders) {
        ProjectWorkItemFieldModel projectField = extractFutureResult(projectFieldFuture);
        Future<ProcessFieldResponseModel> processFieldAdditionHolder = executorService.submit(() -> addAlertCustomFieldToProcess(processId, workItemTypeRefName, projectField));
        processFieldAdditionHolders.add(processFieldAdditionHolder);
    }
    for (Future<ProcessFieldResponseModel> processFieldAdditionHolder : processFieldAdditionHolders) {
        extractFutureResult(processFieldAdditionHolder);
    }
}
Also used : ProcessFieldResponseModel(com.synopsys.integration.azure.boards.common.service.process.ProcessFieldResponseModel) ProjectWorkItemFieldModel(com.synopsys.integration.azure.boards.common.service.project.ProjectWorkItemFieldModel) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) TeamProjectReferenceResponseModel(com.synopsys.integration.azure.boards.common.service.project.TeamProjectReferenceResponseModel)

Aggregations

ProjectWorkItemFieldModel (com.synopsys.integration.azure.boards.common.service.project.ProjectWorkItemFieldModel)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 HttpServiceException (com.synopsys.integration.azure.boards.common.http.HttpServiceException)1 ProcessFieldResponseModel (com.synopsys.integration.azure.boards.common.service.process.ProcessFieldResponseModel)1 TeamProjectReferenceResponseModel (com.synopsys.integration.azure.boards.common.service.project.TeamProjectReferenceResponseModel)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1