CE中choiceList取值

   需求中需要从choiceList中去的数据,找了一些代码但是因为缺少UserContextUtils.pushSubject(userSession.getSubject());一直报错,后来经过伟东的帮忙解决了。

下面是该过程的代码,应为需要的数据形式 不同所以代码里经过了一些修饰,核心代码为红色标记。

 

 

 
public  String getSystemNames(UserSession userSession){
		try{
			UserContextUtils.pushSubject(userSession.getSubject());
			return choiceListUtil.getSystemNames(userSession.getObjectStore());
		}catch(Exception e){
			logger.error("choiceList cannot be get due to the reason:" + e.getMessage());
			return "";
		}finally{
			UserContextUtils.popSubject();
		}
	}

/**
	 * @Title: getSystemNames
	 * @Description: 查询CE中系统名称
	 * @param @return    设定文件
	 * @return String    返回类型
	 * @throws
	 */
	public  String getSystemNames(ObjectStore objectStore){
		String systemNames = "<item label=\"信息系统名称\">";
		try {	
			ChoiceList fetchInstance = Factory.ChoiceList.fetchInstance(objectStore, new Id(ConfigUtils.getIsChoiceListId()), null);		
			com.filenet.api.collection.ChoiceList choices = fetchInstance.get_ChoiceValues();
			
			systemNames = cycleChoiceList(systemNames, choices);	
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		systemNames += "</item>";
		//System.out.println(systemNames);
		
		return systemNames;
	}
	
	//ChoiceList 
	@SuppressWarnings("rawtypes")
	private  String cycleChoiceList(String systemNames, com.filenet.api.collection.ChoiceList choices) {		
		try {
			Iterator iter = choices.iterator();
			while(iter.hasNext()){
				Choice choice = (Choice) iter.next();
				systemNames += "\n";
				systemNames += "  <item label=\""+ choice.get_Name() +"\">";
				if(choice.get_ChoiceType() == com.filenet.api.constants.ChoiceType.MIDNODE_STRING) {
					com.filenet.api.collection.ChoiceList clist = choice.get_ChoiceValues();
					systemNames = cycleChoiceList(systemNames, clist);
				}
				systemNames += "</item>";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}		
		systemNames += "\n";
		return systemNames;
	}


另外ConfigUtils.getIsChoiceListId()是从FCM中的choicelist的properties中查看的相应的choiceList的ID值。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值