/* * */ 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 listproperty = new ArrayList(); private Property uniqueProperty = null; private Property referenceProperty = null; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public List getListproperty() { return listproperty; } public void setListproperty(List 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 getTemplateMdpConstants() { ArrayList result = new ArrayList(); SysModel sysmodel = ModelFactory.getSysmodel(); Iterator 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; } }