Java API extending - create IFolder instance from IVersionableHandle
Peter Moraza (48●19●24)
| asked Sep 17 '13, 9:08 p.m.
edited Sep 18 '13, 8:32 a.m. by Ralph Schoon (63.5k●3●36●46)
Hi,
Using the RTC 4.0.2 API, I build a Map of already-created component folders using IConfiguration.childEntries(). The returned map contains <key, value> of type <String, IVersionableHandle>. I would like to cast or convert one of the IVersionableHandle values to IFolder and use that IFolder to create a child folder. Is it possible to convert IVersionableHandle to IFolder?
// This returns an instance of Map:
iconfig.childEntries(ifh, monitor);
// From the Map 'value', I am able to get an IVersionableHandle:
IVersionableHandle thisVersionable = (IVersionableHandle) mapEntry.getValue();
// This line does nothing, tmp is left as null
IFolder tmp = (IFolder) thisVersionable.getFullState();
Do I need to retrieve a different type of handle, or is there a different method in IConfiguration that I might use? Thanks!
Peter
|
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Sep 18 '13, 8:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Sep 18 '13, 8:25 a.m.
As far as I can tell, you need to fetch the item that the handle represents and then you can look at what kind of item it is. The code would look like:
List{IVersionable} items = workspace.configuration(component).fetchCompleteItems( new ArrayList{IVersionableHandle}(handles.values()), monitor);You can then test if your Item is an IFolder and cast it. Please note, I had to replace < with { and > with } above. Peter Moraza selected this answer as the correct answer
Comments
Peter Moraza
commented Sep 18 '13, 3:40 p.m.
Hi Ralph,
Thanks for shining some light down the correct path! I was able to populate a new IFolder instance with the following code, then setParent and setName referencing a new IFolder:
IVersionable item = wkspccnctn.configuration(cmpnthndl).fetchCompleteItem(innerVersionable, monitor);
IFolder tmp = (IFolder) item;
I went with fetchCompleteItem because I was not able to find the correct data type for the argument "handles" in your fetchCompleteItems example that includes a values() method. In your example, what data type is "handles"? How is handles.values() able to be instantiated?
Hi Peter,
Map{String, IVersionableHandle} handles = fCompConfig.childEntries( parentFolder, monitor); Again { } to avoid < and >. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.