moduleprocessbean.java
来自「OBPM是一个开源」· Java 代码 · 共 179 行
JAVA
179 行
package cn.myapps.core.deploy.module.ejb;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.collections.map.LinkedMap;
import cn.myapps.base.dao.DAOFactory;
import cn.myapps.base.dao.IBaseDAO;
import cn.myapps.base.ejb.BaseProcessBean;
import cn.myapps.core.deploy.application.ejb.ApplicationProcess;
import cn.myapps.core.deploy.application.ejb.ApplicationVO;
import cn.myapps.core.expimp.exp.ejb.ExpObject;
import cn.myapps.util.ProcessFactory;
public class ModuleProcessBean extends BaseProcessBean implements ModuleProcess {
public void doRemove(String pk) throws Exception {
// 检查是否有下级模块
super.doRemove(pk);
}
protected IBaseDAO getDAO() throws Exception {
IBaseDAO dao = DAOFactory.getDefaultDAO(ModuleVO.class.getName());
return dao;
}
public Map deepSearchModuleTree(Collection cols, String applicationId,
ModuleVO startNode, String excludeNodeId, int deep)
throws Exception {
Map list = new LinkedHashMap();
list.put("", "No");
String prefix = "|------------------------------------------------";
if (startNode != null) {
list.put(startNode.getId(), prefix.substring(0, deep * 2)
+ startNode.getName());
}
Iterator iter = cols.iterator();
while (iter.hasNext()) {
ModuleVO vo = (ModuleVO) iter.next();
if (applicationId == null || vo.getApplication() == null
|| !applicationId.equals(vo.getApplication().getId())) {
continue;
}
if (startNode == null) {
if (vo.getSuperior() == null) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Map tmp = deepSearchModuleTree(cols, applicationId, vo,
excludeNodeId, deep + 1);
list.putAll(tmp);
}
}
} else {
if (vo.getSuperior() != null
&& vo.getSuperior().getId().equals(startNode.getId())) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Map tmp = deepSearchModuleTree(cols, applicationId, vo,
excludeNodeId, deep + 1);
list.putAll(tmp);
}
}
}
}
return list;
}
public Map deepSearchModuleTree(Collection cols, String applicationId,
ModuleVO startNode, String excludeNodeId) throws Exception {
Map list = new LinkedHashMap();
if (startNode != null) {
list.put(startNode.getId(), startNode.getName());
}
Iterator iter = cols.iterator();
while (iter.hasNext()) {
ModuleVO vo = (ModuleVO) iter.next();
if (applicationId == null || vo.getApplication() == null
|| !applicationId.equals(vo.getApplication().getId())) {
continue;
}
if (startNode == null) {
if (vo.getSuperior() == null) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Map tmp = deepSearchModuleTree(cols, applicationId, vo,
excludeNodeId);
list.putAll(tmp);
}
}
} else {
if (vo.getSuperior() != null
&& vo.getSuperior().getId().equals(startNode.getId())) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Map tmp = deepSearchModuleTree(cols, applicationId, vo,
excludeNodeId);
list.putAll(tmp);
}
}
}
}
return list;
}
public String[] deepSearchModuleid(String applicationId, String moduleId)
throws Exception {
ApplicationProcess ap = (ApplicationProcess) ProcessFactory
.createProcess(ApplicationProcess.class);
ApplicationVO app = (ApplicationVO) ap.doView(applicationId);
Collection colls = app.getModules();
ModuleVO moduleVO = (ModuleVO) this.doView(moduleId);
if (moduleVO.getSuperior() != null) { // 从最上层的module开始deepSearch
return deepSearchModuleid(applicationId, moduleVO.getSuperior()
.getId());
} else {
Map subModules = this.deepSearchModuleTree(colls, applicationId,
moduleVO, null);
String[] idList = new String[subModules.size()];
int count = 0;
for (Iterator iter = subModules.keySet().iterator(); iter.hasNext();) {
String id = (String) iter.next();
idList[count] = id;
count++;
}
return idList;
}
}
public Collection deepSearchModule(Collection colls, ModuleVO startNode,
String excludeNodeId, int deep) throws Exception {
Collection rtn = new ArrayList();
if (startNode != null) {
rtn.add(startNode);
}
Iterator iter = colls.iterator();
while (iter.hasNext()) {
ModuleVO vo = (ModuleVO) iter.next();
if (startNode == null) {
if (vo.getSuperior() == null) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Collection idList = deepSearchModule(colls, vo,
excludeNodeId, deep);
rtn.addAll(idList);
}
}
} else {
if (vo.getSuperior() != null
&& vo.getSuperior().getId().equals(startNode.getId())) {
if (vo.getId() != null && !vo.getId().equals(excludeNodeId)) {
Collection idList = deepSearchModule(colls, vo,
excludeNodeId, deep);
rtn.addAll(idList);
}
}
}
}
return rtn;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?