0c73346c5b2137ec7ea26819bbfb3c58f8f925bc.svn-base 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. *
  3. */
  4. package com.sysmodel.datamodel.xmlmodel.impl;
  5. import java.util.ArrayList;
  6. import java.util.Iterator;
  7. import java.util.List;
  8. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  9. import com.sysmodel.datamodel.xmlmodel.able.Property;
  10. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  11. import com.sysmodel.datamodel.xmlmodel.able.Template;
  12. public class TemplateImpl implements Template{
  13. /** 模板名称 */
  14. private String name = null;
  15. /** 模板数据存放的表名称. */
  16. private String tableName = null;
  17. /** 模板描述. */
  18. private String description = null;
  19. /** 数据库链接编号. */
  20. private int dataSource;
  21. private List<PropertyImpl> listproperty = new ArrayList<PropertyImpl>();
  22. private Property uniqueProperty = null;
  23. private Property referenceProperty = null;
  24. public String getDescription() {
  25. return description;
  26. }
  27. public void setDescription(String description) {
  28. this.description = description;
  29. }
  30. public List<PropertyImpl> getListproperty() {
  31. return listproperty;
  32. }
  33. public void setListproperty(List<PropertyImpl> listproperty) {
  34. this.listproperty = listproperty;
  35. refresh();
  36. }
  37. public String getName() {
  38. return name;
  39. }
  40. public void setName(String name) {
  41. this.name = name;
  42. }
  43. public Property getReferenceProperty() {
  44. return referenceProperty;
  45. }
  46. public Property getUniqueProperty() {
  47. return uniqueProperty;
  48. }
  49. public Property getPropertyByName(String propertyName) {
  50. for (int i = 0; i < listproperty.size(); i++) {
  51. Property property = (Property) listproperty.get(i);
  52. if (property.getName().equals(propertyName))
  53. return property;
  54. }
  55. return null;
  56. }
  57. public void refresh() {
  58. for (int i = 0; i < listproperty.size(); i++) {
  59. Property property = (Property) listproperty.get(i);
  60. if (property.isUnique())
  61. uniqueProperty = property;
  62. if (!property.getReferenceParentName().equals(""))
  63. referenceProperty = property;
  64. }
  65. }
  66. public void setTableName(String tableName) {
  67. this.tableName = tableName;
  68. }
  69. /*
  70. * (non-Javadoc)
  71. *
  72. * @see com.sysmodel.datamodel.xmlmodel.able.Template#getTableName()
  73. */
  74. public String getTableName() {
  75. return tableName;
  76. }
  77. /*
  78. * (non-Javadoc)
  79. *
  80. * @see
  81. * com.sysmodel.datamodel.xmlmodel.able.Template#getTemplateMdpConstants()
  82. */
  83. public ArrayList<MdpConstantImpl> getTemplateMdpConstants() {
  84. ArrayList<MdpConstantImpl> result = new ArrayList<MdpConstantImpl>();
  85. SysModel sysmodel = ModelFactory.getSysmodel();
  86. Iterator<MdpConstantImpl> it = sysmodel.getMdpConstants().iterator();
  87. while (it.hasNext()) {
  88. MdpConstantImpl vo = it.next();
  89. if (vo.getTemplateName().equalsIgnoreCase(this.getName())) {
  90. result.add(vo);
  91. }
  92. }
  93. return result;
  94. }
  95. public void setDataSource(int dataSource) {
  96. this.dataSource = dataSource;
  97. }
  98. public int getDataSource() {
  99. return dataSource;
  100. }
  101. }