123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- package model.setup.menutree;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.log4j.Logger;
- import com.sysmodel.XFormFactory;
- import com.sysmodel.XFormModel;
- import com.sysmodel.collectmodel.xmlmodel.able.FormCollection;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.MdpModule;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpConstantImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpDataSourceImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.TemplateImpl;
- import com.sysmodel.listmodel.xmlmodel.impl.FormListImpl;
- import com.toolkit.tree.DIVTree;
- import com.toolkit.tree.TreeNode;
- public class MenuTree extends DIVTree{
- private final static Logger log = Logger.getLogger(MenuTree.class);
- private final static SysModel sysmodel = ModelFactory.getSysmodel();
- private final static XFormModel xFormModel = XFormFactory.getXFormModel();
- private String path = "";
- private String LinkTarget = "";
- private boolean ispublish = false;
- public MenuTree(String path, String LinkTarget, boolean ispublish) {
- this.path = path;
- this.LinkTarget = LinkTarget;
- this.ispublish = ispublish;
- }
- public String getLinkTarget() {
- return LinkTarget;
- }
- public String getTreeImagePath() {
- return path + "/admin/images/tree_images/";
- }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List getChildTreeNode(String nodeID) {
- ArrayList<MenuTreeNode> al = new ArrayList<MenuTreeNode>();
- List array_elements = this.getElements(nodeID);
- // log.info("array_elements = " + array_elements.size());
- String[] array_element = null;
- for (int i = 0; i < array_elements.size(); i++) {
- array_element = (String[]) array_elements.get(i);
- String nodeLink = this.getNodeLink(nodeID, array_element);
- MenuTreeNode MenuTreeNode = new MenuTreeNode(array_element, path, nodeLink);
- al.add(MenuTreeNode);
- array_element = null;
- }
- return al;
- }
- @Override
- public TreeNode getCurrentTreeNode(String nodeID) {
- MenuTreeNode MenuTreeNode = null;
- if (nodeID.equals("mdpModules")) {
- String[] tempArry = new String[4];
- tempArry[0] = "mdpModules";
- tempArry[1] = "系统模块配置";
- tempArry[2] = "mdpModules";
- tempArry[3] = "1";
- return new MenuTreeNode(tempArry, path,
- "/admin/setup/sysmodel/objmanager/module/list.jsp");
- }
- if (nodeID.equals("mdpDataSources")) {
- String[] tempArry = new String[4];
- tempArry[0] = "mdpDataSources";
- tempArry[1] = "数据库链接";
- tempArry[2] = "mdpDataSources";
- tempArry[3] = "2";
- return new MenuTreeNode(tempArry, path,
- "/admin/setup/sysmodel/objmanager/DBLink/list.jsp");
- }
- if (nodeID.equals("template")) {
- String[] tempArry = new String[4];
- tempArry[0] = "template";
- tempArry[1] = "常量模板";
- tempArry[2] = "template";
- tempArry[3] = "3";
- return new MenuTreeNode(tempArry, path,
- "/admin/setup/sysmodel/objmanager/constant/template/list.jsp");
- }
- if (nodeID.indexOf(".") != -1) {
- String type = nodeID.substring(nodeID.indexOf(".") + 1);
- MdpModule MdpModule = sysmodel.getMdpModuleByCode(type);
- String[] tempArry = new String[4];
- tempArry[0] = nodeID;
- tempArry[1] = MdpModule.getName();
- tempArry[2] = nodeID;
- String urllink = "";
- if (nodeID.startsWith("mdpConstant.")) {
- tempArry[3] = "4";
- urllink = "/admin/setup/sysmodel/objmanager/constant/list.jsp?type=" + type;
- } else if (nodeID.startsWith("mdpClasses.")) {
- tempArry[3] = "5";
- urllink = "/admin/setup/sysmodel/objmanager/table/list.jsp?type=" + type;
- } else if (nodeID.startsWith("pageList.")) {
- tempArry[3] = "6";
- urllink = "/admin/setup/listmodel/objmanager/list.jsp?type=" + type;
- } else if (nodeID.startsWith("pageCollection.")) {
- tempArry[3] = "7";
- urllink = "/admin/setup/collectmodel/objmanager/list.jsp?type=" + type;
- }
- return new MenuTreeNode(tempArry, path, urllink);
- }
- return MenuTreeNode;
- }
- public boolean hasChild(TreeNode currentNode) {
- if (currentNode.getNodeID().equals("mdpConstant")
- || currentNode.getNodeID().equals("mdpClasses")) {
- return true;
- }
- if (currentNode.getNodeID().equals("mdpDataSources")) {
- return true;
- }
- if (currentNode.getNodeID().equals("template")) {
- return true;
- }
- if (currentNode.getNodeID().equals("mdpModules")) {
- return true;
- }
- if (currentNode.getNodeID().startsWith("mdpModules_")) {
- // 模块维护功能下的树编码
- if (currentNode.getNodeID().indexOf("mdpModules_") != -1) {
- String pCode = currentNode.getNodeID().substring(
- currentNode.getNodeID().indexOf("_") + 1);
- if (sysmodel.getMdpModulesByPcode(pCode).size() > 0)
- return true;
- }
- }
- /**
- *
- */
- // if(currentNode.getNodeID().indexOf(".") != -1) return true;
- if (currentNode.getNodeID().indexOf(".") != -1) {
- String type = currentNode.getNodeID().substring(
- currentNode.getNodeID().indexOf(".") + 1);
- int iModules = sysmodel.getMdpModulesByPcode(type).size();
- if (currentNode.getNodeID().startsWith("mdpConstant.")) {
- if (iModules == 0 && sysmodel.getMdpConstantByType(type).size() == 0)
- return false;
- else
- return true;
- }
- if (currentNode.getNodeID().startsWith("mdpClasses.")) {
- if (iModules == 0 && sysmodel.getMdpClassByType(type).size() == 0)
- return false;
- else
- return true;
- }
- if (currentNode.getNodeID().startsWith("pageList.")) {
- if (iModules == 0 && xFormModel.getFormListByType(type).size() == 0)
- return false;
- else
- return true;
- }
- if (currentNode.getNodeID().startsWith("pageCollection.")) {
- if (iModules == 0 && xFormModel.getFormCollectionsByType(type).size() == 0)
- return false;
- else
- return true;
- }
- }
- return false;
- }
- @SuppressWarnings("rawtypes")
- private List getElements(String nodeID) {
- ArrayList<String[]> result = new ArrayList<String[]>();
- ArrayList templist = new ArrayList();
- if (nodeID.startsWith("mdpModules")) {
- String pCode = "";
- if (nodeID.indexOf("_") != -1) {
- pCode = nodeID.substring(nodeID.indexOf("_") + 1);
- }
- templist = sysmodel.getMdpModulesByPcode(pCode);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "mdpModules_" + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode();
- tempArry[3] = "10";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.equals("mdpDataSources")) {
- templist = sysmodel.getMdpDataSources();
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpDataSourceImpl MdpDataSource = (MdpDataSourceImpl) templist.get(i);
- tempArry[0] = String.valueOf(MdpDataSource.getDataSourceid());
- tempArry[1] = MdpDataSource.getDescription();
- tempArry[2] = String.valueOf(MdpDataSource.getDataSourceid());
- tempArry[3] = "20";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.equals("template")) {
- templist = sysmodel.getTemplates();
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- TemplateImpl Template = (TemplateImpl) templist.get(i);
- tempArry[0] = Template.getName();
- tempArry[1] = Template.getDescription() + "-" + Template.getName();
- tempArry[2] = Template.getName();
- tempArry[3] = "30";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.equals("mdpConstant")) {
- templist = sysmodel.getMdpModulesByPcode("");
- // templist = sysmodel.getMdpModules();
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "mdpConstant." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode();
- tempArry[3] = "4";
- log.info(tempArry[0] + " " + tempArry[1]);
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.startsWith("mdpConstant.")) {
- String type = nodeID.substring(nodeID.indexOf(".") + 1);
- templist = sysmodel.getMdpConstantByType(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpConstantImpl MdpConstantImpl = (MdpConstantImpl) templist.get(i);
- tempArry[0] = MdpConstantImpl.getCodeName();
- tempArry[1] = MdpConstantImpl.getDescription() + "-"
- + MdpConstantImpl.getCodeName();
- tempArry[2] = MdpConstantImpl.getCodeName();
- tempArry[3] = "40";
- result.add(tempArry);
- tempArry = null;
- }
- templist = sysmodel.getMdpModulesByPcode(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "mdpConstant." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode();
- tempArry[3] = "4";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.equals("mdpClasses")) {
- // templist = sysmodel.getMdpModules();
- templist = sysmodel.getMdpModulesByPcode("");
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "mdpClasses." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode() + "";
- tempArry[3] = "5";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.startsWith("mdpClasses.")) {
- String type = nodeID.substring(nodeID.indexOf(".") + 1);
- log.info(type + " = type");
- templist = sysmodel.getMdpClassByType(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpClassImpl MdpClass = (MdpClassImpl) templist.get(i);
- tempArry[0] = String.valueOf(MdpClass.getClassid());
- tempArry[1] = MdpClass.getDescription() + "-[" + MdpClass.getClassid() + "-"
- + MdpClass.getName() + "]";
- tempArry[2] = String.valueOf(MdpClass.getClassid());
- tempArry[3] = "50";
- result.add(tempArry);
- tempArry = null;
- }
- templist = sysmodel.getMdpModulesByPcode(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "mdpClasses." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode();
- tempArry[3] = "5";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.equals("pageList")) {
- // templist = sysmodel.getMdpModules();
- templist = sysmodel.getMdpModulesByPcode("");
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "pageList." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode() + "";
- tempArry[3] = "6";
- result.add(tempArry);
- tempArry = null;
- }
- } else if (nodeID.startsWith("pageList.")) {
- String type = nodeID.substring(nodeID.indexOf(".") + 1);
- templist = xFormModel.getFormListByType(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- FormListImpl FormList = (FormListImpl) templist.get(i);
- tempArry[0] = FormList.getListid();
- // tempArry[1] = FormList.getListHead().getTitle();
- tempArry[1] = FormList.getDescription();
- tempArry[2] = FormList.getListid();
- tempArry[3] = "60";
- result.add(tempArry);
- tempArry = null;
- }
- templist = sysmodel.getMdpModulesByPcode(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "pageList." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode() + "";
- tempArry[3] = "6";
- result.add(tempArry);
- tempArry = null;
- }
- }
- else if (nodeID.equals("pageCollection")) {
- // templist = sysmodel.getMdpModules();
- templist = sysmodel.getMdpModulesByPcode("");
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "pageCollection." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode() + "";
- tempArry[3] = "7";
- result.add(tempArry);
- tempArry = null;
- }
- }
- else if (nodeID.startsWith("pageCollection.")) {
- String type = nodeID.substring(nodeID.indexOf(".") + 1);
- templist = xFormModel.getFormCollectionsByType(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- FormCollection FormCollection = (FormCollection) templist.get(i);
- tempArry[0] = FormCollection.getPageid();
- tempArry[1] = FormCollection.getDescription();
- tempArry[2] = FormCollection.getPageid();
- tempArry[3] = "70";
- result.add(tempArry);
- tempArry = null;
- }
- templist = sysmodel.getMdpModulesByPcode(type);
- for (int i = 0; i < templist.size(); i++) {
- String[] tempArry = new String[4];
- MdpModule MdpModule = (MdpModule) templist.get(i);
- tempArry[0] = "pageCollection." + MdpModule.getCode();
- tempArry[1] = MdpModule.getName();
- tempArry[2] = MdpModule.getCode() + "";
- tempArry[3] = "7";
- result.add(tempArry);
- tempArry = null;
- }
- }
- return result;
- }
- private String getNodeLink(String nodeID, String[] arrayData) {
- String resultStr = "";
- String nodeType = arrayData[3];
- if (nodeType.equals("10")) { // nodeID.startsWith("mdpModules")
- resultStr = "/admin/setup/sysmodel/objmanager/module/edit.jsp?code=";
- }
- else if (nodeType.equals("20")) { // nodeID.equals("mdpDataSources")
- resultStr = "/admin/setup/sysmodel/objmanager/DBLink/edit.jsp?dataSourceid=";
- }
- else if (nodeType.equals("30")) { // nodeID.equals("template")
- resultStr = "/admin/setup/sysmodel/objmanager/constant/template/container.jsp?name=";
- }
- // else if(nodeID.startsWith("mdpConstant")){
- else if (nodeType.equals("4")) {
- if (this.ispublish)
- return "";
- resultStr = "/admin/setup/sysmodel/objmanager/constant/list.jsp?type=";
- }
- // else if(nodeID.startsWith("mdpConstant.")){
- else if (nodeType.equals("40")) {
- if (this.ispublish)
- resultStr = "/admin/setup/constantinit/index.jsp?name=";
- else
- resultStr = "/admin/setup/sysmodel/objmanager/constant/edit.jsp?name=";
- }
- else if (nodeType.equals("5")) { // else
- // if(nodeID.equals("mdpClasses")){
- resultStr = "/admin/setup/sysmodel/objmanager/table/list.jsp?type=";
- } else if (nodeType.equals("50")) { // else
- // if(nodeID.startsWith("mdpClasses.")){
- resultStr = "/admin/setup/sysmodel/objmanager/table/container.jsp?classid=";
- }
- else if (nodeType.equals("6")) { // nodeID.equals("pageList")
- if (this.ispublish)
- return "";
- resultStr = "/admin/setup/listmodel/objmanager/list_exc.jsp?type=";
- } else if (nodeType.equals("60")) { // else
- // if(nodeID.startsWith("pageList.")){
- if (this.ispublish)
- resultStr = "/sample/formlist/sample.jsp?listid=";
- else
- resultStr = "/admin/setup/listmodel/objmanager/container.html?listid=";
- }
- else if (nodeType.equals("7")) { // nodeID.equals("pageCollection")
- if (this.ispublish)
- return "";
- resultStr = "/admin/setup/collectmodel/objmanager/list_exc.jsp?type=";
- } else if (nodeType.equals("70")) { // nodeID.startsWith("pageCollection.")
- if (this.ispublish)
- resultStr = "/sample/formcollect/sample.jsp?pageid=";
- else
- resultStr = "/admin/setup/collectmodel/objmanager/container.html?pagid=";
- }
- return resultStr + arrayData[2];
- }
- }
|