You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2010/12/30 19:35:35 UTC
svn commit: r1053970 - in
/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin:
announcement/AnnouncementMojo.java jira/JiraAdapter.java jira/JiraXML.java
Author: dennisl
Date: Thu Dec 30 18:35:35 2010
New Revision: 1053970
URL: http://svn.apache.org/viewvc?rev=1053970&view=rev
Log:
o Refactoring: move adapter methods from the XML parser class to its own class.
Added:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java (with props)
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java?rev=1053970&r1=1053969&r2=1053970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java Thu Dec 30 18:35:35 2010
@@ -30,6 +30,7 @@ import java.util.Map;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.changes.ChangesXML;
import org.apache.maven.plugin.changes.ReleaseUtils;
+import org.apache.maven.plugin.jira.JiraAdapter;
import org.apache.maven.plugin.jira.JiraXML;
import org.apache.maven.plugins.changes.model.Release;
import org.apache.maven.project.MavenProject;
@@ -573,7 +574,7 @@ public class AnnouncementMojo
List issues = jiraParser.getIssueList();
- return JiraXML.getReleases( issues );
+ return JiraAdapter.getReleases( issues );
}
else
{
Added: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java?rev=1053970&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java (added)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java Thu Dec 30 18:35:35 2010
@@ -0,0 +1,125 @@
+package org.apache.maven.plugin.jira;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugins.changes.model.Action;
+import org.apache.maven.plugins.changes.model.Release;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An adapter that can adapt JIRA specific data models to the data model used
+ * by a changes.xml file.
+ *
+ * @version $Id: JiraAdapter.java 1050925 2010-12-19 18:09:36Z dennisl $
+ */
+public class JiraAdapter
+{
+ /**
+ * Adapt a <code>List</code> of <code>JiraIssue</code>s to a
+ * <code>List</code> of <code>Release</code>s.
+ *
+ * @param issues The JIRA issues
+ * @return A list of releases
+ */
+ public static List getReleases( List issues )
+ {
+ // A Map of releases keyed by fixVersion
+ Map releasesMap = new HashMap();
+
+ // Loop through all issues looking for fixVersions
+ for ( int i = 0; i < issues.size(); i++ )
+ {
+ JiraIssue issue = (JiraIssue) issues.get( i );
+ // Do NOT create a release for issues that lack a fixVersion
+ if ( issue.getFixVersions() != null )
+ {
+ for ( Iterator iterator = issue.getFixVersions().iterator(); iterator.hasNext(); )
+ {
+ String fixVersion = (String) iterator.next();
+
+ // Try to get a matching Release from the map
+ Release release = (Release) releasesMap.get( fixVersion );
+ if ( release == null )
+ {
+ // Add a new Release to the Map if it wasn't there
+ release = new Release();
+ release.setVersion( fixVersion );
+ releasesMap.put( fixVersion, release );
+ }
+
+ // Add this issue as an Action to this release
+ Action action = createAction( issue );
+ release.addAction( action );
+ }
+ }
+ }
+
+ // Extract the releases from the Map to a List
+ List releasesList = new ArrayList();
+ for ( Iterator iterator = releasesMap.entrySet().iterator(); iterator.hasNext(); )
+ {
+ Release o = (Release) ( (Map.Entry) iterator.next() ).getValue();
+ releasesList.add( o );
+ }
+ return releasesList;
+ }
+
+ /**
+ * Create an <code>Action</code> from a JIRA issue.
+ *
+ * @param issue The issue to extract the information from
+ * @return An <code>Action</code>
+ */
+ public static Action createAction( JiraIssue issue )
+ {
+ Action action = new Action();
+
+ action.setIssue( issue.getKey() );
+
+ String type = "";
+ if ( issue.getType().equals( "Bug" ) )
+ {
+ type = "fix";
+ }
+ else if ( issue.getType().equals( "New Feature" ) )
+ {
+ type = "add";
+ }
+ else if ( issue.getType().equals( "Improvement" ) )
+ {
+ type = "update";
+ }
+ action.setType( type );
+
+ action.setDev( issue.getAssignee() );
+
+ // Set dueTo to the empty String instead of null to make Velocity happy
+ action.setDueTo( "" );
+ //action.setDueTo( issue.getReporter() );
+
+ action.setAction( issue.getSummary() );
+ return action;
+ }
+}
Propchange: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java?rev=1053970&r1=1053969&r2=1053970&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java Thu Dec 30 18:35:35 2010
@@ -161,84 +161,4 @@ public class JiraXML
{
return this.issueList;
}
-
- public static List getReleases( List issues )
- {
- // A Map of releases keyed by fixVersion
- Map releasesMap = new HashMap();
-
- // Loop through all issues looking for fixVersions
- for ( int i = 0; i < issues.size(); i++ )
- {
- JiraIssue issue = (JiraIssue) issues.get( i );
- // Do NOT create a release for issues that lack a fixVersion
- if ( issue.getFixVersions() != null )
- {
- for ( Iterator iterator = issue.getFixVersions().iterator(); iterator.hasNext(); )
- {
- String fixVersion = (String) iterator.next();
-
- // Try to get a matching Release from the map
- Release release = (Release) releasesMap.get( fixVersion );
- if ( release == null )
- {
- // Add a new Release to the Map if it wasn't there
- release = new Release();
- release.setVersion( fixVersion );
- releasesMap.put( fixVersion, release );
- }
-
- // Add this issue as an Action to this release
- Action action = createAction( issue );
- release.addAction( action );
- }
- }
- }
-
- // Extract the releases from the Map to a List
- List releasesList = new ArrayList();
- for ( Iterator iterator = releasesMap.entrySet().iterator(); iterator.hasNext(); )
- {
- Release o = (Release) ( (Map.Entry) iterator.next() ).getValue();
- releasesList.add( o );
- }
- return releasesList;
- }
-
- /**
- * Create an <code>Action</code> from a JIRA issue.
- *
- * @param issue The issue to extract the information from
- * @return An <code>Action</code>
- */
- private static Action createAction( JiraIssue issue )
- {
- Action action = new Action();
-
- action.setIssue( issue.getKey() );
-
- String type = "";
- if ( issue.getType().equals( "Bug" ) )
- {
- type = "fix";
- }
- else if ( issue.getType().equals( "New Feature" ) )
- {
- type = "add";
- }
- else if ( issue.getType().equals( "Improvement" ) )
- {
- type = "update";
- }
- action.setType( type );
-
- action.setDev( issue.getAssignee() );
-
- // Set dueTo to the empty String instead of null to make Velocity happy
- action.setDueTo( "" );
- //action.setDueTo( issue.getReporter() );
-
- action.setAction( issue.getSummary() );
- return action;
- }
}