1 | |
package org.apache.maven.plugin.issues; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.commons.collections.bidimap.DualHashBidiMap; |
23 | |
import org.apache.maven.plugin.logging.Log; |
24 | |
|
25 | |
import java.util.ArrayList; |
26 | |
import java.util.Iterator; |
27 | |
import java.util.List; |
28 | |
import java.util.Map; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class IssuesReportHelper |
38 | |
{ |
39 | |
public static final int COLUMN_ASSIGNEE = 0; |
40 | |
|
41 | |
public static final int COLUMN_COMPONENT = 1; |
42 | |
|
43 | |
public static final int COLUMN_CREATED = 2; |
44 | |
|
45 | |
public static final int COLUMN_FIX_VERSION = 3; |
46 | |
|
47 | |
public static final int COLUMN_ID = 4; |
48 | |
|
49 | |
public static final int COLUMN_KEY = 5; |
50 | |
|
51 | |
public static final int COLUMN_PRIORITY = 6; |
52 | |
|
53 | |
public static final int COLUMN_REPORTER = 7; |
54 | |
|
55 | |
public static final int COLUMN_RESOLUTION = 8; |
56 | |
|
57 | |
public static final int COLUMN_STATUS = 9; |
58 | |
|
59 | |
public static final int COLUMN_SUMMARY = 10; |
60 | |
|
61 | |
public static final int COLUMN_TYPE = 11; |
62 | |
|
63 | |
public static final int COLUMN_UPDATED = 12; |
64 | |
|
65 | |
public static final int COLUMN_VERSION = 13; |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
public static List<Integer> getColumnIds( String columnNames, Map<String,Integer> allColumns ) |
75 | |
{ |
76 | 1 | return getColumnIds( columnNames, allColumns, null, null ); |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public static List<Integer> getColumnIds( String columnNames, Map<String,Integer> allColumns, |
92 | |
Map<String,Integer> deprecatedColumns, Log log ) |
93 | |
{ |
94 | 1 | DualHashBidiMap bidiColumns = null; |
95 | 1 | List<Integer> columnIds = new ArrayList<Integer>(); |
96 | 1 | String[] columnNamesArray = columnNames.split( "," ); |
97 | |
|
98 | 1 | if ( deprecatedColumns != null ) |
99 | |
{ |
100 | 0 | bidiColumns = new DualHashBidiMap( allColumns ); |
101 | |
} |
102 | |
|
103 | |
|
104 | 7 | for ( int i = 0; i < columnNamesArray.length; i++ ) |
105 | |
{ |
106 | 6 | String columnName = columnNamesArray[i].trim(); |
107 | 6 | if ( allColumns.containsKey( columnName ) ) |
108 | |
{ |
109 | 5 | columnIds.add( allColumns.get( columnName ) ); |
110 | |
} |
111 | 1 | else if ( deprecatedColumns != null && deprecatedColumns.containsKey( columnName ) ) |
112 | |
{ |
113 | 0 | Integer columnId = deprecatedColumns.get( columnName ); |
114 | 0 | columnIds.add( columnId ); |
115 | 0 | if ( log != null ) |
116 | |
{ |
117 | 0 | log.warn( "The columnName '" + columnName + "' has been deprecated." + " Please use " |
118 | |
+ "the columnName '" + bidiColumns.getKey( columnId ) + "' instead." ); |
119 | |
} |
120 | |
} |
121 | |
} |
122 | 1 | return columnIds; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public static String printValues( List<String> values ) |
132 | |
{ |
133 | 0 | StringBuffer sb = new StringBuffer(); |
134 | 0 | if ( values != null ) |
135 | |
{ |
136 | 0 | Iterator<String> iterator = values.iterator(); |
137 | 0 | while ( iterator.hasNext() ) |
138 | |
{ |
139 | 0 | String value = iterator.next(); |
140 | 0 | sb.append( value ); |
141 | 0 | if ( iterator.hasNext() ) |
142 | |
{ |
143 | 0 | sb.append( ", " ); |
144 | |
} |
145 | 0 | } |
146 | |
} |
147 | 0 | return sb.toString(); |
148 | |
} |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
public static int[] toIntArray( List<Integer> list ) |
157 | |
{ |
158 | 1 | int[] intArray = new int[list.size()]; |
159 | 6 | for ( int j = 0; j < intArray.length; j++ ) |
160 | |
{ |
161 | 5 | intArray[j] = ( list.get( j ) ).intValue(); |
162 | |
} |
163 | 1 | return intArray; |
164 | |
} |
165 | |
} |