3ed77f6d5e8fd49d363758fdb184c278473cfd45.svn-base 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. package model.setup.menutree;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.apache.log4j.Logger;
  5. import com.sysmodel.XFormFactory;
  6. import com.sysmodel.XFormModel;
  7. import com.sysmodel.collectmodel.xmlmodel.able.FormCollection;
  8. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  9. import com.sysmodel.datamodel.xmlmodel.able.MdpModule;
  10. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  11. import com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl;
  12. import com.sysmodel.datamodel.xmlmodel.impl.MdpConstantImpl;
  13. import com.sysmodel.datamodel.xmlmodel.impl.MdpDataSourceImpl;
  14. import com.sysmodel.datamodel.xmlmodel.impl.TemplateImpl;
  15. import com.sysmodel.listmodel.xmlmodel.impl.FormListImpl;
  16. import com.toolkit.tree.DIVTree;
  17. import com.toolkit.tree.TreeNode;
  18. public class MenuTree extends DIVTree{
  19. private final static Logger log = Logger.getLogger(MenuTree.class);
  20. private final static SysModel sysmodel = ModelFactory.getSysmodel();
  21. private final static XFormModel xFormModel = XFormFactory.getXFormModel();
  22. private String path = "";
  23. private String LinkTarget = "";
  24. private boolean ispublish = false;
  25. public MenuTree(String path, String LinkTarget, boolean ispublish) {
  26. this.path = path;
  27. this.LinkTarget = LinkTarget;
  28. this.ispublish = ispublish;
  29. }
  30. public String getLinkTarget() {
  31. return LinkTarget;
  32. }
  33. public String getTreeImagePath() {
  34. return path + "/admin/images/tree_images/";
  35. }
  36. @SuppressWarnings({ "rawtypes", "unchecked" })
  37. public List getChildTreeNode(String nodeID) {
  38. ArrayList<MenuTreeNode> al = new ArrayList<MenuTreeNode>();
  39. List array_elements = this.getElements(nodeID);
  40. // log.info("array_elements = " + array_elements.size());
  41. String[] array_element = null;
  42. for (int i = 0; i < array_elements.size(); i++) {
  43. array_element = (String[]) array_elements.get(i);
  44. String nodeLink = this.getNodeLink(nodeID, array_element);
  45. MenuTreeNode MenuTreeNode = new MenuTreeNode(array_element, path, nodeLink);
  46. al.add(MenuTreeNode);
  47. array_element = null;
  48. }
  49. return al;
  50. }
  51. @Override
  52. public TreeNode getCurrentTreeNode(String nodeID) {
  53. MenuTreeNode MenuTreeNode = null;
  54. if (nodeID.equals("mdpModules")) {
  55. String[] tempArry = new String[4];
  56. tempArry[0] = "mdpModules";
  57. tempArry[1] = "系统模块配置";
  58. tempArry[2] = "mdpModules";
  59. tempArry[3] = "1";
  60. return new MenuTreeNode(tempArry, path,
  61. "/admin/setup/sysmodel/objmanager/module/list.jsp");
  62. }
  63. if (nodeID.equals("mdpDataSources")) {
  64. String[] tempArry = new String[4];
  65. tempArry[0] = "mdpDataSources";
  66. tempArry[1] = "数据库链接";
  67. tempArry[2] = "mdpDataSources";
  68. tempArry[3] = "2";
  69. return new MenuTreeNode(tempArry, path,
  70. "/admin/setup/sysmodel/objmanager/DBLink/list.jsp");
  71. }
  72. if (nodeID.equals("template")) {
  73. String[] tempArry = new String[4];
  74. tempArry[0] = "template";
  75. tempArry[1] = "常量模板";
  76. tempArry[2] = "template";
  77. tempArry[3] = "3";
  78. return new MenuTreeNode(tempArry, path,
  79. "/admin/setup/sysmodel/objmanager/constant/template/list.jsp");
  80. }
  81. if (nodeID.indexOf(".") != -1) {
  82. String type = nodeID.substring(nodeID.indexOf(".") + 1);
  83. MdpModule MdpModule = sysmodel.getMdpModuleByCode(type);
  84. String[] tempArry = new String[4];
  85. tempArry[0] = nodeID;
  86. tempArry[1] = MdpModule.getName();
  87. tempArry[2] = nodeID;
  88. String urllink = "";
  89. if (nodeID.startsWith("mdpConstant.")) {
  90. tempArry[3] = "4";
  91. urllink = "/admin/setup/sysmodel/objmanager/constant/list.jsp?type=" + type;
  92. } else if (nodeID.startsWith("mdpClasses.")) {
  93. tempArry[3] = "5";
  94. urllink = "/admin/setup/sysmodel/objmanager/table/list.jsp?type=" + type;
  95. } else if (nodeID.startsWith("pageList.")) {
  96. tempArry[3] = "6";
  97. urllink = "/admin/setup/listmodel/objmanager/list.jsp?type=" + type;
  98. } else if (nodeID.startsWith("pageCollection.")) {
  99. tempArry[3] = "7";
  100. urllink = "/admin/setup/collectmodel/objmanager/list.jsp?type=" + type;
  101. }
  102. return new MenuTreeNode(tempArry, path, urllink);
  103. }
  104. return MenuTreeNode;
  105. }
  106. public boolean hasChild(TreeNode currentNode) {
  107. if (currentNode.getNodeID().equals("mdpConstant")
  108. || currentNode.getNodeID().equals("mdpClasses")) {
  109. return true;
  110. }
  111. if (currentNode.getNodeID().equals("mdpDataSources")) {
  112. return true;
  113. }
  114. if (currentNode.getNodeID().equals("template")) {
  115. return true;
  116. }
  117. if (currentNode.getNodeID().equals("mdpModules")) {
  118. return true;
  119. }
  120. if (currentNode.getNodeID().startsWith("mdpModules_")) {
  121. // 模块维护功能下的树编码
  122. if (currentNode.getNodeID().indexOf("mdpModules_") != -1) {
  123. String pCode = currentNode.getNodeID().substring(
  124. currentNode.getNodeID().indexOf("_") + 1);
  125. if (sysmodel.getMdpModulesByPcode(pCode).size() > 0)
  126. return true;
  127. }
  128. }
  129. /**
  130. *
  131. */
  132. // if(currentNode.getNodeID().indexOf(".") != -1) return true;
  133. if (currentNode.getNodeID().indexOf(".") != -1) {
  134. String type = currentNode.getNodeID().substring(
  135. currentNode.getNodeID().indexOf(".") + 1);
  136. int iModules = sysmodel.getMdpModulesByPcode(type).size();
  137. if (currentNode.getNodeID().startsWith("mdpConstant.")) {
  138. if (iModules == 0 && sysmodel.getMdpConstantByType(type).size() == 0)
  139. return false;
  140. else
  141. return true;
  142. }
  143. if (currentNode.getNodeID().startsWith("mdpClasses.")) {
  144. if (iModules == 0 && sysmodel.getMdpClassByType(type).size() == 0)
  145. return false;
  146. else
  147. return true;
  148. }
  149. if (currentNode.getNodeID().startsWith("pageList.")) {
  150. if (iModules == 0 && xFormModel.getFormListByType(type).size() == 0)
  151. return false;
  152. else
  153. return true;
  154. }
  155. if (currentNode.getNodeID().startsWith("pageCollection.")) {
  156. if (iModules == 0 && xFormModel.getFormCollectionsByType(type).size() == 0)
  157. return false;
  158. else
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164. @SuppressWarnings("rawtypes")
  165. private List getElements(String nodeID) {
  166. ArrayList<String[]> result = new ArrayList<String[]>();
  167. ArrayList templist = new ArrayList();
  168. if (nodeID.startsWith("mdpModules")) {
  169. String pCode = "";
  170. if (nodeID.indexOf("_") != -1) {
  171. pCode = nodeID.substring(nodeID.indexOf("_") + 1);
  172. }
  173. templist = sysmodel.getMdpModulesByPcode(pCode);
  174. for (int i = 0; i < templist.size(); i++) {
  175. String[] tempArry = new String[4];
  176. MdpModule MdpModule = (MdpModule) templist.get(i);
  177. tempArry[0] = "mdpModules_" + MdpModule.getCode();
  178. tempArry[1] = MdpModule.getName();
  179. tempArry[2] = MdpModule.getCode();
  180. tempArry[3] = "10";
  181. result.add(tempArry);
  182. tempArry = null;
  183. }
  184. } else if (nodeID.equals("mdpDataSources")) {
  185. templist = sysmodel.getMdpDataSources();
  186. for (int i = 0; i < templist.size(); i++) {
  187. String[] tempArry = new String[4];
  188. MdpDataSourceImpl MdpDataSource = (MdpDataSourceImpl) templist.get(i);
  189. tempArry[0] = String.valueOf(MdpDataSource.getDataSourceid());
  190. tempArry[1] = MdpDataSource.getDescription();
  191. tempArry[2] = String.valueOf(MdpDataSource.getDataSourceid());
  192. tempArry[3] = "20";
  193. result.add(tempArry);
  194. tempArry = null;
  195. }
  196. } else if (nodeID.equals("template")) {
  197. templist = sysmodel.getTemplates();
  198. for (int i = 0; i < templist.size(); i++) {
  199. String[] tempArry = new String[4];
  200. TemplateImpl Template = (TemplateImpl) templist.get(i);
  201. tempArry[0] = Template.getName();
  202. tempArry[1] = Template.getDescription() + "-" + Template.getName();
  203. tempArry[2] = Template.getName();
  204. tempArry[3] = "30";
  205. result.add(tempArry);
  206. tempArry = null;
  207. }
  208. } else if (nodeID.equals("mdpConstant")) {
  209. templist = sysmodel.getMdpModulesByPcode("");
  210. // templist = sysmodel.getMdpModules();
  211. for (int i = 0; i < templist.size(); i++) {
  212. String[] tempArry = new String[4];
  213. MdpModule MdpModule = (MdpModule) templist.get(i);
  214. tempArry[0] = "mdpConstant." + MdpModule.getCode();
  215. tempArry[1] = MdpModule.getName();
  216. tempArry[2] = MdpModule.getCode();
  217. tempArry[3] = "4";
  218. log.info(tempArry[0] + " " + tempArry[1]);
  219. result.add(tempArry);
  220. tempArry = null;
  221. }
  222. } else if (nodeID.startsWith("mdpConstant.")) {
  223. String type = nodeID.substring(nodeID.indexOf(".") + 1);
  224. templist = sysmodel.getMdpConstantByType(type);
  225. for (int i = 0; i < templist.size(); i++) {
  226. String[] tempArry = new String[4];
  227. MdpConstantImpl MdpConstantImpl = (MdpConstantImpl) templist.get(i);
  228. tempArry[0] = MdpConstantImpl.getCodeName();
  229. tempArry[1] = MdpConstantImpl.getDescription() + "-"
  230. + MdpConstantImpl.getCodeName();
  231. tempArry[2] = MdpConstantImpl.getCodeName();
  232. tempArry[3] = "40";
  233. result.add(tempArry);
  234. tempArry = null;
  235. }
  236. templist = sysmodel.getMdpModulesByPcode(type);
  237. for (int i = 0; i < templist.size(); i++) {
  238. String[] tempArry = new String[4];
  239. MdpModule MdpModule = (MdpModule) templist.get(i);
  240. tempArry[0] = "mdpConstant." + MdpModule.getCode();
  241. tempArry[1] = MdpModule.getName();
  242. tempArry[2] = MdpModule.getCode();
  243. tempArry[3] = "4";
  244. result.add(tempArry);
  245. tempArry = null;
  246. }
  247. } else if (nodeID.equals("mdpClasses")) {
  248. // templist = sysmodel.getMdpModules();
  249. templist = sysmodel.getMdpModulesByPcode("");
  250. for (int i = 0; i < templist.size(); i++) {
  251. String[] tempArry = new String[4];
  252. MdpModule MdpModule = (MdpModule) templist.get(i);
  253. tempArry[0] = "mdpClasses." + MdpModule.getCode();
  254. tempArry[1] = MdpModule.getName();
  255. tempArry[2] = MdpModule.getCode() + "";
  256. tempArry[3] = "5";
  257. result.add(tempArry);
  258. tempArry = null;
  259. }
  260. } else if (nodeID.startsWith("mdpClasses.")) {
  261. String type = nodeID.substring(nodeID.indexOf(".") + 1);
  262. log.info(type + " = type");
  263. templist = sysmodel.getMdpClassByType(type);
  264. for (int i = 0; i < templist.size(); i++) {
  265. String[] tempArry = new String[4];
  266. MdpClassImpl MdpClass = (MdpClassImpl) templist.get(i);
  267. tempArry[0] = String.valueOf(MdpClass.getClassid());
  268. tempArry[1] = MdpClass.getDescription() + "-[" + MdpClass.getClassid() + "-"
  269. + MdpClass.getName() + "]";
  270. tempArry[2] = String.valueOf(MdpClass.getClassid());
  271. tempArry[3] = "50";
  272. result.add(tempArry);
  273. tempArry = null;
  274. }
  275. templist = sysmodel.getMdpModulesByPcode(type);
  276. for (int i = 0; i < templist.size(); i++) {
  277. String[] tempArry = new String[4];
  278. MdpModule MdpModule = (MdpModule) templist.get(i);
  279. tempArry[0] = "mdpClasses." + MdpModule.getCode();
  280. tempArry[1] = MdpModule.getName();
  281. tempArry[2] = MdpModule.getCode();
  282. tempArry[3] = "5";
  283. result.add(tempArry);
  284. tempArry = null;
  285. }
  286. } else if (nodeID.equals("pageList")) {
  287. // templist = sysmodel.getMdpModules();
  288. templist = sysmodel.getMdpModulesByPcode("");
  289. for (int i = 0; i < templist.size(); i++) {
  290. String[] tempArry = new String[4];
  291. MdpModule MdpModule = (MdpModule) templist.get(i);
  292. tempArry[0] = "pageList." + MdpModule.getCode();
  293. tempArry[1] = MdpModule.getName();
  294. tempArry[2] = MdpModule.getCode() + "";
  295. tempArry[3] = "6";
  296. result.add(tempArry);
  297. tempArry = null;
  298. }
  299. } else if (nodeID.startsWith("pageList.")) {
  300. String type = nodeID.substring(nodeID.indexOf(".") + 1);
  301. templist = xFormModel.getFormListByType(type);
  302. for (int i = 0; i < templist.size(); i++) {
  303. String[] tempArry = new String[4];
  304. FormListImpl FormList = (FormListImpl) templist.get(i);
  305. tempArry[0] = FormList.getListid();
  306. // tempArry[1] = FormList.getListHead().getTitle();
  307. tempArry[1] = FormList.getDescription();
  308. tempArry[2] = FormList.getListid();
  309. tempArry[3] = "60";
  310. result.add(tempArry);
  311. tempArry = null;
  312. }
  313. templist = sysmodel.getMdpModulesByPcode(type);
  314. for (int i = 0; i < templist.size(); i++) {
  315. String[] tempArry = new String[4];
  316. MdpModule MdpModule = (MdpModule) templist.get(i);
  317. tempArry[0] = "pageList." + MdpModule.getCode();
  318. tempArry[1] = MdpModule.getName();
  319. tempArry[2] = MdpModule.getCode() + "";
  320. tempArry[3] = "6";
  321. result.add(tempArry);
  322. tempArry = null;
  323. }
  324. }
  325. else if (nodeID.equals("pageCollection")) {
  326. // templist = sysmodel.getMdpModules();
  327. templist = sysmodel.getMdpModulesByPcode("");
  328. for (int i = 0; i < templist.size(); i++) {
  329. String[] tempArry = new String[4];
  330. MdpModule MdpModule = (MdpModule) templist.get(i);
  331. tempArry[0] = "pageCollection." + MdpModule.getCode();
  332. tempArry[1] = MdpModule.getName();
  333. tempArry[2] = MdpModule.getCode() + "";
  334. tempArry[3] = "7";
  335. result.add(tempArry);
  336. tempArry = null;
  337. }
  338. }
  339. else if (nodeID.startsWith("pageCollection.")) {
  340. String type = nodeID.substring(nodeID.indexOf(".") + 1);
  341. templist = xFormModel.getFormCollectionsByType(type);
  342. for (int i = 0; i < templist.size(); i++) {
  343. String[] tempArry = new String[4];
  344. FormCollection FormCollection = (FormCollection) templist.get(i);
  345. tempArry[0] = FormCollection.getPageid();
  346. tempArry[1] = FormCollection.getDescription();
  347. tempArry[2] = FormCollection.getPageid();
  348. tempArry[3] = "70";
  349. result.add(tempArry);
  350. tempArry = null;
  351. }
  352. templist = sysmodel.getMdpModulesByPcode(type);
  353. for (int i = 0; i < templist.size(); i++) {
  354. String[] tempArry = new String[4];
  355. MdpModule MdpModule = (MdpModule) templist.get(i);
  356. tempArry[0] = "pageCollection." + MdpModule.getCode();
  357. tempArry[1] = MdpModule.getName();
  358. tempArry[2] = MdpModule.getCode() + "";
  359. tempArry[3] = "7";
  360. result.add(tempArry);
  361. tempArry = null;
  362. }
  363. }
  364. return result;
  365. }
  366. private String getNodeLink(String nodeID, String[] arrayData) {
  367. String resultStr = "";
  368. String nodeType = arrayData[3];
  369. if (nodeType.equals("10")) { // nodeID.startsWith("mdpModules")
  370. resultStr = "/admin/setup/sysmodel/objmanager/module/edit.jsp?code=";
  371. }
  372. else if (nodeType.equals("20")) { // nodeID.equals("mdpDataSources")
  373. resultStr = "/admin/setup/sysmodel/objmanager/DBLink/edit.jsp?dataSourceid=";
  374. }
  375. else if (nodeType.equals("30")) { // nodeID.equals("template")
  376. resultStr = "/admin/setup/sysmodel/objmanager/constant/template/container.jsp?name=";
  377. }
  378. // else if(nodeID.startsWith("mdpConstant")){
  379. else if (nodeType.equals("4")) {
  380. if (this.ispublish)
  381. return "";
  382. resultStr = "/admin/setup/sysmodel/objmanager/constant/list.jsp?type=";
  383. }
  384. // else if(nodeID.startsWith("mdpConstant.")){
  385. else if (nodeType.equals("40")) {
  386. if (this.ispublish)
  387. resultStr = "/admin/setup/constantinit/index.jsp?name=";
  388. else
  389. resultStr = "/admin/setup/sysmodel/objmanager/constant/edit.jsp?name=";
  390. }
  391. else if (nodeType.equals("5")) { // else
  392. // if(nodeID.equals("mdpClasses")){
  393. resultStr = "/admin/setup/sysmodel/objmanager/table/list.jsp?type=";
  394. } else if (nodeType.equals("50")) { // else
  395. // if(nodeID.startsWith("mdpClasses.")){
  396. resultStr = "/admin/setup/sysmodel/objmanager/table/container.jsp?classid=";
  397. }
  398. else if (nodeType.equals("6")) { // nodeID.equals("pageList")
  399. if (this.ispublish)
  400. return "";
  401. resultStr = "/admin/setup/listmodel/objmanager/list_exc.jsp?type=";
  402. } else if (nodeType.equals("60")) { // else
  403. // if(nodeID.startsWith("pageList.")){
  404. if (this.ispublish)
  405. resultStr = "/sample/formlist/sample.jsp?listid=";
  406. else
  407. resultStr = "/admin/setup/listmodel/objmanager/container.html?listid=";
  408. }
  409. else if (nodeType.equals("7")) { // nodeID.equals("pageCollection")
  410. if (this.ispublish)
  411. return "";
  412. resultStr = "/admin/setup/collectmodel/objmanager/list_exc.jsp?type=";
  413. } else if (nodeType.equals("70")) { // nodeID.startsWith("pageCollection.")
  414. if (this.ispublish)
  415. resultStr = "/sample/formcollect/sample.jsp?pageid=";
  416. else
  417. resultStr = "/admin/setup/collectmodel/objmanager/container.html?pagid=";
  418. }
  419. return resultStr + arrayData[2];
  420. }
  421. }