12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157 |
- package com.sysmodel.datamodel.xmlmanager.xmlobjdll;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.google.api.translate.Language;
- import com.google.api.translate.Translate;
- import com.sysmodel.datamodel.Parameter.XmlManagerPara;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.Reference;
- import com.sysmodel.datamodel.xmlmodel.able.MdpClass;
- import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
- import com.sysmodel.datamodel.xmlmodel.able.MdpModule;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpAttributeImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpConstantImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpDataSourceImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.MdpModuleImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.PropertyImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.SysModelImpl;
- import com.sysmodel.datamodel.xmlmodel.impl.TemplateImpl;
- import com.toolkit.file.FileOperate;
- public class SysModeldllimplTest implements SysModeldllable{
- private Log log = LogFactory.getLog(SysModeldllimpl.class);
- public String addAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
- String result = isRepeatAttribute(imp, mdlclass);
- if (!result.equals(""))
- return result;
- ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
- .getAllMdpAttributes();
- list.add(imp);
- mdlclass.setMdpAttributes(list);
- return XmlManagerPara.add_success;
- }
- public String addDataSource(MdpDataSourceImpl imp) {
- SysModelImpl.getInstance().getMdpDataSources().add(imp);
- return XmlManagerPara.add_success;
- }
- public String addTable(MdpClassImpl imp) {
- String result = isRepeatTableName(imp);
- if (!result.equals(""))
- return result;
- SysModelImpl.getInstance().getMdpClasses().add(imp);
- return XmlManagerPara.add_success;
- }
- public String addTemplate(TemplateImpl imp) {
- SysModelImpl.getInstance().getTemplates().add(imp);
- return XmlManagerPara.add_success;
- }
- public String deleteAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
- String result = isQuotedAttribute(imp, mdlclass);
- if (!result.equals(""))
- return result;
- ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
- .getAllMdpAttributes();
- for (int i = 0; i < list.size(); i++) {
- MdpAttributeImpl oImpl = list.get(i);
- if (oImpl.getName().equals(imp.getName())) {
- list.remove(i);
- }
- }
- mdlclass.setMdpAttributes(list);
- return XmlManagerPara.delete_success;
- }
- public String deleteDataSource(MdpDataSourceImpl imp) {
- Iterator<MdpDataSourceImpl> it = SysModelImpl.getInstance().getMdpDataSources().iterator();
- while (it.hasNext()) {
- MdpDataSourceImpl temp = it.next();
- if (temp.getDataSourceid() == imp.getDataSourceid())
- it.remove();
- }
- return XmlManagerPara.delete_success;
- }
- public String deleteTable(MdpClassImpl imp) {
- // 如果有关系,删除与之关联的关系
- Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
- while (it.hasNext()) {
- MdpClassImpl temp = it.next();
- if (temp.getClassid() == imp.getClassid())
- it.remove();
- }
- return XmlManagerPara.delete_success;
- }
- public String deleteTemplate(TemplateImpl imp) {
- Iterator<TemplateImpl> it = SysModelImpl.getInstance().getTemplates().iterator();
- while (it.hasNext()) {
- TemplateImpl temp = (TemplateImpl) it.next();
- if (temp.getName() == imp.getName())
- it.remove();
- }
- return XmlManagerPara.delete_success;
- }
- public String updateAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass, String oName) {
- // 得到修改前的表字段信息
- MdpAttributeImpl old = (MdpAttributeImpl) mdlclass.getMdpAttributeByName(oName);
- // 该数据源中表的字段英文名不能相同
- String result = this.isRepeatAttribute(imp, mdlclass);
- if (!imp.getName().equals(old.getName()) && !result.equals(""))
- return result;
- old.setValidate(imp.isValidate());
- old.setName(imp.getName());
- old.setDescription(imp.getDescription());
- old.setLogicPrimaryKey(imp.isLogicPrimaryKey());
- old.setDataType(imp.getDataType());
- old.setReferenceType(imp.getReferenceType());
- old.setScale(imp.getScale());
- old.setPrecision(imp.getPrecision());
- old.setIndex(imp.isIndex());
- old.setIndexType(imp.getIndexType());
- old.setDefaultValue(imp.getDefaultValue());
- old.setNotNull(imp.isNotNull());
- old.setUnit(imp.getUnit());
- Reference oReference = old.getReference();
- if (oReference != null) {
- if (imp.getReference() != null) {
- oReference.setReferenceTable(imp.getReference().getReferenceTable());
- oReference.setStoreName(imp.getReference().getStoreName());
- oReference.setDisplayName(imp.getReference().getDisplayName());
- }
- } else {
- if (imp.getReference() != null) {
- oReference = new Reference();
- oReference.setReferenceTable(imp.getReference().getReferenceTable());
- oReference.setStoreName(imp.getReference().getStoreName());
- oReference.setDisplayName(imp.getReference().getDisplayName());
- old.setReference(oReference);
- }
- }
- String classid = "" + mdlclass.getClassid();
- SysModel sysmodel = ModelFactory.getSysmodel();
- ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
- for (int i = 0; i < mdpClasses.size(); i++) {
- MdpClassImpl MdpClass = mdpClasses.get(i);
- ArrayList<MdpAttributeImpl> attributelist = (ArrayList<MdpAttributeImpl>) MdpClass
- .getAllMdpAttributes();
- for (int j = 0; j < attributelist.size(); j++) {
- MdpAttributeImpl MdpAttribute = attributelist.get(j);
- Reference reference = MdpAttribute.getReference();
- if (reference != null) {
- if (reference.getReferenceTable().equals(classid)
- && reference.getStoreName().equals(oName)) {
- reference.setStoreName(imp.getName());
- }
- }
- }
- }
- return XmlManagerPara.update_success;
- }
- public String updateDataSource(MdpDataSourceImpl imp) {
- // 得到修改前的表信息
- MdpDataSourceImpl old = (MdpDataSourceImpl) SysModelImpl.getInstance().getDataSourceByCode(
- imp.getDataSourceid());
- // 判断数据源是否改变
- old.setDataSourceid(imp.getDataSourceid());
- old.setDataBase(imp.getDataBase());
- old.setDescription(imp.getDescription());
- old.setJNDI(imp.getJNDI());
- old.setPassword(imp.getPassword());
- old.setURL(imp.getURL());
- old.setUser(imp.getUser());
- return XmlManagerPara.update_success;
- }
- public String updateTable(MdpClassImpl imp) {
- // 得到修改前的表信息
- MdpClassImpl old = (MdpClassImpl) SysModelImpl.getInstance().getMdpClassByClassID(
- imp.getClassid());
- // 该数据源中表的中英文名不能相同
- String result = this.isRepeatTableName(imp);
- if (!result.equals(""))
- return result;
- // 判断数据源是否改变
- old.setDataSource(imp.getDataSource());
- old.setValidate(imp.isValidate());
- old.setDescription(imp.getDescription());
- old.setName(imp.getName());
- old.setType(imp.getType());
- return XmlManagerPara.update_success;
- }
- public String updateTemplate(TemplateImpl imp, String constantname) {
- // 得到修改前的表字段信息
- TemplateImpl old = (TemplateImpl) SysModelImpl.getInstance()
- .getTemplateByName(constantname);
- // 该数据源中表的字段英文名不能相同
- old.setName(imp.getName());
- old.setDescription(imp.getDescription());
- return XmlManagerPara.update_success;
- }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public String addProperty(PropertyImpl imp, TemplateImpl template) {
- if (isRepeatProperty(imp, template))
- return "重复了";
- ArrayList<PropertyImpl> list = (ArrayList) template.getListproperty();
- list.add(imp);
- template.setListproperty(list);
- return XmlManagerPara.add_success;
- }
- public String updateProperty(PropertyImpl imp, TemplateImpl template, String oName) {
- if (imp.getName().equals(oName)
- || (!imp.getName().equals(oName) && !this.isRepeatProperty(imp, template))) {
- PropertyImpl old = (PropertyImpl) template.getPropertyByName(oName);
- old.setName(imp.getName());
- old.setDescription(imp.getDescription());
- old.setDataType(imp.getDataType());
- old.setLength(imp.getLength());
- old.setScale(imp.getScale());
- old.setReferenceParentName(imp.getReferenceParentName());
- old.setDisplay(imp.isDisplay());
- old.setUnique(imp.isUnique());
- log.info("imp validate :" + imp.getValidate().getInvalidMessage()
- + imp.getValidate().getDojoType());
- old.setValidate(imp.getValidate());
- return XmlManagerPara.update_success;
- }
- return XmlManagerPara.repeat_ENname;
- }
- public String deleteProperty(PropertyImpl imp, TemplateImpl template) {
- String result = isQuotedTemplate(template);
- if (!result.equals(""))
- return result;
- ArrayList<PropertyImpl> list = (ArrayList<PropertyImpl>) template.getListproperty();
- for (int i = 0; i < list.size(); i++) {
- PropertyImpl pImpl = (PropertyImpl) list.get(i);
- if (pImpl.getName().equals(imp.getName())) {
- list.remove(i);
- }
- }
- template.setListproperty(list);
- return XmlManagerPara.delete_success;
- }
- public String addMdpModule(MdpModuleImpl imp) {
- SysModelImpl.getInstance().getMdpModules().add(imp);
- return XmlManagerPara.add_success;
- }
- public String deleteMdpModule(MdpModuleImpl imp) {
- Iterator<MdpModuleImpl> it = SysModelImpl.getInstance().getMdpModules().iterator();
- while (it.hasNext()) {
- MdpModuleImpl temp = it.next();
- if (temp.getCode() == imp.getCode())
- it.remove();
- }
- return XmlManagerPara.delete_success;
- }
- public String updateMdpModule(MdpModuleImpl imp) {
- // 得到修改前的表信息
- MdpModuleImpl old = (MdpModuleImpl) SysModelImpl.getInstance().getMdpModuleByCode(
- imp.getCode());
- // 判断数据源是否改变
- old.setCode(imp.getCode());
- old.setDescription(imp.getDescription());
- old.setName(imp.getName());
- old.setPackageName(imp.getPackageName());
- old.setPcode(imp.getPcode());
- return XmlManagerPara.update_success;
- }
- public String addConstant(MdpConstantImpl imp) {
- SysModelImpl.getInstance().getMdpConstants().add(imp);
- return XmlManagerPara.add_success;
- }
- public String deleteConstant(MdpConstantImpl imp) {
- Iterator<MdpConstantImpl> it = SysModelImpl.getInstance().getMdpConstants().iterator();
- while (it.hasNext()) {
- MdpConstantImpl temp = it.next();
- if (temp.getCodeName() == imp.getCodeName())
- it.remove();
- }
- return XmlManagerPara.delete_success;
- }
- @SuppressWarnings("deprecation")
- public String updateConstant(MdpConstantImpl imp, String constantname) {
- // 得到修改前的表信息
- MdpConstantImpl old = (MdpConstantImpl) SysModelImpl.getInstance().getMdpConstantByName(
- imp.getCodeName());
- // 判断数据源是否改变
- old.setCodeName(imp.getCodeName());
- old.setDataSource(imp.getDataSource());
- old.setDescription(imp.getDescription());
- old.setKeyCodeAuto(imp.isKeyCodeAuto());
- old.setOrderMethod(imp.getOrderMethod());
- old.setOrderProperty(imp.getOrderProperty());
- old.setType(imp.getType());
- log.info("old.getType()=" + old.getType());
- old.setTemplateName(imp.getTemplateName());
- old.setRootFrom(imp.getRootFrom());
- return XmlManagerPara.update_success;
- }
- public String checkTableConfig(MdpClassImpl imp) {
- StringBuffer sb = new StringBuffer();
- sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
- + "] 验证...<br>");
- sb.append("<font color=\"#FF0000\">");
- // 判断引用的数据源是否存在
- if (!isDataSourceExist(imp.getDataSource())) {
- sb.append(datasource_notexist).append("<br>");
- }
- if (isRepeatTableClassid(imp)) {
- sb.append(" 数据库表配置唯一标示 classid 重复 <br>");
- }
- ArrayList<MdpClassImpl> list = SysModel.getMdpClasses();
- // 判断表名是否唯一
- MdpClassImpl tempMdpClass = null;
- for (int i = 0; i < list.size(); i++) {
- tempMdpClass = list.get(i);
- if (tempMdpClass.getClassid() != imp.getClassid()) {
- if (imp.getDescription().equals(tempMdpClass.getDescription())) {
- sb.append(" 数据库表");
- sb.append(XmlManagerPara.repeat_CNname).append(
- ",与【" + tempMdpClass.getClassid() + " " + tempMdpClass.getDescription()
- + "】表<br>");
- }
- if (imp.getName().equals(tempMdpClass.getName())) {
- sb.append(" 数据库表");
- sb.append(XmlManagerPara.repeat_ENname).append(
- ",与【" + tempMdpClass.getClassid() + " " + tempMdpClass.getDescription()
- + "】表<br>");
- }
- }
- }
- // 判断表中字段定义信息的正确性
- List<MdpAttributeImpl> listFields = imp.getAllMdpAttributes();
- MdpAttributeImpl MdpAttribute = null;
- for (int i = 0; i < listFields.size(); i++) {
- MdpAttribute = listFields.get(i);
- /**
- * 判断英文名重复的字段
- */
- if (this.getNumByNameFromMdpClass(MdpAttribute.getName(), imp) > 1) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(XmlManagerPara.repeat_ENname);
- sb.append("<br>");
- }
- /**
- * 判断中文名重复的字段
- */
- if (this.getNumByDescriptionFromMdpClass(MdpAttribute.getDescription(), imp) > 1) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(XmlManagerPara.repeat_CNname);
- sb.append("<br>");
- }
- /**
- * 判断配置信息中的必填项目是否填写正确
- */
- if (MdpAttribute.getName().equals("")) {
- sb.append(" [");
- sb.append(MdpAttribute.getFieldDefine() + "] 没有定义英文名<br>");
- }
- if (MdpAttribute.getDescription().equals("")) {
- sb.append(" [");
- sb.append(MdpAttribute.getFieldDefine() + "] 没有定义中文名<br>");
- }
- if (MdpAttribute.getDataType().equals("")) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "] 没有定义数据类型<br>");
- }
- if (MdpAttribute.getDataType().equals("date")) {
- if (MdpAttribute.getScale() == ""
- || !MdpAttribute.getScale().startsWith("yyyy-MM-dd")) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 没有定义正确的数据格式<br>");
- }
- } else { // 非日期类型的字段必须有字段长度
- if (MdpAttribute.getPrecision() == 0 && !MdpAttribute.getDataType().equals("blob")
- && !MdpAttribute.getDataType().equals("clob")) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "] 没有定义长度<br>");
- }
- // oracle 中最大的长度是4000 其他数据库不知道????
- if (MdpAttribute.getPrecision() > 4000) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "] 字段长度定义过大<br>");
- }
- }
- /**
- * 判断常量字段配置是否正确
- */
- if (MdpAttribute.getReference() != null && MdpAttribute.getReferenceType() == 0) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的字段引用类型有误<br>");
- }
- if (MdpAttribute.getReferenceType() != 0) {
- if (MdpAttribute.getReference() == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的常量类型格式不完整<br>");
- }
- // 常量引用
- if (MdpAttribute.getReferenceType() == 2) {
- if (MdpAttribute.getReference() == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 常量类型没有指定引用的的常量<br>");
- } else if (SysModel.getMdpConstantByName(MdpAttribute.getReference()
- .getReferenceTable()) == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的常量类型引用的常量‘"
- + MdpAttribute.getReference().getReferenceTable() + "’不存在<br>");
- }
- }
- // 表数据引用
- if (MdpAttribute.getReferenceType() == 1) {
- try {
- if (MdpAttribute.getReference() == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 引用业务表类型没有指定引用表信息<br>");
- } else {
- String storeName = MdpAttribute.getReference().getStoreName();
- String displayName = MdpAttribute.getReference().getDisplayName();
- int iclassid = Integer.parseInt(MdpAttribute.getReference()
- .getReferenceTable());
- if (SysModel.getMdpClassByClassID(iclassid) == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的常量类型引用的表编号‘" + iclassid + "’不存在<br>");
- }
- if (storeName.toUpperCase().equals("FD_OBJECTID")) {
- if (SysModel.getMdpAttributeByName(iclassid, displayName) == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的常量类型引用的表中StoreName字段不存在<br>");
- }
- } else if (SysModel.getMdpAttributeByName(iclassid, storeName) == null
- || SysModel.getMdpAttributeByName(iclassid, displayName) == null) {
- sb.append(" [" + MdpAttribute.getFieldDefine() + "]");
- sb.append(" 定义的常量类型引用的表中字段不存在<br>");
- }
- }
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- }
- }
- }
- sb.append("</font>");
- return sb.toString();
- }
- public String checkConstantConfig(MdpConstantImpl imp) {
- StringBuffer sb = new StringBuffer();
- sb.append("【" + imp.getCodeName() + "】: " + imp.getDescription() + " 模板‘"
- + imp.getTemplateName() + "’ 验证...<br>");
- sb.append("<font color=\"#FF0000\">");
- // 判断引用的数据源是否存在
- if (!isDataSourceExist(imp.getDataSource())) {
- sb.append(" 引用的数据源‘" + imp.getDataSource() + "’")
- .append(datasource_notexist).append("<br>");
- }
- /**
- * 必填项检验
- */
- // description="台站类型" templateName="codevalue"
- // dataSource="1" keyCodeAuto="false" type="1"
- if (imp.getDescription().equals("")) {
- sb.append(" ").append("没有指定中文名").append("<br>");
- }
- if (imp.getTemplateName().equals("")) {
- sb.append(" ").append("没有指定常量表生成模板类型").append("<br>");
- }
- if (imp.getTemplate() != null) {
- if (imp.isTree() && imp.getRootFrom().equals(""))
- sb.append(" ").append("没有指定树型常量的根节点").append("<br>");
- } else {
- sb.append(" ").append("指定的模板类型'" + imp.getTemplateName() + "'不存在")
- .append("<br>");
- }
- /**
- * 验证重复
- */
- if (this.getNumByNameFromMdpConstant(imp.getCodeName()) > 1) {
- sb.append(" 存在多个常量配置英文名相同");
- sb.append(XmlManagerPara.repeat_name);
- sb.append("<br>");
- }
- if (this.getNumByDescriptionFromMdpMdpConstant(imp.getDescription()) > 1) {
- sb.append(" 存在多个常量配置中文名相同");
- sb.append(XmlManagerPara.repeat_CNname);
- sb.append("<br>");
- }
- sb.append("</font>");
- return sb.toString();
- }
- private int getNumByNameFromMdpConstant(String name) {
- int iresult = 0;
- ArrayList<MdpConstantImpl> mdpConstants = SysModel.getMdpConstants();
- for (int i = 0; i < mdpConstants.size(); i++) {
- MdpConstant constant = mdpConstants.get(i);
- if (constant.getCodeName().equals(name))
- iresult++;
- }
- return iresult;
- }
- private int getNumByDescriptionFromMdpMdpConstant(String name) {
- int iresult = 0;
- ArrayList<MdpConstantImpl> mdpConstants = SysModel.getMdpConstants();
- for (int i = 0; i < mdpConstants.size(); i++) {
- MdpConstant constant = mdpConstants.get(i);
- if (constant.getDescription().equals(name))
- iresult++;
- }
- return iresult;
- }
- /**
- * 判断 CLASSID 是否存在重复对象
- *
- * @param imp
- * @return
- */
- private boolean isRepeatTableClassid(MdpClassImpl imp) {
- Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
- int i = 0;
- while (it.hasNext()) {
- MdpClassImpl temp = it.next();
- if (temp.getClassid() == imp.getClassid())
- i++;
- }
- return i > 1;
- }
- private int getNumByNameFromMdpClass(String name, MdpClassImpl mdlclass) {
- int iresult = 0;
- ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
- .getAllMdpAttributes();
- for (int i = 0; i < list.size(); i++) {
- MdpAttributeImpl temp = list.get(i);
- if (temp.getName().equals(name))
- iresult++;
- }
- return iresult;
- }
- private int getNumByDescriptionFromMdpClass(String name, MdpClassImpl mdlclass) {
- int iresult = 0;
- ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
- .getAllMdpAttributes();
- for (int i = 0; i < list.size(); i++) {
- MdpAttributeImpl temp = list.get(i);
- if (temp.getDescription().equals(name))
- iresult++;
- }
- return iresult;
- }
- /**
- * 判断数据源是否存在
- *
- * @param sourceid
- * @return
- */
- private boolean isDataSourceExist(int sourceid) {
- ArrayList<MdpDataSourceImpl> list = SysModel.getMdpDataSources();
- MdpDataSourceImpl MdpDataSource = null;
- for (int i = 0; i < list.size(); i++) {
- MdpDataSource = list.get(i);
- if (MdpDataSource.getDataSourceid() == sourceid)
- return true;
- }
- return false;
- }
- // ================================================
- /**
- * 相同数据源表的中英文名不能相同
- */
- private String isRepeatTableName(MdpClassImpl imp) {
- Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
- while (it.hasNext()) {
- MdpClassImpl temp = it.next();
- if (temp.getClassid() == imp.getClassid())
- continue;
- if (temp.getDataSource() == imp.getDataSource()) {
- if (temp.getName().equals(imp.getName()))
- return XmlManagerPara.repeat_ENname;
- if (temp.getDescription().equals(imp.getDescription()))
- return XmlManagerPara.repeat_CNname;
- }
- }
- return "";
- }
- /**
- * 表的中英文字段名称不能相同
- */
- private String isRepeatAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
- ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
- .getAllMdpAttributes();
- for (int i = 0; i < list.size(); i++) {
- MdpAttributeImpl temp = list.get(i);
- if (temp.getName().equals(imp.getName()))
- return XmlManagerPara.repeat_ENname;
- }
- return "";
- }
- /**
- * 表的英文字段是否被其他表引用
- */
- private String isQuotedAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
- String classid = "" + mdlclass.getClassid();
- SysModel sysmodel = ModelFactory.getSysmodel();
- ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
- for (int i = 0; i < mdpClasses.size(); i++) {
- MdpClassImpl MdpClass = mdpClasses.get(i);
- if (MdpClass.getClassid() != mdlclass.getClassid()) {
- ArrayList<MdpAttributeImpl> attributelist = (ArrayList<MdpAttributeImpl>) MdpClass
- .getAllMdpAttributes();
- for (int j = 0; j < attributelist.size(); j++) {
- MdpAttributeImpl MdpAttribute = attributelist.get(j);
- Reference reference = MdpAttribute.getReference();
- if (reference != null) {
- if (reference.getReferenceTable().equals(classid)
- && reference.getStoreName().equals(imp.getName())) {
- return XmlManagerPara.realtion_reference;
- }
- }
- }
- }
- }
- return "";
- }
- /**
- * 模板中的英文属性名称不能相同
- */
- private boolean isRepeatProperty(PropertyImpl imp, TemplateImpl template) {
- ArrayList<PropertyImpl> list = (ArrayList<PropertyImpl>) template.getListproperty();
- for (int i = 0; i < list.size(); i++) {
- PropertyImpl temp = (PropertyImpl) list.get(i);
- if (temp.getName().equals(imp.getName()))
- return true;
- }
- return false;
- }
- /**
- * 模板是否被用
- */
- private String isQuotedTemplate(TemplateImpl template) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- List<MdpConstantImpl> list = sysmodel.getMdpConstants();
- for (int i = 0; i < list.size(); i++) {
- MdpConstantImpl MdpConstant = list.get(i);
- if (MdpConstant.getTemplateName().equals(template.getName()))
- return XmlManagerPara.repeat_ENname;
- }
- return "";
- }
- public String createJavaCode(MdpClassImpl imp) {
- MdpModule MdpModule = SysModel.getMdpModuleByCode(imp.getType());
- StringBuffer sb = new StringBuffer();
- sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
- + "] 生成JAVA文件...<br>");
- sb.append("package " + MdpModule.getPackageName() + ".model<br>");
- // 第一步:生成JAVA文件内容
- StringBuffer sbjava = new StringBuffer();
- sbjava.append("package " + MdpModule.getPackageName() + ".model\n");
- // 这个地方写入引入的包
- sbjava.append("");
- sbjava.append("@Entity\n");
- sbjava.append("@Table(name = \"" + imp.getName() + "\")\n");
- sbjava.append("public class " + imp.getName() + " {\n");
- sbjava.append(" //java对象对应DataModel.xml中编号:" + imp.getClassid() + "\n");
- // 先生成表的字段属性定义
- List<MdpAttributeImpl> list = imp.getAllMdpAttributes();
- MdpAttributeImpl MdpAttribute = null;
- for (int i = 0; i < list.size(); i++) {
- MdpAttribute = list.get(i);
- sbjava.append(" /**\n");
- sbjava.append(" *" + MdpAttribute.getDescription() + " 长度:"
- + MdpAttribute.getPrecision() + "\n");
- sbjava.append(" */\n");
- if (MdpAttribute.getDataType().equals("string")) {
- sbjava.append(" private String " + MdpAttribute.getName() + ";\n");
- } else if (MdpAttribute.getDataType().equals("date")) {
- sbjava.append(" private String " + MdpAttribute.getName() + ";\n");
- } else if (MdpAttribute.getDataType().equals("number")) {
- sbjava.append(" private int " + MdpAttribute.getName() + ";\n");
- }
- }
- // 生成SET GET 方法
- sbjava.append("}\n");
- log.info("sbjava :" + sbjava.toString());
- // 第二步:把JAVA文件写入JAVA文件夹子
- try {
- String folder = SysModel.getFileLoadFolder().replace("WEB-INF", "java");
- // + MdpModule.getPackageName().replace(".", "\\")+"\\" ;
- String filepath = folder + imp.getName() + ".java";
- log.info("JAVA 路径:" + filepath);
- // 建立存储JAVA的文件夹子
- log.info("JAVA 文件夹:" + folder.replace("\\", "/"));
- FileOperate.createFolder(folder.replace("\\", "/"));
- FileOperate fileOperate = new FileOperate();
- fileOperate.createFile(filepath, sbjava.toString());
- // String s = sbjava.toString();
- // FileOutputStream fo = null;
- // try{
- // fo = new FileOutputStream(filepath);
- // fo.write(s.getBytes("utf-8"));
- // fo.close();//关闭
- // } catch (IOException e){
- // e.printStackTrace();
- // }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return sb.toString();
- }
- public String checkDescriptionConfig(MdpClassImpl imp) {
- StringBuffer sb = new StringBuffer();
- List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
- if (isDescriptionExist(imp)) {
- for (int i = 0; i < mdpAttributes.size(); i++) {
- MdpAttributeImpl mdpAttribute = mdpAttributes.get(i);
- if (mdpAttribute.getName().equals(mdpAttribute.getDescription())) {
- sb.append("<tr><td width='80'>" + imp.getName() + "</td><td width='150'>"
- + imp.getDescription() + "</td><td width='150'>"
- + mdpAttribute.getName() + "</td><td width=''> </td></tr>");
- }
- }
- }
- return sb.toString();
- }
- public boolean isDescriptionExist(MdpClassImpl imp) {
- boolean flag = false;
- List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
- int num = 0;
- for (int i = 0; i < mdpAttributes.size(); i++) {
- MdpAttributeImpl mdpAttribute = mdpAttributes.get(i);
- if (mdpAttribute.getName().equals(mdpAttribute.getDescription())) {
- num++;
- }
- }
- if (num > 0) {
- flag = true;
- }
- return flag;
- }
- public String getEnglishByDescription(MdpClassImpl imp) throws Exception {
- StringBuffer sb = new StringBuffer();
- String EnTableName = "";
- if (imp.getDescription().equals(imp.getName())) {
- Translate.setHttpReferrer("http://localhost");
- EnTableName = Translate.execute(imp.getDescription(), Language.CHINESE,
- Language.ENGLISH);
- imp.setNgoogleEn(EnTableName);
- }
- sb.append("classid:<b>" + imp.getClassid() + "</b><br>");
- sb.append("表中文名:<b>" + imp.getDescription() + "</b><br>");
- sb.append("English name:<b>" + EnTableName + "</b><br>");
- log.info(imp.getDescription() + " " + imp.getClassid());
- sb.append("<table align=\"center\" width=\"80%\" border=\"1\" class=\"ltab2\"><tr><td><b>字段中文名</b></td><td><b>English name</b></td></tr>");
- List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
- MdpAttributeImpl mdpAttribute = null;
- log.info("字段个数:" + mdpAttributes.size());
- String EnName = "";
- for (int i = 0; i < mdpAttributes.size(); i++) {
- mdpAttribute = mdpAttributes.get(i);
- /*
- * if(mdpAttribute.getDescription().equals(mdpAttribute.getName())
- * || mdpAttribute.getDescription().equals("") ||
- * !mdpAttribute.getNgoogleEn().equals("")){
- *
- * //如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文 EnName =
- * mdpAttribute.getNgoogleEn();
- *
- * }else{
- */
- Translate.setHttpReferrer("http://localhost");
- EnName = Translate.execute(mdpAttribute.getDescription(), Language.CHINESE,
- Language.ENGLISH);
- log.info(mdpAttribute.getDescription() + " " + EnName);
- mdpAttribute.setNgoogleEn(EnName);
- // }
- sb.append("<tr><td>" + mdpAttribute.getDescription() + "</td>");
- sb.append("<td> " + EnName + "</td></tr>");
- }
- sb.append("</table>");
- return sb.toString();
- }
- public String getEnglishByDescription() throws Exception {
- ArrayList<MdpModuleImpl> arrModules = SysModelImpl.getInstance().getMdpModules();
- ArrayList<MdpConstantImpl> arrConstants = SysModelImpl.getInstance().getMdpConstants();
- String EnName = "";
- MdpModuleImpl Module = null;
- MdpConstantImpl MdpConstant = null;
- StringBuffer sb = new StringBuffer();
- sb.append("<table align=\"center\" width=\"80%\" border=\"1\" class=\"ltab2\"><tr><td><b>模块名称</b></td><td><b>English name</b></td></tr>");
- for (int i = 0; i < arrModules.size(); i++) {
- Module = arrModules.get(i);
- if (Module.getName().equals("") || !Module.getNgoogleEn().equals("")) {
- // 如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文
- EnName = Module.getNgoogleEn();
- } else {
- Translate.setHttpReferrer("http://localhost");
- EnName = Translate.execute(Module.getName(), Language.CHINESE, Language.ENGLISH);
- log.info(Module.getName() + " " + EnName);
- Module.setNgoogleEn(EnName);
- }
- sb.append("<tr><td>" + Module.getName() + "</td>");
- sb.append("<td> " + EnName + "</td></tr>");
- }
- sb.append("</table>");
- sb.append("<table align=\"center\" valign='top' width=\"80%\" border=\"1\" class=\"ltab2\"><tr><td><b>常量名称</b></td><td><b>English name</b></td></tr>");
- for (int i = 0; i < arrConstants.size(); i++) {
- MdpConstant = arrConstants.get(i);
- if (MdpConstant.getDescription().equals("") || !MdpConstant.getNgoogleEn().equals("")) {
- // 如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文
- EnName = MdpConstant.getNgoogleEn();
- } else {
- Translate.setHttpReferrer("http://localhost");
- EnName = Translate.execute(MdpConstant.getDescription(), Language.CHINESE,
- Language.ENGLISH);
- log.info(MdpConstant.getDescription() + " " + EnName);
- MdpConstant.setNgoogleEn(EnName);
- }
- sb.append("<tr><td>" + MdpConstant.getDescription() + "</td>");
- sb.append("<td> " + EnName + "</td></tr>");
- }
- sb.append("</table>");
- return sb.toString();
- }
- public String checkNameDefine(MdpClassImpl imp) {
- // sql的保留字
- String sqlKeyWords = ",action,add,aggregate,all,alter,after,and,as,asc,avg,avg_row_length,auto_increment,"
- + "between,bigint,bit,binary,blob,bool,both,by,cascade,case,char,character,change,check,checksum,"
- + "column,columns,comment,constraint,create,cross,current_date,current_time,current_timestamp,data,"
- + "database,databases,date,datetime,day,day_hour,day_minute,day_second,dayofmonth,dayofweek,"
- + "dayofyear,dec,decimal,default,delayed,delay_key_write,delete,desc,describe,distinct,distinctrow,"
- + "double,drop,end,else,escape,escaped,enclosed,enum,explain,exists,fields,file,first,float,float4,"
- + "float8,flush,foreign,from,for,full,function,global,grant,grants,group,having,heap,high_priority,hour,"
- + "hour_minute,hour_second,hosts,identified,ignore,in,index,infile,inner,insert,insert_id,int,integer,"
- + "interval,int1,int2,int3,int4,int8,into,if,is,isam,join,key,keys,kill,last_insert_id,leading,left,length,"
- + "like,lines,limit,load,local,lock,logs,long,longblob,longtext,low_priority,max,max_rows,match,mediumblob,"
- + "mediumtext,mediumint,middleint,min_rows,minute,minute_second,modify,month,monthname,myisam,natural,"
- + "numeric,no,not,null,on,optimize,option,optionally,or,order,outer,outfile,pack_keys,partial,password,"
- + "precision,primary,procedure,process,processlist,privileges,read,real,references,reload,regexp,rename,"
- + "replace,restrict,returns,revoke,rlike,row,rows,second,select,set,show,shutdown,smallint,soname,"
- + "sql_big_tables,sql_big_selects,sql_low_priority_updates,sql_log_off,sql_log_update,sql_select_limit,"
- + "sql_small_result,sql_big_result,sql_warnings,straight_join,starting,status,string,table,tables,temporary,"
- + "terminated,text,then,time,timestamp,tinyblob,tinytext,tinyint,trailing,to,type,use,using,unique,unlock,"
- + "unsigned,update,usage,values,varchar,variables,varying,varbinary,with,write,when,where,year,year_month,zerofill,";
- List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
- StringBuffer sb = new StringBuffer();
- sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
- + "] 验证...<br>");
- sb.append("<font color=\"#FF0000\">");
- for (int j = 0; j < mdpAttributes.size(); j++) {
- MdpAttributeImpl mdpAttribute = mdpAttributes.get(j);
- String attributeName = "," + mdpAttribute.getName() + ",";
- if (sqlKeyWords.toUpperCase().indexOf(attributeName) != -1) {
- sb.append(" [" + mdpAttribute.getName() + "]"
- + mdpAttribute.getDescription() + "是sql保留字<br>");
- }
- }
- sb.append("</font>");
- return sb.toString();
- }
- public static final String datasource_notexist = "所指定的数据链接不存在";
- /**
- * 获得系统模型配置
- */
- private SysModel SysModel = ModelFactory.getSysmodel();
- /**
- * @param classidStr
- * 表描述模型
- * @return 生成出DATAMODEL属性排序
- */
- public String createDataModelSort(String classidStr) {
- StringBuffer sb = new StringBuffer();
- MdpClassImpl mdpclassImpl;
- String[] classids = classidStr.split(",");
- SysModel sysmodel = ModelFactory.getSysmodel();
- for (int j = 0; j < classids.length; j++) {
- String cl = classids[j];
- int classid = Integer.parseInt(cl);
- mdpclassImpl = (MdpClassImpl) sysmodel.getMdpClassByClassID(classid);
- sb.append(classObjToXml(mdpclassImpl));
- }
- return sb.toString();
- }
- public String createDataModelSort() {
- StringBuffer sb = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- for (int iclass = 10; iclass < 1000; iclass++) {
- MdpClass mdpClass = sysmodel.getMdpClassByClassID(iclass);
- if (mdpClass != null) {
- sb.append(classObjToXml((MdpClassImpl) mdpClass));
- }
- }
- return sb.toString();
- }
- private StringBuffer classObjToXml(MdpClassImpl imp) {
- StringBuffer sb = new StringBuffer();
- List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
- sb.append(" <mdpClass classid=\"" + imp.getClassid() + "\" description=\""
- + imp.getDescription() + "\" name=\"" + imp.getName() + "\" oldName=\""
- + imp.getOldName() + "\" ngoogleEn=\"" + imp.getNgoogleEn() + "\" type=\""
- + imp.getType() + "\" catche=\"" + imp.isCatche() + "\" exist=\"" + imp.isExist()
- + "\" dataSource=\"" + imp.getDataSource() + "\" validate=\"" + imp.isValidate()
- + "\"><br>");
- for (int k = 0; k < mdpAttributes.size(); k++) {
- MdpAttributeImpl mdpAttribute = mdpAttributes.get(k);
- Reference reference = mdpAttribute.getReference();
- if (mdpAttribute.getReferenceType() != 0) {
- sb.append(" <mdpAttribute description=\"" + mdpAttribute.getDescription()
- + "\" name=\"" + mdpAttribute.getName() + "\" oldName=\""
- + mdpAttribute.getOldName() + "\" ngoogleEn=\""
- + mdpAttribute.getNgoogleEn() + "\" unit=\"" + mdpAttribute.getUnit()
- + "\" dataType=\"" + mdpAttribute.getDataType() + "\" precision=\""
- + mdpAttribute.getPrecision() + "\" scale=\"" + mdpAttribute.getScale()
- + "\" referenceType=\"" + mdpAttribute.getReferenceType()
- + "\" defaultValue=\"" + mdpAttribute.getDefaultValue()
- + "\" logicPrimaryKey=\"" + mdpAttribute.isLogicPrimaryKey()
- + "\" notNull=\"" + mdpAttribute.isNotNull() + "\" validate=\""
- + mdpAttribute.isValidate() + "\" index=\"" + mdpAttribute.isIndex()
- + "\" indexType=\"" + mdpAttribute.getIndexType() + "\"><br>");
- sb.append(" <reference displayName=\"" + reference.getDisplayName()
- + "\" referenceTable=\"" + mdpAttribute.getReference().getReferenceTable()
- + "\" storeName=\"" + reference.getStoreName() + "\"/><br>");
- sb.append(" </mdpAttribute><br>");
- } else {
- sb.append(" <mdpAttribute description=\"" + mdpAttribute.getDescription()
- + "\" name=\"" + mdpAttribute.getName() + "\" oldName=\""
- + mdpAttribute.getOldName() + "\" ngoogleEn=\""
- + mdpAttribute.getNgoogleEn() + "\" unit=\"" + mdpAttribute.getUnit()
- + "\" dataType=\"" + mdpAttribute.getDataType() + "\" precision=\""
- + mdpAttribute.getPrecision() + "\" scale=\"" + mdpAttribute.getScale()
- + "\" referenceType=\"" + mdpAttribute.getReferenceType()
- + "\" defaultValue=\"" + mdpAttribute.getDefaultValue()
- + "\" logicPrimaryKey=\"" + mdpAttribute.isLogicPrimaryKey()
- + "\" notNull=\"" + mdpAttribute.isNotNull() + "\" validate=\""
- + mdpAttribute.isValidate() + "\" index=\"" + mdpAttribute.isIndex()
- + "\" indexType=\"" + mdpAttribute.getIndexType() + "\"/><br>");
- }
- }
- sb.append(" </mdpClass><br>");
- return sb;
- }
- @SuppressWarnings("unused")
- public StringBuffer createAtrributesByCNName(String sname) {
- StringBuffer sb = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
- String[] names = sname.split(",");
- loop1: for (int i = 0; i < names.length; i++) {
- loop: for (int j = 0; j < mdpClasses.size(); j++) {
- MdpClassImpl mdpClass = mdpClasses.get(j);
- List<MdpAttributeImpl> mdpAttributes = mdpClass.getAllMdpAttributes();
- loop2: for (int n = 0; n < mdpAttributes.size(); n++) {
- MdpAttributeImpl mdpAttribute = mdpAttributes.get(n);
- if (names[i].trim().equals(mdpAttribute.getDescription())) {
- if (mdpAttribute.getReference() != null) {
- sb.append(" <mdpAttribute description=\""
- + mdpAttribute.getDescription() + "\" name=\""
- + mdpAttribute.getName() + "\" oldName=\""
- + mdpAttribute.getOldName() + "\" ngoogleEn=\""
- + mdpAttribute.getNgoogleEn() + "\" unit=\""
- + mdpAttribute.getUnit() + "\" dataType=\""
- + mdpAttribute.getDataType() + "\" precision=\""
- + mdpAttribute.getPrecision() + "\" scale=\""
- + mdpAttribute.getScale() + "\" referenceType=\""
- + mdpAttribute.getReferenceType() + "\" defaultValue=\""
- + mdpAttribute.getDefaultValue() + "\" logicPrimaryKey=\""
- + mdpAttribute.isLogicPrimaryKey() + "\" notNull=\""
- + mdpAttribute.isNotNull() + "\" validate=\""
- + mdpAttribute.isValidate() + "\" index=\""
- + mdpAttribute.isIndex() + "\" indexType=\""
- + mdpAttribute.getIndexType() + "\"><br>");
- sb.append(" <reference displayName=\""
- + mdpAttribute.getReference().getDisplayName()
- + "\" referenceTable=\""
- + mdpAttribute.getReference().getReferenceTable()
- + "\" storeName=\""
- + mdpAttribute.getReference().getStoreName() + "\"/><br>");
- sb.append(" </mdpAttribute><br>");
- } else {
- sb.append(" <mdpAttribute description=\""
- + mdpAttribute.getDescription() + "\" name=\""
- + mdpAttribute.getName() + "\" oldName=\""
- + mdpAttribute.getOldName() + "\" ngoogleEn=\""
- + mdpAttribute.getNgoogleEn() + "\" unit=\""
- + mdpAttribute.getUnit() + "\" dataType=\""
- + mdpAttribute.getDataType() + "\" precision=\""
- + mdpAttribute.getPrecision() + "\" scale=\""
- + mdpAttribute.getScale() + "\" referenceType=\""
- + mdpAttribute.getReferenceType() + "\" defaultValue=\""
- + mdpAttribute.getDefaultValue() + "\" logicPrimaryKey=\""
- + mdpAttribute.isLogicPrimaryKey() + "\" notNull=\""
- + mdpAttribute.isNotNull() + "\" validate=\""
- + mdpAttribute.isValidate() + "\" index=\""
- + mdpAttribute.isIndex() + "\" indexType=\""
- + mdpAttribute.getIndexType() + "\"/><br>");
- }
- break loop;
- } else if (names[i].trim().indexOf("编号") > -1) {
- sb.append(" <mdpAttribute validate=\"true\" name=\"_Code\" description=\""
- + names[i].trim()
- + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/><br>");
- break loop;
- } else if (names[i].trim().indexOf("日期") > -1) {
- sb.append(" <mdpAttribute validate=\"true\" name=\"_Date\" description=\""
- + names[i].trim()
- + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"date\" referenceType=\"0\" scale=\"\" precision=\"yyyy-MM-dd HH:mm:ss\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/><br>");
- break loop;
- } else if (names[i].trim().indexOf("名称") > -1) {
- sb.append(" <mdpAttribute validate=\"true\" name=\"_Name\" description=\""
- + names[i].trim()
- + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/><br>");
- break loop;
- } else if (names[i].trim().indexOf("性别") > -1) {
- sb.append(" <mdpAttribute description=\""
- + names[i].trim()
- + "\" name=\"sex\" oldName=\"\" ngoogleEn=\"\" unit=\"\" dataType=\"string\" precision=\"5\" scale=\"\" referenceType=\"2\" defaultValue=\"\" logicPrimaryKey=\"false\" notNull=\"false\" validate=\"true\" index=\"false\" indexType=\"\"><br>");
- sb.append(" <reference displayName=\"\" referenceTable=\"BM$_Gender\" storeName=\"\"/><br>");
- sb.append(" </mdpAttribute><br>");
- break loop;
- } else if (names[i].trim().indexOf("桩号") > -1) {
- sb.append(" <mdpAttribute validate=\"true\" name=\"\" description=\""
- + names[i].trim()
- + "\" unit=\"\" logicPrimaryKey=\"false\" dataType=\"number\" referenceType=\"0\" scale=\"3\" precision=\"18\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/><br>");
- break loop;
- } else if (names[i].trim().indexOf("代码") > -1) {
- sb.append(" <mdpAttribute validate=\"true\" name=\"_Code\" description=\""
- + names[i].trim()
- + "\" unit=\"\" logicPrimaryKey=\"false\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/><br>");
- break loop;
- }
- }
- }
- }
- return sb;
- }
- }
|