|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
8 @2 z. E R1 k+ J1 DTeamenter SOA开发源码:通过user ID 找 User+ V/ o5 _- X; ] a
; w/ a* e4 g* ]# R2 t' i; m% F
[mw_shl_code=applescript,true]import com.Teamcenter.services.strong.query.SavedQueryService;5 T6 \6 P' r, I( w! b
import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;2 W# I9 V9 }/ @
import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;8 @( Y6 l# _# |! O& U/ @
import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;5 S3 s* |% Q1 m3 f
import com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;
, Z, c$ {! W+ w2 o0 F6 C( Qimport com.teamcenter.services.strong.core.DataManagementService;
& ?1 `: J: x2 J* k' H% ~8 ximport com.teamcenter.soa.client.model.ModelObject;
6 }3 h" O, q1 |import com.teamcenter.soa.client.model.ServiceData;
3 U6 F5 I6 K1 O; p4 W5 fimport com.teamcenter.soa.client.model.strong.ImanQuery;
# B) ]4 |, T* B _0 D0 [0 J# ~" m) [+ a$ i5 o
import com.teamcenter.soa.client.model.strong.User;0 A3 L" C/ F5 ?8 m( x" a/ a& t
1 N: a) F0 P- n% D+ [. t
* y% U5 f! H' s
public User findUser(String userId)' C1 t+ @( y" f5 N0 S0 k5 z7 t- U
{
n6 e# O* [# @& X ImanQuery query = null;
+ q3 G Q( u7 {) w8 [! } User user = null;! r$ q) U, O" F" n4 h& b
& e8 S3 R1 L$ G! R8 ]$ n& u. o, c5 |
SavedQueryService queryService = SavedQueryService.getService(AppXSession.geTConnection());
4 q2 f5 i4 u% y L0 u( R" x. g DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());
+ y8 d3 d) ~3 a# p! a
* G7 t8 Y* T( ~! u* c/ _7 y try
/ e. s3 G1 ]! O$ L8 Y+ b {
B1 T* G8 L$ a8 a6 A GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
+ {4 G/ O: F* H; M if (savedQueries.queries.length == 0)
+ E% ^% o/ k2 B b( t, o {
! G6 ~" F* z" X n2 l System.out.println("There are no saved queries in the system.");
* D1 E# | K3 N9 j }, h return user;
/ s* }1 F H( F# O: T+ M8 a }
/ \) |9 S; ?$ t" E* R 8 J9 p& ?' d! `
for (int i = 0; i < savedQueries.queries.length; i++)
6 j/ j1 q5 c: f3 i {% y* c* v( R0 S3 [
$ v9 v% B* F5 ?9 ]1 k. I4 y' b/ N4 G7 C if (savedQueries.queries.name.equals("__WEB_find_user"))6 j T$ \2 |- \+ G0 F2 @
{
( {# b( V2 F2 P: a$ j query = savedQueries.queries.query;9 t2 y/ p% G, R
break;; h p9 j2 ]6 M2 j4 [1 X- f
}
$ w3 d; N0 U. E/ C9 c, @4 q }4 M; h9 f2 X3 y% n" _1 @. }
}" E; l' X* P1 [1 T6 J' x$ b# @( u
catch (ServiceException e)8 j) }/ T- K& J9 G
{
/ i. I- h2 O& v- A# A5 Q System.out.println("GetSavedQueries service request failed.");( ?; g# o0 Q1 z+ f$ c
System.out.println(e.getMessage());
' _5 c2 J/ V9 n- [ return user;
3 b: d7 m; O8 u$ G2 z }: O: p, _0 K6 F2 D8 C
" X( S* J" O4 S" J1 w, ?4 Q
if (query == null)
0 U [/ c* L& R/ C! M {' j( Y/ C1 ^5 [& m! k5 W% y
System.out.println("There is not an '__WEB_find_user' query.");. j- Y& D$ a" F- P0 E: ?/ e
return user;
. E0 V; u0 Q" V5 O% G- z" [ }" U5 ^ J- g9 @% P/ X/ J
2 x v$ J2 p; D9 M( t
try
F. k: s% t! I% `6 A% l {8 r# O9 `& Z' H& Z3 l: x7 j3 R
QueryInput savedQueryInput[] = new QueryInput[1];" V# {' _9 L' h2 A
savedQueryInput[0] = new QueryInput();
8 A2 x7 |: T3 F) y savedQueryInput[0].query = query;: h5 X2 }* K2 ]3 c
savedQueryInput[0].entries = new String[1];5 H4 X3 U& N, M- a" D3 N
savedQueryInput[0].values = new String[1];
5 Y: J; }/ i6 H) R savedQueryInput[0].entries[0] = "User ID" ;
) O7 k5 H8 U+ V# H1 k" ?# y savedQueryInput[0].values[0] = userId;! T- ?- S) h1 V8 e$ w1 \; Y- V* p0 V% J
savedQueryInput[0].maxNumToReturn = 25;
- |) G1 W- P+ C5 U! d! H5 ^- {( P
0 ^* K& N2 Z% K2 _" } SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);4 S" n( e$ A$ u1 m
QueryResults found = savedQueryResult.arrayOfResults[0];0 P% w' H2 k4 C. Z0 W" f+ {3 W
" ]$ D) g; L1 i7 }0 g4 U5 j int length = found.objectUIDS.length;
. I1 X6 y9 q P+ \$ T 1 K* e- m) i& D7 I
String[] uids = new String[length];
$ \' ]. S! c+ }6 w for( int ii = 0; ii < length; ii++)/ R( w% F# }" S; g+ E4 X" e
{. d3 P* x$ F& o# Y! D( G1 N
uids[ii]= found.objectUIDS[ii];
) X3 r: K. P. D3 ] }$ \* ?7 s+ E, C5 _* J9 z$ }' w
ServiceData sd = dmService.loadObjects(uids);# n) i8 J% ?- j y0 e
ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];
& Y6 }" N+ K/ @' N+ _ for( int k =0; k< sd.sizeOfPlainObjects(); k++)
9 G% s. u% R$ C+ u {+ P; P1 U3 h1 _5 ]5 y2 Q
foundObjs[k] = sd.getPlainObject(k);8 D; b y, ~+ B+ F2 V5 Y
}
4 v5 F" W7 t% w user = (User) foundObjs[0]; , \8 n6 |$ B+ s2 b% r& r
}
( Q8 n0 i/ f, ?6 I) \: [8 v catch (Exception e)
/ Z o4 f r' w t$ n! D5 K. U/ D- G8 E {
1 c/ h( n; c4 B+ f4 V System.out.println("ExecuteSavedQuery service request failed.");
: q5 t, N4 h+ g7 c2 O8 z1 _ System.out.println(e.getMessage());
, W/ d3 Q' D' S( r } & j1 S# d) {* }
return user;% [9 {- V* s" t, `/ R3 R
}" X$ e. O* I& O, U
[/mw_shl_code]5 C' V' g# o, B" g0 G
|
|