Cognos 8 SDK简介 下载本文

new BaseClass[group.getMembers().getValue().length - 1]; int index = 0; BaseClass obj = null; for (int i = 0; i < group.getMembers().getValue().length; i++) { obj = group.getMembers().getValue()[i]; BaseClass[] memberProps = csHandler.queryObjectInCS(connection, obj.getSearchPath().getValue()); if (memberProps[0] .getDefaultName() .getValue() .compareTo(member.getDefaultName().getValue()) != 0 && memberProps[0].getSearchPath().getValue().compareTo( member.getSearchPath().getValue()) != 0) { newMembers[index] = obj; index++; } } group.setMembers(new BaseClassArrayProp()); group.getMembers().setValue(newMembers); // 更新成员. csHandler.updateObjectInCS(connection, objects); }

/**

* 从指定角色中删除指定成员. *

* @param connection Cognos 8连接

* @param pathOfRole 角色的搜索路径. * @param member 成员对象. * */

public void removeFromRole( CRNConnect connection, String pathOfRole, BaseClass member)

throws java.rmi.RemoteException { //得到当前角色下的成员. PropEnum[] props = { PropEnum.defaultName, PropEnum.searchPath, PropEnum.members }; BaseClass[] objects = csHandler.queryObjectInCS(connection, pathOfRole, props); Role role = (Role)objects[0]; // 保留除待删除成员外的所有成员. BaseClass[] newMembers = new BaseClass[role.getMembers().getValue().length - 1]; int index = 0; String csMember; String csMemberPath; BaseClass obj = null; for (int i = 0; i < role.getMembers().getValue().length; i++) { obj = role.getMembers().getValue()[i]; BaseClass[] memberProps = csHandler.queryObjectInCS(connection, obj.getSearchPath().getValue()); csMember = memberProps[0].getDefaultName().getValue(); csMemberPath = memberProps[0].getSearchPath().getValue(); if ((csMember.compareTo(member.getDefaultName().getValue()) != 0) &&

(csMemberPath.compareTo(member.getSearchPath().getValue()) != 0)) { newMembers[index] = obj; index++; } } role.setMembers(new BaseClassArrayProp()); role.getMembers().setValue(newMembers); // 更新成员. csHandler.updateObjectInCS(connection, objects); }

/**

*删除指定用户组. *

* @param connection Cognos 8连接

* @param groupSearchPath 待删除组的搜索路径. * @return 返回成功字符串. * */

public String deleteGroup(CRNConnect connection, String groupSearchPath) throws java.rmi.RemoteException { //根据搜索路径创建对象 Group obj = new Group(); obj.setSearchPath(new StringProp()); obj.getSearchPath().setValue(groupSearchPath); //从内容库中删除 csHandler.deleteObjectFromCS(connection, obj); }

return (\

/**

* 删除指定的角色. *

* @param connection Cognos 8连接 * @param roleSearchPath 待删除的角色. * @return 返回的成功信息. * */

public String deleteRole(CRNConnect connection, String roleSearchPath) throws java.rmi.RemoteException { //根据搜索路径创建角色对象 Role obj = new Role(); obj.setSearchPath(new StringProp()); obj.getSearchPath().setValue(roleSearchPath); }

//从内容库中删除角色对象

csHandler.deleteObjectFromCS(connection, obj); return (\

/**

* 得到指定成员的信息. *

* @param connection Cognos 8连接

* @param pathOfUser 成员的搜索路径 * @return 返回成员信息. * */

public BaseClass[] getMemberInfo( CRNConnect connection, String pathOfUser) { //设置查询参数 BaseClass groups[] = new BaseClass[] {}; PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName }; try { //找到成员对象数组 groups = connection.getCMService().query( new SearchPathMultipleObject(pathOfUser), props, new Sort[] {}, new QueryOptions()); } catch (Exception e) { System.out.println(e); } return groups; }

/**

* 从指定组中找到成员 *

* @param connection Cognos 8连接

* @param group 组或角色的搜索路径. * */

public BaseClass[] getAvailableMembers(CRNConnect connection, String group) { //查找属性 PropEnum props[] =

new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName, PropEnum.members }; BaseClass[] availableMembers; try { //找出成员 availableMembers = csHandler.queryObjectInCS(connection, group, props); return availableMembers; } catch (java.rmi.RemoteException remoteEx) { remoteEx.printStackTrace(); return null; } }

/**

*找出指定名称空间下的组. *

* @param connection Cognos 8连接

* @param namespace 名称空间的搜索路径. * */

public BaseClass[] getAvailableGroups( CRNConnect connection, String namespace) { //查找属性 PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName }; BaseClass[] availableGroups; try { //找出所有的组 availableGroups = csHandler.queryObjectInCS(connection, namespace + \props); return availableGroups; } catch (java.rmi.RemoteException remoteEx) {