Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes


Accepted answer

Permanent link
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

1 vote

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


Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,947
× 17

Question asked: Sep 17 '13, 9:08 p.m.

Question was seen: 6,671 times

Last updated: Sep 19 '13, 2:41 a.m.

Confirmation Cancel Confirm