Java API extending - create IFolder instance from IVersionableHandle
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
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.
Comments
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,
I am just a beginner with the SCM API as well 8-). I found some hints here: http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html
In my code (derived from the post above) I get the children from a parent folder I have.
Map{String, IVersionableHandle} handles = fCompConfig.childEntries( parentFolder, monitor);
Again { } to avoid < and >.