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

Get teamAreaList attribute with RTC Java API

Hi All,

I would like to extract custom field type; "teamAreaList", using RTC Java API.

Team Area List:

AffTeamArea

"Affected Team Area" is a custom field; "com.test.issue.attribute.affectedTeam", type;"teamAreaList"

 I am able to extract the Team Area Hierarchy, nevertheless I do not know how to obtain expected data from that customized field.

To extract the Team Area Hierarchy, I do the following:
IProjectArea projectArea = getProjectArea(repo, "Sandbox");
   System.out.println(projectArea);
   listTeams = projectArea.getTeamAreaHierarchy().getTeamAreas();
   for (int i=0;i<listTeams.size();i++) { 
        ITeamAreaHandle defaultTeamArea2 = (ITeamAreaHandle)listTeams.get(i);
ITeamArea teamArea = (ITeamArea)repo.itemManager().fetchCompleteItem(defaultTeamArea2, 0, null);
System.out.println(teamArea.getName());
Thanks in advance.

Regards.

0 votes


Accepted answer

Permanent link
Gustavo,

I would suggest to setup your development environment to be able to debug. This makes it so much easier to look at objects and to understand what they are. Please consider to read the following http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and the liked posts to set up PlainJava.

Code I have used looks like below. It casts the ItemList attribute value to a collection and then iterates the enclosed handles.
	private String convertItemListAttributeType(IWorkItem workItem,
			IAttribute iAttribute, Object value) {

		String displayValue = "ITEM LIST: " + iAttribute.getAttributeType();
		if (null != value && value instanceof Collection) {
			Collection values = (Collection) value;
			for (Iterator iterator = values.iterator(); iterator.hasNext();) {
				Object object = (Object) iterator.next();
				if (null != object && object instanceof IItemHandle) {
					IItemHandle itemHandle = (IItemHandle) object;
					// do something
					// for example resolve the item and identify it as a teamArea.
					return itemHandle.toString();
				} else if (null != object && object instanceof IItemHandle) {
					IItem item = (IItem) object;
					return item.toString();
				}
				displayValue += " " + object.toString();
			}
		}
		return displayValue + " Item List Not yet implemented";
	}




 
Gustavo Leyva selected this answer as the correct answer

0 votes

Comments

Hi Ralph,


I implemented the code you mentioned and it works!
Thank you so much! Have an excellent day.


2 other answers

Permanent link
 Last time I tried, I casted it to List and then accessed the element and casted that to the desired Object.

0 votes

Comments

  Hi Ralp,

Thank you for comment.
I did not mentioned "listTeams" is a list "List<iteamareahandle> listTeams=null;"
Can you please add more details to your comment? I did not get which element did you cast.
Thanks in advance.


Permanent link
I do something similar:
        IProjectArea projectArea = rtcm.getProjectArea();
        String name = "";
        if (projectArea != null) {
            List teamAreas = projectArea.getTeamAreas();
            ITeamAreaHierarchy hierarchy = projectArea.getTeamAreaHierarchy();
            for (int i=0;i<teamAreas.size();i++) {
                String ILNames = "";
                String parentName = "Not Yet Set";
                ITeamAreaHandle teamAreaHandle = (ITeamAreaHandle)teamAreas.get(i);
                ITeamAreaHandle teamParent = hierarchy.getParent(teamAreaHandle);
                if (teamParent != null) {
                    ITeamArea parentTeamArea = (ITeamArea)rtcm.getRepository().itemManager().fetchCompleteItem(teamParent,0,null);
                    parentName = parentTeamArea.getName();
                }
                else {
                    //System.out.println("I have a null parent for " + teamAreaHandle.toString());
                }
                ITeamArea teamArea = (ITeamArea)rtcm.getRepository().itemManager().fetchCompleteItem(teamAreaHandle,0,null);
                if (!teamArea.isArchived()) {
                        ITeamData teamData = teamArea.getTeamData();
                        name = teamArea.getName();
                        IDescription desc=  teamArea.getDescription();
                        IContent content = desc.getDetails();
                        String descriptionString="";
                        if (content != null) {
                                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                                rtcm.getRepository().contentManager().retrieveContent(content, stream,null);
                                try {
                                    descriptionString = stream.toString(HttpConstants.ENCODING_UTF8);
                                } catch (UnsupportedEncodingException exception) {
                                    descriptionString = stream.toString();
                                }
                            }
.....


I do alot more "stuff" below that, but this should at least give you an idea of what I do to get the name and description. 

Susa

0 votes

Comments

 Hi Susan,

Thank you for your comment!
I am able to extract Team Area Hierarchy  I think I was not clear, I updated my question with more details, sorry for the inconvinient.
Thank you and have a nice day.

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,937
× 457
× 411
× 169
× 89
× 10

Question asked: Apr 02 '13, 3:22 p.m.

Question was seen: 8,092 times

Last updated: Apr 03 '13, 5:53 p.m.

Confirmation Cancel Confirm