2c1848c2861abb609de804d21f01d240a5ca6c20.svn-base 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <%@ page pageEncoding="UTF-8"%>
  2. <%@ page contentType="text/html; charset=UTF-8" language="java" %>
  3. <%@ page language="java"
  4. import="com.sysmodel.datamodel.xmlmodel.ModelFactory,
  5. com.sysmodel.datamodel.xmlmodel.able.SysModel,
  6. com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl,
  7. com.sysmodel.datamodel.xmlmodel.impl.MdpAttributeImpl,
  8. com.sysmodel.datamodel.xmlmodel.Reference,
  9. com.sysmodel.datamodel.xmlmanager.xmlobjdll.SysModeldllable,
  10. com.sysmodel.datamodel.xmlmanager.xmlobjdll.SysModeldllimpl"%>
  11. <%
  12. String classid = request.getParameter("classid") == null ? "0" : request.getParameter("classid");
  13. String action = request.getParameter("action") == null ? "" : request.getParameter("action");
  14. String attributeName = request.getParameter("oName") == null ? "" : request.getParameter("oName");
  15. int iclassid = Integer.parseInt(classid);
  16. SysModel sysmodel = ModelFactory.getSysmodel();
  17. MdpClassImpl MdpClass = (MdpClassImpl)sysmodel.getMdpClassByClassID(iclassid);
  18. MdpAttributeImpl MdpAttribute = null;
  19. SysModeldllable SysModeldllable = new SysModeldllimpl();
  20. if(action.equals("save") || action.equals("edit")){
  21. MdpAttribute = new MdpAttributeImpl();
  22. String validate = request.getParameter("validate") == null ? "" : request.getParameter("validate");
  23. String name = request.getParameter("name") == null ? "" : request.getParameter("name");
  24. String description = request.getParameter("description") == null ? "" : request.getParameter("description");
  25. String unit = request.getParameter("unit") == null ? "" : request.getParameter("unit");
  26. String logicPrimaryKey = request.getParameter("logicPrimaryKey") == null ? "" : request.getParameter("logicPrimaryKey");
  27. String dataType = request.getParameter("dataType") == null ? "" : request.getParameter("dataType");
  28. String referenceType = request.getParameter("referenceType") == null ? "" : request.getParameter("referenceType");
  29. String referenceTable = "";
  30. String storeName = "";
  31. String displayName = "";
  32. if(referenceType.equals("1")){
  33. referenceTable = request.getParameter("referenceTable_table") == null ? "" : request.getParameter("referenceTable_table");
  34. storeName = request.getParameter("storeName") == null ? "" : request.getParameter("storeName");
  35. displayName = request.getParameter("displayName") == null ? "" : request.getParameter("displayName");
  36. }else if(referenceType.equals("2")){
  37. referenceTable = request.getParameter("referenceTable_constant") == null ? "" : request.getParameter("referenceTable_constant");
  38. }
  39. String scale = request.getParameter("scale") == null ? "" : request.getParameter("scale");
  40. String precision = request.getParameter("precision") == null ? "" : request.getParameter("precision");
  41. String index = request.getParameter("index") == null ? "false" : request.getParameter("index");
  42. String indexType = request.getParameter("indexType") == null ? "" : request.getParameter("indexType");
  43. String defaultValue = request.getParameter("defaultValue") == null ? "" : request.getParameter("defaultValue");
  44. String notNull = request.getParameter("notNull") == null ? "true" : request.getParameter("notNull");
  45. MdpAttribute.setValidate(new Boolean(validate).booleanValue());
  46. MdpAttribute.setName(name);
  47. MdpAttribute.setDescription(description);
  48. MdpAttribute.setUnit(unit);
  49. MdpAttribute.setLogicPrimaryKey(new Boolean(logicPrimaryKey).booleanValue());
  50. MdpAttribute.setDataType(dataType);
  51. if(!referenceType.equals("")){
  52. MdpAttribute.setReferenceType(new Integer(referenceType).intValue());
  53. }
  54. MdpAttribute.setScale(scale);
  55. if(!precision.equals("")){
  56. MdpAttribute.setPrecision(new Integer(precision).intValue());
  57. }
  58. MdpAttribute.setIndex(new Boolean(index).booleanValue());
  59. MdpAttribute.setIndexType(indexType);
  60. MdpAttribute.setDefaultValue(defaultValue);
  61. MdpAttribute.setNotNull(new Boolean(notNull).booleanValue());
  62. Reference Reference = MdpAttribute.getReference() ;
  63. if (Reference!= null){
  64. Reference.setReferenceTable(referenceTable);
  65. Reference.setStoreName(storeName);
  66. Reference.setDisplayName(displayName);
  67. } else {
  68. Reference = new Reference();
  69. Reference.setReferenceTable(referenceTable);
  70. Reference.setStoreName(storeName);
  71. Reference.setDisplayName(displayName);
  72. MdpAttribute.setReference(Reference);
  73. }
  74. if(action.equals("save")){
  75. SysModeldllable.addAttribute(MdpAttribute , MdpClass);
  76. }else if (action.equals("edit")){
  77. SysModeldllable.updateAttribute(MdpAttribute , MdpClass , attributeName);
  78. }
  79. } else if (action.equals("del")){
  80. MdpAttribute = (MdpAttributeImpl)MdpClass.getMdpAttributeByName(attributeName);
  81. SysModeldllable.deleteAttribute(MdpAttribute,MdpClass);
  82. }
  83. response.sendRedirect("list.jsp?classid="+classid);
  84. %>