Search in sources :

Example 6 with ConfiguredIssueService

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();
    }
}
Also used : ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository)

Example 7 with ConfiguredIssueService

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));
        }
    }
}
Also used : ConfigurationValidationException(net.nemerosa.ontrack.model.support.ConfigurationValidationException) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)

Example 8 with ConfiguredIssueService

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);
}
Also used : ExportedIssues(net.nemerosa.ontrack.extension.issues.export.ExportedIssues) HttpHeaders(org.springframework.http.HttpHeaders) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) ResponseEntity(org.springframework.http.ResponseEntity) Issue(net.nemerosa.ontrack.extension.issues.model.Issue) SCMChangeLogIssue(net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue)

Example 9 with ConfiguredIssueService

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;
}
Also used : ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)

Example 10 with ConfiguredIssueService

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);
    }
}
Also used : IssueServiceConfigurationRepresentation(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfigurationRepresentation) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) Issue(net.nemerosa.ontrack.extension.issues.model.Issue) IssueServiceNotConfiguredException(net.nemerosa.ontrack.extension.issues.model.IssueServiceNotConfiguredException) Transaction(net.nemerosa.ontrack.tx.Transaction)

Aggregations

ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)12 Issue (net.nemerosa.ontrack.extension.issues.model.Issue)5 SVNRepository (net.nemerosa.ontrack.extension.svn.db.SVNRepository)3 Transaction (net.nemerosa.ontrack.tx.Transaction)3 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 ExportedIssues (net.nemerosa.ontrack.extension.issues.export.ExportedIssues)2 IssueServiceConfigurationRepresentation (net.nemerosa.ontrack.extension.issues.model.IssueServiceConfigurationRepresentation)2 SCMChangeLogIssue (net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue)2 SCMIssueCommitBranchInfo (net.nemerosa.ontrack.extension.scm.model.SCMIssueCommitBranchInfo)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 Service (org.springframework.stereotype.Service)2 LocalDateTime (java.time.LocalDateTime)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Consumer (java.util.function.Consumer)1 Time (net.nemerosa.ontrack.common.Time)1 IssueServiceExtension (net.nemerosa.ontrack.extension.issues.IssueServiceExtension)1 IssueServiceRegistry (net.nemerosa.ontrack.extension.issues.IssueServiceRegistry)1