use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class SVNChangeLogServiceImpl method changeLogExportFormats.
@Override
public Collection<ExportFormat> changeLogExportFormats(ID branchId) {
// Gets the branch
Branch branch = structureService.getBranch(branchId);
// Gets the SVN repository
SVNRepository svnRepository = getSVNRepository(branch);
ConfiguredIssueService configuredIssueService = svnRepository.getConfiguredIssueService();
if (configuredIssueService != null) {
return configuredIssueService.getIssueServiceExtension().exportFormats(configuredIssueService.getIssueServiceConfiguration());
} else {
return Collections.emptyList();
}
}
use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class SVNConfigurationServiceImpl method validateAndCheck.
@Override
protected void validateAndCheck(SVNConfiguration configuration) {
super.validateAndCheck(configuration);
// Checks the issue service identifier
String issueServiceConfigurationIdentifier = configuration.getIssueServiceConfigurationIdentifier();
if (StringUtils.isNotBlank(issueServiceConfigurationIdentifier)) {
ConfiguredIssueService configuredIssueService = issueServiceRegistry.getConfiguredIssueService(issueServiceConfigurationIdentifier);
if (configuredIssueService == null || configuredIssueService.getIssueServiceConfiguration() == null) {
throw new ConfigurationValidationException(configuration, String.format("Issue service configuration cannot be validated: %s", issueServiceConfigurationIdentifier));
}
}
}
use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class SVNController method changeLog.
/**
* Change log export
*/
@RequestMapping(value = "changelog/export", method = RequestMethod.GET)
public ResponseEntity<String> changeLog(IssueChangeLogExportRequest request) {
// Gets the change log
SVNChangeLog changeLog = changeLogService.changeLog(request);
// Gets the issue service
ConfiguredIssueService configuredIssueService = changeLog.getRepository().getConfiguredIssueService();
if (configuredIssueService == null) {
return new ResponseEntity<>("The branch is not configured for issues", HttpStatus.NO_CONTENT);
}
// Gets the issue change log
SVNChangeLogIssues changeLogIssues = changeLogService.getChangeLogIssues(changeLog);
// List of issues
List<Issue> issues = changeLogIssues.getList().stream().map(SCMChangeLogIssue::getIssue).collect(Collectors.toList());
// Exports the change log using the given format
ExportedIssues exportedChangeLogIssues = configuredIssueService.getIssueServiceExtension().exportIssues(configuredIssueService.getIssueServiceConfiguration(), issues, request);
// Content type
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Content-Type", exportedChangeLogIssues.getFormat());
// Body and headers
return new ResponseEntity<>(exportedChangeLogIssues.getContent(), responseHeaders, HttpStatus.OK);
}
use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class GitServiceImpl method getMessageAnnotators.
private List<? extends MessageAnnotator> getMessageAnnotators(GitConfiguration gitConfiguration) {
List<? extends MessageAnnotator> messageAnnotators;
ConfiguredIssueService configuredIssueService = gitConfiguration.getConfiguredIssueService().orElse(null);
if (configuredIssueService != null) {
// Gets the message annotator
Optional<MessageAnnotator> messageAnnotator = configuredIssueService.getMessageAnnotator();
// If present annotate the messages
messageAnnotators = messageAnnotator.map(Collections::singletonList).orElseGet(Collections::emptyList);
} else {
messageAnnotators = Collections.emptyList();
}
return messageAnnotators;
}
use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService 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