Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
seen this code &/or request for containerteam, role, users or grups & its users, when I had a similar task.
So I generated some code to generate output to show tree (somewhat) of the above.
the zip with codce/class/readme/sample output is in zip on my site:
http://www.datajett.com/windchill/wc_dev/TeamRoleParticipants.zip
readme is:
http://www.datajett.com/windchill/wc_dev/TeamRoleParticipants/TeamRoleParticipants_readme.txt
Sample output is:
http://www.datajett.com/windchill/wc_dev/TeamRoleParticipants/TeamRoleParticipants_090510_232140.txt
class/java are in zip or same folder.
I will throw java at end of message, so future searches will find its methods/etc.
command line is: java ext.TeamRoleParticipants & this will throw output to screen.
it will take one arg if you want to create time stamped file in a chosen directory (dir path is arg):
java ext.TeamRoleParticipants c:\temp
/**/ can be replaced with tabs for java creation, but the /**/ is used for formatting & makes for better viewing.
Let me know if you see errors &/or need adds. The user fullname, phone, email, etc was left off, but could be easily added.
Larry Jett
cadjett@aolo.com;datajett@aol.com
code:===============================
package ext;
import java.io.*;
import java.util.*;
import java.text.*;
import wt.query.*;
import wt.fc.*;
import wt.team.Team;
import wt.project.Role;
import wt.inf.team.ContainerTeam;
import wt.project.Role;
import wt.org.*;
import wt.org.WTUser;
import wt.org.WTOrganization;
import wt.org.WTGroup;
import wt.org.WTPrincipal;
import wt.org.WTPrincipalReference;
import wt.inf.team.*;
import wt.inf.container.*;
import wt.inf.container.WTContainer;
import wt.projmgmt.admin.*;
import wt.method.RemoteMethodServer;
import wt.httpgw.GatewayAuthenticator;
public class TeamRoleParticipants{
/**/static File outPath;
/**/static PrintWriter printwriter;
/**/public static void main(String[] args) throws Exception{
/**//**/RemoteMethodServer rms = RemoteMethodServer.getDefault();
/**//**/GatewayAuthenticator auth = new GatewayAuthenticator();
/**//**/auth.setRemoteUser("wcadmin");
/**//**/rms.setAuthenticator(auth);
/**//**/boolean writeFlag = false;
/**//**/if(args.length == 1)
/**//**/{
/**//**//**/writeFlag = true;
/**//**//**/SimpleDateFormat df = new SimpleDateFormat ("MMddyy_HHmmss", Locale.getDefault());
/**//**//**/java.util.Date tm = new java.util.Date();
/**//**//**/String dtStg = df.format(tm);
/**//**//**/outPath = new File(args[0]+"\\TeamRoleParticipants_"+dtStg+".txt");
/**//**//**/System.out.println( "\nWriting Ouput to File: "+args[0]+"\\TeamRoleParticipants_"+dtStg+".txt\n" );
/**//**/}
/**//**/if(writeFlag)
/**//**//**/printwriter = new PrintWriter(new FileWriter(outPath));
/**//**/QueryResult resCTT=PersistenceHelper.manager.find(new QuerySpec(ContainerTeam.class));
/**//**/while(resCTT.hasMoreElements()) {
/**//**//**/ContainerTeam contTeam = (ContainerTeam)resCTT.nextElement();
/**//**//**/System.out.println( "\nContainerTeam: " + contTeam.getName()+"\n" );
/**//**//**/if(writeFlag)
/**//**//**//**/printwriter.println((new StringBuilder()).append("\nContainerTeam: " + contTeam.getName()+"\n").toString());
/**//**//**/Vector vector = contTeam.getRoles();
/**//**//**/int i = vector.size();
/**//**/label0:
/**//**//**/for(int j = 0; j < i; j++)
/**//**//**/{
/**//**//**//**/Role role = (Role)vector.get(j);
/**//**//**//**/System.out.println("\tRole: "+role.getDisplay());
/**//**//**//**/if(writeFlag)
/**//**//**//**//**/printwriter.println((new StringBuilder()).append("\tRole: "+role.getDisplay()).toString());
/**//**//**//**/ArrayList arraylist = contTeam.getAllPrincipalsForTarget(role);
/**//**//**//**/int k = 0;
/**//**//**//**/do
/**//**//**//**/{
/**//**//**//**//**/if(k >= arraylist.size()) {
/**//**//**//**//**//**/continue label0;
/**//**//**//**//**/}
/**//**//**//**//**/WTPrincipalReference wtprincipalreference1 = (WTPrincipalReference)(WTPrincipalReference)arraylist.get(k);
/**//**//**//**//**/WTPrincipal wtprincipal = (WTPrincipal)wtprincipalreference1.getObject();
/**//**//**//**//**/if(wtprincipal instanceof WTUser) {
/**//**//**//**//**//**/WTUser wtuser = (WTUser)wtprincipal;
/**//**//**//**//**//**/System.out.println( "\t\tUser: "+wtuser.getName());
/**//**//**//**//**//**/if(writeFlag)
/**//**//**//**//**//**//**/printwriter.println((new StringBuilder()).append("\t\tUser: "+wtuser.getName()).toString());
/**//**//**//**//**/}
/**//**//**//**//**/else if(wtprincipal instanceof WTGroup)
/**//**//**//**//**/{
/**//**//**//**//**//**/WTGroup wtgroup = (WTGroup)wtprincipal;
/**//**//**//**//**//**/System.out.println( "\t\tGroup: "+wtgroup.getName());
/**//**//**//**//**//**/if(writeFlag)
/**//**//**//**//**//**//**/printwriter.println((new StringBuilder()).append("\t\tGroup: "+wtgroup.getName()).toString());
/**//**//**//**//**//**//**/for(Enumeration enumeration = wtgroup.members(); enumeration.hasMoreElements();)
/**//**//**//**//**//**//**/{
/**//**//**//**//**//**//**//**/WTUser wtuser = (WTUser)enumeration.nextElement();
/**//**//**//**//**//**//**//**/System.out.println( "\t\t\tUser: "+wtuser.getName());
/**//**//**//**//**//**//**//**/if(writeFlag)
/**//**//**//**//**//**//**//**//**/printwriter.println((new StringBuilder()).append("\t\t\tUser: "+wtuser.getName()).toString());
/**//**//**//**//**//**//**/}
/**//**//**//**//**/}
/**//**//**//**//**/else if(wtprincipal instanceof WTOrganization)
/**//**//**//**//**/{
/**//**//**//**//**//**/WTOrganization wtorg = (WTOrganization)wtprincipal;
/**//**//**//**//**//**/System.out.println( "\t\tOrg: "+wtorg.getName());
/**//**//**//**//**//**/if(writeFlag)
/**//**//**//**//**//**//**/printwriter.println((new StringBuilder()).append("\t\tOrg: "+wtorg.getName()).toString());;
/**//**//**//**//**/}
/**//**//**//**//**/k++;
/**//**//**//**/} while(true);
/**//**//**/}
/**//**/}
/**//**/System.out.println("\nNumber of ContainerTeams: "+resCTT.size() + "\n");
/**//**/if(writeFlag) {
/**//**//**/printwriter.println((new StringBuilder()).append("\nNumber of ContainerTeams: "+resCTT.size() + "\n").toString());
/**//**//**/printwriter.flush();
/**//**//**/printwriter.close();
/**//**/}
/**/}
}
This is awesome Thanks Man it really helps alot
This is awesome Thanks Man it really helps alot 🙂