Search in sources :

Example 1 with JIRAIssue

use of net.nemerosa.ontrack.extension.jira.model.JIRAIssue in project ontrack by nemerosa.

the class JIRAServiceExtension method followLinks.

/**
 * Given an issue seed, and a list of link names, follows the given links recursively and
 * puts the associated issues into the {@code collectedIssues} map.
 *
 * @param configuration   JIRA configuration to use to load the issues
 * @param seed            Issue to start from.
 * @param linkNames       Links to follow
 * @param collectedIssues Collected issues, indexed by their key
 */
public void followLinks(JIRAConfiguration configuration, JIRAIssue seed, Set<String> linkNames, Map<String, JIRAIssue> collectedIssues) {
    try (Transaction tx = transactionService.start()) {
        JIRASession session = getJIRASession(tx, configuration);
        // Gets the client from the current session
        JIRAClient client = session.getClient();
        // Puts the seed into the list
        collectedIssues.put(seed.getKey(), seed);
        // Gets the linked issue keys
        seed.getLinks().stream().filter(linkedIssue -> linkNames.contains(linkedIssue.getLinkName())).filter(linkedIssue -> !collectedIssues.containsKey(linkedIssue.getKey())).map(linkedIssue -> client.getIssue(linkedIssue.getKey(), configuration)).forEach(linkedIssue -> followLinks(configuration, linkedIssue, linkNames, collectedIssues));
    }
}
Also used : PropertyService(net.nemerosa.ontrack.model.structure.PropertyService) java.util(java.util) Autowired(org.springframework.beans.factory.annotation.Autowired) JIRAIssue(net.nemerosa.ontrack.extension.jira.model.JIRAIssue) JIRAClient(net.nemerosa.ontrack.extension.jira.client.JIRAClient) StringUtils(org.apache.commons.lang3.StringUtils) Issue(net.nemerosa.ontrack.extension.issues.model.Issue) Transaction(net.nemerosa.ontrack.tx.Transaction) Matcher(java.util.regex.Matcher) MessageAnnotation(net.nemerosa.ontrack.model.support.MessageAnnotation) JIRASessionFactory(net.nemerosa.ontrack.extension.jira.tx.JIRASessionFactory) JIRASession(net.nemerosa.ontrack.extension.jira.tx.JIRASession) AbstractIssueServiceExtension(net.nemerosa.ontrack.extension.issues.support.AbstractIssueServiceExtension) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) Component(org.springframework.stereotype.Component) URLEncoder(java.net.URLEncoder) Validate(org.apache.commons.lang3.Validate) IssueExportServiceFactory(net.nemerosa.ontrack.extension.issues.export.IssueExportServiceFactory) MessageAnnotator(net.nemerosa.ontrack.model.support.MessageAnnotator) RegexMessageAnnotator(net.nemerosa.ontrack.model.support.RegexMessageAnnotator) TransactionService(net.nemerosa.ontrack.tx.TransactionService) Project(net.nemerosa.ontrack.model.structure.Project) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) JIRAClient(net.nemerosa.ontrack.extension.jira.client.JIRAClient) Transaction(net.nemerosa.ontrack.tx.Transaction) JIRASession(net.nemerosa.ontrack.extension.jira.tx.JIRASession)

Aggregations

Sets (com.google.common.collect.Sets)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 String.format (java.lang.String.format)1 URLEncoder (java.net.URLEncoder)1 java.util (java.util)1 Matcher (java.util.regex.Matcher)1 Collectors (java.util.stream.Collectors)1 IssueExportServiceFactory (net.nemerosa.ontrack.extension.issues.export.IssueExportServiceFactory)1 Issue (net.nemerosa.ontrack.extension.issues.model.Issue)1 IssueServiceConfiguration (net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration)1 AbstractIssueServiceExtension (net.nemerosa.ontrack.extension.issues.support.AbstractIssueServiceExtension)1 JIRAClient (net.nemerosa.ontrack.extension.jira.client.JIRAClient)1 JIRAIssue (net.nemerosa.ontrack.extension.jira.model.JIRAIssue)1 JIRASession (net.nemerosa.ontrack.extension.jira.tx.JIRASession)1 JIRASessionFactory (net.nemerosa.ontrack.extension.jira.tx.JIRASessionFactory)1 Project (net.nemerosa.ontrack.model.structure.Project)1 PropertyService (net.nemerosa.ontrack.model.structure.PropertyService)1 MessageAnnotation (net.nemerosa.ontrack.model.support.MessageAnnotation)1 MessageAnnotator (net.nemerosa.ontrack.model.support.MessageAnnotator)1 RegexMessageAnnotator (net.nemerosa.ontrack.model.support.RegexMessageAnnotator)1