How to import attachments??
11 answers
Hi,
My query is how can we import attachments using import utility in Rational Team Concert?
Thanks & Regards,
Ritika
Hi,
I don't think there is a feature in RTC to import attachments. You can solve it programmatic using the Plain Java Client API. Things like this are discussed in the Extending Team Concert Forum.
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation shows how to create work items programmatic. You can extend that code by this code to upload attachments to the work item:
private static void attachFile(String name, WorkItemWorkingCopy workItem,
IProjectArea fProjectArea, IWorkItemClient workItemClient)
throws TeamRepositoryException, IOException {
File attachmentFile = new File(name);
FileInputStream fis = new FileInputStream(attachmentFile);
try {
IAttachment newAttachment = workItemClient.createAttachment(
fProjectArea, attachmentFile.getName(), "", "text",
"UTF-8", fis, null);
newAttachment = (IAttachment) newAttachment.getWorkingCopy();
newAttachment = workItemClient.saveAttachment(newAttachment, null);
IItemReference reference = WorkItemLinkTypes
.createAttachmentReference(newAttachment);
workItem.getReferences().add(WorkItemEndPoints.ATTACHMENT,
reference);
} finally {
if (fis != null) {
fis.close();
if (attachmentFile != null) {
attachmentFile.delete();
}
}
}
}
The code that worked for me to modify a work Item you have the ID is shown below. Please note, this code can also used with the examples provided in the link:
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);
try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText(summary));
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
wcm.disconnect(workItem);
}
You should also look here: https://jazz.net/wiki/bin/view/Main/RtcSdk20
How to set up for development is covered here: https://jazz.net/wiki/bin/view/Main/RTCSDK20_DevelopmentEnvironmentSetup
You can import work item attachments using the Bugzilla importer using the format that it expects. See Importing from Other Issue Tracking Systems in https://jazz.net/library/article/69.
Hi,
I have already gone through this link and have also tried the same but could not achieve much.
Please let me if you have already tried the same and got some positive results.
Thanks,
Ritika
You can use the importer to import attachments if you use the
CQ/Bugzilla format. See https://jazz.net/library/article/69 for details.
If this is not sufficient, enhanced support for importing attachments is
requested in work item 100993. Please feel free to add a comment to
indicate what additional support you'd like to see.
Cheers,
Geoff
On 8/10/2011 5:53 AM, rschoon wrote:
CQ/Bugzilla format. See https://jazz.net/library/article/69 for details.
If this is not sufficient, enhanced support for importing attachments is
requested in work item 100993. Please feel free to add a comment to
indicate what additional support you'd like to see.
Cheers,
Geoff
On 8/10/2011 5:53 AM, rschoon wrote:
ritikaaggarwalwrote:
Hi,
My query is how can we import attachments using import utility in
Rational Team Concert?
Thanks& Regards,
Ritika
Hi,
I don't think there is a feature in RTC to import attachments. You can
solve it programmatic using the Plain Java Client API. Things like
this are discussed in the Extending Team Concert Forum.
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation shows
how to create work items programmatic. You can extend that code by
this code to upload attachments to the work item:
private static void attachFile(String name, WorkItemWorkingCopy
workItem,
IProjectArea fProjectArea, IWorkItemClient workItemClient)
throws TeamRepositoryException, IOException {
File attachmentFile = new File(name);
FileInputStream fis = new FileInputStream(attachmentFile);
try {
IAttachment newAttachment = workItemClient.createAttachment(
fProjectArea, attachmentFile.getName(), "",
"text",
"UTF-8", fis, null);
newAttachment = (IAttachment)
newAttachment.getWorkingCopy();
newAttachment = workItemClient.saveAttachment(newAttachment,
null);
IItemReference reference = WorkItemLinkTypes
.createAttachmentReference(newAttachment);
workItem.getReferences().add(WorkItemEndPoints.ATTACHMENT,
reference);
} finally {
if (fis != null) {
fis.close();
if (attachmentFile != null) {
attachmentFile.delete();
}
}
}
}
The code that worked for me to modify a work Item you have the ID is
shown below. Please note, this code can also used with the examples
provided in the link:
IWorkItem workItem = workItemClient.findWorkItemById(id,
IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm =
workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);
try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText(summary));
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work
item",
s.getException());
}
} finally {
wcm.disconnect(workItem);
}
You should also look here:
https://jazz.net/wiki/bin/view/Main/RtcSdk20
How to set up for development is covered here:
https://jazz.net/wiki/bin/view/Main/RTCSDK20_DevelopmentEnvironmentSetup
You pretty much have to follow the same instructions as mentioned in article:
https://jazz.net/library/article/69
I have pasted below a very simple XML file which you can use to import WI aith attachment:
<xml>
<bugzilla>
<bug>
<bug_id>294</bug_id>
<Defect_Custom1>3816</Defect_Custom1>
<short_desc>Import WI and attach</short_desc>
<attachment>
<attachid>file1.txt</attachid>
<desc>Attachment description 1</desc>
</attachment>
<attachment>
<attachid>file2.txt</attachid>
<desc>Attachment description 2</desc>
</attachment>
</bug>
</bugzilla>
where file1.txt and file2.txt are the name of attachments to be attached. Please try with this file.
I would be able to help better if you can share what exact error message you get when you try to import.
https://jazz.net/library/article/69
I have pasted below a very simple XML file which you can use to import WI aith attachment:
<xml>
<bugzilla>
<bug>
<bug_id>294</bug_id>
<Defect_Custom1>3816</Defect_Custom1>
<short_desc>Import WI and attach</short_desc>
<attachment>
<attachid>file1.txt</attachid>
<desc>Attachment description 1</desc>
</attachment>
<attachment>
<attachid>file2.txt</attachid>
<desc>Attachment description 2</desc>
</attachment>
</bug>
</bugzilla>
where file1.txt and file2.txt are the name of attachments to be attached. Please try with this file.
I would be able to help better if you can share what exact error message you get when you try to import.
@Achal,
Thats a great news. Can you please guide me how to do that?
Thanks,
Ritika
@gmclemm,lngooi and rschoon
Guys i also need your advise:
We have some WI's in RTC and we need to update them with attachments, perferably using Bugzilla Bug report importer.Can we do it?
We are not able to find any option in importer interface. We also tried by updating mapping but no positive results.
any pointers??
Guys i also need your advise:
We have some WI's in RTC and we need to update them with attachments, perferably using Bugzilla Bug report importer.Can we do it?
We are not able to find any option in importer interface. We also tried by updating mapping but no positive results.
any pointers??
@Achal,
Thanks for the explanation. I am now able to create new work items with attachments. But the same , updating existing work item, is not happening for me as well.
I played around with mapping xml but no positive results.
Everytime a new work item is created.
Please share if you get any way out.
Thanks,
Ritika
Thanks for the explanation. I am now able to create new work items with attachments. But the same , updating existing work item, is not happening for me as well.
I played around with mapping xml but no positive results.
Everytime a new work item is created.
Please share if you get any way out.
Thanks,
Ritika
I've created work item 175276 asking for the importer to support the
addition of an attachment to an existing work item. Anyone interested
in doing so should subscribe to the work item, so that they get notified
by email if the development team comes up with a workaround.
Cheers,
Geoff
On 8/26/2011 2:38 AM, achal wrote:
addition of an attachment to an existing work item. Anyone interested
in doing so should subscribe to the work item, so that they get notified
by email if the development team comes up with a workaround.
Cheers,
Geoff
On 8/26/2011 2:38 AM, achal wrote:
@gmclemm,lngooi and rschoon
Guys i also need your advise:
We have some WI's in RTC and we need to update them with attachments,
perferably using Bugzilla Bug report importer.Can we do it?
We are not able to find any option in importer interface. We also
tried by updating mapping but no positive results.
any pointers??
page 1of 1 pagesof 2 pages