cancel
Showing results for 
Search instead for 
Did you mean: 

Teamcenter Service: ProjectLevelSecurity.ModifyProjectsInfo

Creator
Creator

Hello,

I am using ProjectLevelSecurity.ProjectOpsResponse modifyProjects(ProjectLevelSecurity.ModifyProjectsInfo[] modifyProjectsInfos) to be able to manage projects. My objective is to perform the following operations:

  • Add new members
  • Remove existing members
  • Change status of members (privileged/non-privileged)

I did some tests but I am not geeting the desired behaviour.

 

Steps:

  1. I created a project with the following members: Administrator, Alice Developer(Privileged user), Max Power(non-privileged member).1.png
  2.  Next I want to remove users Alice and Max from the Project. So from the soa_client sample project HelloTeamcenter I call the following class: 
package com.teamcenter.hello;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.strong.core.ProjectLevelSecurityService;
import com.teamcenter.services.strong.core._2012_09.ProjectLevelSecurity;
import com.teamcenter.services.strong.core._2012_09.ProjectLevelSecurity.ModifyProjectsInfo;
import com.teamcenter.services.strong.core._2012_09.ProjectLevelSecurity.ProjectInformation;
import com.teamcenter.services.strong.core._2012_09.ProjectLevelSecurity.ProjectOpsResponse;
import com.teamcenter.services.strong.core._2012_09.ProjectLevelSecurity.TeamMemberInfo;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.Property;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.GroupMember;
import com.teamcenter.soa.client.model.strong.TC_Project;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.exceptions.NotLoadedException;

public class ProjectManagement {

	private final String projectUID = "wxThN2f8YH3MfD"; 
	 // Team administrator
	private final String userId = "gsbhlo7zYH3MfD";	
	private final String grpMemberId = "QlWhX76hYH3MfD";

	private TC_Project project;
	private User teamAdmin;
	private GroupMember grpMember;

	public void modifyProjects()
	{
DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection());
		ServiceData sData = dmService.loadObjects(new String[] {projectUID, userId, grpMemberId});			
		project = (TC_Project) sData.getPlainObject(0);
		teamAdmin = (User) sData.getPlainObject(1);
		grpMember = (GroupMember) sData.getPlainObject(2);

        ProjectLevelSecurityService prjService = ProjectLevelSecurityService.getService(AppXSession.getConnection());
        
        ModifyProjectsInfo modifyInput = new ModifyProjectsInfo();
        ProjectInformation projInfo = new ProjectInformation();       
	TeamMemberInfo memberInfo[] = new TeamMemberInfo[2];       
        
	memberInfo[0] = new TeamMemberInfo();
        memberInfo[0].teamMember = teamAdmin;
        memberInfo[0].teamMemberType = 2;
              
        memberInfo[1] = new TeamMemberInfo();
        memberInfo[1].teamMember = grpMember;
        memberInfo[1].teamMemberType = 0;

        projInfo.projectDescription = "Project 4";
        projInfo.projectName = "Project 4";
        projInfo.projectId = "4";
        projInfo.active = true;
        
        projInfo.teamMembers = memberInfo;

        modifyInput.sourceProject = project;
        modifyInput.projectInfo = projInfo;
                      
        ProjectOpsResponse resp = prjService.modifyProjects(new ModifyProjectsInfo[] {modifyInput});
        
        if(!ServiceDataError(resp.serviceData))
        {
        	System.out.println("Project succesfully Modified !");
        }
        else
        {
        	System.out.println("Project Modification failed ...");
        }
       
        System.out.println("-> ProjectManagement() -> modifyProjects()");
        
	}
	
    protected boolean ServiceDataError(final ServiceData data)
    {
       if(data.sizeOfPartialErrors() > 0)
       {
           for(int i = 0; i < data.sizeOfPartialErrors(); i++)
           {
	           for(String msg : data.getPartialError(i).getMessages())
	                          System.out.println(msg);
           }
           
           return true;
       }
       
       return false;
    }
}

The resulting output is as follows:

 

 

 

The members Alice and Max are still present in the project and the only change is that the status of user Alice has been changed from “Privileged” to “Non-Privileged”. I was expecting users Alice and Max to be removed since according to https://docs.plm.automation.siemens.com/data_services/resources/tc/11.2.3/tcrefs/en_US/custom/servic...

It says, “The entire Project Team, with the exception of the Project Administrator, is replaced with the specified team.”

 

Is this behaviour normal or should the users have been removed from the project?

Thank you very much for your help.