123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /*
- *
- */
- package com.sysmodel.datamodel.xmlmodel.impl;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.Property;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.datamodel.xmlmodel.able.Template;
- public class TemplateImpl implements Template{
- /** 模板名称 */
- private String name = null;
- /** 模板数据存放的表名称. */
- private String tableName = null;
- /** 模板描述. */
- private String description = null;
- /** 数据库链接编号. */
- private int dataSource;
- private List<PropertyImpl> listproperty = new ArrayList<PropertyImpl>();
- private Property uniqueProperty = null;
- private Property referenceProperty = null;
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public List<PropertyImpl> getListproperty() {
- return listproperty;
- }
- public void setListproperty(List<PropertyImpl> listproperty) {
- this.listproperty = listproperty;
- refresh();
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Property getReferenceProperty() {
- return referenceProperty;
- }
- public Property getUniqueProperty() {
- return uniqueProperty;
- }
- public Property getPropertyByName(String propertyName) {
- for (int i = 0; i < listproperty.size(); i++) {
- Property property = (Property) listproperty.get(i);
- if (property.getName().equals(propertyName))
- return property;
- }
- return null;
- }
- public void refresh() {
- for (int i = 0; i < listproperty.size(); i++) {
- Property property = (Property) listproperty.get(i);
- if (property.isUnique())
- uniqueProperty = property;
- if (!property.getReferenceParentName().equals(""))
- referenceProperty = property;
- }
- }
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.sysmodel.datamodel.xmlmodel.able.Template#getTableName()
- */
- public String getTableName() {
- return tableName;
- }
- /*
- * (non-Javadoc)
- *
- * @see
- * com.sysmodel.datamodel.xmlmodel.able.Template#getTemplateMdpConstants()
- */
- public ArrayList<MdpConstantImpl> getTemplateMdpConstants() {
- ArrayList<MdpConstantImpl> result = new ArrayList<MdpConstantImpl>();
- SysModel sysmodel = ModelFactory.getSysmodel();
- Iterator<MdpConstantImpl> it = sysmodel.getMdpConstants().iterator();
- while (it.hasNext()) {
- MdpConstantImpl vo = it.next();
- if (vo.getTemplateName().equalsIgnoreCase(this.getName())) {
- result.add(vo);
- }
- }
- return result;
- }
- public void setDataSource(int dataSource) {
- this.dataSource = dataSource;
- }
- public int getDataSource() {
- return dataSource;
- }
- }
|