⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formulatreehelper.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.core.formula;

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

import cn.myapps.base.action.BaseHelper;
import cn.myapps.core.dynaform.form.ejb.Form;
import cn.myapps.core.dynaform.form.ejb.FormField;
import cn.myapps.core.dynaform.form.ejb.FormProcess;
import cn.myapps.util.ProcessFactory;
import cn.myapps.util.web.DWRHtmlUtils;

public class FormulaTreeHelper extends BaseHelper {
	public FormulaTreeHelper() {
		super(null);
	}

	private static Map RELATION_SYMBOL = new LinkedHashMap();

	private static Map OPERATOR_SYMBOL = new LinkedHashMap();

	private static Map COMPARE_SYMBOL = new LinkedHashMap();

	private static Map ALL_SYMBOL = new LinkedHashMap();

	static {
		RELATION_SYMBOL.put("AND", "AND");
		RELATION_SYMBOL.put("OR", "OR");

		OPERATOR_SYMBOL.put("+", "+");
		OPERATOR_SYMBOL.put("-", "-");
		OPERATOR_SYMBOL.put("*", "*");
		OPERATOR_SYMBOL.put("/", "/");

		COMPARE_SYMBOL.put("LIKE", "LIKE");
		COMPARE_SYMBOL.put(">", ">");
		COMPARE_SYMBOL.put(">=", ">=");
		COMPARE_SYMBOL.put("<", "<");
		COMPARE_SYMBOL.put("<=", "<=");
		COMPARE_SYMBOL.put("=", "=");
		COMPARE_SYMBOL.put("IN", "IN");
		COMPARE_SYMBOL.put("NOT IN", "NOT IN");

		ALL_SYMBOL.putAll(RELATION_SYMBOL);
		ALL_SYMBOL.putAll(OPERATOR_SYMBOL);
		ALL_SYMBOL.putAll(COMPARE_SYMBOL);
	}

	public static Map getCOMPARE_SYMBOL() {
		return COMPARE_SYMBOL;
	}

	public static Map getOPERATOR_SYMBOL() {
		return OPERATOR_SYMBOL;
	}

	public static Map getRELATION_SYMBOL() {
		return RELATION_SYMBOL;
	}

	public static Map getALL_SYMBOL() {
		return ALL_SYMBOL;
	}

	private Map getFormsByModule(String moduleid, String application)
			throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("", "Please Choose");

		FormProcess fp = (FormProcess) ProcessFactory
				.createProcess(FormProcess.class);
		Collection colls = fp.getFormsByModule(moduleid, application);
		for (Iterator iter = colls.iterator(); iter.hasNext();) {
			Form form = (Form) iter.next();
			map.put(form.getId(), form.getName());
		}

		return map;
	}

	private Map getFieldsByForm(String formid) throws Exception {
		LinkedHashMap map = new LinkedHashMap();
		map.put("", "Please Choose");

		FormProcess fp = (FormProcess) ProcessFactory
				.createProcess(FormProcess.class);
		Form form = (Form) fp.doView(formid);

		if (form != null) {
			Collection colls = form.getFields();
			for (Iterator iter = colls.iterator(); iter.hasNext();) {
				FormField field = (FormField) iter.next();
				map.put(field.getName(), field.getName());
			}
			map.put("$formname", "$formname");
			map.put("$lastmodified", "$lastmodified");
			map.put("$state.state", "$state.state");
		}
		return map;
	}

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

	public String createFiled(String selectFieldName, String formid, String def)
			throws Exception {
		Map map = getFieldsByForm(formid);

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

	public String getFieldtype(String selectFieldName, String formid)
			throws Exception {
		FormProcess fp = (FormProcess) ProcessFactory
				.createProcess(FormProcess.class);
		Form form = (Form) fp.doView(formid);
		if (form != null) {
			Collection colls = form.getFields();
			for (Iterator iter = colls.iterator(); iter.hasNext();) {
				FormField field = (FormField) iter.next();
				if (selectFieldName.equals(field.getName())) {
					return field.getFieldtype();
				}
			}
		}
		if (selectFieldName.indexOf("$") != -1) {
			return "VALUE_TYPE_PROPERTY";
		}
		return "";
	}

}

⌨️ 快捷键说明

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