package com.vci.server.workflow.server.interfaceImpl; import java.util.ArrayList; import java.util.List; import com.vci.corba.bofactory.BOFactoryServicePrx; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.BusinessObject; import com.vci.corba.omd.data.LinkObject; import com.vci.server.base.utility.ServerServiceProvider; import com.vci.server.workflow.server.interfaces.IWorkflowUserService; import com.vci.common.log.ServerWithLog4j; public class WorkFlowUserParserNewImpl implements IWorkflowUserService { private BOFactoryServicePrx bofService = null; public String[] getAllUsers2Task(String[] paramArrayOfString, String userName) throws Exception { List canditates = new ArrayList(); ServerWithLog4j.logger.debug("用户解析类:WorkFlowUserParserNewImpl----------------------------------------"); List index = new ArrayList(); for(String s : paramArrayOfString) { String[] strs = s.split(","); for(String str : strs) { index.add(str); } } if (bofService == null) bofService = ServerServiceProvider.getBOFService(); paramArrayOfString = index.toArray(new String[0]); for (int i = 0; i < paramArrayOfString.length; i++) { int indexOf = paramArrayOfString[i].indexOf(":"); String flag = paramArrayOfString[i].substring(0, indexOf).toLowerCase().trim(); String substring = paramArrayOfString[i] .substring(indexOf + 1); if ("user".equals(flag)) { ServerWithLog4j.logger.debug(flag + "----------------------------------------"); if(!canditates.contains(substring)){ canditates.add(substring); } ServerWithLog4j.logger.debug("user:"+substring); } if ("role".equals(flag)) { BusinessObject bo = bofService.readBusinessObject(substring, "role"); if(bo != null && bo.oid != null && bo.oid.length() > 0) { LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "roleperson"); for(LinkObject lo : los) { addToList(flag, canditates, lo.toOid); } } } if ("dept".equals(flag)) { BusinessObject bo = bofService.readBusinessObject(substring, "department"); if(bo != null && bo.oid != null && bo.oid.length() > 0) { LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "deptperson"); for(LinkObject lo : los) { addToList(flag, canditates, lo.toOid); } } } if ("org".equals(flag)) { BusinessObject bo = bofService.readBusinessObject(substring, "organization"); if(bo != null && bo.oid != null && bo.oid.length() > 0) { LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "orgperson"); for(LinkObject lo : los) { addToList(flag, canditates, lo.toOid); } } } if ("dept1".equals(flag)) { String[] strs = substring.split(":"); if(strs != null && strs.length > 1) { BusinessObject bo = bofService.readBusinessObject(strs[0], "department"); if(bo != null && bo.oid != null && bo.oid.length() > 0) { LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "deptperson"); for(LinkObject lo : los) { for(AttributeValue av : lo.hisAttrValList) { if("refpost".equals(av.attrName) && strs[1].equals(av.attrVal)) { addToList(flag, canditates, lo.toOid); } } } } } } } return canditates.toArray(new String[0]); } private void addToList(String flag, List list , String oid) throws Exception { BusinessObject obj = bofService.readBusinessObject(oid, "person"); if(obj != null && obj.oid != null && obj.oid.length() > 0) { String userName = obj.id; ServerWithLog4j.logger.debug(flag + "----------------------------------------"); if(!list.contains(userName)){ list.add(userName); } ServerWithLog4j.logger.debug("user:"+userName); } } }