All,
I am trying to write an Eclipse plugin that will be run against a Work Item which should contain Change Sets and also Links to our internal peer review software. The objective is to compare the files being delivered to a stream with the files which were peer reviewed and provide the approver with a report of the differences.
For this effort I start with the work item in the Eclipse Work Item editor and invoke the process with a menu item. From there, I pull the list of Change sets from the work item and loop through them with the following code (Thanks Ralph :) ). I extract the files to a temporary working area so that I can compare them with what was uploaded to the peer review software. Right now, the below code will extract all the files, but will not put them in the relative path the change set would show them in.
for (IReference iReference : references) {
if (iReference.isItemReference() ) {
Object resItem = iReference.resolve();
if (resItem instanceof IChangeSetHandle) {
IChangeSetHandle csHandle = (IChangeSetHandle) resItem;
IChangeSet cs = (IChangeSet) this.itemManager.fetchCompleteItem(csHandle, IItemManager.DEFAULT, null);
cs.getOriginalSourceId();
for (Object change : cs.changes()) {
IChange aChange = (IChange) change;
if (aChange.item() instanceof IFileItemHandle) {
IFileItemHandle fiHandle = (IFileItemHandle) aChange.afterState();
IFileItem fItem = (IFileItem) verManager.fetchCompleteState(fiHandle, null);
IFileContent fContent = fItem.getContent();
IFolderHandle foldHand = fItem.getParent();
IFolder fold = (IFolder) verManager.fetchCompleteState(foldHand, null);
System.out.println(fold);
System.out.println(fold.getOrigin());
System.out.println(fold.getParent());
File newFile = new File(destDir.getAbsolutePath() + '\\' + fItem.getName());
OutputStream out = new FileOutputStream(newFile);
vcm.retrieveContent(fItem, fContent, out, null);
out.close();
}
}
}
}
}
The above code gets an error on the fetchCompleteState for the Folder because it does not have a state. Obviously that isn't the right way to extract the relative path. Other examples I have pulled up show using the IConfiguration to get the history or use the Resolve Path method. My problem is that the IConfiguration seems to want a work space as a point of reference. As I am coming from a work item, I don't have a specific work space.
I know that when I am working in the Eclipse system and highlight all the changes sets and select Open that RTC aggregates all the change sets for me and normally provides a relative path in the change summary view. What work space does the system use for this, or is there some magical internal call that I don't know about they are using?
Alternatively, what approach would be the best for pulling the path of the files when I don't have a specific work space?
It may be that this is already answered and I just don't understand how the answer applies. If so, please let me know where and I will try to understand the answer better.
Thanks in advance for any advice and please ask questions if I have not provided enough information to make the question clear.