PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2018-10-9 01:46:46 | 显示全部楼层 |阅读模式

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

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

x

5 V- g" u, X9 H7 c1 xTeamenter SOA开发源码:通过user ID 找 User
( r! n/ t1 \# {, ^
. u: |2 _' x+ c. ~[mw_shl_code=applescript,true]import com.Teamcenter.services.strong.query.SavedQueryService;7 r' v. P6 X3 W1 S- u  X
import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;
7 D: x$ x' `- O' l+ B" s5 Himport com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;
1 v2 n/ l/ H( b! F: bimport com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;8 Y9 w9 O" b2 {  |
import com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;: e2 t% v: W0 o2 d! w; m) V" F3 Q
import com.teamcenter.services.strong.core.DataManagementService;
. p  o) [$ p# v: Q/ a" E- W2 Wimport com.teamcenter.soa.client.model.ModelObject;
' y2 L; S+ N" h5 B. X* d( @import com.teamcenter.soa.client.model.ServiceData;5 K1 F5 H% v5 g  h0 k7 L' e
import com.teamcenter.soa.client.model.strong.ImanQuery;" s, ^7 w4 j0 L. U1 G. e9 z
# O9 f& g  K6 \2 u$ J- `2 G! b
import com.teamcenter.soa.client.model.strong.User;
2 e; D' ^0 z: o7 j" p
& x8 j8 @' I5 I! F. f
8 N- k% \' R% w2 n- [+ N2 m% f; p$ W: p    public User findUser(String userId)& e' G" Q& o6 q4 m% j
    {
0 q1 f7 V! Z! M7 {4 Z2 [# }        ImanQuery query = null;
* _% y. W8 n2 v; y+ A        User user = null;1 }. O3 K6 r: v3 i4 j) K
        ( O. {2 ?( I# P4 ?$ U8 m. R
. B( G2 X6 \6 g9 o0 x2 j
        SavedQueryService queryService = SavedQueryService.getService(AppXSession.geTConnection());- E! V" C- p9 _
        DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());
, G4 K: S* _6 D. V4 L/ y: j        $ J" k& I+ ?$ o2 h, A3 c& F& W
        try
1 o0 @2 D6 c9 o, _$ X        {) L+ }2 Q4 f# h+ C: `1 F+ O& S: u" o
            GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();  |0 t4 Q* {' m  S3 i: D, v  ~
            if (savedQueries.queries.length == 0)
$ N/ b  I& F) ~5 _7 e9 _7 W            {
$ Y; N! R9 V  R5 R) E                System.out.println("There are no saved queries in the system.");% f% B1 E2 f& U- X# k. ?) ^
                return user;
$ o6 @. E; J* m( Y9 j% _- n1 r0 S            }, K1 e6 o9 n7 v; E- T
            # y6 x# u3 s/ l, F8 s( a1 H0 x) f
            for (int i = 0; i < savedQueries.queries.length; i++)# n8 h; {. a6 [) ^
            {; s/ f8 A$ h9 y: F/ d+ y! O. H% ^
1 f; _5 p: `' v
                if (savedQueries.queries.name.equals("__WEB_find_user"))# K+ ]1 g: `  e8 n8 i
                {9 M- j' P" p: V3 Y& W
                    query = savedQueries.queries.query;
  `% D) N5 d7 P. J" f" \/ l) S# L                    break;
2 W2 o4 n8 j2 d5 k: u( p                }
: h* X4 P1 Q- P5 G            }
: I# w0 g) K. N$ x+ A8 B5 {        }
# d- R+ M, c, o* y4 Z9 x        catch (ServiceException e)
5 H( W8 U' R5 q+ U2 `, R        {
) x* @! h8 [3 p$ `/ y            System.out.println("GetSavedQueries service request failed.");
: o0 y! ~0 q3 B1 N) K            System.out.println(e.getMessage());
( L7 ?1 k4 X  i+ u- c4 l            return user;3 k0 j! E8 k# d9 |: [" M# ^
        }
/ W1 t3 @* S; m3 O, t# J- a% S8 B% e$ K( f( ~
        if (query == null)
9 _/ G3 J, n' v8 T: Z' K. G        {
" ~+ z& \; H& E+ {& L: X) a+ C% o* M            System.out.println("There is not an '__WEB_find_user' query.");2 _6 f- t( p' x, x7 y( J1 r
            return user;/ o) G1 M4 B( k, k1 s* G- ~- E0 D
        }8 _6 G+ y) \" G; ]6 p! M) J% R
) c4 V9 @7 _; H9 y. K
        try0 Q+ G) h. D& M" F  [
        {8 ?% I8 u0 d$ d3 I+ N$ l* v1 H
            QueryInput savedQueryInput[] = new QueryInput[1];) w! |- h; _* ^" b
            savedQueryInput[0] = new QueryInput();
* x5 y  h. q+ Z            savedQueryInput[0].query = query;
2 h0 F. g# \% s+ V            savedQueryInput[0].entries = new String[1];
0 d7 n! o* A! j4 c            savedQueryInput[0].values = new String[1];; R* P. @% W$ J, `
            savedQueryInput[0].entries[0] = "User ID" ;
- A8 s5 Y7 J' N( U  g            savedQueryInput[0].values[0] = userId;: G9 y' p" y  a
            savedQueryInput[0].maxNumToReturn = 25;
, V) I( b; g0 o            
% N) n6 ]% I7 q+ ~            SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
# `0 E* }5 V* [! Z5 @2 _            QueryResults found = savedQueryResult.arrayOfResults[0];- g+ A8 V0 @7 [' P- J- ~+ t, l8 {

" T' O$ E3 o1 W5 m            int length = found.objectUIDS.length;( S4 x0 u8 N9 A8 Z
            * J, x. b+ Y3 }% w4 @
            String[] uids = new String[length];
# N! b" D* K" H# J  c$ W& R: m            for( int ii = 0; ii < length; ii++); T" q0 i3 E9 ~- ]/ N8 H$ r8 P
            {% N% g& s, {6 e) E4 a6 J- K
                uids[ii]= found.objectUIDS[ii];1 ^0 Y! {2 O, _3 K. ^; P
            }: A% q2 ]& u8 I8 B
            ServiceData sd = dmService.loadObjects(uids);
# k- @1 p# L  A' J            ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];% ^  s% Y  C+ K: d5 W: {6 C
            for( int k =0; k< sd.sizeOfPlainObjects(); k++)( f$ L+ o, g" Y( [9 _
            {2 |/ S+ v1 }8 p3 P3 v0 R! R
                foundObjs[k] = sd.getPlainObject(k);
  ?% P+ A" p- X: |            }
0 ^( N8 ?- y' I            user = (User) foundObjs[0];   
( ~2 Q0 Q( f5 l3 u7 K/ P        }
+ g" p" S# q8 l; x        catch (Exception e)
5 n- X3 N& \$ J0 S1 I' {        {/ N" C8 z9 F4 O$ ]5 W
            System.out.println("ExecuteSavedQuery service request failed.");
; f( b, z; i7 }: R+ a: Q. k            System.out.println(e.getMessage());
8 H  ~: W1 i7 R8 g2 J) c3 N        }            2 A- c7 }: r! X0 K! x4 l8 W
        return user;
2 u) @- N! S8 x' ]: S    }# A- x2 w( F+ e& ^) B1 h: m+ D( ~
[/mw_shl_code]
! s- E$ y! R" p$ a5 T! Q! D
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了