Search in sources :

Example 1 with IssueServiceExtension

use of net.nemerosa.ontrack.extension.issues.IssueServiceExtension in project ontrack by nemerosa.

the class IndexationServiceImpl method indexIssues.

private void indexIssues(SVNRepository repository, SVNLogEntry logEntry) {
    // Is the repository associated with any issue service?
    ConfiguredIssueService configuredIssueService = repository.getConfiguredIssueService();
    if (configuredIssueService != null) {
        IssueServiceExtension issueServiceExtension = configuredIssueService.getIssueServiceExtension();
        IssueServiceConfiguration issueServiceConfiguration = configuredIssueService.getIssueServiceConfiguration();
        // Revision information to scan
        long revision = logEntry.getRevision();
        String message = logEntry.getMessage();
        // Cache for issues
        Set<String> revisionIssues = new HashSet<>();
        // Gets all issues from the message
        Set<String> issues = issueServiceExtension.extractIssueKeysFromMessage(issueServiceConfiguration, message);
        // For each issue in the message
        issues.stream().filter(issueKey -> !revisionIssues.contains(issueKey)).forEach(issueKey -> {
            revisionIssues.add(issueKey);
            logger.info(String.format("     Indexing revision %d <-> %s", revision, issueKey));
            // Indexes this issue
            issueRevisionDao.link(repository.getId(), revision, issueKey);
        });
    }
}
Also used : java.util(java.util) SVNUtils(net.nemerosa.ontrack.extension.svn.support.SVNUtils) LoggerFactory(org.slf4j.LoggerFactory) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) org.tmatesoft.svn.core(org.tmatesoft.svn.core) StringUtils(org.apache.commons.lang3.StringUtils) net.nemerosa.ontrack.extension.svn.db(net.nemerosa.ontrack.extension.svn.db) Transaction(net.nemerosa.ontrack.tx.Transaction) Service(org.springframework.stereotype.Service) StartupService(net.nemerosa.ontrack.model.support.StartupService) net.nemerosa.ontrack.job(net.nemerosa.ontrack.job) SVNConfiguration(net.nemerosa.ontrack.extension.svn.model.SVNConfiguration) Ack(net.nemerosa.ontrack.model.Ack) Logger(org.slf4j.Logger) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) IssueServiceExtension(net.nemerosa.ontrack.extension.issues.IssueServiceExtension) GlobalSettings(net.nemerosa.ontrack.model.security.GlobalSettings) ConfigurationServiceListener(net.nemerosa.ontrack.model.support.ConfigurationServiceListener) LastRevisionInfo(net.nemerosa.ontrack.extension.svn.model.LastRevisionInfo) IssueServiceRegistry(net.nemerosa.ontrack.extension.issues.IssueServiceRegistry) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) SVNClient(net.nemerosa.ontrack.extension.svn.client.SVNClient) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) Consumer(java.util.function.Consumer) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) Time(net.nemerosa.ontrack.common.Time) SVNIndexationException(net.nemerosa.ontrack.extension.svn.model.SVNIndexationException) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionService(net.nemerosa.ontrack.tx.TransactionService) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) IssueServiceExtension(net.nemerosa.ontrack.extension.issues.IssueServiceExtension) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration)

Aggregations

LocalDateTime (java.time.LocalDateTime)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Time (net.nemerosa.ontrack.common.Time)1 IssueServiceExtension (net.nemerosa.ontrack.extension.issues.IssueServiceExtension)1 IssueServiceRegistry (net.nemerosa.ontrack.extension.issues.IssueServiceRegistry)1 ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)1 IssueServiceConfiguration (net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration)1 SVNClient (net.nemerosa.ontrack.extension.svn.client.SVNClient)1 net.nemerosa.ontrack.extension.svn.db (net.nemerosa.ontrack.extension.svn.db)1 LastRevisionInfo (net.nemerosa.ontrack.extension.svn.model.LastRevisionInfo)1 SVNConfiguration (net.nemerosa.ontrack.extension.svn.model.SVNConfiguration)1 SVNIndexationException (net.nemerosa.ontrack.extension.svn.model.SVNIndexationException)1 SVNUtils (net.nemerosa.ontrack.extension.svn.support.SVNUtils)1 net.nemerosa.ontrack.job (net.nemerosa.ontrack.job)1 Ack (net.nemerosa.ontrack.model.Ack)1 GlobalSettings (net.nemerosa.ontrack.model.security.GlobalSettings)1 SecurityService (net.nemerosa.ontrack.model.security.SecurityService)1 ConfigurationServiceListener (net.nemerosa.ontrack.model.support.ConfigurationServiceListener)1