db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1129117 - in /db/derby/code/trunk/tools/release: ./ jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/
Date Mon, 30 May 2011 10:27:18 GMT
Author: kristwaa
Date: Mon May 30 10:27:18 2011
New Revision: 1129117

URL: http://svn.apache.org/viewvc?rev=1129117&view=rev
Log:
DERBY-5080: Utilize JQL to fetch JIRA issue list for release notes generation

Added JQL functionality, allowing the list of JIRA issues for a release to be
obtained without having to create a JIRA filter manully.
Actived by specifying a JIRA filter id of 0 (zero) when running
'ant genrelnotes'.

Patch file: derby-5080-2a-utilize_jql.diff


Modified:
    db/derby/code/trunk/tools/release/build.xml
    db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/DerbyVersion.java
    db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueLister.java
    db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueListerAntWrapper.java

Modified: db/derby/code/trunk/tools/release/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/build.xml?rev=1129117&r1=1129116&r2=1129117&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/build.xml (original)
+++ db/derby/code/trunk/tools/release/build.xml Mon May 30 10:27:18 2011
@@ -163,7 +163,7 @@
         <echo message="  jira.user             = ${jira.user}"/>
         <echo message="  jira.password         = ${jira.password}"/>
         <echo message="  jira.filter.id        = ${jira.filter.id}"/>
-        <echo message="                          (digits only)"/>
+        <echo message="                          (digits only, 0 for JQL)"/>
         <echo message="  release.version       = ${release.version}"/>
         <echo message="                          (i.e. 10.7.1.0)"/>
         <echo message="  relnotes.src.reports  = ${relnotes.src.reports}"/>

Modified: db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/DerbyVersion.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/DerbyVersion.java?rev=1129117&r1=1129116&r2=1129117&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/DerbyVersion.java
(original)
+++ db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/DerbyVersion.java
Mon May 30 10:27:18 2011
@@ -96,6 +96,15 @@ class DerbyVersion
     }
 
     /**
+     * Returns the Derby version string quoted for use in JQL.
+     *
+     * @return Quoted version string, for instance '"10.6.2.1"'.
+     */
+    public String getQuotedVersion() {
+        return "\"" + getVersion() + "\"";
+    }
+
+    /**
      * Returns the release date in milliseconds since the Epoch.
      *
      * @return Release date as milliseconds since the Epoch.

Modified: db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueLister.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueLister.java?rev=1129117&r1=1129116&r2=1129117&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueLister.java
(original)
+++ db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueLister.java
Mon May 30 10:27:18 2011
@@ -82,7 +82,9 @@ public class FilteredIssueLister {
 "  o VERSION\n" +
 "      Derby version string, i.e. 10.6.2.1\n" +
 "  o FILTERID\n" +
-"      JIRA id, only digits allowed\n" +
+"      JIRA id, only digits allowed.\n" +
+"      If '0' (zero), a JQL query will be generated instead of using an\n" +
+"      existing (manually created) JIRA filter.\n" +
 "  o ANCESTRY\n" +
 "      if necessary, the release ancestry can be overridden by specifying\n " +
 "      the ancestors by version manually. Valid values:\n" +
@@ -108,6 +110,8 @@ public class FilteredIssueLister {
      * Apache Derby community convention.
      */
     private static final String RELEASE_NOTE_NAME = "releaseNote.html";
+    /** Constant used to choose using JQL over an existing filter. */
+    private static final int GENERATE_JQL = 0;
 
     private PrintStream logOut = new PrintStream(System.out);
     private JiraSoapService jiraSoapService;
@@ -358,20 +362,14 @@ public class FilteredIssueLister {
             out.write("//   " + excludeFixVersions[i].getVersion());
             out.newLine();
         }
-        out.write("// Filter id: " + filterId + ", user id " + user);
-        out.newLine();
-        log("fetching issues from filter (id = " + filterId + ")");
         RemoteIssue[] issues = null;
-        try {
-            issues= jiraSoapService.getIssuesFromFilterWithLimit(
-                auth, Long.toString(filterId), 0, 1000);
-        } catch (org.apache.derbyBuild.jirasoap.RemoteException re) {
-            throw new IllegalArgumentException(
-                    "invalid filter id: " + filterId +
-                    " (" + re.getFaultString() + ")");
+        if (filterId == GENERATE_JQL) {
+            issues = execJiraJQLQuery(out, auth, targetVersion);
+        } else {
+            issues = execJiraFilterQuery(out, auth, filterId);
         }
-        log("persisting issues (filter matched " + issues.length + " issues)");
-        out.write("// Filter issue count: " + issues.length);
+        log("persisting issues (" + issues.length + " candidate issues)");
+        out.write("// Candidate issue count: " + issues.length);
         out.newLine();
         int count = 0;
         int issuesWithReleaseNote = 0;
@@ -544,6 +542,92 @@ public class FilteredIssueLister {
     }
 
     /**
+     * Fetches JIRA issues matched by a predefined filter search.
+     * <p>
+     * The filter must be created manually and before the release notes are
+     * generated.
+     *
+     * @param out output stream
+     * @param auth JIRA authententication token
+     * @param filterId JIRA filter id (digits only)
+     * @return A list of matching issues.
+     * @throws IOException if something goes wrong
+     */
+    private RemoteIssue[] execJiraFilterQuery(BufferedWriter out, String auth,
+                                              long filterId)
+            throws IOException {
+        out.write("// Filter id: " + filterId + ", user id " + user);
+        out.newLine();
+        log("fetching issues from filter (id = " + filterId + ")");
+        try {
+             return jiraSoapService.getIssuesFromFilterWithLimit(
+                auth, Long.toString(filterId), 0, 1000);
+        } catch (org.apache.derbyBuild.jirasoap.RemoteException re) {
+            throw new IllegalArgumentException(
+                    "invalid filter id: " + filterId +
+                    " (" + re.getFaultString() + ")");
+        }
+    }
+
+    /**
+     * Fetches JIRA issues matching a generated JQL (Jira Query Language)
+     * search.
+     *
+     * @param out output stream
+     * @param auth JIRA authententication token
+     * @param targetVersion the target release version
+     * @return A list of matching issues.
+     * @throws IOException if something goes wrong
+     */
+    private RemoteIssue[] execJiraJQLQuery(BufferedWriter out, String auth,
+                                           DerbyVersion targetVersion)
+            throws IOException {
+        // Here we have two scenarions:
+        // a) A single target version number - the release has already been
+        //    made, or there is only one release candidate.
+        // b) Multiple target version numbers - there are multiple release
+        //    candidates, and we want to include issues fixed in all of them.
+        // To simplify code, just build an IN-clause for all scenarios.
+
+        // Identify versions.
+        List rcs = new ArrayList();
+        for (int i=0; i < allVersions.length; i++) {
+            DerbyVersion ver = allVersions[i];
+            if (targetVersion.isSameFixPack(ver) &&
+                    ver.compareTo(targetVersion) < 1) {
+                rcs.add(ver);
+            }
+        }
+        Collections.sort(rcs);
+        Collections.reverse(rcs);
+        Iterator rcIter = rcs.iterator();
+
+        // Build JQL query.
+        String jql = "project = DERBY AND resolution = fixed AND fixversion ";
+        StringBuffer sb = new StringBuffer("in (");
+        while (rcIter.hasNext()) {
+            DerbyVersion rc = (DerbyVersion)rcIter.next();
+            sb.append(rc.getQuotedVersion());
+            sb.append(", ");
+        }
+        sb.deleteCharAt(sb.length() -1).deleteCharAt(sb.length() -1);
+        sb.append(')');
+        jql += sb.toString();
+
+        // Execute the query.
+        out.write("// JQL query: " + jql);
+        out.newLine();
+        log("executing JQL query: " + jql);
+        try {
+             return jiraSoapService.getIssuesFromJqlSearch(auth, jql, 1000);
+        } catch (org.apache.derbyBuild.jirasoap.RemoteException re) {
+            throw new IllegalArgumentException(
+                    "JQL query '" + jql + "' failed (" +
+                    re.getFaultString() + ")");
+        }
+    }
+
+    /**
      * Interface for running from the command line.
      *
      * @param args see USAGE constant, or invoke with zero arguments

Modified: db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueListerAntWrapper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueListerAntWrapper.java?rev=1129117&r1=1129116&r2=1129117&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueListerAntWrapper.java
(original)
+++ db/derby/code/trunk/tools/release/jirasoap/src/main/java/org/apache/derbyBuild/jirasoap/FilteredIssueListerAntWrapper.java
Mon May 30 10:27:18 2011
@@ -31,6 +31,7 @@ public class FilteredIssueListerAntWrapp
     private String user;
     private String password;
     private String releaseVersion;
+    /** JIRA filter id, or 0 (zero) for JQL. */
     private long filterId;
     private String output;
 
@@ -50,6 +51,8 @@ public class FilteredIssueListerAntWrapp
 
     public void setFilterId(String id)
             throws BuildException {
+        // NOTE: A filter id of 0 (zero) will be treated specially,
+        //       resulting in a JQL query being generated.
         try {
             filterId = Long.parseLong(id);
         } catch (NumberFormatException nfe) {
@@ -67,6 +70,8 @@ public class FilteredIssueListerAntWrapp
         try {
             FilteredIssueLister issueLister =
                 new FilteredIssueLister(user, password);
+            // NOTE: A filter id of 0 (zero) will be treated specially,
+            //       resulting in a JQL query being generated.
             issueLister.prepareReleaseNotes(
                     releaseVersion, filterId, output, null);
         } catch (Exception e) {



Mime
View raw message