modulehelper.java

来自「OBPM是一个开源」· Java 代码 · 共 128 行

JAVA
128
字号
package cn.myapps.core.deploy.module.action;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import cn.myapps.base.dao.PersistenceUtils;
import cn.myapps.core.deploy.application.ejb.ApplicationProcess;
import cn.myapps.core.deploy.application.ejb.ApplicationVO;
import cn.myapps.core.deploy.module.ejb.ModuleProcess;
import cn.myapps.core.deploy.module.ejb.ModuleVO;
import cn.myapps.core.report.query.ejb.Query;
import cn.myapps.core.report.query.ejb.QueryProcess;
import cn.myapps.util.ProcessFactory;
import cn.myapps.util.web.DWRHtmlUtils;

public class ModuleHelper {

	public String createSuperiorOptionFunc(String selectFieldName,
			String applicationId, String excludeNodeId, String def, String application)
			throws Exception {

		ModuleProcess mp = (ModuleProcess) ProcessFactory
				.createProcess(ModuleProcess.class);

		Collection dc = mp.doSimpleQuery(null, application);
		Map dm = mp.deepSearchModuleTree(dc, applicationId, null,
				excludeNodeId, 0);

		// if (dm.isEmpty()) {
		// dm.put("", "无");
		// }

		return DWRHtmlUtils.createOptions(dm, selectFieldName, def);
	}

	public Collection get_moduleList(String application) throws Exception {
		ModuleProcess mp = (ModuleProcess) ProcessFactory
				.createProcess(ModuleProcess.class);
		return mp.doSimpleQuery(null, application);
	}

//	public String createQueryOption(String selectFieldName,
//			String applicationId, String moduleid, String def, String application) throws Exception {
//
//		QueryProcess qp = (QueryProcess) ProcessFactory
//				.createProcess(QueryProcess.class);
//		Collection qc = null;
//		if (moduleid == null || moduleid.trim().length() == 0) {
//			qc = qp.get_queryByAppId(applicationId, application);
//		} else {
//			qc = qp.get_queryStringList(applicationId, moduleid, application);
//		}
//
//		Map temp = new LinkedHashMap();
//		temp.put("", "none");
//		for (Iterator iter = qc.iterator(); iter.hasNext();) {
//			Query element = (Query) iter.next();
//			temp.put(element.getId(), element.getName());
//		}
//		return DWRHtmlUtils.createOptions(temp, selectFieldName, def);
//	}

	public Map getModuleSel(String applicationid) throws Exception {
//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		ApplicationProcess ap = (ApplicationProcess) ProcessFactory
				.createProcess(ApplicationProcess.class);
		ApplicationVO av = (ApplicationVO) ap.doView(applicationid);

		Map map = new LinkedHashMap();
		map.put("", "Select");
		if (applicationid != null && !applicationid.equals("none")
				&& !applicationid.equals(""))
			map = deepSearchModuleTree(av.getModules(), applicationid, null,
					null, 0);
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();

		return map;
	}

	public Map deepSearchModuleTree(Collection cols, String applicationId,
			ModuleVO startNode, String excludeNodeId, int deep)
			throws Exception {
		Map list = new LinkedHashMap();
		list.put("", "Select");
		if (applicationId == null || applicationId.equals(""))
			return list;

		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;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?