getAttributeXml.jsp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <%@ page contentType="text/xml; charset=UTF-8" language="java"%>
  2. <%@ page
  3. import ="com.sysmodel.datamodel.xmlmodel.ModelFactory,
  4. com.sysmodel.datamodel.xmlmodel.able.SysModel,
  5. com.sysmodel.datamodel.xmlmodel.impl.MdpAttributeImpl,
  6. com.sysmodel.datamodel.xmlmodel.able.MdpClass,
  7. com.sysmodel.datamodel.xmlmodel.able.MdpAttribute,
  8. java.util.*"
  9. %>
  10. <%
  11. SysModel sysmodel = ModelFactory.getSysmodel();
  12. String classid = request.getParameter("classid") == null ? "0" : request.getParameter("classid");
  13. String name = request.getParameter("name") == null ? "" : request.getParameter("name");
  14. String gettype = request.getParameter("gettype") == null ? "all" : request.getParameter("gettype");
  15. MdpClass MdpClass = sysmodel.getMdpClassByClassID(Integer.parseInt(classid));
  16. ArrayList Attributes = (ArrayList)MdpClass.getAllMdpAttributes();
  17. out.print("<root>");
  18. if(name.equals("")){
  19. for (int i = 0; i < Attributes.size(); i++) {
  20. MdpAttributeImpl MdpAttributeImpl = (MdpAttributeImpl) Attributes.get(i);
  21. if(gettype.equals("all")){
  22. out.print("<name>"+MdpAttributeImpl.getName()+"</name>");
  23. out.print("<description>"+MdpAttributeImpl.getDescription()+"</description>");
  24. } else if (gettype.equals("constant") && MdpAttributeImpl.getReferenceType() != 0){
  25. out.print("<name>"+MdpAttributeImpl.getName()+"</name>");
  26. out.print("<description>"+MdpAttributeImpl.getDescription()+"</description>");
  27. } else if (gettype.equals("date") && MdpAttributeImpl.getDataType().equals("date")){
  28. out.print("<name>"+MdpAttributeImpl.getName()+"</name>");
  29. out.print("<description>"+MdpAttributeImpl.getDescription()+"</description>");
  30. } else if (gettype.equals("text")
  31. && MdpAttributeImpl.getReferenceType() == 0
  32. && !MdpAttributeImpl.getDataType().equals("date")){
  33. out.print("<name>"+MdpAttributeImpl.getName()+"</name>");
  34. out.print("<description>"+MdpAttributeImpl.getDescription()+"</description>");
  35. }
  36. }
  37. } else {
  38. MdpAttribute MdpAttribute = MdpClass.getMdpAttributeByName(name);
  39. if(MdpAttribute.getReferenceType() == 1 && MdpAttribute.getReference().getReferenceTable() != null){
  40. MdpClass mdpClass = sysmodel.getMdpClassByClassID(Integer.parseInt(MdpAttribute.getReference().getReferenceTable()));
  41. List attributes = mdpClass.getAllMdpAttributes();
  42. for (int i = 0; i < attributes.size(); i++) {
  43. MdpAttributeImpl MdpAttributeImpl = (MdpAttributeImpl) attributes.get(i);
  44. out.print("<name>"+MdpAttributeImpl.getName()+"</name>");
  45. out.print("<description>"+MdpAttributeImpl.getDescription()+"</description>");
  46. }
  47. }
  48. }
  49. out.print("</root>");
  50. %>