1 package org.apache.maven.plugin.changes;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.issues.Issue;
23 import org.apache.maven.plugin.issues.IssueManagementSystem;
24 import org.apache.maven.plugins.changes.model.Action;
25 import org.apache.maven.plugins.changes.model.Release;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32
33
34
35
36
37
38
39
40 public class IssueAdapter
41 {
42 private static final String UNKNOWN_ISSUE_TYPE = "";
43 private IssueManagementSystem ims;
44
45
46
47
48
49
50 public IssueAdapter( IssueManagementSystem ims )
51 {
52 this.ims = ims;
53 }
54
55 private Map<String, IssueType> getIssueTypeMap()
56 {
57 return ims.getIssueTypeMap();
58 }
59
60
61
62
63
64
65
66 public List<Release> getReleases( List<Issue> issues )
67 {
68
69 Map<String, Release> releasesMap = new HashMap<String, Release>();
70
71
72 for ( Issue issue : issues )
73 {
74
75 if ( issue.getFixVersions() != null )
76 {
77 for ( String fixVersion : issue.getFixVersions() )
78 {
79
80 Release release = releasesMap.get( fixVersion );
81 if ( release == null )
82 {
83
84 release = new Release();
85 release.setVersion( fixVersion );
86 releasesMap.put( fixVersion, release );
87 }
88
89
90 Action action = createAction( issue );
91 release.addAction( action );
92 }
93 }
94 }
95
96
97 List<Release> releasesList = new ArrayList<Release>();
98 for ( Release release : releasesMap.values() )
99 {
100 releasesList.add( release );
101 }
102 return releasesList;
103 }
104
105
106
107
108
109
110
111 public Action createAction( Issue issue )
112 {
113 Action action = new Action();
114
115
116
117 action.setIssue( issue.getKey() );
118
119
120 IssueType type = null;
121 if ( getIssueTypeMap().containsKey( issue.getType() ) )
122 {
123 type = getIssueTypeMap().get( issue.getType() );
124 action.setType( type.modelRepresentation() );
125 }
126 else
127 {
128 action.setType( UNKNOWN_ISSUE_TYPE );
129 }
130
131 action.setDev( issue.getAssignee() );
132
133
134 action.setDueTo( "" );
135
136
137 action.setAction( issue.getSummary() );
138 return action;
139 }
140 }