a36583740a52302cbcb43ae951e22420debadd54.svn-base 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <%@ page contentType="text/html;charset=UTF-8"%>
  2. <%@ page language="java"
  3. import="com.sysmodel.datamodel.xmlmodel.ModelFactory,
  4. com.sysmodel.datamodel.xmlmodel.able.SysModel,
  5. com.sysmodel.datamodel.xmlmodel.able.MdpConstant,
  6. com.sysmodel.datamodel.xmlmodel.able.Property,
  7. com.sysmodel.datamodel.xmlmodel.PropertyValue,
  8. com.persistence.service.PersistenceFactory,
  9. com.persistence.service.SysPersistence,
  10. com.sysmodel.datamodel.xmlmodel.able.Template"%>
  11. <%@ page language="java"
  12. import="java.util.*"%>
  13. <html>
  14. <head>
  15. <title></title>
  16. </head>
  17. </html>
  18. <%
  19. request.setCharacterEncoding("UTF-8");
  20. MdpConstant constant = null;
  21. String command = request.getParameter("cmd")==null?"":(String)request.getParameter("cmd");
  22. String codeName = request.getParameter("codeName")==null?"":(String)request.getParameter("codeName");
  23. String nodeID = request.getParameter("nodeID")==null?"":(String)request.getParameter("nodeID");
  24. constant = ModelFactory.getSysmodel().getMdpConstantByName(codeName);
  25. ArrayList listPropertyValue = new ArrayList();
  26. List listProperty = constant.getTemplate().getListproperty();
  27. Template templ = ModelFactory.getSysmodel().getTemplateByName(constant.getTemplateName());
  28. String templateName = templ.getTableName();
  29. Iterator it = listProperty.iterator();
  30. String newNodeID = "";
  31. while(it.hasNext()){
  32. PropertyValue pv = new PropertyValue();
  33. Property field = (Property)it.next();
  34. pv.setPropertyName(field.getName());
  35. String fieldValue = request.getParameter(field.getName());
  36. if(fieldValue == null) fieldValue = "";
  37. if(field.isUnique()) newNodeID = fieldValue;
  38. if(field.isUnique()
  39. && command.equals("add")
  40. && constant.isKeyCodeAuto()){
  41. pv.setPropertyValue(fieldValue);
  42. } else {
  43. pv.setPropertyValue(fieldValue);
  44. }
  45. listPropertyValue.add(pv);
  46. }
  47. SysModel sysModel = ModelFactory.getSysmodel();
  48. SysPersistence sysPersistenceObject = PersistenceFactory.getInstance(sysModel);
  49. String paramString = "";
  50. boolean success = false;
  51. if(command.equalsIgnoreCase("modify")){
  52. out.println("modify canstant!!!!");
  53. success = sysPersistenceObject.updateConstant(templateName,listPropertyValue);
  54. ArrayList newValueList = sysPersistenceObject.searchConstant(templateName,nodeID);
  55. constant.updateDataContent(newValueList);
  56. }
  57. if(command.equalsIgnoreCase("add")){
  58. success = sysPersistenceObject.insertConstant(templateName,listPropertyValue);
  59. ArrayList newValueList = sysPersistenceObject.searchConstant(templateName,newNodeID);
  60. constant.addDataContent(newValueList);
  61. }
  62. if(command.equalsIgnoreCase("delete")){
  63. success = sysPersistenceObject.deleteConstant(templateName,nodeID);
  64. constant.deleteDataContent(nodeID);
  65. }
  66. if(!success){
  67. response.getWriter().write("{\"success\":"+new Boolean(false).toString()+"}");
  68. %>
  69. <SCRIPT LANGUAGE="JavaScript">
  70. <!--
  71. alert("新增数据错误,请检查编码值是否重复!");
  72. history.go(-1);
  73. //-->
  74. </SCRIPT>
  75. <%
  76. }else{
  77. response.getWriter().write("{\"success\":"+new Boolean(true).toString()+"}");
  78. %>
  79. <SCRIPT LANGUAGE="JavaScript">
  80. <!--
  81. alert("成功操作数据!");
  82. //-->
  83. </SCRIPT>
  84. <%
  85. //response.sendRedirect("list.jsp?codeName=" + codeName+paramString);
  86. }
  87. response.getWriter().flush();
  88. response.getWriter().close();
  89. %>