cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the principals from a product team role

Highlighted
Newbie

How to retrieve the principals from a product team role

Dear all,


We have our companies products set up in Windchill products. We now want our Change Management process to automatically assignan implementation plan activity to an assignee. These assignees are member of a Product (context)role.


I am able to create the implementation plan activities, but I can not seem to get to the principals in the context team roles.


Below is the code I am testing to retrieve te principals in the PRODUCT MANAGER role. I think the issue is in the team2 definition line. the rest of the code works accept for the fact that the enumeration pprincipals holds no principals. Anyone has an idea?


while (queryresult.hasMoreElements()) {
Object obj = queryresult.nextElement();
if (obj instanceof wt.pdmlink.PDMLinkProduct) {
wt.pdmlink.PDMLinkProduct product = (wt.pdmlink.PDMLinkProduct) obj;
String displayIdentifier = product.getDisplayIdentifier().toString();
System.out.println("Product :"+displayIdentifier);


// issue in next line???
wt.inf.team.ContainerTeam team2 = wt.inf.team.ContainerTeamHelper.service.getContainerTeam(product);


java.util.Enumeration teamrolese = team2.getRoles().elements();
while (teamrolese.hasMoreElements()) {
Object roleobj =teamrolese.nextElement();
wt.project.Role role = (wt.project.Role) roleobj;
System.out.println(role);
if (role.getDisplay().equalsIgnoreCase("PRODUCT MANAGER")){
System.out.println("in if");
java.util.Enumeration pprincipals = (team2.getPrincipalTarget(role));
System.out.println(pprincipals.toString());
try {
while (pprincipals!=null&&pprincipals.hasMoreElements()){
wt.org.WTPrincipal principal = ((wt.org.WTPrincipalReference)pprincipals.nextElement()).getPrincipal();
System.out.println(principal);
}
}
catch (Throwable t)
{
System.out.println("Error extracting/removing the pre assigned approver(s).");
t.printStackTrace (System.err);
}



Greetings



Marc.

1 REPLY 1
Highlighted

RE: How to retrieve the principals from a product team role

Hi Marc,


Once you have the container team, you can get the Product Manager role directly without iterating over all of them:


WTGroup productManagerGroup = ContainerTeamHelper.service.findContainerTeamGroup(containerTeam,ContainerTeamHelper.ROLE_GROUPS,"PRODUCT MANAGER");



Then get the members and do what you want the the enumeration.


Enumeration roleEnum = productManagerGroup.members();


Hope this helps.



~Jamie

Announcements