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 getColumnIds( String columnNames, Map allColumns ) |
75 | |
{ |
76 | 0 | return getColumnIds( columnNames, allColumns, null, null ); |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public static List getColumnIds( String columnNames, Map allColumns, Map deprecatedColumns, Log log ) |
92 | |
{ |
93 | 0 | DualHashBidiMap bidiColumns = null; |
94 | 0 | List columnIds = new ArrayList(); |
95 | 0 | String[] columnNamesArray = columnNames.split( "," ); |
96 | |
|
97 | 0 | if ( deprecatedColumns != null ) |
98 | |
{ |
99 | 0 | bidiColumns = new DualHashBidiMap( allColumns ); |
100 | |
} |
101 | |
|
102 | |
|
103 | 0 | for ( int i = 0; i < columnNamesArray.length; i++ ) |
104 | |
{ |
105 | 0 | String columnName = columnNamesArray[i].trim(); |
106 | 0 | if ( allColumns.containsKey( columnName ) ) |
107 | |
{ |
108 | 0 | columnIds.add( (Integer) allColumns.get( columnName ) ); |
109 | |
} |
110 | 0 | else if ( deprecatedColumns != null && deprecatedColumns.containsKey( columnName ) ) |
111 | |
{ |
112 | 0 | Integer columnId = (Integer) deprecatedColumns.get( columnName ); |
113 | 0 | columnIds.add( columnId ); |
114 | 0 | if ( log != null ) |
115 | |
{ |
116 | 0 | log.warn( "The columnName '" + columnName + "' has been deprecated." + " Please use " |
117 | |
+ "the columnName '" + bidiColumns.getKey( columnId ) + "' instead." ); |
118 | |
} |
119 | |
} |
120 | |
} |
121 | 0 | return columnIds; |
122 | |
} |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public static String printValues( List values ) |
131 | |
{ |
132 | 0 | StringBuffer sb = new StringBuffer(); |
133 | 0 | if ( values != null ) |
134 | |
{ |
135 | 0 | Iterator iterator = values.iterator(); |
136 | 0 | while ( iterator.hasNext() ) |
137 | |
{ |
138 | 0 | String value = (String) iterator.next(); |
139 | 0 | sb.append( value ); |
140 | 0 | if ( iterator.hasNext() ) |
141 | |
{ |
142 | 0 | sb.append( ", " ); |
143 | |
} |
144 | 0 | } |
145 | |
} |
146 | 0 | return sb.toString(); |
147 | |
} |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public static int[] toIntArray( List list ) |
156 | |
{ |
157 | 0 | int[] intArray = new int[list.size()]; |
158 | 0 | for ( int j = 0; j < intArray.length; j++ ) |
159 | |
{ |
160 | 0 | intArray[j] = ( (Integer) list.get( j ) ).intValue(); |
161 | |
} |
162 | 0 | return intArray; |
163 | |
} |
164 | |
} |