| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.services.util; |
| 20 |
|
|
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Arrays; |
| 23 |
|
import java.util.List; |
| 24 |
|
import java.util.Locale; |
| 25 |
|
import java.util.NoSuchElementException; |
| 26 |
|
import java.util.StringTokenizer; |
| 27 |
|
|
| 28 |
|
import org.itracker.model.Component; |
| 29 |
|
import org.itracker.model.CustomFieldValue; |
| 30 |
|
import org.itracker.model.NameValuePair; |
| 31 |
|
import org.itracker.model.User; |
| 32 |
|
import org.itracker.model.Version; |
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 89 (89) |
Complexity: 24 |
Complexity Density: 0.45 |
|
| 34 |
|
public class Convert { |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@param |
| 39 |
|
|
| 40 |
|
@return |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
public static List<NameValuePair> customFieldOptionsToNameValuePairs(... |
| 43 |
|
List<CustomFieldValue> options) { |
| 44 |
0
|
return customFieldOptionsToNameValuePairs(options, null); |
| 45 |
|
|
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@param |
| 51 |
|
|
| 52 |
|
@return |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 54 |
0
|
public static List<NameValuePair> customFieldOptionsToNameValuePairs(... |
| 55 |
|
List<CustomFieldValue> options, Locale locale) { |
| 56 |
0
|
List<NameValuePair> returnValues = new ArrayList<NameValuePair>(); |
| 57 |
0
|
String name; |
| 58 |
0
|
if (options != null) { |
| 59 |
0
|
returnValues = new ArrayList<NameValuePair>(); |
| 60 |
0
|
for (int i = 0; i < options.size(); i++) { |
| 61 |
0
|
name = CustomFieldUtilities.getCustomFieldOptionName(options.get(i), locale); |
| 62 |
0
|
returnValues |
| 63 |
|
.add(new NameValuePair(name, options.get(i).getValue())); |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
|
|
| 67 |
0
|
return returnValues; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@param |
| 73 |
|
|
| 74 |
|
@return |
| 75 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 76 |
0
|
public static List<NameValuePair> usersToNameValuePairs(List<User> users) {... |
| 77 |
0
|
List<NameValuePair> returnValues = new ArrayList<NameValuePair>(); |
| 78 |
|
|
| 79 |
0
|
if (users != null) { |
| 80 |
0
|
returnValues = new ArrayList<NameValuePair>(); |
| 81 |
0
|
for (int i = 0; i < users.size(); i++) { |
| 82 |
0
|
returnValues.add(new NameValuePair(users.get(i).getFirstName() |
| 83 |
|
+ " " + users.get(i).getLastName(), users.get(i) |
| 84 |
|
.getId().toString())); |
| 85 |
|
} |
| 86 |
|
} |
| 87 |
|
|
| 88 |
0
|
return returnValues; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
@param |
| 95 |
|
|
| 96 |
|
@return |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 98 |
0
|
public static List<NameValuePair> componentsToNameValuePairs(... |
| 99 |
|
List<Component> components) { |
| 100 |
0
|
NameValuePair[] returnValues = new NameValuePair[0]; |
| 101 |
|
|
| 102 |
0
|
if (components != null) { |
| 103 |
0
|
returnValues = new NameValuePair[components.size()]; |
| 104 |
0
|
for (int i = 0; i < components.size(); i++) { |
| 105 |
0
|
returnValues[i] = new NameValuePair( |
| 106 |
|
components.get(i).getName(), components.get(i).getId() |
| 107 |
|
.toString()); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
|
| 111 |
0
|
return Arrays.asList(returnValues); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
@param |
| 118 |
|
|
| 119 |
|
@return |
| 120 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 121 |
0
|
public static List<NameValuePair> versionsToNameValuePairs(... |
| 122 |
|
List<Version> versions) { |
| 123 |
0
|
NameValuePair[] returnValues = new NameValuePair[0]; |
| 124 |
|
|
| 125 |
0
|
if (versions != null) { |
| 126 |
0
|
returnValues = new NameValuePair[versions.size()]; |
| 127 |
0
|
for (int i = 0; i < versions.size(); i++) { |
| 128 |
0
|
returnValues[i] = new NameValuePair( |
| 129 |
|
versions.get(i).getNumber(), versions.get(i).getId() |
| 130 |
|
.toString()); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
|
| 134 |
0
|
return Arrays.asList(returnValues); |
| 135 |
|
} |
| 136 |
|
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 11 |
Complexity Density: 0.42 |
|
| 137 |
0
|
public static String[] stringToArray(String input) {... |
| 138 |
0
|
if (input == null || "".equals(input)) { |
| 139 |
0
|
return new String[0]; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
0
|
List<String> tokenList = new ArrayList<String>(); |
| 143 |
0
|
StringTokenizer tokenizer = new StringTokenizer(input, " "); |
| 144 |
0
|
while (tokenizer.hasMoreElements()) { |
| 145 |
0
|
boolean quotedToken = false; |
| 146 |
0
|
String tokenString = tokenizer.nextToken(); |
| 147 |
0
|
if (tokenString.startsWith("\"")) { |
| 148 |
0
|
quotedToken = true; |
| 149 |
0
|
tokenString = tokenString.substring(1); |
| 150 |
0
|
if (tokenString.endsWith("\"") && !tokenString.endsWith("\\\"")) { |
| 151 |
0
|
quotedToken = false; |
| 152 |
0
|
tokenString = tokenString.substring(0, tokenString.length() - 1); |
| 153 |
|
} |
| 154 |
|
} |
| 155 |
|
|
| 156 |
0
|
if (quotedToken) { |
| 157 |
0
|
boolean getNext = true; |
| 158 |
|
|
| 159 |
0
|
StringBuffer token = new StringBuffer(tokenString); |
| 160 |
0
|
while (getNext) { |
| 161 |
0
|
try { |
| 162 |
0
|
token.append(tokenizer.nextToken("\"")); |
| 163 |
0
|
if (!token.toString().endsWith("\\\"")) { |
| 164 |
0
|
getNext = false; |
| 165 |
|
} |
| 166 |
|
} catch (NoSuchElementException e) { |
| 167 |
0
|
break; |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
0
|
tokenString = token.toString(); |
| 171 |
|
} |
| 172 |
|
|
| 173 |
0
|
tokenList.add(tokenString); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
0
|
String[] stringArray = (String[]) tokenList.toArray(new String[] {}); |
| 177 |
|
|
| 178 |
0
|
return stringArray; |
| 179 |
|
} |
| 180 |
|
} |