PLM之家PLMHome-工业软件与AI结合践行者

Teamenter SOA开发源码:通过user ID 找 User

[复制链接]

2018-10-9 01:46:46 3374 0

admin 发表于 2018-10-9 01:46:46 |阅读模式

admin 楼主

2018-10-9 01:46:46

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
# J: X/ X% ?/ G: F
Teamenter SOA开发源码:通过user ID 找 User) a6 G$ @$ O& {, U
" ^2 _+ ?4 v; v- D5 z# F
[mw_shl_code=applescript,true]import com.Teamcenter.services.strong.query.SavedQueryService;
% \$ s0 g" a- n) B! F  Mimport com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;
  U/ Q  T5 o$ w( n" @import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;- `8 {  [0 P0 ?; Y0 ?
import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;
! n& ]: @# F: ^; H; J" M* x# Yimport com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;$ G# |; u: W- s( ^
import com.teamcenter.services.strong.core.DataManagementService;/ A7 G4 A1 i3 a/ |3 O, i9 z8 K* c
import com.teamcenter.soa.client.model.ModelObject;, D  x( |2 D7 _$ o* H
import com.teamcenter.soa.client.model.ServiceData;% l" Y/ W: P8 U0 a. _/ Z. u# P' c
import com.teamcenter.soa.client.model.strong.ImanQuery;
" K& a' m4 [1 [
) A5 ~$ t  W( c$ g4 g6 vimport com.teamcenter.soa.client.model.strong.User;5 c9 z/ T$ Z! @8 M5 y% t+ O

1 `- n5 c- D+ o: t! [! ~9 D1 P! t
    public User findUser(String userId)
: w5 `7 b8 c' c& l1 b    {  t5 e( c9 R& l4 j4 s  h% i. x6 W( o
        ImanQuery query = null;- `9 t7 @& y- p2 m) w! h7 ]6 v
        User user = null;1 F# p6 T5 X3 k% R; g" ?$ f" [
        
; P3 L3 ]: D* N3 K' N: ^
- U2 \9 d" C* R6 l  m: X        SavedQueryService queryService = SavedQueryService.getService(AppXSession.geTConnection());
( Y1 E0 X) }- q" e" P        DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());: D; W) U- K2 o4 B6 P& \
        
8 N' B' ~* o% e9 P3 R1 N) t        try
9 J' Y: }. x$ {        {0 U2 z& c. q- c  X, n% v
            GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
; a2 V# v4 D4 j+ [            if (savedQueries.queries.length == 0)# O, r* P2 W: ]5 \4 D( d
            {8 o% G) `7 x5 Q; q5 o( `
                System.out.println("There are no saved queries in the system.");
: m- X! O4 s4 |2 I, \3 W                return user;9 h' V; p& G4 G9 h
            }
. D/ }7 I( k5 s- o7 F. p            
# a8 ]# @1 f2 k/ [! S4 W0 E' T+ i1 o7 f            for (int i = 0; i < savedQueries.queries.length; i++)
+ n3 a+ D  J' G0 N            {
: d! @+ e! k' x8 w9 U; G3 @6 W: Y6 D1 N/ Y: w
                if (savedQueries.queries.name.equals("__WEB_find_user"))
7 E' Z& L, V" E9 U/ K  e                {' B6 q- V$ K! Y6 ^
                    query = savedQueries.queries.query;
+ W3 h0 `  {  |/ N6 J- M* H6 K                    break;  l8 W1 D4 J: y7 X! s
                }- T  y$ m, K: ~: M
            }: |$ ]. {- h6 J2 J5 q. O
        }
8 c, e) A% U3 t        catch (ServiceException e)
# f' G0 q4 U+ L! J3 b        {
5 Z' U  Q8 d! ]- ]" U  J, p: ?            System.out.println("GetSavedQueries service request failed.");
: e- }5 m7 }$ P. t! h, f            System.out.println(e.getMessage());' w, R- {' }# g: d% T
            return user;4 O) g6 h& V% ^0 X2 E
        }) r: W5 |2 F) f( ]# o* d- O
0 `& k5 C  G4 J5 g* m& Q
        if (query == null)
8 z- z. m* X9 p0 t: F2 i. h( l5 X        {' s$ l0 y9 L) U
            System.out.println("There is not an '__WEB_find_user' query.");
, R5 `# Q( e7 j7 j% @2 c' _            return user;- a; d/ n7 b0 v2 M
        }9 y( i) @  a) F/ m

6 u! O# q1 g; s7 s2 X. u        try* F# w0 r0 n$ F: L* G' i' x
        {
6 g, t/ w/ O$ H1 W7 l( C0 T            QueryInput savedQueryInput[] = new QueryInput[1];
8 o- [$ h5 n( u7 ~: _2 c( y. m            savedQueryInput[0] = new QueryInput();( Y3 F+ V$ I( H! {
            savedQueryInput[0].query = query;
* z4 i  ^" C" r- w$ u0 r+ X            savedQueryInput[0].entries = new String[1];
; p: o0 ^' G$ m4 e            savedQueryInput[0].values = new String[1];: T' V& A, ~2 h
            savedQueryInput[0].entries[0] = "User ID" ;
  s# x4 c6 r% {            savedQueryInput[0].values[0] = userId;) H1 B. b$ T5 S& ^. h$ f
            savedQueryInput[0].maxNumToReturn = 25;
# i# v7 Z+ V; N, k4 w) h            7 s0 W  t- V3 ?7 D9 W
            SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
9 Z5 T0 g2 z; T/ u  L7 V            QueryResults found = savedQueryResult.arrayOfResults[0];
; W2 Q# T9 l4 L9 W! w6 b  F4 ], b' _+ ~) v9 {( G% h- r5 S
            int length = found.objectUIDS.length;
. @7 d5 y. R" R            
3 f- [# E4 q% e3 B1 `+ l" u            String[] uids = new String[length];
3 S: }$ b# a8 g2 O            for( int ii = 0; ii < length; ii++)% g% L; H! Y4 l" ~
            {
# G" k' O4 m5 ]. Y* U                uids[ii]= found.objectUIDS[ii];+ \$ Y0 b) A" @' [  R* D
            }) ]0 |) M6 x1 m. c* u
            ServiceData sd = dmService.loadObjects(uids);
/ u6 f% B5 ~0 {/ w) t/ {# R            ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];9 t) Y+ O4 L& N0 s% R9 A
            for( int k =0; k< sd.sizeOfPlainObjects(); k++)* F, g# Q3 W+ Y: J3 }
            {
6 b& C4 g3 ^- \9 N: v' `6 e                foundObjs[k] = sd.getPlainObject(k);) S* p/ |* Y- ^. \+ `4 z
            }- x, u# o- J" S( o. E; y( w  W
            user = (User) foundObjs[0];   
+ r# d! \0 ~7 v& I  P. r, H        }
. H# n, n: m6 M1 S$ S: A% O, Q5 ]        catch (Exception e)7 s" u* x2 ?' d) s$ u2 k9 _% F
        {
4 D; D+ j/ L0 M2 M            System.out.println("ExecuteSavedQuery service request failed.");
% f+ O2 E. O- G$ `! s            System.out.println(e.getMessage());
/ j6 Z  J3 @5 Y. e6 b0 ?        }            
- Y7 Y, b* v1 A3 h( G0 X        return user;
5 X  s2 r% N; n9 \4 `    }) P7 ?. P. r/ a# T! t  A3 ^
[/mw_shl_code]3 K% |9 S% B: G
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了