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

📄 impactivity.java

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

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

import org.apache.commons.beanutils.DynaBean;

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.util.ProcessFactory;

public class ImpActivity extends ImpElement {

	public final static String NAME = "T_ACTIVITY";

	public final static String DISPLAY_NAME = "activity";

	public final static String FOREINGKEY_COLUMN_FORM_ID = "FORM_ID";

	public final static String FOREINGKEY_COLUMN_ONACTIONFORM_ID = "ONACTIONFORM_ID";

	public final static String FOREINGKEY_COLUMN_VIEW_ID = "VIEW_ID";

	public final static String FOREINGKEY_COLUMN_ONACTIONVIEW_ID = "ONACTIONVIEW_ID";

	public final static String FOREINGKEY_COLUMN_ONACTIONFLOW_ID = "ONACTIONFLOW_ID";

	public ImpActivity(String appId, String modId) {
		super(appId, modId);
	}

	public Map getImportDatas(Collection dynaBeans, String[] ids,
			String ignoreId) throws Exception {
		Map rtn = new LinkedHashMap();

		Collection beans = getBeansOfTable(dynaBeans, getTableName());

		for (Iterator iter = beans.iterator(); iter.hasNext();) {
			DynaBean bean = (DynaBean) iter.next();
			String id = (String) bean.get(IMPOBJECT_ID);
			for (int i = 0; i < ids.length; i++) {
				if (id.equals(ids[i])) {
					// 相关的onactionflow
					String flowid = (String) bean
							.get(FOREINGKEY_COLUMN_ONACTIONFLOW_ID);
					if (flowid != null && !flowid.equals(ignoreId)) {
						String[] oflowId = new String[] { flowid };
						Map impOflow = new ImpBillDefi(applicationid, moduleid).getImportDatas(dynaBeans, oflowId);
						rtn.putAll(impOflow);
					}

					// 相关的onactionview
					String viewid = (String) bean
							.get(FOREINGKEY_COLUMN_ONACTIONVIEW_ID);
					if (viewid != null && !viewid.equals(ignoreId)) {
						String[] oviewId = new String[] { viewid };
						Map impOview = new ImpView(applicationid, moduleid).getImportDatas(dynaBeans, oviewId);
						rtn.putAll(impOview);
					}

					// 相关的onactionform
					String formid = (String) bean
							.get(FOREINGKEY_COLUMN_ONACTIONFORM_ID);
					if (formid != null && !formid.equals(ignoreId)) {
						String[] oformId = new String[] { formid };
						Map impOform = new ImpView(applicationid, moduleid).getImportDatas(dynaBeans, oformId);
						rtn.putAll(impOform);
					}

					setForeignKeyValue(bean);
					rtn.put(id, bean);
				}
			}
		}

		return rtn;
	}

	public String getTableName() {
		return NAME;
	}

	public String getDisplayName() {
		return DISPLAY_NAME;
	}

	public String getErrorMessage(DynaBean bean) throws Exception {
		StringBuffer rtn = new StringBuffer();

		String value = (String) bean.get(IMPOBJECT_NAME);

		ViewProcess vp = (ViewProcess) ProcessFactory
				.createProcess(ViewProcess.class);
		FormProcess fp = (FormProcess) ProcessFactory
				.createProcess(FormProcess.class);

		String formid = (String) bean.get(FOREINGKEY_COLUMN_FORM_ID);
		String viewid = (String) bean.get(FOREINGKEY_COLUMN_VIEW_ID);

		rtn.append(" ");
		rtn.append(getDisplayName() + "->" + value);

		if (formid != null && formid.trim().length() > 0) {
			rtn.append(" from");
			Form form = (Form) fp.doView(formid);
			rtn.append(" parent form->" + form.getName());
		}

		if (viewid != null && viewid.trim().length() > 0) {
			rtn.append(" from");
			View view = (View) vp.doView(viewid);
			rtn.append(" parent view->" + view.getName());
		}

		rtn.append(" is duplicate, please delete it before import");
		return rtn.toString();
	}

	public void setForeignKeyValue(DynaBean bean) {
		resetPrimaryKey(bean);

		resetForeignKey(bean, FOREINGKEY_COLUMN_FORM_ID);
		resetForeignKey(bean, FOREINGKEY_COLUMN_VIEW_ID);
		resetForeignKey(bean, FOREINGKEY_COLUMN_ONACTIONFORM_ID);
		resetForeignKey(bean, FOREINGKEY_COLUMN_ONACTIONVIEW_ID);
		resetForeignKey(bean, FOREINGKEY_COLUMN_ONACTIONFLOW_ID);

		bean.set(FOREIGNKEY_COLUMN_APPLICATION, applicationid);
	}

}

⌨️ 快捷键说明

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