<%@ page pageEncoding="UTF-8"%> <%@ page contentType="text/html; charset=UTF-8" language="java" %> <%@ page language="java" import="com.sysmodel.datamodel.xmlmodel.ModelFactory, com.sysmodel.datamodel.xmlmodel.able.SysModel, com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl, com.sysmodel.datamodel.xmlmodel.impl.MdpAttributeImpl, com.sysmodel.datamodel.xmlmodel.Reference, com.sysmodel.datamodel.xmlmanager.xmlobjdll.SysModeldllable, com.sysmodel.datamodel.xmlmanager.xmlobjdll.SysModeldllimpl"%> <% String classid = request.getParameter("classid") == null ? "0" : request.getParameter("classid"); String action = request.getParameter("action") == null ? "" : request.getParameter("action"); String attributeName = request.getParameter("oName") == null ? "" : request.getParameter("oName"); int iclassid = Integer.parseInt(classid); SysModel sysmodel = ModelFactory.getSysmodel(); MdpClassImpl MdpClass = (MdpClassImpl)sysmodel.getMdpClassByClassID(iclassid); MdpAttributeImpl MdpAttribute = null; SysModeldllable SysModeldllable = new SysModeldllimpl(); if(action.equals("save") || action.equals("edit")){ MdpAttribute = new MdpAttributeImpl(); String validate = request.getParameter("validate") == null ? "" : request.getParameter("validate"); String name = request.getParameter("name") == null ? "" : request.getParameter("name"); String description = request.getParameter("description") == null ? "" : request.getParameter("description"); String unit = request.getParameter("unit") == null ? "" : request.getParameter("unit"); String logicPrimaryKey = request.getParameter("logicPrimaryKey") == null ? "" : request.getParameter("logicPrimaryKey"); String dataType = request.getParameter("dataType") == null ? "" : request.getParameter("dataType"); String referenceType = request.getParameter("referenceType") == null ? "" : request.getParameter("referenceType"); String referenceTable = ""; String storeName = ""; String displayName = ""; if(referenceType.equals("1")){ referenceTable = request.getParameter("referenceTable_table") == null ? "" : request.getParameter("referenceTable_table"); storeName = request.getParameter("storeName") == null ? "" : request.getParameter("storeName"); displayName = request.getParameter("displayName") == null ? "" : request.getParameter("displayName"); }else if(referenceType.equals("2")){ referenceTable = request.getParameter("referenceTable_constant") == null ? "" : request.getParameter("referenceTable_constant"); } String scale = request.getParameter("scale") == null ? "" : request.getParameter("scale"); String precision = request.getParameter("precision") == null ? "" : request.getParameter("precision"); String index = request.getParameter("index") == null ? "false" : request.getParameter("index"); String indexType = request.getParameter("indexType") == null ? "" : request.getParameter("indexType"); String defaultValue = request.getParameter("defaultValue") == null ? "" : request.getParameter("defaultValue"); String notNull = request.getParameter("notNull") == null ? "true" : request.getParameter("notNull"); MdpAttribute.setValidate(new Boolean(validate).booleanValue()); MdpAttribute.setName(name); MdpAttribute.setDescription(description); MdpAttribute.setUnit(unit); MdpAttribute.setLogicPrimaryKey(new Boolean(logicPrimaryKey).booleanValue()); MdpAttribute.setDataType(dataType); if(!referenceType.equals("")){ MdpAttribute.setReferenceType(new Integer(referenceType).intValue()); } MdpAttribute.setScale(scale); if(!precision.equals("")){ MdpAttribute.setPrecision(new Integer(precision).intValue()); } MdpAttribute.setIndex(new Boolean(index).booleanValue()); MdpAttribute.setIndexType(indexType); MdpAttribute.setDefaultValue(defaultValue); MdpAttribute.setNotNull(new Boolean(notNull).booleanValue()); Reference Reference = MdpAttribute.getReference() ; if (Reference!= null){ Reference.setReferenceTable(referenceTable); Reference.setStoreName(storeName); Reference.setDisplayName(displayName); } else { Reference = new Reference(); Reference.setReferenceTable(referenceTable); Reference.setStoreName(storeName); Reference.setDisplayName(displayName); MdpAttribute.setReference(Reference); } if(action.equals("save")){ SysModeldllable.addAttribute(MdpAttribute , MdpClass); }else if (action.equals("edit")){ SysModeldllable.updateAttribute(MdpAttribute , MdpClass , attributeName); } } else if (action.equals("del")){ MdpAttribute = (MdpAttributeImpl)MdpClass.getMdpAttributeByName(attributeName); SysModeldllable.deleteAttribute(MdpAttribute,MdpClass); } response.sendRedirect("list.jsp?classid="+classid); %>