Teamenter SOA开发源码:通过user ID 找 User
Teamenter SOA开发源码:通过user ID 找 User
import com.teamcenter.services.strong.query.SavedQueryService;
import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;
import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;
import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;
import com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.ImanQuery;
import com.teamcenter.soa.client.model.strong.User;
public User findUser(String userId)
{
ImanQuery query = null;
User user = null;
SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection());
DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());
try
{
GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
if (savedQueries.queries.length == 0)
{
System.out.println("There are no saved queries in the system.");
return user;
}
for (int i = 0; i < savedQueries.queries.length; i++)
{
if (savedQueries.queries.name.equals("__WEB_find_user"))
{
query = savedQueries.queries.query;
break;
}
}
}
catch (ServiceException e)
{
System.out.println("GetSavedQueries service request failed.");
System.out.println(e.getMessage());
return user;
}
if (query == null)
{
System.out.println("There is not an '__WEB_find_user' query.");
return user;
}
try
{
QueryInput savedQueryInput[] = new QueryInput;
savedQueryInput = new QueryInput();
savedQueryInput.query = query;
savedQueryInput.entries = new String;
savedQueryInput.values = new String;
savedQueryInput.entries = "User ID" ;
savedQueryInput.values = userId;
savedQueryInput.maxNumToReturn = 25;
SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
QueryResults found = savedQueryResult.arrayOfResults;
int length = found.objectUIDS.length;
String[] uids = new String;
for( int ii = 0; ii < length; ii++)
{
uids= found.objectUIDS;
}
ServiceData sd = dmService.loadObjects(uids);
ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];
for( int k =0; k< sd.sizeOfPlainObjects(); k++)
{
foundObjs = sd.getPlainObject(k);
}
user = (User) foundObjs;
}
catch (Exception e)
{
System.out.println("ExecuteSavedQuery service request failed.");
System.out.println(e.getMessage());
}
return user;
}
页:
[1]