|
Lines 14-25
Link Here
|
| 14 |
import java.util.Locale; |
14 |
import java.util.Locale; |
| 15 |
import java.util.Map; |
15 |
import java.util.Map; |
| 16 |
|
16 |
|
| 17 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractAttributeFactory; |
17 |
import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper; |
| 18 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.LegacyTaskDataCollector; |
18 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
| 19 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryAttachment; |
19 |
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; |
| 20 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute; |
20 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
| 21 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData; |
21 |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
| 22 |
import org.eclipse.mylyn.internal.tasks.core.deprecated.TaskComment; |
|
|
| 23 |
import org.xml.sax.Attributes; |
22 |
import org.xml.sax.Attributes; |
| 24 |
import org.xml.sax.SAXException; |
23 |
import org.xml.sax.SAXException; |
| 25 |
import org.xml.sax.helpers.DefaultHandler; |
24 |
import org.xml.sax.helpers.DefaultHandler; |
|
Lines 37-69
Link Here
|
| 37 |
|
36 |
|
| 38 |
private StringBuffer characters; |
37 |
private StringBuffer characters; |
| 39 |
|
38 |
|
| 40 |
private TaskComment taskComment; |
39 |
private TaskAttribute taskComment; |
| 41 |
|
40 |
|
| 42 |
private Map<String, TaskComment> attachIdToComment = new HashMap<String, TaskComment>(); |
41 |
private Map<String, TaskAttribute> attachIdToComment = new HashMap<String, TaskAttribute>(); |
| 43 |
|
42 |
|
| 44 |
private int commentNum = 0; |
43 |
private int commentNum = 0; |
| 45 |
|
44 |
|
| 46 |
private RepositoryAttachment attachment; |
45 |
private int attachmentNum = 0; |
| 47 |
|
46 |
|
| 48 |
private final Map<String, RepositoryTaskData> taskDataMap; |
47 |
private TaskAttribute attachment; |
| 49 |
|
48 |
|
| 50 |
private RepositoryTaskData repositoryTaskData; |
49 |
private final Map<String, TaskData> taskDataMap; |
| 51 |
|
50 |
|
| 52 |
private List<TaskComment> longDescs; |
51 |
private TaskData repositoryTaskData; |
|
|
52 |
|
| 53 |
private List<TaskAttribute> longDescs; |
| 53 |
|
54 |
|
| 54 |
private String errorMessage = null; |
55 |
private String errorMessage = null; |
| 55 |
|
56 |
|
| 56 |
private final AbstractAttributeFactory attributeFactory; |
57 |
private final TaskAttributeMapper attributeMapper; |
| 57 |
|
58 |
|
| 58 |
private final List<BugzillaCustomField> customFields; |
59 |
private final List<BugzillaCustomField> customFields; |
| 59 |
|
60 |
|
| 60 |
private final LegacyTaskDataCollector collector; |
61 |
private final TaskDataCollector collector; |
|
|
62 |
|
| 63 |
private TaskAttribute commentContainer; |
| 64 |
|
| 65 |
private TaskAttribute attachmentContainer; |
| 66 |
|
| 67 |
private boolean isDeprecated = false; |
| 68 |
|
| 69 |
private boolean isPatch = false; |
| 61 |
|
70 |
|
| 62 |
//private int retrieved = 1; |
71 |
//private int retrieved = 1; |
| 63 |
|
72 |
|
| 64 |
public SaxMultiBugReportContentHandler(AbstractAttributeFactory factory, LegacyTaskDataCollector collector, |
73 |
public SaxMultiBugReportContentHandler(TaskAttributeMapper mapper, TaskDataCollector collector, |
| 65 |
Map<String, RepositoryTaskData> taskDataMap, List<BugzillaCustomField> customFields) { |
74 |
Map<String, TaskData> taskDataMap, List<BugzillaCustomField> customFields) { |
| 66 |
this.attributeFactory = factory; |
75 |
|
|
|
76 |
this.attributeMapper = mapper; |
| 67 |
this.taskDataMap = taskDataMap; |
77 |
this.taskDataMap = taskDataMap; |
| 68 |
this.customFields = customFields; |
78 |
this.customFields = customFields; |
| 69 |
this.collector = collector; |
79 |
this.collector = collector; |
|
Lines 114-133
Link Here
|
| 114 |
if (attributes != null && (attributes.getValue("error") != null)) { |
124 |
if (attributes != null && (attributes.getValue("error") != null)) { |
| 115 |
errorMessage = attributes.getValue("error"); |
125 |
errorMessage = attributes.getValue("error"); |
| 116 |
} |
126 |
} |
| 117 |
attachIdToComment = new HashMap<String, TaskComment>(); |
127 |
attachIdToComment = new HashMap<String, TaskAttribute>(); |
| 118 |
commentNum = 0; |
128 |
commentNum = 0; |
|
|
129 |
attachmentNum = 0; |
| 119 |
taskComment = null; |
130 |
taskComment = null; |
| 120 |
longDescs = new ArrayList<TaskComment>(); |
131 |
longDescs = new ArrayList<TaskAttribute>(); |
| 121 |
break; |
132 |
break; |
| 122 |
case LONG_DESC: |
133 |
case LONG_DESC: |
| 123 |
taskComment = new TaskComment(attributeFactory, commentNum++); |
134 |
taskComment = commentContainer.createAttribute("" + commentNum++); |
| 124 |
break; |
135 |
break; |
| 125 |
case WHO: |
136 |
case WHO: |
| 126 |
if (taskComment != null) { |
137 |
if (taskComment != null) { |
| 127 |
if (attributes != null && attributes.getLength() > 0) { |
138 |
if (attributes != null && attributes.getLength() > 0) { |
| 128 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
139 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
| 129 |
if (name != null) { |
140 |
if (name != null) { |
| 130 |
taskComment.setAttributeValue(BugzillaReportElement.WHO_NAME.getKeyString(), name); |
141 |
taskComment.createAttribute(BugzillaReportElement.WHO_NAME.getKey()).setValue(name); |
| 131 |
} |
142 |
} |
| 132 |
} |
143 |
} |
| 133 |
} |
144 |
} |
|
Lines 136-144
Link Here
|
| 136 |
if (attributes != null && attributes.getLength() > 0) { |
147 |
if (attributes != null && attributes.getLength() > 0) { |
| 137 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
148 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
| 138 |
if (name != null) { |
149 |
if (name != null) { |
| 139 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(BugzillaReportElement.REPORTER_NAME.getKeyString()); |
150 |
repositoryTaskData.getRoot() |
| 140 |
attr.setValue(name); |
151 |
.createAttribute(BugzillaReportElement.REPORTER_NAME.getKey()) |
| 141 |
repositoryTaskData.addAttribute(BugzillaReportElement.REPORTER_NAME.getKeyString(), attr); |
152 |
.setValue(name); |
| 142 |
} |
153 |
} |
| 143 |
} |
154 |
} |
| 144 |
break; |
155 |
break; |
|
Lines 146-168
Link Here
|
| 146 |
if (attributes != null && attributes.getLength() > 0) { |
157 |
if (attributes != null && attributes.getLength() > 0) { |
| 147 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
158 |
String name = attributes.getValue(ATTRIBUTE_NAME); |
| 148 |
if (name != null) { |
159 |
if (name != null) { |
| 149 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(BugzillaReportElement.ASSIGNED_TO_NAME.getKeyString()); |
160 |
repositoryTaskData.getRoot() |
| 150 |
attr.setValue(name); |
161 |
.createAttribute(BugzillaReportElement.ASSIGNED_TO_NAME.getKey()) |
| 151 |
repositoryTaskData.addAttribute(BugzillaReportElement.ASSIGNED_TO_NAME.getKeyString(), attr); |
162 |
.setValue(name); |
| 152 |
} |
163 |
} |
| 153 |
} |
164 |
} |
| 154 |
break; |
165 |
break; |
| 155 |
case ATTACHMENT: |
166 |
case ATTACHMENT: |
| 156 |
attachment = new RepositoryAttachment(attributeFactory); |
|
|
| 157 |
if (attributes != null) { |
167 |
if (attributes != null) { |
| 158 |
if ("1".equals(attributes.getValue(BugzillaReportElement.IS_OBSOLETE.getKeyString()))) { |
168 |
isDeprecated = "1".equals(attributes.getValue(BugzillaReportElement.IS_OBSOLETE.getKey())); |
| 159 |
attachment.addAttribute(BugzillaReportElement.IS_OBSOLETE.getKeyString(), |
169 |
isPatch = "1".equals(attributes.getValue(BugzillaReportElement.IS_PATCH.getKey())); |
| 160 |
attributeFactory.createAttribute(BugzillaReportElement.IS_OBSOLETE.getKeyString())); |
|
|
| 161 |
attachment.setObsolete(true); |
| 162 |
} |
| 163 |
if ("1".equals(attributes.getValue(BugzillaReportElement.IS_PATCH.getKeyString()))) { |
| 164 |
attachment.setPatch(true); |
| 165 |
} |
| 166 |
} |
170 |
} |
| 167 |
break; |
171 |
break; |
| 168 |
} |
172 |
} |
|
Lines 175-181
Link Here
|
| 175 |
String parsedText = characters.toString(); |
179 |
String parsedText = characters.toString(); |
| 176 |
|
180 |
|
| 177 |
if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { |
181 |
if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { |
| 178 |
RepositoryTaskAttribute attribute = repositoryTaskData.getAttribute(localName); |
182 |
TaskAttribute attribute = repositoryTaskData.getRoot().getAttribute(localName); |
| 179 |
if (attribute == null) { |
183 |
if (attribute == null) { |
| 180 |
String desc = "???"; |
184 |
String desc = "???"; |
| 181 |
for (BugzillaCustomField bugzillaCustomField : customFields) { |
185 |
for (BugzillaCustomField bugzillaCustomField : customFields) { |
|
Lines 183-192
Link Here
|
| 183 |
desc = bugzillaCustomField.getDescription(); |
187 |
desc = bugzillaCustomField.getDescription(); |
| 184 |
} |
188 |
} |
| 185 |
} |
189 |
} |
| 186 |
RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute(localName, desc, true); |
190 |
TaskAttribute atr = repositoryTaskData.getRoot().createAttribute(localName); |
| 187 |
newattribute.setReadOnly(false); |
191 |
atr.putMetaDataValue(TaskAttribute.META_READ_ONLY, Boolean.toString(false)); |
| 188 |
newattribute.setValue(parsedText); |
192 |
atr.setValue(parsedText); |
| 189 |
repositoryTaskData.addAttribute(localName, newattribute); |
|
|
| 190 |
} else { |
193 |
} else { |
| 191 |
attribute.addValue(parsedText); |
194 |
attribute.addValue(parsedText); |
| 192 |
} |
195 |
} |
|
Lines 213-247
Link Here
|
| 213 |
errorMessage = "Bug id from server did not match requested id."; |
216 |
errorMessage = "Bug id from server did not match requested id."; |
| 214 |
} |
217 |
} |
| 215 |
|
218 |
|
| 216 |
RepositoryTaskAttribute attr = repositoryTaskData.getAttribute(tag.getKeyString()); |
219 |
TaskAttribute attr = repositoryTaskData.getMappedAttribute(tag.getKey()); |
| 217 |
if (attr == null) { |
220 |
if (attr == null) { |
| 218 |
attr = attributeFactory.createAttribute(tag.getKeyString()); |
221 |
attr = BugzillaTaskDataHandler.createAttribute(repositoryTaskData, BugzillaReportElement.BUG_ID); |
| 219 |
repositoryTaskData.addAttribute(tag.getKeyString(), attr); |
|
|
| 220 |
} |
222 |
} |
| 221 |
attr.setValue(parsedText); |
223 |
attr.setValue(parsedText); |
|
|
224 |
|
| 225 |
commentContainer = repositoryTaskData.getRoot().createAttribute(TaskAttribute.CONTAINER_COMMENTS); |
| 226 |
attachmentContainer = repositoryTaskData.getRoot().createAttribute(TaskAttribute.CONTAINER_ATTACHMENTS); |
| 227 |
|
| 222 |
break; |
228 |
break; |
| 223 |
} |
229 |
} |
| 224 |
|
230 |
|
| 225 |
// Comment attributes |
231 |
// Comment attributes |
| 226 |
case WHO: |
232 |
case WHO: |
| 227 |
if (taskComment != null) { |
|
|
| 228 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(tag.getKeyString()); |
| 229 |
attr.setValue(parsedText); |
| 230 |
taskComment.addAttribute(tag.getKeyString(), attr); |
| 231 |
} |
| 232 |
break; |
| 233 |
case BUG_WHEN: |
233 |
case BUG_WHEN: |
| 234 |
if (taskComment != null) { |
234 |
if (taskComment != null) { |
| 235 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(tag.getKeyString()); |
235 |
BugzillaTaskDataHandler.createAttribute(taskComment, tag).setValue(parsedText); |
| 236 |
attr.setValue(parsedText); |
|
|
| 237 |
taskComment.addAttribute(tag.getKeyString(), attr); |
| 238 |
} |
236 |
} |
| 239 |
break; |
237 |
break; |
| 240 |
case THETEXT: |
238 |
case THETEXT: |
| 241 |
if (taskComment != null) { |
239 |
if (taskComment != null) { |
| 242 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(tag.getKeyString()); |
240 |
BugzillaTaskDataHandler.createAttribute(taskComment, tag).setValue(parsedText); |
| 243 |
attr.setValue(parsedText); |
|
|
| 244 |
taskComment.addAttribute(tag.getKeyString(), attr); |
| 245 |
|
241 |
|
| 246 |
// Check for attachment |
242 |
// Check for attachment |
| 247 |
parseAttachment(taskComment, parsedText); |
243 |
parseAttachment(taskComment, parsedText); |
|
Lines 255-260
Link Here
|
| 255 |
|
251 |
|
| 256 |
// Attachment attributes |
252 |
// Attachment attributes |
| 257 |
case ATTACHID: |
253 |
case ATTACHID: |
|
|
254 |
attachment = attachmentContainer.createAttribute(parsedText); |
| 255 |
attributeMapper.setBooleanValue(attachment.createAttribute(TaskAttribute.ATTACHMENT_IS_PATCH), isPatch); |
| 256 |
attributeMapper.setBooleanValue(attachment.createAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED), |
| 257 |
isDeprecated); |
| 258 |
break; |
| 259 |
|
| 258 |
case DATE: |
260 |
case DATE: |
| 259 |
case DESC: |
261 |
case DESC: |
| 260 |
case FILENAME: |
262 |
case FILENAME: |
|
Lines 262-278
Link Here
|
| 262 |
case TYPE: |
264 |
case TYPE: |
| 263 |
case SIZE: |
265 |
case SIZE: |
| 264 |
if (attachment != null) { |
266 |
if (attachment != null) { |
| 265 |
RepositoryTaskAttribute attr = attributeFactory.createAttribute(tag.getKeyString()); |
267 |
attachment.createAttribute(tag.getKey()).setValue(parsedText); |
| 266 |
attr.setValue(parsedText); |
|
|
| 267 |
attachment.addAttribute(tag.getKeyString(), attr); |
| 268 |
} |
268 |
} |
| 269 |
break; |
269 |
break; |
| 270 |
case DATA: |
270 |
case DATA: |
| 271 |
break; |
271 |
break; |
| 272 |
case ATTACHMENT: |
272 |
case ATTACHMENT: |
| 273 |
if (attachment != null) { |
273 |
isPatch = false; |
| 274 |
repositoryTaskData.addAttachment(attachment); |
274 |
isDeprecated = false; |
| 275 |
} |
275 |
attachment = null; |
| 276 |
break; |
276 |
break; |
| 277 |
|
277 |
|
| 278 |
// IGNORED ELEMENTS |
278 |
// IGNORED ELEMENTS |
|
Lines 297-386
Link Here
|
| 297 |
// comments |
297 |
// comments |
| 298 |
int longDescsSize = longDescs.size() - 1; |
298 |
int longDescsSize = longDescs.size() - 1; |
| 299 |
if (longDescsSize == 0) { |
299 |
if (longDescsSize == 0) { |
| 300 |
repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, longDescs.get(0).getText()); |
300 |
//Description = comment 0 |
|
|
301 |
repositoryTaskData.getRoot().createAttribute(TaskAttribute.DESCRIPTION).setValue( |
| 302 |
longDescs.get(0).getMappedAttribute(BugzillaReportElement.THETEXT.getKey()).getValue()); |
| 301 |
} else if (longDescsSize == 1) { |
303 |
} else if (longDescsSize == 1) { |
| 302 |
if (longDescs.get(0).getCreated().compareTo(longDescs.get(1).getCreated()) <= 0) { |
304 |
String val0 = longDescs.get(0).getMappedAttribute(BugzillaReportElement.BUG_WHEN.getKey()).getValue(); |
|
|
305 |
String val1 = longDescs.get(1).getMappedAttribute(BugzillaReportElement.BUG_WHEN.getKey()).getValue(); |
| 306 |
|
| 307 |
if (val0.compareTo(val1) <= 0) { |
| 303 |
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description. |
308 |
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description. |
| 304 |
repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, longDescs.get(0) |
309 |
repositoryTaskData.getRoot().createAttribute(TaskAttribute.DESCRIPTION).setValue( |
| 305 |
.getText()); |
310 |
longDescs.get(0).getMappedAttribute(BugzillaReportElement.THETEXT.getKey()).getValue()); |
| 306 |
repositoryTaskData.addComment(longDescs.get(1)); |
|
|
| 307 |
} else { |
311 |
} else { |
| 308 |
repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, longDescs.get(1) |
312 |
repositoryTaskData.getRoot().createAttribute(TaskAttribute.DESCRIPTION).setValue( |
| 309 |
.getText()); |
313 |
longDescs.get(1).getMappedAttribute(BugzillaReportElement.THETEXT.getKey()).getValue()); |
| 310 |
commentNum = 1; |
|
|
| 311 |
longDescs.get(0).setNumber(commentNum); |
| 312 |
repositoryTaskData.addComment(longDescs.get(0)); |
| 313 |
} |
314 |
} |
| 314 |
} else if (longDescsSize > 1) { |
315 |
} else if (longDescsSize > 1) { |
| 315 |
String created_0 = longDescs.get(0).getCreated(); |
316 |
String val0 = longDescs.get(0).getMappedAttribute(BugzillaReportElement.BUG_WHEN.getKey()).getValue(); |
| 316 |
String created_1 = longDescs.get(1).getCreated(); |
317 |
String val1 = longDescs.get(1).getMappedAttribute(BugzillaReportElement.BUG_WHEN.getKey()).getValue(); |
| 317 |
String created_n = longDescs.get(longDescsSize).getCreated(); |
318 |
|
|
|
319 |
String created_0 = val0; |
| 320 |
String created_1 = val1; |
| 321 |
String created_n = longDescs.get(longDescsSize).getMappedAttribute( |
| 322 |
BugzillaReportElement.BUG_WHEN.getKey()).getValue(); |
| 318 |
commentNum = 1; |
323 |
commentNum = 1; |
| 319 |
if (created_0.compareTo(created_1) <= 0 && created_0.compareTo(created_n) < 0) { |
324 |
if (created_0.compareTo(created_1) <= 0 && created_0.compareTo(created_n) < 0) { |
| 320 |
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description. |
325 |
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description. |
| 321 |
repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, longDescs.get(0) |
326 |
repositoryTaskData.getRoot().createAttribute(TaskAttribute.DESCRIPTION).setValue( |
| 322 |
.getText()); |
327 |
longDescs.get(0).getMappedAttribute(BugzillaReportElement.THETEXT.getKey()).getValue()); |
| 323 |
if (created_1.compareTo(created_n) < 0) { |
328 |
|
| 324 |
for (int i = 1; i <= longDescsSize; i++) { |
329 |
// TODO: move into presentation? |
| 325 |
longDescs.get(i).setNumber(commentNum++); |
330 |
// if (created_1.compareTo(created_n) < 0) { |
| 326 |
repositoryTaskData.addComment(longDescs.get(i)); |
331 |
// for (int i = 1; i <= longDescsSize; i++) { |
| 327 |
} |
332 |
// longDescs.get(i).setNumber(commentNum++); |
| 328 |
} else { |
333 |
// repositoryTaskData.addComment(longDescs.get(i)); |
| 329 |
for (int i = longDescsSize; i > 0; i--) { |
334 |
// } |
| 330 |
longDescs.get(i).setNumber(commentNum++); |
335 |
// } else { |
| 331 |
repositoryTaskData.addComment(longDescs.get(i)); |
336 |
// for (int i = longDescsSize; i > 0; i--) { |
| 332 |
} |
337 |
// longDescs.get(i).setNumber(commentNum++); |
| 333 |
} |
338 |
// repositoryTaskData.addComment(longDescs.get(i)); |
|
|
339 |
// } |
| 340 |
// } |
| 334 |
} else { |
341 |
} else { |
| 335 |
repositoryTaskData.setAttributeValue(RepositoryTaskAttribute.DESCRIPTION, longDescs.get( |
342 |
repositoryTaskData.getRoot().createAttribute(TaskAttribute.DESCRIPTION).setValue( |
| 336 |
longDescsSize).getText()); |
343 |
longDescs.get(longDescsSize) |
| 337 |
if (created_0.compareTo(created_1) < 0) { |
344 |
.getMappedAttribute(BugzillaReportElement.THETEXT.getKey()) |
| 338 |
for (int i = 0; i < longDescsSize; i++) { |
345 |
.getValue()); |
| 339 |
longDescs.get(i).setNumber(commentNum++); |
346 |
// if (created_0.compareTo(created_1) < 0) { |
| 340 |
repositoryTaskData.addComment(longDescs.get(i)); |
347 |
// for (int i = 0; i < longDescsSize; i++) { |
| 341 |
} |
348 |
// longDescs.get(i).setNumber(commentNum++); |
| 342 |
} else { |
349 |
// repositoryTaskData.addComment(longDescs.get(i)); |
| 343 |
for (int i = longDescsSize - 1; i >= 0; i--) { |
350 |
// } |
| 344 |
longDescs.get(i).setNumber(commentNum++); |
351 |
// } else { |
| 345 |
repositoryTaskData.addComment(longDescs.get(i)); |
352 |
// for (int i = longDescsSize - 1; i >= 0; i--) { |
| 346 |
} |
353 |
// longDescs.get(i).setNumber(commentNum++); |
| 347 |
} |
354 |
// repositoryTaskData.addComment(longDescs.get(i)); |
|
|
355 |
// } |
| 356 |
// } |
| 348 |
} |
357 |
} |
| 349 |
} |
358 |
} |
| 350 |
|
359 |
|
| 351 |
RepositoryTaskAttribute numCommentsAttribute = repositoryTaskData.getAttribute(BugzillaReportElement.LONGDESCLENGTH.getKeyString()); |
360 |
TaskAttribute container = repositoryTaskData.getMappedAttribute(TaskAttribute.CONTAINER_COMMENTS); |
|
|
361 |
TaskAttribute numCommentsAttribute = repositoryTaskData.getMappedAttribute(BugzillaReportElement.LONGDESCLENGTH.getKey()); |
| 352 |
if (numCommentsAttribute == null) { |
362 |
if (numCommentsAttribute == null) { |
| 353 |
numCommentsAttribute = attributeFactory.createAttribute(BugzillaReportElement.LONGDESCLENGTH.getKeyString()); |
363 |
numCommentsAttribute = BugzillaTaskDataHandler.createAttribute(repositoryTaskData, |
| 354 |
numCommentsAttribute.setValue("" + repositoryTaskData.getComments().size()); |
364 |
BugzillaReportElement.LONGDESCLENGTH); |
| 355 |
repositoryTaskData.addAttribute(BugzillaReportElement.LONGDESCLENGTH.getKeyString(), |
365 |
numCommentsAttribute.setValue("" + container.getAttributes().size()); |
| 356 |
numCommentsAttribute); |
|
|
| 357 |
} else { |
366 |
} else { |
| 358 |
numCommentsAttribute.setValue("" + repositoryTaskData.getComments().size()); |
367 |
numCommentsAttribute.setValue("" |
|
|
368 |
+ repositoryTaskData.getMappedAttribute(BugzillaReportElement.LONGDESCLENGTH.getKey()) |
| 369 |
.getValue()); |
| 359 |
} |
370 |
} |
| 360 |
|
371 |
|
| 361 |
// Set the creator name on all attachments |
372 |
// Set the creator name on all attachments |
| 362 |
for (RepositoryAttachment attachment : repositoryTaskData.getAttachments()) { |
373 |
for (TaskAttribute attachment : container.getAttributes().values()) { |
| 363 |
TaskComment taskComment = attachIdToComment.get(attachment.getId()); |
374 |
TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attachment); |
|
|
375 |
TaskAttribute taskComment = attachIdToComment.get(attachment.getId()); |
| 364 |
if (taskComment != null) { |
376 |
if (taskComment != null) { |
| 365 |
attachment.setCreator(taskComment.getAuthor()); |
377 |
String commentAuthor = taskComment.getMappedAttribute(TaskAttribute.COMMENT_AUTHOR).getValue(); |
| 366 |
} |
378 |
attachmentMapper.setAuthor(repositoryTaskData.getAttributeMapper() |
| 367 |
attachment.setAttributeValue(RepositoryTaskAttribute.ATTACHMENT_URL, |
379 |
.getTaskRepository() |
| 368 |
repositoryTaskData.getRepositoryUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX |
380 |
.createPerson(commentAuthor)); |
| 369 |
+ attachment.getId()); |
381 |
} |
| 370 |
attachment.setRepositoryKind(repositoryTaskData.getConnectorKind()); |
382 |
attachmentMapper.setUrl(repositoryTaskData.getRepositoryUrl() |
| 371 |
attachment.setRepositoryUrl(repositoryTaskData.getRepositoryUrl()); |
383 |
+ IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachment.getId()); |
| 372 |
attachment.setTaskId(repositoryTaskData.getTaskId()); |
384 |
// attachment.setRepositoryKind(repositoryTaskData.getConnectorKind()); |
|
|
385 |
// attachment.setRepositoryUrl(repositoryTaskData.getRepositoryUrl()); |
| 386 |
// attachment.setTaskId(repositoryTaskData.getTaskId()); |
| 373 |
} |
387 |
} |
| 374 |
collector.accept(repositoryTaskData); |
388 |
collector.accept(repositoryTaskData); |
| 375 |
break; |
389 |
break; |
| 376 |
|
390 |
|
| 377 |
case BLOCKED: |
391 |
case BLOCKED: |
| 378 |
case DEPENDSON: |
392 |
case DEPENDSON: |
| 379 |
RepositoryTaskAttribute dependancyAttribute = repositoryTaskData.getAttribute(tag.getKeyString()); |
393 |
TaskAttribute dependancyAttribute = repositoryTaskData.getMappedAttribute(tag.getKey()); |
| 380 |
if (dependancyAttribute == null) { |
394 |
if (dependancyAttribute == null) { |
| 381 |
dependancyAttribute = attributeFactory.createAttribute(tag.getKeyString()); |
395 |
BugzillaTaskDataHandler.createAttribute(repositoryTaskData, BugzillaReportElement.DEPENDSON).setValue( |
| 382 |
dependancyAttribute.setValue(parsedText); |
396 |
parsedText); |
| 383 |
repositoryTaskData.addAttribute(tag.getKeyString(), dependancyAttribute); |
|
|
| 384 |
} else { |
397 |
} else { |
| 385 |
if (dependancyAttribute.getValue().equals("")) { |
398 |
if (dependancyAttribute.getValue().equals("")) { |
| 386 |
dependancyAttribute.setValue(parsedText); |
399 |
dependancyAttribute.setValue(parsedText); |
|
Lines 391-401
Link Here
|
| 391 |
break; |
404 |
break; |
| 392 |
// All others added as report attribute |
405 |
// All others added as report attribute |
| 393 |
default: |
406 |
default: |
| 394 |
RepositoryTaskAttribute attribute = repositoryTaskData.getAttribute(tag.getKeyString()); |
407 |
TaskAttribute attribute = repositoryTaskData.getMappedAttribute(tag.getKey()); |
| 395 |
if (attribute == null) { |
408 |
if (attribute == null) { |
| 396 |
attribute = attributeFactory.createAttribute(tag.getKeyString()); |
409 |
attribute = BugzillaTaskDataHandler.createAttribute(repositoryTaskData, tag); |
| 397 |
attribute.setValue(parsedText); |
410 |
attribute.setValue(parsedText); |
| 398 |
repositoryTaskData.addAttribute(tag.getKeyString(), attribute); |
|
|
| 399 |
} else { |
411 |
} else { |
| 400 |
attribute.addValue(parsedText); |
412 |
attribute.addValue(parsedText); |
| 401 |
} |
413 |
} |
|
Lines 405-411
Link Here
|
| 405 |
} |
417 |
} |
| 406 |
|
418 |
|
| 407 |
/** determines attachment id from comment */ |
419 |
/** determines attachment id from comment */ |
| 408 |
private void parseAttachment(TaskComment taskComment, String commentText) { |
420 |
private void parseAttachment(TaskAttribute taskComment, String commentText) { |
| 409 |
|
421 |
|
| 410 |
String attachmentID = ""; |
422 |
String attachmentID = ""; |
| 411 |
|
423 |
|
|
Lines 414-421
Link Here
|
| 414 |
if (endIndex > 0 && endIndex < commentText.length()) { |
426 |
if (endIndex > 0 && endIndex < commentText.length()) { |
| 415 |
attachmentID = commentText.substring(COMMENT_ATTACHMENT_STRING.length(), endIndex); |
427 |
attachmentID = commentText.substring(COMMENT_ATTACHMENT_STRING.length(), endIndex); |
| 416 |
if (!attachmentID.equals("")) { |
428 |
if (!attachmentID.equals("")) { |
| 417 |
taskComment.setHasAttachment(true); |
429 |
TaskAttribute attachmentContainer = taskComment.getMappedAttribute(TaskAttribute.CONTAINER_ATTACHMENTS); |
| 418 |
taskComment.setAttachmentId(attachmentID); |
430 |
if (attachmentContainer == null) { |
|
|
431 |
attachmentContainer = taskComment.createAttribute(TaskAttribute.CONTAINER_ATTACHMENTS); |
| 432 |
} |
| 433 |
attachmentContainer.createAttribute(attachmentID); |
| 419 |
attachIdToComment.put(attachmentID, taskComment); |
434 |
attachIdToComment.put(attachmentID, taskComment); |
| 420 |
} |
435 |
} |
| 421 |
} |
436 |
} |