|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
$ }0 I! e) ?' R0 k" _% q$ _Teamenter SOA开发源码:通过user ID 找 User' K+ t$ e8 \7 N$ p
* f/ V9 Z* v; G+ G9 W% C. ?
[mw_shl_code=applescript,true]import com.Teamcenter.services.strong.query.SavedQueryService;
1 ]4 c3 M/ q d8 V% Ximport com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;0 x3 n1 J# F6 ]3 W4 {' v+ W
import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;% b' n& D6 Q+ M; \* t7 {1 k
import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;
k! i( F1 z1 rimport com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;
; N( u& p* ^9 Z w k$ \import com.teamcenter.services.strong.core.DataManagementService;: m' r- ]8 U2 e$ E# m
import com.teamcenter.soa.client.model.ModelObject;
$ |+ P: ?/ r* x u0 k" F* aimport com.teamcenter.soa.client.model.ServiceData;7 ^) Z. V+ j7 n0 l) ?8 E
import com.teamcenter.soa.client.model.strong.ImanQuery;
% g$ ^0 p1 y6 \3 e* n8 @" ?' _9 b1 s
import com.teamcenter.soa.client.model.strong.User;
* `0 V& |! g7 @4 y- }/ f$ B& @! I. x0 v' @9 _& T% w
/ Y; L& C r4 k) t( ~ public User findUser(String userId)
' O( o( h" p' I {
8 r+ B3 R& V! k/ G ImanQuery query = null;
0 p2 Y! n& P8 }/ d a1 y3 i8 v User user = null;
& g$ N# r/ t, u4 v. ^ a, B 8 ?8 d7 S3 N2 S6 I
, v% c* Y+ w; Q! t& z4 G7 l SavedQueryService queryService = SavedQueryService.getService(AppXSession.geTConnection());
1 w& J- ]: N& C L8 n7 Z6 p; l' j DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());$ B0 S0 L0 u# P+ z$ F9 [6 l
( E6 C0 s8 U3 D( l& V try; B: I a" M! u. Q7 K& G/ K! y
{
6 g6 z4 C; R4 d+ `8 F+ b GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
- V) L( X& R7 L; B if (savedQueries.queries.length == 0) @7 K) \/ L# y
{
4 F3 N7 `( I! p" g$ V# r6 g8 g6 X$ H6 H System.out.println("There are no saved queries in the system.");! n6 l! C* a6 Y, {
return user;" W2 b( a4 n4 M3 ^
}
$ g! B. ?- B+ f& v% D5 U2 B$ ]: B( Z' I ! Z. p! M, Q% G" t- a9 E: j
for (int i = 0; i < savedQueries.queries.length; i++)( A( ]6 v% L. W( C* S/ |9 l
{
, ]/ y; J4 a& C4 c# `) u$ R- h3 _
* Y n( P) Q; f& k& J1 h if (savedQueries.queries.name.equals("__WEB_find_user"))3 ` g; X+ i% d3 e0 j
{
4 G4 e9 m2 T: T( m8 W( Q6 V$ [ query = savedQueries.queries.query;
1 X, D" _. Q5 t& b# U break;
, z8 E' ~1 J1 q }* @ s# j5 A3 ?( ~7 u
}( E2 f6 _7 m+ \9 f* W% _
}
/ y' ]4 s2 y" _2 | W! m( v7 ~ catch (ServiceException e)0 z" h# m) m" ?! t. H
{- S- a4 C8 H q7 w2 q) b# L$ o# J
System.out.println("GetSavedQueries service request failed.");
! O9 ~4 f; \2 k- ?% g System.out.println(e.getMessage());3 f$ |/ K2 g5 N: v, w3 t; C
return user;0 @7 V: K; j/ D @" ?* E
}
' j( C, o, v, j1 @
9 v \/ }+ D Y6 K, {/ V if (query == null)
, J! o1 m/ U) u8 u, ] {3 M4 d! j |# @: K2 q
System.out.println("There is not an '__WEB_find_user' query.");
7 W# O' z9 p5 |( E% ` return user;$ }" [9 {6 y+ d+ X J Y2 A5 P: W
}
# `" l5 e; t0 Y5 F/ `8 Y' ` ^( u$ A% h, ^: z& r& n
try
3 x! B" M9 J& j" y {
$ c, Q% A2 E4 l+ | u( L4 q- ~ QueryInput savedQueryInput[] = new QueryInput[1];
' c- Z' K1 P% U4 m% ? m7 y& L savedQueryInput[0] = new QueryInput();2 Y/ J6 Z8 I5 d% X
savedQueryInput[0].query = query;9 l' |, W& G$ }2 \
savedQueryInput[0].entries = new String[1];
$ f. p) Q& d- |' R* Z savedQueryInput[0].values = new String[1];
: Z, F( d: m) R" Y savedQueryInput[0].entries[0] = "User ID" ;: i# f* o2 H& b3 b" k$ t
savedQueryInput[0].values[0] = userId; v1 d& J( C2 W3 l) v5 I4 s5 ~1 t
savedQueryInput[0].maxNumToReturn = 25;) T7 S |6 G1 Q/ [7 Y* r' j
2 ]* O1 x, v5 x) b# d9 p SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);; J2 M1 Q6 I5 j2 m( A: H4 m
QueryResults found = savedQueryResult.arrayOfResults[0];
" b) W7 A! R! _. V" V9 i) n: F- R! }) m5 T$ L( k
int length = found.objectUIDS.length;
: I- z$ |2 }1 X1 N 7 O* @+ w& B4 l- ^6 Z
String[] uids = new String[length];3 R! ~- _ h" H/ F6 G- i z
for( int ii = 0; ii < length; ii++)9 `4 c* Y* L& d/ U3 o5 {* y
{1 w! d: [/ g$ M X( t
uids[ii]= found.objectUIDS[ii];$ q9 w4 F4 ?2 X s* U" k
}
/ K+ m# ~% T3 X: T0 X' } ServiceData sd = dmService.loadObjects(uids);- D, E! @% N0 z% b3 b
ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];* I& P2 T/ n3 a3 b2 W
for( int k =0; k< sd.sizeOfPlainObjects(); k++)
% S' g- @# _% W+ b) B& S* t+ ~ {' w$ w- B8 [7 e; K d
foundObjs[k] = sd.getPlainObject(k);
. ~9 r; D$ O) A; \0 h& B4 n }
8 X$ W7 q. V2 M user = (User) foundObjs[0];
5 M% U4 X0 O& P' M: | S! j' M }
) l* O; s9 {0 R) H catch (Exception e)
. k! {& P% S# k h4 H* u: S {% @2 c. v* i' @3 M+ H
System.out.println("ExecuteSavedQuery service request failed.");$ h6 }; P+ Y! i6 c) O
System.out.println(e.getMessage());, c& F4 P& J2 w0 x5 u0 Y
} 5 M) Y! I$ \; S2 I
return user;: t9 g* n" r3 a0 H3 e
}- [9 }( z3 b1 X
[/mw_shl_code]
9 ]& ]9 k4 k/ e$ _' T1 {4 ]1 h4 { |
|