123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <%@ page contentType="text/html;charset=UTF-8"%>
- <%@ page language="java"
- import="com.sysmodel.datamodel.xmlmodel.ModelFactory,
- com.sysmodel.datamodel.xmlmodel.able.SysModel,
- com.sysmodel.datamodel.xmlmodel.able.MdpConstant,
- com.sysmodel.datamodel.xmlmodel.able.Property,
- com.sysmodel.datamodel.xmlmodel.PropertyValue,
- com.persistence.service.PersistenceFactory,
- com.persistence.service.SysPersistence,
- com.sysmodel.datamodel.xmlmodel.able.Template"%>
- <%@ page language="java"
- import="java.util.*"%>
- <html>
- <head>
- <title></title>
- </head>
- </html>
- <%
- request.setCharacterEncoding("UTF-8");
- MdpConstant constant = null;
- String command = request.getParameter("cmd")==null?"":(String)request.getParameter("cmd");
- String codeName = request.getParameter("codeName")==null?"":(String)request.getParameter("codeName");
- String nodeID = request.getParameter("nodeID")==null?"":(String)request.getParameter("nodeID");
-
-
- constant = ModelFactory.getSysmodel().getMdpConstantByName(codeName);
- ArrayList listPropertyValue = new ArrayList();
- List listProperty = constant.getTemplate().getListproperty();
-
- Template templ = ModelFactory.getSysmodel().getTemplateByName(constant.getTemplateName());
- String templateName = templ.getTableName();
- Iterator it = listProperty.iterator();
- String newNodeID = "";
- while(it.hasNext()){
- PropertyValue pv = new PropertyValue();
- Property field = (Property)it.next();
- pv.setPropertyName(field.getName());
-
- String fieldValue = request.getParameter(field.getName());
- if(fieldValue == null) fieldValue = "";
- if(field.isUnique()) newNodeID = fieldValue;
-
- if(field.isUnique()
- && command.equals("add")
- && constant.isKeyCodeAuto()){
- pv.setPropertyValue(fieldValue);
- } else {
- pv.setPropertyValue(fieldValue);
- }
- listPropertyValue.add(pv);
- }
-
-
-
- SysModel sysModel = ModelFactory.getSysmodel();
- SysPersistence sysPersistenceObject = PersistenceFactory.getInstance(sysModel);
-
- String paramString = "";
- boolean success = false;
- if(command.equalsIgnoreCase("modify")){
- out.println("modify canstant!!!!");
- success = sysPersistenceObject.updateConstant(templateName,listPropertyValue);
- ArrayList newValueList = sysPersistenceObject.searchConstant(templateName,nodeID);
- constant.updateDataContent(newValueList);
- }
- if(command.equalsIgnoreCase("add")){
- success = sysPersistenceObject.insertConstant(templateName,listPropertyValue);
- ArrayList newValueList = sysPersistenceObject.searchConstant(templateName,newNodeID);
- constant.addDataContent(newValueList);
- }
- if(command.equalsIgnoreCase("delete")){
- success = sysPersistenceObject.deleteConstant(templateName,nodeID);
- constant.deleteDataContent(nodeID);
- }
- if(!success){
- response.getWriter().write("{\"success\":"+new Boolean(false).toString()+"}");
- %>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- alert("新增数据错误,请检查编码值是否重复!");
- history.go(-1);
- //-->
- </SCRIPT>
- <%
- }else{
- response.getWriter().write("{\"success\":"+new Boolean(true).toString()+"}");
- %>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- alert("成功操作数据!");
- //-->
- </SCRIPT>
- <%
- //response.sendRedirect("list.jsp?codeName=" + codeName+paramString);
- }
- response.getWriter().flush();
- response.getWriter().close();
- %>
|