applicationutil.java

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

JAVA
273
字号
package cn.myapps.core.deploy.application.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.ModuleVO;
import cn.myapps.core.dynaform.form.ejb.Form;
import cn.myapps.core.dynaform.form.ejb.FormProcess;
import cn.myapps.core.dynaform.view.ejb.View;
import cn.myapps.core.dynaform.view.ejb.ViewProcess;
import cn.myapps.core.page.ejb.Page;
import cn.myapps.core.page.ejb.PageProcess;
import cn.myapps.core.report.reportconfig.ejb.ReportConfig;
import cn.myapps.core.report.reportconfig.ejb.ReportConfigProcess;
import cn.myapps.util.ProcessFactory;
import cn.myapps.util.web.DWRHtmlUtils;

public class ApplicationUtil {

	// public Map getApplication(String application) throws Exception {
	// LinkedHashMap map = new LinkedHashMap();
	// map.put("none", "Select");
	// //PersistenceUtils.getSessionSignal().sessionSignal++;
	// ApplicationProcess ap = (ApplicationProcess) ProcessFactory
	// .createProcess(ApplicationProcess.class);
	// Collection datas = ap.doSimpleQuery(null, application);
	// Iterator it = datas.iterator();
	// while (it.hasNext()) {
	// ApplicationVO av = (ApplicationVO) it.next();
	// map.put(av.getId(), av.getName());
	// }
	// //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("none", "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;
	}

	public Map getModuleByApp(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("none", "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 getViewByMod(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("", "Select");

		ViewProcess vp = (ViewProcess) ProcessFactory
				.createProcess(ViewProcess.class);
		Collection col = vp.getViewsByModule(moduleid, application);

		if (col != null && col.size() > 0) {
			Iterator it = col.iterator();
			while (it.hasNext()) {
				View vw = (View) it.next();
				map.put(vw.getId(), vw.getName());
			}
		}
		return map;
	}

	public Map getViewByModule(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("none", "Select");
//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		if (moduleid.equals("") || application.equals("")) {
			return map;
		}
		ViewProcess vp = (ViewProcess) ProcessFactory
				.createProcess(ViewProcess.class);
		Collection col = vp.getViewsByModule(moduleid, application);

		Iterator it = col.iterator();
		while (it.hasNext()) {
			View vw = (View) it.next();
			map.put(vw.getId(), vw.getName());
		}
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();
		return map;

	}

	public Map getFormByModule(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("none", "Select");
//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		if (moduleid != null && !moduleid.equals("")) {
			FormProcess proc = (FormProcess) ProcessFactory
					.createProcess(FormProcess.class);
			Collection col = proc.getFormsByModule(moduleid, application);

			Iterator it = col.iterator();
			while (it.hasNext()) {
				Form vo = (Form) it.next();
				map.put(vo.getId(), vo.getName());
			}
		}
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();
		return map;
	}

	public Map getPageByModule(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("none", "Select");
//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		if (moduleid.equals("") || application.equals("")) {
			return map;
		}
		PageProcess pp = (PageProcess) ProcessFactory
				.createProcess(PageProcess.class);
		Collection col = pp.getPagesByModule(moduleid, application);

		Iterator it = col.iterator();
		while (it.hasNext()) {
			Page p = (Page) it.next();
			map.put(p.getId(), p.getName());
		}
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();
		return map;
	}

	// public String creatApplication(String selectFieldName, String def,
	// String application) throws Exception {
	// Map map = getApplication(application);
	// return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	// }

	public String creatModule(String selectFieldName, String applicationid,
			String def) throws Exception {
		Map map = getModuleByApp(applicationid);
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	}

	public String creatView(String selectFieldName, String application,
			String moduleid, String def) throws Exception {
		Map map = getViewByModule(moduleid, application);
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	}

	public String creatPage(String selectFieldName, String application,
			String moduleid, String def) throws Exception {
		Map map = getPageByModule(moduleid, application);
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	}

	public String creatForm(String selectFieldName, String application,
			String moduleid, String def) throws Exception {
		Map map = getFormByModule(moduleid, application);
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	}

	public String creatSearchForm(String selectFieldName, String application,
			String moduleid, String def) throws Exception {

//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		FormProcess fp = (FormProcess) ProcessFactory
				.createProcess(FormProcess.class);
		LinkedHashMap map = new LinkedHashMap();
		map.put("none", "Select");
		if (application != null && application.length() > 0
				&& !application.equals("none")) {
			Collection col = fp.getSearchFormsByModule(moduleid, application);
			Iterator it = col.iterator();
			while (it.hasNext()) {
				Form vw = (Form) it.next();
				map.put(vw.getId(), vw.getName());
			}
		}
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);

	}

	public String creatReports(String selectFieldName, String application,
			String moduleid, String def) throws Exception {
//		//PersistenceUtils.getSessionSignal().sessionSignal++;
		Map map = getReportByModule(moduleid, application);
//		//PersistenceUtils.getSessionSignal().sessionSignal--;
		PersistenceUtils.closeSession();
		return DWRHtmlUtils.createOptions(map, selectFieldName, def);
	}

	public Map getReportByModule(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("none", "Select");
		if (moduleid.equals("") || application.equals("")) {
			return map;
		}
		ReportConfigProcess vp = (ReportConfigProcess) ProcessFactory
				.createProcess(ReportConfigProcess.class);
		Collection col = vp.getReportByModule(moduleid, application);

		Iterator it = col.iterator();
		while (it.hasNext()) {
			ReportConfig vw = (ReportConfig) it.next();
			map.put(vw.getId(), vw.getName());
		}
		return map;

	}

}

⌨️ 快捷键说明

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