123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- package com.sinosoft.lz.common;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import model.setup.constant.ConstantTreeNode;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.toolkit.tree.DIVTree;
- import com.toolkit.tree.TreeNode;
- public class RefTableTree extends DIVTree{
- /** The referenceclass name. */
- String referenceclassName = "";
- String keyField = "";
- String displayName = "";
- String parentField = "";
- String condition = "";
- String order = "";
- int referenceclassid = 0;
- private String path = "";
- SysModel sysModel = ModelFactory.getSysmodel();
- private SysPersistence sysPersistenceObject = PersistenceFactory.getInstance(sysModel);
- public RefTableTree(HttpServletRequest req) {
- path = req.getContextPath();
- referenceclassid = Integer.valueOf(
- req.getParameter("referenceclassid") == null ? "99" : (String) req
- .getParameter("referenceclassid")).intValue();
- referenceclassName = sysModel.getMdpClassByClassID(referenceclassid).getName();
- keyField = req.getParameter("storeCode") == null ? "" : (String) req
- .getParameter("storeCode");
- displayName = req.getParameter("displayName") == null ? "" : (String) req
- .getParameter("displayName");
- parentField = req.getParameter("parentCode") == null ? "" : (String) req
- .getParameter("parentCode");
- condition = req.getParameter("condition") == null ? "" : (String) req
- .getParameter("condition");
- order = req.getParameter("order") == null ? " " : (String) req.getParameter("order");
- }
- /*
- * (non-Javadoc)
- *
- * @see com.nxs.commons.tree.DIVTree#getLinkTarget()
- */
- public String getLinkTarget() {
- // TODO Auto-generated method stub
- return null;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.nxs.commons.tree.DIVTree#getTreeImagePath()
- */
- public String getTreeImagePath() {
- return path + "/images/tree_images/";
- }
- /*
- * (non-Javadoc)
- *
- * @see com.nxs.commons.tree.DIVTree#getChildTreeNode(java.lang.String)
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List getChildTreeNode(String nodeID) {
- StringBuffer sb = new StringBuffer();
- sb.append("select " + keyField + "," + displayName + " from " + referenceclassName
- + " where 1=1 ");
- if (!parentField.equals("")) {
- sb.append(" and " + parentField + "='" + nodeID + "'");
- if (nodeID == null)
- sb.append(" and " + parentField + " is null");
- }
- if (!condition.equals(""))
- sb.append(" and " + condition);
- sb.append(" " + order);
- ArrayList vect = null;
- try {
- vect = sysPersistenceObject.getSearchResult(referenceclassid, sb.toString());
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- ArrayList al = new ArrayList();
- for (int i = 0; i < vect.size(); i++) {
- String[] array_element = (String[]) vect.get(i);
- ConstantTreeNode constantTreeNode = new ConstantTreeNode(array_element,
- referenceclassName, path, "");
- constantTreeNode.MouseEventName = "onclick";
- constantTreeNode.NodeOnMouseEvent = "returnValue(this);";
- al.add(constantTreeNode);
- }
- return al;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.nxs.commons.tree.DIVTree#getCurrentTreeNode(java.lang.String)
- */
- @SuppressWarnings("rawtypes")
- public TreeNode getCurrentTreeNode(String nodeID) {
- StringBuffer sb = new StringBuffer();
- sb.append("select " + keyField + (displayName.equals("") ? "" : ("," + displayName))
- + " from " + referenceclassName + " ");
- sb.append(" where " + keyField + (nodeID == null ? (" is null") : ("='" + nodeID + "' ")));
- // sb.append((condition.equals("")?"":(" and "+condition)));
- ArrayList vect = null;
- try {
- vect = sysPersistenceObject.getSearchResult(referenceclassid, sb.toString());
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (vect.size() > 0) {
- ConstantTreeNode constantTreeNode = new ConstantTreeNode((String[]) vect.get(0),
- referenceclassName, path, ""); // &@
- // �˴�ע��,������Ҫ��TestNode
- // ��ʵ�� @&
- constantTreeNode.MouseEventName = "onclick";
- constantTreeNode.NodeOnMouseEvent = "returnValue(this);";
- return constantTreeNode;
- }
- return null;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.nxs.commons.tree.DIVTree#hasChild(com.nxs.commons.tree.TreeNode)
- */
- @SuppressWarnings("rawtypes")
- public boolean hasChild(TreeNode currentNode) {
- if (parentField.equals(""))
- return false;
- else {
- String sql = "select count(*) from " + referenceclassName + " where " + parentField
- + "='" + currentNode.getNodeID() + "'";
- System.out.print(sql);
- ArrayList vect = null;
- try {
- vect = sysPersistenceObject.getSearchResult(referenceclassid, sql);
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (vect.size() > 0) {
- String[] temp = (String[]) vect.get(0);
- return temp[0].equals("0") ? false : true;
- } else
- return false;
- }
- }
- }
|