use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.
the class JiraExactIssueFinder method findExistingIssuesByProjectIssueModel.
@Override
public List<ExistingIssueDetails<String>> findExistingIssuesByProjectIssueModel(ProjectIssueModel projectIssueModel) throws AlertException {
LinkableItem provider = projectIssueModel.getProvider();
LinkableItem project = projectIssueModel.getProject();
IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
ComponentConcernType concernType = ComponentConcernType.VULNERABILITY;
String policyName = null;
Optional<IssuePolicyDetails> policyDetails = projectIssueModel.getPolicyDetails();
Optional<String> optionalPolicyName = policyDetails.map(IssuePolicyDetails::getName);
if (optionalPolicyName.isPresent()) {
concernType = ComponentConcernType.POLICY;
policyName = optionalPolicyName.get();
}
if (projectIssueModel.getComponentUnknownVersionDetails().isPresent()) {
concernType = ComponentConcernType.UNKNOWN_VERSION;
}
String jqlString = JqlStringCreator.createBlackDuckComponentConcernIssuesSearchString(jiraProjectKey, provider, project, projectIssueModel.getProjectVersion().orElse(null), bomComponent.getComponent(), bomComponent.getComponentVersion().orElse(null), concernType, policyName);
logger.debug("Searching for Jira issues with this Query: {}", jqlString);
IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromComponentConcernType(concernType);
return jqlQueryExecutor.executeQuery(jqlString).stream().map(jiraSearcherResponseModel -> searchResultCreator.createExistingIssueDetails(jiraSearcherResponseModel, issueCategory)).collect(Collectors.toList());
}
use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method convertToIssueModels.
public List<ProjectIssueModel> convertToIssueModels(ProjectMessage projectMessage) {
List<ProjectIssueModel> projectIssueModels = new LinkedList<>();
for (BomComponentDetails bomComponent : projectMessage.getBomComponents()) {
IssueBomComponentDetails issueBomComponent = IssueBomComponentDetails.fromBomComponentDetails(bomComponent);
List<ProjectIssueModel> projectIssueModelsForConcerns = convertToIssueModels(projectMessage, issueBomComponent, bomComponent.getComponentConcerns());
projectIssueModels.addAll(projectIssueModelsForConcerns);
}
return projectIssueModels;
}
use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.
the class ProjectMessageToIssueModelTransformer method convertToIssueModels.
private List<ProjectIssueModel> convertToIssueModels(ProjectMessage projectMessage, IssueBomComponentDetails issueBomComponent, List<ComponentConcern> componentConcerns) {
List<ComponentConcern> policyConcerns = new LinkedList<>();
List<ComponentConcern> vulnerabilityConcerns = new LinkedList<>();
List<ComponentConcern> estimatedRiskConcerns = new LinkedList<>();
for (ComponentConcern componentConcern : componentConcerns) {
if (ComponentConcernType.POLICY.equals(componentConcern.getType())) {
policyConcerns.add(componentConcern);
} else if (ComponentConcernType.UNKNOWN_VERSION.equals(componentConcern.getType())) {
estimatedRiskConcerns.add(componentConcern);
} else {
vulnerabilityConcerns.add(componentConcern);
}
}
List<ProjectIssueModel> projectIssueModels = new LinkedList<>();
policyConcerns.stream().map(concern -> createPolicyProjectIssueModel(projectMessage, issueBomComponent, concern)).forEach(projectIssueModels::add);
if (!vulnerabilityConcerns.isEmpty()) {
ProjectIssueModel vulnerabilityProjectIssueModel = createVulnerabilityProjectIssueModel(projectMessage, issueBomComponent, vulnerabilityConcerns);
projectIssueModels.add(vulnerabilityProjectIssueModel);
}
if (!estimatedRiskConcerns.isEmpty()) {
ProjectIssueModel estimatedRiskProjectIssueModel = createEstimatedRiskProjectIssueModel(projectMessage, issueBomComponent, estimatedRiskConcerns);
projectIssueModels.add(estimatedRiskProjectIssueModel);
}
return projectIssueModels;
}
use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreatorTest method createIssueCreationModel.
private IssueCreationModel createIssueCreationModel() {
ProviderDetails providerDetails = new ProviderDetails(1L, null);
ProjectIssueModel policy = ProjectIssueModel.policy(providerDetails, null, null, null, null);
return IssueCreationModel.project("title", "description", List.of(), policy);
}
use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel 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);
}
Aggregations