It's all about the answers!

Ask a question

Java API extending - create IFolder instance from IVersionableHandle


Peter Moraza (481924) | asked Sep 17 '13, 9:08 p.m.
edited Sep 18 '13, 8:32 a.m. by Ralph Schoon (63.5k33646)
 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


permanent link
Ralph Schoon (63.5k33646) | 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?


Ralph Schoon commented Sep 19 '13, 2:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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  >.


Your answer


Register or to post 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.