use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfigurationRepresentation in project ontrack by nemerosa.
the class SVNChangeLogServiceImpl method getChangeLogIssues.
@Override
@Transactional
public SVNChangeLogIssues getChangeLogIssues(SVNChangeLog changeLog) {
// Revisions must have been loaded first
if (changeLog.getRevisions() == null) {
changeLog.withRevisions(getChangeLogRevisions(changeLog));
}
// In a transaction
try (Transaction ignored = transactionService.start()) {
// Repository
SVNRepository repository = changeLog.getRepository();
// Index of issues, sorted by keys
Map<String, SVNChangeLogIssue> issues = new TreeMap<>();
// For all revisions in this revision log
for (SVNChangeLogRevision changeLogRevision : changeLog.getRevisions().getList()) {
long revision = changeLogRevision.getRevision();
collectIssuesForRevision(repository, issues, revision);
}
// List of issues
List<SVNChangeLogIssue> issuesList = new ArrayList<>(issues.values());
// Validations
validateIssues(issuesList, changeLog);
// Issues link
IssueServiceConfigurationRepresentation issueServiceConfiguration = null;
String allIssuesLink = "";
ConfiguredIssueService configuredIssueService = repository.getConfiguredIssueService();
if (configuredIssueService != null) {
issueServiceConfiguration = configuredIssueService.getIssueServiceConfigurationRepresentation();
allIssuesLink = configuredIssueService.getLinkForAllIssues(issuesList.stream().map(SVNChangeLogIssue::getIssue).collect(Collectors.toList()));
}
// OK
return new SVNChangeLogIssues(allIssuesLink, issueServiceConfiguration, issuesList);
}
}
use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfigurationRepresentation in project ontrack by nemerosa.
the class GitServiceImpl method getChangeLogIssues.
@Override
public GitChangeLogIssues getChangeLogIssues(GitChangeLog changeLog) {
// Commits must have been loaded first
if (changeLog.getCommits() == null) {
changeLog.withCommits(getChangeLogCommits(changeLog));
}
// In a transaction
try (Transaction ignored = transactionService.start()) {
// Configuration
GitConfiguration configuration = getRequiredProjectConfiguration(changeLog.getProject());
// Issue service
ConfiguredIssueService configuredIssueService = configuration.getConfiguredIssueService().orElse(null);
if (configuredIssueService == null) {
throw new IssueServiceNotConfiguredException();
}
// Index of issues, sorted by keys
Map<String, GitChangeLogIssue> issues = new TreeMap<>();
// For all commits in this commit log
for (GitUICommit gitUICommit : changeLog.getCommits().getLog().getCommits()) {
Set<String> keys = configuredIssueService.extractIssueKeysFromMessage(gitUICommit.getCommit().getFullMessage());
for (String key : keys) {
GitChangeLogIssue existingIssue = issues.get(key);
if (existingIssue != null) {
existingIssue.add(gitUICommit);
} else {
Issue issue = configuredIssueService.getIssue(key);
if (issue != null) {
existingIssue = GitChangeLogIssue.of(issue, gitUICommit);
issues.put(key, existingIssue);
}
}
}
}
// List of issues
List<GitChangeLogIssue> issuesList = new ArrayList<>(issues.values());
// Issues link
IssueServiceConfigurationRepresentation issueServiceConfiguration = configuredIssueService.getIssueServiceConfigurationRepresentation();
// OK
return new GitChangeLogIssues(issueServiceConfiguration, issuesList);
}
}
Aggregations