使用 WebSphere Process Server 关系开发集成解决方案
http://tech.ddvip.com 2008年06月12日 社区交流 收藏本文
内容摘要:本文将介绍 WebSphere Process Server Relationship Service 的功能(包括 V6.1 中的新功能),并说明使用这些功能的场合。之前掌握 Process Server 的相关知识将会有所帮助,但并非必须的。
[create|retrieve|deactivate|delete|exists]Participant 创建、检索、禁用或删除参与者。参与者是给定实例中的角色的值,可以为简单值,也可以为业务对象。 [exists|deactivate|delete]ParticipantByID 按实例 ID(与按值操作的方式相对)检查参与者是否存在、禁用或删除。 addParticipantWithID 将新参与者添加到给定实例(仅用于多对多关系) retrieveInstanceIDs 返回给定角色的参与者的 ID 数组。对于身份关系,该数组最多只能包括一个实例 ID。 staticLookup 根据输入业务对象中的属性值在输出业务对象中查询属性值(6.1 中新推出的功能) correlate 在动态关系中自动维护两个业务对象间的相关性(6.1 中新推出的;以前为 maintainIdentity) [get|set|unset][Relationship|Role]Property 将属性(如创建时间)与角色或关系实例关联
清单 1 显示了采用编程方式检索、添加和删除实例数据的代码示例。
清单 1. 使用关系实例数据的 CRUD API 元素
//locate the Relationship Service
RelationshipService relService = (RelationshipService)ServiceManager.INSTANCE.
locateService("com/ibm/wbiserver/rel/RelationshipService");
//The names of our relationship and its roles
String relationshipName = "http://CRMLib/StateCode";
String roleName_full = "http://CRMLib/FullStateName";
String roleName_code = "http://CRMLib/StateCode";
//programmatically query a lookup relationship
String fullName = "California";
String code = null;
int[] ids =
relService.retrieveInstanceIDsByString(relationshipName, roleName_full, fullName);
if( ids.length > 0 ){
List codes = relService.retrieveParticipants(relationshipName, roleName_code, ids[0]);
if( !codes.isEmpty() )
code = (String)codes.get(0);
}
//add a new relationship instance
String newFullName = "Alabama";
String newCode = "AL";
int genId =
relService.addParticipantString(relationshipName, roleName_full, newFullName);
relService.addParticipantStringWithID(relationshipName, roleName_code, genId, newCode);
//remove relationship instance
relService.deleteParticipantString( relationshipName, roleName_full, newFullName);
relService.deleteParticipantString(relationshipName, roleName_code, newCode);
来源:ibm 作者:Benjamin Busjaeger 责编:豆豆技术应用