a7f35158e9333c96c6a7afbd42b6069601f7360f.svn-base 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  1. package com.sysmodel.datamodel.xmlmanager.xmlobjdll;
  2. import java.util.ArrayList;
  3. import java.util.Iterator;
  4. import java.util.List;
  5. import org.apache.commons.logging.Log;
  6. import org.apache.commons.logging.LogFactory;
  7. import com.google.api.translate.Language;
  8. import com.google.api.translate.Translate;
  9. import com.sysmodel.datamodel.Parameter.XmlManagerPara;
  10. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  11. import com.sysmodel.datamodel.xmlmodel.Reference;
  12. import com.sysmodel.datamodel.xmlmodel.able.MdpClass;
  13. import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
  14. import com.sysmodel.datamodel.xmlmodel.able.MdpModule;
  15. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  16. import com.sysmodel.datamodel.xmlmodel.impl.MdpAttributeImpl;
  17. import com.sysmodel.datamodel.xmlmodel.impl.MdpClassImpl;
  18. import com.sysmodel.datamodel.xmlmodel.impl.MdpConstantImpl;
  19. import com.sysmodel.datamodel.xmlmodel.impl.MdpDataSourceImpl;
  20. import com.sysmodel.datamodel.xmlmodel.impl.MdpModuleImpl;
  21. import com.sysmodel.datamodel.xmlmodel.impl.PropertyImpl;
  22. import com.sysmodel.datamodel.xmlmodel.impl.SysModelImpl;
  23. import com.sysmodel.datamodel.xmlmodel.impl.TemplateImpl;
  24. import com.toolkit.file.FileOperate;
  25. public class SysModeldllimplTest implements SysModeldllable{
  26. private Log log = LogFactory.getLog(SysModeldllimpl.class);
  27. public String addAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
  28. String result = isRepeatAttribute(imp, mdlclass);
  29. if (!result.equals(""))
  30. return result;
  31. ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
  32. .getAllMdpAttributes();
  33. list.add(imp);
  34. mdlclass.setMdpAttributes(list);
  35. return XmlManagerPara.add_success;
  36. }
  37. public String addDataSource(MdpDataSourceImpl imp) {
  38. SysModelImpl.getInstance().getMdpDataSources().add(imp);
  39. return XmlManagerPara.add_success;
  40. }
  41. public String addTable(MdpClassImpl imp) {
  42. String result = isRepeatTableName(imp);
  43. if (!result.equals(""))
  44. return result;
  45. SysModelImpl.getInstance().getMdpClasses().add(imp);
  46. return XmlManagerPara.add_success;
  47. }
  48. public String addTemplate(TemplateImpl imp) {
  49. SysModelImpl.getInstance().getTemplates().add(imp);
  50. return XmlManagerPara.add_success;
  51. }
  52. public String deleteAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
  53. String result = isQuotedAttribute(imp, mdlclass);
  54. if (!result.equals(""))
  55. return result;
  56. ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
  57. .getAllMdpAttributes();
  58. for (int i = 0; i < list.size(); i++) {
  59. MdpAttributeImpl oImpl = list.get(i);
  60. if (oImpl.getName().equals(imp.getName())) {
  61. list.remove(i);
  62. }
  63. }
  64. mdlclass.setMdpAttributes(list);
  65. return XmlManagerPara.delete_success;
  66. }
  67. public String deleteDataSource(MdpDataSourceImpl imp) {
  68. Iterator<MdpDataSourceImpl> it = SysModelImpl.getInstance().getMdpDataSources().iterator();
  69. while (it.hasNext()) {
  70. MdpDataSourceImpl temp = it.next();
  71. if (temp.getDataSourceid() == imp.getDataSourceid())
  72. it.remove();
  73. }
  74. return XmlManagerPara.delete_success;
  75. }
  76. public String deleteTable(MdpClassImpl imp) {
  77. // 如果有关系,删除与之关联的关系
  78. Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
  79. while (it.hasNext()) {
  80. MdpClassImpl temp = it.next();
  81. if (temp.getClassid() == imp.getClassid())
  82. it.remove();
  83. }
  84. return XmlManagerPara.delete_success;
  85. }
  86. public String deleteTemplate(TemplateImpl imp) {
  87. Iterator<TemplateImpl> it = SysModelImpl.getInstance().getTemplates().iterator();
  88. while (it.hasNext()) {
  89. TemplateImpl temp = (TemplateImpl) it.next();
  90. if (temp.getName() == imp.getName())
  91. it.remove();
  92. }
  93. return XmlManagerPara.delete_success;
  94. }
  95. public String updateAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass, String oName) {
  96. // 得到修改前的表字段信息
  97. MdpAttributeImpl old = (MdpAttributeImpl) mdlclass.getMdpAttributeByName(oName);
  98. // 该数据源中表的字段英文名不能相同
  99. String result = this.isRepeatAttribute(imp, mdlclass);
  100. if (!imp.getName().equals(old.getName()) && !result.equals(""))
  101. return result;
  102. old.setValidate(imp.isValidate());
  103. old.setName(imp.getName());
  104. old.setDescription(imp.getDescription());
  105. old.setLogicPrimaryKey(imp.isLogicPrimaryKey());
  106. old.setDataType(imp.getDataType());
  107. old.setReferenceType(imp.getReferenceType());
  108. old.setScale(imp.getScale());
  109. old.setPrecision(imp.getPrecision());
  110. old.setIndex(imp.isIndex());
  111. old.setIndexType(imp.getIndexType());
  112. old.setDefaultValue(imp.getDefaultValue());
  113. old.setNotNull(imp.isNotNull());
  114. old.setUnit(imp.getUnit());
  115. Reference oReference = old.getReference();
  116. if (oReference != null) {
  117. if (imp.getReference() != null) {
  118. oReference.setReferenceTable(imp.getReference().getReferenceTable());
  119. oReference.setStoreName(imp.getReference().getStoreName());
  120. oReference.setDisplayName(imp.getReference().getDisplayName());
  121. }
  122. } else {
  123. if (imp.getReference() != null) {
  124. oReference = new Reference();
  125. oReference.setReferenceTable(imp.getReference().getReferenceTable());
  126. oReference.setStoreName(imp.getReference().getStoreName());
  127. oReference.setDisplayName(imp.getReference().getDisplayName());
  128. old.setReference(oReference);
  129. }
  130. }
  131. String classid = "" + mdlclass.getClassid();
  132. SysModel sysmodel = ModelFactory.getSysmodel();
  133. ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
  134. for (int i = 0; i < mdpClasses.size(); i++) {
  135. MdpClassImpl MdpClass = mdpClasses.get(i);
  136. ArrayList<MdpAttributeImpl> attributelist = (ArrayList<MdpAttributeImpl>) MdpClass
  137. .getAllMdpAttributes();
  138. for (int j = 0; j < attributelist.size(); j++) {
  139. MdpAttributeImpl MdpAttribute = attributelist.get(j);
  140. Reference reference = MdpAttribute.getReference();
  141. if (reference != null) {
  142. if (reference.getReferenceTable().equals(classid)
  143. && reference.getStoreName().equals(oName)) {
  144. reference.setStoreName(imp.getName());
  145. }
  146. }
  147. }
  148. }
  149. return XmlManagerPara.update_success;
  150. }
  151. public String updateDataSource(MdpDataSourceImpl imp) {
  152. // 得到修改前的表信息
  153. MdpDataSourceImpl old = (MdpDataSourceImpl) SysModelImpl.getInstance().getDataSourceByCode(
  154. imp.getDataSourceid());
  155. // 判断数据源是否改变
  156. old.setDataSourceid(imp.getDataSourceid());
  157. old.setDataBase(imp.getDataBase());
  158. old.setDescription(imp.getDescription());
  159. old.setJNDI(imp.getJNDI());
  160. old.setPassword(imp.getPassword());
  161. old.setURL(imp.getURL());
  162. old.setUser(imp.getUser());
  163. return XmlManagerPara.update_success;
  164. }
  165. public String updateTable(MdpClassImpl imp) {
  166. // 得到修改前的表信息
  167. MdpClassImpl old = (MdpClassImpl) SysModelImpl.getInstance().getMdpClassByClassID(
  168. imp.getClassid());
  169. // 该数据源中表的中英文名不能相同
  170. String result = this.isRepeatTableName(imp);
  171. if (!result.equals(""))
  172. return result;
  173. // 判断数据源是否改变
  174. old.setDataSource(imp.getDataSource());
  175. old.setValidate(imp.isValidate());
  176. old.setDescription(imp.getDescription());
  177. old.setName(imp.getName());
  178. old.setType(imp.getType());
  179. return XmlManagerPara.update_success;
  180. }
  181. public String updateTemplate(TemplateImpl imp, String constantname) {
  182. // 得到修改前的表字段信息
  183. TemplateImpl old = (TemplateImpl) SysModelImpl.getInstance()
  184. .getTemplateByName(constantname);
  185. // 该数据源中表的字段英文名不能相同
  186. old.setName(imp.getName());
  187. old.setDescription(imp.getDescription());
  188. return XmlManagerPara.update_success;
  189. }
  190. @SuppressWarnings({ "unchecked", "rawtypes" })
  191. public String addProperty(PropertyImpl imp, TemplateImpl template) {
  192. if (isRepeatProperty(imp, template))
  193. return "重复了";
  194. ArrayList<PropertyImpl> list = (ArrayList) template.getListproperty();
  195. list.add(imp);
  196. template.setListproperty(list);
  197. return XmlManagerPara.add_success;
  198. }
  199. public String updateProperty(PropertyImpl imp, TemplateImpl template, String oName) {
  200. if (imp.getName().equals(oName)
  201. || (!imp.getName().equals(oName) && !this.isRepeatProperty(imp, template))) {
  202. PropertyImpl old = (PropertyImpl) template.getPropertyByName(oName);
  203. old.setName(imp.getName());
  204. old.setDescription(imp.getDescription());
  205. old.setDataType(imp.getDataType());
  206. old.setLength(imp.getLength());
  207. old.setScale(imp.getScale());
  208. old.setReferenceParentName(imp.getReferenceParentName());
  209. old.setDisplay(imp.isDisplay());
  210. old.setUnique(imp.isUnique());
  211. log.info("imp validate :" + imp.getValidate().getInvalidMessage()
  212. + imp.getValidate().getDojoType());
  213. old.setValidate(imp.getValidate());
  214. return XmlManagerPara.update_success;
  215. }
  216. return XmlManagerPara.repeat_ENname;
  217. }
  218. public String deleteProperty(PropertyImpl imp, TemplateImpl template) {
  219. String result = isQuotedTemplate(template);
  220. if (!result.equals(""))
  221. return result;
  222. ArrayList<PropertyImpl> list = (ArrayList<PropertyImpl>) template.getListproperty();
  223. for (int i = 0; i < list.size(); i++) {
  224. PropertyImpl pImpl = (PropertyImpl) list.get(i);
  225. if (pImpl.getName().equals(imp.getName())) {
  226. list.remove(i);
  227. }
  228. }
  229. template.setListproperty(list);
  230. return XmlManagerPara.delete_success;
  231. }
  232. public String addMdpModule(MdpModuleImpl imp) {
  233. SysModelImpl.getInstance().getMdpModules().add(imp);
  234. return XmlManagerPara.add_success;
  235. }
  236. public String deleteMdpModule(MdpModuleImpl imp) {
  237. Iterator<MdpModuleImpl> it = SysModelImpl.getInstance().getMdpModules().iterator();
  238. while (it.hasNext()) {
  239. MdpModuleImpl temp = it.next();
  240. if (temp.getCode() == imp.getCode())
  241. it.remove();
  242. }
  243. return XmlManagerPara.delete_success;
  244. }
  245. public String updateMdpModule(MdpModuleImpl imp) {
  246. // 得到修改前的表信息
  247. MdpModuleImpl old = (MdpModuleImpl) SysModelImpl.getInstance().getMdpModuleByCode(
  248. imp.getCode());
  249. // 判断数据源是否改变
  250. old.setCode(imp.getCode());
  251. old.setDescription(imp.getDescription());
  252. old.setName(imp.getName());
  253. old.setPackageName(imp.getPackageName());
  254. old.setPcode(imp.getPcode());
  255. return XmlManagerPara.update_success;
  256. }
  257. public String addConstant(MdpConstantImpl imp) {
  258. SysModelImpl.getInstance().getMdpConstants().add(imp);
  259. return XmlManagerPara.add_success;
  260. }
  261. public String deleteConstant(MdpConstantImpl imp) {
  262. Iterator<MdpConstantImpl> it = SysModelImpl.getInstance().getMdpConstants().iterator();
  263. while (it.hasNext()) {
  264. MdpConstantImpl temp = it.next();
  265. if (temp.getCodeName() == imp.getCodeName())
  266. it.remove();
  267. }
  268. return XmlManagerPara.delete_success;
  269. }
  270. @SuppressWarnings("deprecation")
  271. public String updateConstant(MdpConstantImpl imp, String constantname) {
  272. // 得到修改前的表信息
  273. MdpConstantImpl old = (MdpConstantImpl) SysModelImpl.getInstance().getMdpConstantByName(
  274. imp.getCodeName());
  275. // 判断数据源是否改变
  276. old.setCodeName(imp.getCodeName());
  277. old.setDataSource(imp.getDataSource());
  278. old.setDescription(imp.getDescription());
  279. old.setKeyCodeAuto(imp.isKeyCodeAuto());
  280. old.setOrderMethod(imp.getOrderMethod());
  281. old.setOrderProperty(imp.getOrderProperty());
  282. old.setType(imp.getType());
  283. log.info("old.getType()=" + old.getType());
  284. old.setTemplateName(imp.getTemplateName());
  285. old.setRootFrom(imp.getRootFrom());
  286. return XmlManagerPara.update_success;
  287. }
  288. public String checkTableConfig(MdpClassImpl imp) {
  289. StringBuffer sb = new StringBuffer();
  290. sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
  291. + "] 验证...<br>");
  292. sb.append("<font color=\"#FF0000\">");
  293. // 判断引用的数据源是否存在
  294. if (!isDataSourceExist(imp.getDataSource())) {
  295. sb.append(datasource_notexist).append("<br>");
  296. }
  297. if (isRepeatTableClassid(imp)) {
  298. sb.append("&nbsp;&nbsp;数据库表配置唯一标示 classid 重复 <br>");
  299. }
  300. ArrayList<MdpClassImpl> list = SysModel.getMdpClasses();
  301. // 判断表名是否唯一
  302. MdpClassImpl tempMdpClass = null;
  303. for (int i = 0; i < list.size(); i++) {
  304. tempMdpClass = list.get(i);
  305. if (tempMdpClass.getClassid() != imp.getClassid()) {
  306. if (imp.getDescription().equals(tempMdpClass.getDescription())) {
  307. sb.append("&nbsp;&nbsp;数据库表");
  308. sb.append(XmlManagerPara.repeat_CNname).append(
  309. ",与【" + tempMdpClass.getClassid() + " " + tempMdpClass.getDescription()
  310. + "】表<br>");
  311. }
  312. if (imp.getName().equals(tempMdpClass.getName())) {
  313. sb.append("&nbsp;&nbsp;数据库表");
  314. sb.append(XmlManagerPara.repeat_ENname).append(
  315. ",与【" + tempMdpClass.getClassid() + " " + tempMdpClass.getDescription()
  316. + "】表<br>");
  317. }
  318. }
  319. }
  320. // 判断表中字段定义信息的正确性
  321. List<MdpAttributeImpl> listFields = imp.getAllMdpAttributes();
  322. MdpAttributeImpl MdpAttribute = null;
  323. for (int i = 0; i < listFields.size(); i++) {
  324. MdpAttribute = listFields.get(i);
  325. /**
  326. * 判断英文名重复的字段
  327. */
  328. if (this.getNumByNameFromMdpClass(MdpAttribute.getName(), imp) > 1) {
  329. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  330. sb.append(XmlManagerPara.repeat_ENname);
  331. sb.append("<br>");
  332. }
  333. /**
  334. * 判断中文名重复的字段
  335. */
  336. if (this.getNumByDescriptionFromMdpClass(MdpAttribute.getDescription(), imp) > 1) {
  337. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  338. sb.append(XmlManagerPara.repeat_CNname);
  339. sb.append("<br>");
  340. }
  341. /**
  342. * 判断配置信息中的必填项目是否填写正确
  343. */
  344. if (MdpAttribute.getName().equals("")) {
  345. sb.append("&nbsp;&nbsp;[");
  346. sb.append(MdpAttribute.getFieldDefine() + "] 没有定义英文名<br>");
  347. }
  348. if (MdpAttribute.getDescription().equals("")) {
  349. sb.append("&nbsp;&nbsp;[");
  350. sb.append(MdpAttribute.getFieldDefine() + "] 没有定义中文名<br>");
  351. }
  352. if (MdpAttribute.getDataType().equals("")) {
  353. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "] 没有定义数据类型<br>");
  354. }
  355. if (MdpAttribute.getDataType().equals("date")) {
  356. if (MdpAttribute.getScale() == ""
  357. || !MdpAttribute.getScale().startsWith("yyyy-MM-dd")) {
  358. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  359. sb.append(" 没有定义正确的数据格式<br>");
  360. }
  361. } else { // 非日期类型的字段必须有字段长度
  362. if (MdpAttribute.getPrecision() == 0 && !MdpAttribute.getDataType().equals("blob")
  363. && !MdpAttribute.getDataType().equals("clob")) {
  364. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "] 没有定义长度<br>");
  365. }
  366. // oracle 中最大的长度是4000 其他数据库不知道????
  367. if (MdpAttribute.getPrecision() > 4000) {
  368. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "] 字段长度定义过大<br>");
  369. }
  370. }
  371. /**
  372. * 判断常量字段配置是否正确
  373. */
  374. if (MdpAttribute.getReference() != null && MdpAttribute.getReferenceType() == 0) {
  375. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  376. sb.append(" 定义的字段引用类型有误<br>");
  377. }
  378. if (MdpAttribute.getReferenceType() != 0) {
  379. if (MdpAttribute.getReference() == null) {
  380. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  381. sb.append(" 定义的常量类型格式不完整<br>");
  382. }
  383. // 常量引用
  384. if (MdpAttribute.getReferenceType() == 2) {
  385. if (MdpAttribute.getReference() == null) {
  386. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  387. sb.append(" 常量类型没有指定引用的的常量<br>");
  388. } else if (SysModel.getMdpConstantByName(MdpAttribute.getReference()
  389. .getReferenceTable()) == null) {
  390. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  391. sb.append(" 定义的常量类型引用的常量‘"
  392. + MdpAttribute.getReference().getReferenceTable() + "’不存在<br>");
  393. }
  394. }
  395. // 表数据引用
  396. if (MdpAttribute.getReferenceType() == 1) {
  397. try {
  398. if (MdpAttribute.getReference() == null) {
  399. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  400. sb.append(" 引用业务表类型没有指定引用表信息<br>");
  401. } else {
  402. String storeName = MdpAttribute.getReference().getStoreName();
  403. String displayName = MdpAttribute.getReference().getDisplayName();
  404. int iclassid = Integer.parseInt(MdpAttribute.getReference()
  405. .getReferenceTable());
  406. if (SysModel.getMdpClassByClassID(iclassid) == null) {
  407. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  408. sb.append(" 定义的常量类型引用的表编号‘" + iclassid + "’不存在<br>");
  409. }
  410. if (storeName.toUpperCase().equals("FD_OBJECTID")) {
  411. if (SysModel.getMdpAttributeByName(iclassid, displayName) == null) {
  412. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  413. sb.append(" 定义的常量类型引用的表中StoreName字段不存在<br>");
  414. }
  415. } else if (SysModel.getMdpAttributeByName(iclassid, storeName) == null
  416. || SysModel.getMdpAttributeByName(iclassid, displayName) == null) {
  417. sb.append("&nbsp;&nbsp;[" + MdpAttribute.getFieldDefine() + "]");
  418. sb.append(" 定义的常量类型引用的表中字段不存在<br>");
  419. }
  420. }
  421. } catch (NumberFormatException e) {
  422. e.printStackTrace();
  423. }
  424. }
  425. }
  426. }
  427. sb.append("</font>");
  428. return sb.toString();
  429. }
  430. public String checkConstantConfig(MdpConstantImpl imp) {
  431. StringBuffer sb = new StringBuffer();
  432. sb.append("【" + imp.getCodeName() + "】: " + imp.getDescription() + " 模板‘"
  433. + imp.getTemplateName() + "’ 验证...<br>");
  434. sb.append("<font color=\"#FF0000\">");
  435. // 判断引用的数据源是否存在
  436. if (!isDataSourceExist(imp.getDataSource())) {
  437. sb.append("&nbsp;&nbsp;引用的数据源‘" + imp.getDataSource() + "’")
  438. .append(datasource_notexist).append("<br>");
  439. }
  440. /**
  441. * 必填项检验
  442. */
  443. // description="台站类型" templateName="codevalue"
  444. // dataSource="1" keyCodeAuto="false" type="1"
  445. if (imp.getDescription().equals("")) {
  446. sb.append("&nbsp;&nbsp;").append("没有指定中文名").append("<br>");
  447. }
  448. if (imp.getTemplateName().equals("")) {
  449. sb.append("&nbsp;&nbsp;").append("没有指定常量表生成模板类型").append("<br>");
  450. }
  451. if (imp.getTemplate() != null) {
  452. if (imp.isTree() && imp.getRootFrom().equals(""))
  453. sb.append("&nbsp;&nbsp;").append("没有指定树型常量的根节点").append("<br>");
  454. } else {
  455. sb.append("&nbsp;&nbsp;").append("指定的模板类型'" + imp.getTemplateName() + "'不存在")
  456. .append("<br>");
  457. }
  458. /**
  459. * 验证重复
  460. */
  461. if (this.getNumByNameFromMdpConstant(imp.getCodeName()) > 1) {
  462. sb.append("&nbsp;&nbsp;存在多个常量配置英文名相同");
  463. sb.append(XmlManagerPara.repeat_name);
  464. sb.append("<br>");
  465. }
  466. if (this.getNumByDescriptionFromMdpMdpConstant(imp.getDescription()) > 1) {
  467. sb.append("&nbsp;&nbsp;存在多个常量配置中文名相同");
  468. sb.append(XmlManagerPara.repeat_CNname);
  469. sb.append("<br>");
  470. }
  471. sb.append("</font>");
  472. return sb.toString();
  473. }
  474. private int getNumByNameFromMdpConstant(String name) {
  475. int iresult = 0;
  476. ArrayList<MdpConstantImpl> mdpConstants = SysModel.getMdpConstants();
  477. for (int i = 0; i < mdpConstants.size(); i++) {
  478. MdpConstant constant = mdpConstants.get(i);
  479. if (constant.getCodeName().equals(name))
  480. iresult++;
  481. }
  482. return iresult;
  483. }
  484. private int getNumByDescriptionFromMdpMdpConstant(String name) {
  485. int iresult = 0;
  486. ArrayList<MdpConstantImpl> mdpConstants = SysModel.getMdpConstants();
  487. for (int i = 0; i < mdpConstants.size(); i++) {
  488. MdpConstant constant = mdpConstants.get(i);
  489. if (constant.getDescription().equals(name))
  490. iresult++;
  491. }
  492. return iresult;
  493. }
  494. /**
  495. * 判断 CLASSID 是否存在重复对象
  496. *
  497. * @param imp
  498. * @return
  499. */
  500. private boolean isRepeatTableClassid(MdpClassImpl imp) {
  501. Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
  502. int i = 0;
  503. while (it.hasNext()) {
  504. MdpClassImpl temp = it.next();
  505. if (temp.getClassid() == imp.getClassid())
  506. i++;
  507. }
  508. return i > 1;
  509. }
  510. private int getNumByNameFromMdpClass(String name, MdpClassImpl mdlclass) {
  511. int iresult = 0;
  512. ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
  513. .getAllMdpAttributes();
  514. for (int i = 0; i < list.size(); i++) {
  515. MdpAttributeImpl temp = list.get(i);
  516. if (temp.getName().equals(name))
  517. iresult++;
  518. }
  519. return iresult;
  520. }
  521. private int getNumByDescriptionFromMdpClass(String name, MdpClassImpl mdlclass) {
  522. int iresult = 0;
  523. ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
  524. .getAllMdpAttributes();
  525. for (int i = 0; i < list.size(); i++) {
  526. MdpAttributeImpl temp = list.get(i);
  527. if (temp.getDescription().equals(name))
  528. iresult++;
  529. }
  530. return iresult;
  531. }
  532. /**
  533. * 判断数据源是否存在
  534. *
  535. * @param sourceid
  536. * @return
  537. */
  538. private boolean isDataSourceExist(int sourceid) {
  539. ArrayList<MdpDataSourceImpl> list = SysModel.getMdpDataSources();
  540. MdpDataSourceImpl MdpDataSource = null;
  541. for (int i = 0; i < list.size(); i++) {
  542. MdpDataSource = list.get(i);
  543. if (MdpDataSource.getDataSourceid() == sourceid)
  544. return true;
  545. }
  546. return false;
  547. }
  548. // ================================================
  549. /**
  550. * 相同数据源表的中英文名不能相同
  551. */
  552. private String isRepeatTableName(MdpClassImpl imp) {
  553. Iterator<MdpClassImpl> it = SysModelImpl.getInstance().getMdpClasses().iterator();
  554. while (it.hasNext()) {
  555. MdpClassImpl temp = it.next();
  556. if (temp.getClassid() == imp.getClassid())
  557. continue;
  558. if (temp.getDataSource() == imp.getDataSource()) {
  559. if (temp.getName().equals(imp.getName()))
  560. return XmlManagerPara.repeat_ENname;
  561. if (temp.getDescription().equals(imp.getDescription()))
  562. return XmlManagerPara.repeat_CNname;
  563. }
  564. }
  565. return "";
  566. }
  567. /**
  568. * 表的中英文字段名称不能相同
  569. */
  570. private String isRepeatAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
  571. ArrayList<MdpAttributeImpl> list = (ArrayList<MdpAttributeImpl>) mdlclass
  572. .getAllMdpAttributes();
  573. for (int i = 0; i < list.size(); i++) {
  574. MdpAttributeImpl temp = list.get(i);
  575. if (temp.getName().equals(imp.getName()))
  576. return XmlManagerPara.repeat_ENname;
  577. }
  578. return "";
  579. }
  580. /**
  581. * 表的英文字段是否被其他表引用
  582. */
  583. private String isQuotedAttribute(MdpAttributeImpl imp, MdpClassImpl mdlclass) {
  584. String classid = "" + mdlclass.getClassid();
  585. SysModel sysmodel = ModelFactory.getSysmodel();
  586. ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
  587. for (int i = 0; i < mdpClasses.size(); i++) {
  588. MdpClassImpl MdpClass = mdpClasses.get(i);
  589. if (MdpClass.getClassid() != mdlclass.getClassid()) {
  590. ArrayList<MdpAttributeImpl> attributelist = (ArrayList<MdpAttributeImpl>) MdpClass
  591. .getAllMdpAttributes();
  592. for (int j = 0; j < attributelist.size(); j++) {
  593. MdpAttributeImpl MdpAttribute = attributelist.get(j);
  594. Reference reference = MdpAttribute.getReference();
  595. if (reference != null) {
  596. if (reference.getReferenceTable().equals(classid)
  597. && reference.getStoreName().equals(imp.getName())) {
  598. return XmlManagerPara.realtion_reference;
  599. }
  600. }
  601. }
  602. }
  603. }
  604. return "";
  605. }
  606. /**
  607. * 模板中的英文属性名称不能相同
  608. */
  609. private boolean isRepeatProperty(PropertyImpl imp, TemplateImpl template) {
  610. ArrayList<PropertyImpl> list = (ArrayList<PropertyImpl>) template.getListproperty();
  611. for (int i = 0; i < list.size(); i++) {
  612. PropertyImpl temp = (PropertyImpl) list.get(i);
  613. if (temp.getName().equals(imp.getName()))
  614. return true;
  615. }
  616. return false;
  617. }
  618. /**
  619. * 模板是否被用
  620. */
  621. private String isQuotedTemplate(TemplateImpl template) {
  622. SysModel sysmodel = ModelFactory.getSysmodel();
  623. List<MdpConstantImpl> list = sysmodel.getMdpConstants();
  624. for (int i = 0; i < list.size(); i++) {
  625. MdpConstantImpl MdpConstant = list.get(i);
  626. if (MdpConstant.getTemplateName().equals(template.getName()))
  627. return XmlManagerPara.repeat_ENname;
  628. }
  629. return "";
  630. }
  631. public String createJavaCode(MdpClassImpl imp) {
  632. MdpModule MdpModule = SysModel.getMdpModuleByCode(imp.getType());
  633. StringBuffer sb = new StringBuffer();
  634. sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
  635. + "] 生成JAVA文件...<br>");
  636. sb.append("package " + MdpModule.getPackageName() + ".model<br>");
  637. // 第一步:生成JAVA文件内容
  638. StringBuffer sbjava = new StringBuffer();
  639. sbjava.append("package " + MdpModule.getPackageName() + ".model\n");
  640. // 这个地方写入引入的包
  641. sbjava.append("");
  642. sbjava.append("@Entity\n");
  643. sbjava.append("@Table(name = \"" + imp.getName() + "\")\n");
  644. sbjava.append("public class " + imp.getName() + " {\n");
  645. sbjava.append(" //java对象对应DataModel.xml中编号:" + imp.getClassid() + "\n");
  646. // 先生成表的字段属性定义
  647. List<MdpAttributeImpl> list = imp.getAllMdpAttributes();
  648. MdpAttributeImpl MdpAttribute = null;
  649. for (int i = 0; i < list.size(); i++) {
  650. MdpAttribute = list.get(i);
  651. sbjava.append(" /**\n");
  652. sbjava.append(" *" + MdpAttribute.getDescription() + " 长度:"
  653. + MdpAttribute.getPrecision() + "\n");
  654. sbjava.append(" */\n");
  655. if (MdpAttribute.getDataType().equals("string")) {
  656. sbjava.append(" private String " + MdpAttribute.getName() + ";\n");
  657. } else if (MdpAttribute.getDataType().equals("date")) {
  658. sbjava.append(" private String " + MdpAttribute.getName() + ";\n");
  659. } else if (MdpAttribute.getDataType().equals("number")) {
  660. sbjava.append(" private int " + MdpAttribute.getName() + ";\n");
  661. }
  662. }
  663. // 生成SET GET 方法
  664. sbjava.append("}\n");
  665. log.info("sbjava :" + sbjava.toString());
  666. // 第二步:把JAVA文件写入JAVA文件夹子
  667. try {
  668. String folder = SysModel.getFileLoadFolder().replace("WEB-INF", "java");
  669. // + MdpModule.getPackageName().replace(".", "\\")+"\\" ;
  670. String filepath = folder + imp.getName() + ".java";
  671. log.info("JAVA 路径:" + filepath);
  672. // 建立存储JAVA的文件夹子
  673. log.info("JAVA 文件夹:" + folder.replace("\\", "/"));
  674. FileOperate.createFolder(folder.replace("\\", "/"));
  675. FileOperate fileOperate = new FileOperate();
  676. fileOperate.createFile(filepath, sbjava.toString());
  677. // String s = sbjava.toString();
  678. // FileOutputStream fo = null;
  679. // try{
  680. // fo = new FileOutputStream(filepath);
  681. // fo.write(s.getBytes("utf-8"));
  682. // fo.close();//关闭
  683. // } catch (IOException e){
  684. // e.printStackTrace();
  685. // }
  686. } catch (Exception e) {
  687. e.printStackTrace();
  688. }
  689. return sb.toString();
  690. }
  691. public String checkDescriptionConfig(MdpClassImpl imp) {
  692. StringBuffer sb = new StringBuffer();
  693. List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
  694. if (isDescriptionExist(imp)) {
  695. for (int i = 0; i < mdpAttributes.size(); i++) {
  696. MdpAttributeImpl mdpAttribute = mdpAttributes.get(i);
  697. if (mdpAttribute.getName().equals(mdpAttribute.getDescription())) {
  698. sb.append("<tr><td width='80'>" + imp.getName() + "</td><td width='150'>"
  699. + imp.getDescription() + "</td><td width='150'>"
  700. + mdpAttribute.getName() + "</td><td width=''>&nbsp;&nbsp;</td></tr>");
  701. }
  702. }
  703. }
  704. return sb.toString();
  705. }
  706. public boolean isDescriptionExist(MdpClassImpl imp) {
  707. boolean flag = false;
  708. List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
  709. int num = 0;
  710. for (int i = 0; i < mdpAttributes.size(); i++) {
  711. MdpAttributeImpl mdpAttribute = mdpAttributes.get(i);
  712. if (mdpAttribute.getName().equals(mdpAttribute.getDescription())) {
  713. num++;
  714. }
  715. }
  716. if (num > 0) {
  717. flag = true;
  718. }
  719. return flag;
  720. }
  721. public String getEnglishByDescription(MdpClassImpl imp) throws Exception {
  722. StringBuffer sb = new StringBuffer();
  723. String EnTableName = "";
  724. if (imp.getDescription().equals(imp.getName())) {
  725. Translate.setHttpReferrer("http://localhost");
  726. EnTableName = Translate.execute(imp.getDescription(), Language.CHINESE,
  727. Language.ENGLISH);
  728. imp.setNgoogleEn(EnTableName);
  729. }
  730. sb.append("classid:<b>" + imp.getClassid() + "</b><br>");
  731. sb.append("表中文名:<b>" + imp.getDescription() + "</b><br>");
  732. sb.append("English name:<b>" + EnTableName + "</b><br>");
  733. log.info(imp.getDescription() + " " + imp.getClassid());
  734. sb.append("<table align=\"center\" width=\"80%\" border=\"1\" class=\"ltab2\"><tr><td><b>字段中文名</b></td><td><b>English name</b></td></tr>");
  735. List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
  736. MdpAttributeImpl mdpAttribute = null;
  737. log.info("字段个数:" + mdpAttributes.size());
  738. String EnName = "";
  739. for (int i = 0; i < mdpAttributes.size(); i++) {
  740. mdpAttribute = mdpAttributes.get(i);
  741. /*
  742. * if(mdpAttribute.getDescription().equals(mdpAttribute.getName())
  743. * || mdpAttribute.getDescription().equals("") ||
  744. * !mdpAttribute.getNgoogleEn().equals("")){
  745. *
  746. * //如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文 EnName =
  747. * mdpAttribute.getNgoogleEn();
  748. *
  749. * }else{
  750. */
  751. Translate.setHttpReferrer("http://localhost");
  752. EnName = Translate.execute(mdpAttribute.getDescription(), Language.CHINESE,
  753. Language.ENGLISH);
  754. log.info(mdpAttribute.getDescription() + " " + EnName);
  755. mdpAttribute.setNgoogleEn(EnName);
  756. // }
  757. sb.append("<tr><td>" + mdpAttribute.getDescription() + "</td>");
  758. sb.append("<td>&nbsp;" + EnName + "</td></tr>");
  759. }
  760. sb.append("</table>");
  761. return sb.toString();
  762. }
  763. public String getEnglishByDescription() throws Exception {
  764. ArrayList<MdpModuleImpl> arrModules = SysModelImpl.getInstance().getMdpModules();
  765. ArrayList<MdpConstantImpl> arrConstants = SysModelImpl.getInstance().getMdpConstants();
  766. String EnName = "";
  767. MdpModuleImpl Module = null;
  768. MdpConstantImpl MdpConstant = null;
  769. StringBuffer sb = new StringBuffer();
  770. sb.append("<table align=\"center\" width=\"80%\" border=\"1\" class=\"ltab2\"><tr><td><b>模块名称</b></td><td><b>English name</b></td></tr>");
  771. for (int i = 0; i < arrModules.size(); i++) {
  772. Module = arrModules.get(i);
  773. if (Module.getName().equals("") || !Module.getNgoogleEn().equals("")) {
  774. // 如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文
  775. EnName = Module.getNgoogleEn();
  776. } else {
  777. Translate.setHttpReferrer("http://localhost");
  778. EnName = Translate.execute(Module.getName(), Language.CHINESE, Language.ENGLISH);
  779. log.info(Module.getName() + " " + EnName);
  780. Module.setNgoogleEn(EnName);
  781. }
  782. sb.append("<tr><td>" + Module.getName() + "</td>");
  783. sb.append("<td>&nbsp;" + EnName + "</td></tr>");
  784. }
  785. sb.append("</table>");
  786. 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>");
  787. for (int i = 0; i < arrConstants.size(); i++) {
  788. MdpConstant = arrConstants.get(i);
  789. if (MdpConstant.getDescription().equals("") || !MdpConstant.getNgoogleEn().equals("")) {
  790. // 如果中文名和英文名相同或者中文名为空,就不翻译,对于已经翻译了的,直接读取翻译了的英文
  791. EnName = MdpConstant.getNgoogleEn();
  792. } else {
  793. Translate.setHttpReferrer("http://localhost");
  794. EnName = Translate.execute(MdpConstant.getDescription(), Language.CHINESE,
  795. Language.ENGLISH);
  796. log.info(MdpConstant.getDescription() + " " + EnName);
  797. MdpConstant.setNgoogleEn(EnName);
  798. }
  799. sb.append("<tr><td>" + MdpConstant.getDescription() + "</td>");
  800. sb.append("<td>&nbsp;" + EnName + "</td></tr>");
  801. }
  802. sb.append("</table>");
  803. return sb.toString();
  804. }
  805. public String checkNameDefine(MdpClassImpl imp) {
  806. // sql的保留字
  807. String sqlKeyWords = ",action,add,aggregate,all,alter,after,and,as,asc,avg,avg_row_length,auto_increment,"
  808. + "between,bigint,bit,binary,blob,bool,both,by,cascade,case,char,character,change,check,checksum,"
  809. + "column,columns,comment,constraint,create,cross,current_date,current_time,current_timestamp,data,"
  810. + "database,databases,date,datetime,day,day_hour,day_minute,day_second,dayofmonth,dayofweek,"
  811. + "dayofyear,dec,decimal,default,delayed,delay_key_write,delete,desc,describe,distinct,distinctrow,"
  812. + "double,drop,end,else,escape,escaped,enclosed,enum,explain,exists,fields,file,first,float,float4,"
  813. + "float8,flush,foreign,from,for,full,function,global,grant,grants,group,having,heap,high_priority,hour,"
  814. + "hour_minute,hour_second,hosts,identified,ignore,in,index,infile,inner,insert,insert_id,int,integer,"
  815. + "interval,int1,int2,int3,int4,int8,into,if,is,isam,join,key,keys,kill,last_insert_id,leading,left,length,"
  816. + "like,lines,limit,load,local,lock,logs,long,longblob,longtext,low_priority,max,max_rows,match,mediumblob,"
  817. + "mediumtext,mediumint,middleint,min_rows,minute,minute_second,modify,month,monthname,myisam,natural,"
  818. + "numeric,no,not,null,on,optimize,option,optionally,or,order,outer,outfile,pack_keys,partial,password,"
  819. + "precision,primary,procedure,process,processlist,privileges,read,real,references,reload,regexp,rename,"
  820. + "replace,restrict,returns,revoke,rlike,row,rows,second,select,set,show,shutdown,smallint,soname,"
  821. + "sql_big_tables,sql_big_selects,sql_low_priority_updates,sql_log_off,sql_log_update,sql_select_limit,"
  822. + "sql_small_result,sql_big_result,sql_warnings,straight_join,starting,status,string,table,tables,temporary,"
  823. + "terminated,text,then,time,timestamp,tinyblob,tinytext,tinyint,trailing,to,type,use,using,unique,unlock,"
  824. + "unsigned,update,usage,values,varchar,variables,varying,varbinary,with,write,when,where,year,year_month,zerofill,";
  825. List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
  826. StringBuffer sb = new StringBuffer();
  827. sb.append("【" + imp.getClassid() + "】: " + imp.getDescription() + " [" + imp.getName()
  828. + "] 验证...<br>");
  829. sb.append("<font color=\"#FF0000\">");
  830. for (int j = 0; j < mdpAttributes.size(); j++) {
  831. MdpAttributeImpl mdpAttribute = mdpAttributes.get(j);
  832. String attributeName = "," + mdpAttribute.getName() + ",";
  833. if (sqlKeyWords.toUpperCase().indexOf(attributeName) != -1) {
  834. sb.append("&nbsp;&nbsp;[" + mdpAttribute.getName() + "]"
  835. + mdpAttribute.getDescription() + "是sql保留字<br>");
  836. }
  837. }
  838. sb.append("</font>");
  839. return sb.toString();
  840. }
  841. public static final String datasource_notexist = "所指定的数据链接不存在";
  842. /**
  843. * 获得系统模型配置
  844. */
  845. private SysModel SysModel = ModelFactory.getSysmodel();
  846. /**
  847. * @param classidStr
  848. * 表描述模型
  849. * @return 生成出DATAMODEL属性排序
  850. */
  851. public String createDataModelSort(String classidStr) {
  852. StringBuffer sb = new StringBuffer();
  853. MdpClassImpl mdpclassImpl;
  854. String[] classids = classidStr.split(",");
  855. SysModel sysmodel = ModelFactory.getSysmodel();
  856. for (int j = 0; j < classids.length; j++) {
  857. String cl = classids[j];
  858. int classid = Integer.parseInt(cl);
  859. mdpclassImpl = (MdpClassImpl) sysmodel.getMdpClassByClassID(classid);
  860. sb.append(classObjToXml(mdpclassImpl));
  861. }
  862. return sb.toString();
  863. }
  864. public String createDataModelSort() {
  865. StringBuffer sb = new StringBuffer();
  866. SysModel sysmodel = ModelFactory.getSysmodel();
  867. for (int iclass = 10; iclass < 1000; iclass++) {
  868. MdpClass mdpClass = sysmodel.getMdpClassByClassID(iclass);
  869. if (mdpClass != null) {
  870. sb.append(classObjToXml((MdpClassImpl) mdpClass));
  871. }
  872. }
  873. return sb.toString();
  874. }
  875. private StringBuffer classObjToXml(MdpClassImpl imp) {
  876. StringBuffer sb = new StringBuffer();
  877. List<MdpAttributeImpl> mdpAttributes = imp.getAllMdpAttributes();
  878. sb.append(" &lt;mdpClass classid=\"" + imp.getClassid() + "\" description=\""
  879. + imp.getDescription() + "\" name=\"" + imp.getName() + "\" oldName=\""
  880. + imp.getOldName() + "\" ngoogleEn=\"" + imp.getNgoogleEn() + "\" type=\""
  881. + imp.getType() + "\" catche=\"" + imp.isCatche() + "\" exist=\"" + imp.isExist()
  882. + "\" dataSource=\"" + imp.getDataSource() + "\" validate=\"" + imp.isValidate()
  883. + "\"><br>");
  884. for (int k = 0; k < mdpAttributes.size(); k++) {
  885. MdpAttributeImpl mdpAttribute = mdpAttributes.get(k);
  886. Reference reference = mdpAttribute.getReference();
  887. if (mdpAttribute.getReferenceType() != 0) {
  888. sb.append(" &lt;mdpAttribute description=\"" + mdpAttribute.getDescription()
  889. + "\" name=\"" + mdpAttribute.getName() + "\" oldName=\""
  890. + mdpAttribute.getOldName() + "\" ngoogleEn=\""
  891. + mdpAttribute.getNgoogleEn() + "\" unit=\"" + mdpAttribute.getUnit()
  892. + "\" dataType=\"" + mdpAttribute.getDataType() + "\" precision=\""
  893. + mdpAttribute.getPrecision() + "\" scale=\"" + mdpAttribute.getScale()
  894. + "\" referenceType=\"" + mdpAttribute.getReferenceType()
  895. + "\" defaultValue=\"" + mdpAttribute.getDefaultValue()
  896. + "\" logicPrimaryKey=\"" + mdpAttribute.isLogicPrimaryKey()
  897. + "\" notNull=\"" + mdpAttribute.isNotNull() + "\" validate=\""
  898. + mdpAttribute.isValidate() + "\" index=\"" + mdpAttribute.isIndex()
  899. + "\" indexType=\"" + mdpAttribute.getIndexType() + "\"><br>");
  900. sb.append(" &lt;reference displayName=\"" + reference.getDisplayName()
  901. + "\" referenceTable=\"" + mdpAttribute.getReference().getReferenceTable()
  902. + "\" storeName=\"" + reference.getStoreName() + "\"/&gt;<br>");
  903. sb.append(" &lt;/mdpAttribute&gt;<br>");
  904. } else {
  905. sb.append(" &lt;mdpAttribute description=\"" + mdpAttribute.getDescription()
  906. + "\" name=\"" + mdpAttribute.getName() + "\" oldName=\""
  907. + mdpAttribute.getOldName() + "\" ngoogleEn=\""
  908. + mdpAttribute.getNgoogleEn() + "\" unit=\"" + mdpAttribute.getUnit()
  909. + "\" dataType=\"" + mdpAttribute.getDataType() + "\" precision=\""
  910. + mdpAttribute.getPrecision() + "\" scale=\"" + mdpAttribute.getScale()
  911. + "\" referenceType=\"" + mdpAttribute.getReferenceType()
  912. + "\" defaultValue=\"" + mdpAttribute.getDefaultValue()
  913. + "\" logicPrimaryKey=\"" + mdpAttribute.isLogicPrimaryKey()
  914. + "\" notNull=\"" + mdpAttribute.isNotNull() + "\" validate=\""
  915. + mdpAttribute.isValidate() + "\" index=\"" + mdpAttribute.isIndex()
  916. + "\" indexType=\"" + mdpAttribute.getIndexType() + "\"/&gt;<br>");
  917. }
  918. }
  919. sb.append(" &lt;/mdpClass&gt;<br>");
  920. return sb;
  921. }
  922. @SuppressWarnings("unused")
  923. public StringBuffer createAtrributesByCNName(String sname) {
  924. StringBuffer sb = new StringBuffer();
  925. SysModel sysmodel = ModelFactory.getSysmodel();
  926. ArrayList<MdpClassImpl> mdpClasses = sysmodel.getMdpClasses();
  927. String[] names = sname.split(",");
  928. loop1: for (int i = 0; i < names.length; i++) {
  929. loop: for (int j = 0; j < mdpClasses.size(); j++) {
  930. MdpClassImpl mdpClass = mdpClasses.get(j);
  931. List<MdpAttributeImpl> mdpAttributes = mdpClass.getAllMdpAttributes();
  932. loop2: for (int n = 0; n < mdpAttributes.size(); n++) {
  933. MdpAttributeImpl mdpAttribute = mdpAttributes.get(n);
  934. if (names[i].trim().equals(mdpAttribute.getDescription())) {
  935. if (mdpAttribute.getReference() != null) {
  936. sb.append(" &lt;mdpAttribute description=\""
  937. + mdpAttribute.getDescription() + "\" name=\""
  938. + mdpAttribute.getName() + "\" oldName=\""
  939. + mdpAttribute.getOldName() + "\" ngoogleEn=\""
  940. + mdpAttribute.getNgoogleEn() + "\" unit=\""
  941. + mdpAttribute.getUnit() + "\" dataType=\""
  942. + mdpAttribute.getDataType() + "\" precision=\""
  943. + mdpAttribute.getPrecision() + "\" scale=\""
  944. + mdpAttribute.getScale() + "\" referenceType=\""
  945. + mdpAttribute.getReferenceType() + "\" defaultValue=\""
  946. + mdpAttribute.getDefaultValue() + "\" logicPrimaryKey=\""
  947. + mdpAttribute.isLogicPrimaryKey() + "\" notNull=\""
  948. + mdpAttribute.isNotNull() + "\" validate=\""
  949. + mdpAttribute.isValidate() + "\" index=\""
  950. + mdpAttribute.isIndex() + "\" indexType=\""
  951. + mdpAttribute.getIndexType() + "\"><br>");
  952. sb.append(" &lt;reference displayName=\""
  953. + mdpAttribute.getReference().getDisplayName()
  954. + "\" referenceTable=\""
  955. + mdpAttribute.getReference().getReferenceTable()
  956. + "\" storeName=\""
  957. + mdpAttribute.getReference().getStoreName() + "\"/&gt;<br>");
  958. sb.append(" &lt;/mdpAttribute&gt;<br>");
  959. } else {
  960. sb.append(" &lt;mdpAttribute description=\""
  961. + mdpAttribute.getDescription() + "\" name=\""
  962. + mdpAttribute.getName() + "\" oldName=\""
  963. + mdpAttribute.getOldName() + "\" ngoogleEn=\""
  964. + mdpAttribute.getNgoogleEn() + "\" unit=\""
  965. + mdpAttribute.getUnit() + "\" dataType=\""
  966. + mdpAttribute.getDataType() + "\" precision=\""
  967. + mdpAttribute.getPrecision() + "\" scale=\""
  968. + mdpAttribute.getScale() + "\" referenceType=\""
  969. + mdpAttribute.getReferenceType() + "\" defaultValue=\""
  970. + mdpAttribute.getDefaultValue() + "\" logicPrimaryKey=\""
  971. + mdpAttribute.isLogicPrimaryKey() + "\" notNull=\""
  972. + mdpAttribute.isNotNull() + "\" validate=\""
  973. + mdpAttribute.isValidate() + "\" index=\""
  974. + mdpAttribute.isIndex() + "\" indexType=\""
  975. + mdpAttribute.getIndexType() + "\"/&gt;<br>");
  976. }
  977. break loop;
  978. } else if (names[i].trim().indexOf("编号") > -1) {
  979. sb.append(" &lt;mdpAttribute validate=\"true\" name=\"_Code\" description=\""
  980. + names[i].trim()
  981. + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/&gt;<br>");
  982. break loop;
  983. } else if (names[i].trim().indexOf("日期") > -1) {
  984. sb.append(" &lt;mdpAttribute validate=\"true\" name=\"_Date\" description=\""
  985. + names[i].trim()
  986. + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"date\" referenceType=\"0\" scale=\"\" precision=\"yyyy-MM-dd HH:mm:ss\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/&gt;<br>");
  987. break loop;
  988. } else if (names[i].trim().indexOf("名称") > -1) {
  989. sb.append(" &lt;mdpAttribute validate=\"true\" name=\"_Name\" description=\""
  990. + names[i].trim()
  991. + "\" unit=\"\" logicPrimaryKey=\"fals\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/&gt;<br>");
  992. break loop;
  993. } else if (names[i].trim().indexOf("性别") > -1) {
  994. sb.append(" &lt;mdpAttribute description=\""
  995. + names[i].trim()
  996. + "\" name=\"sex\" oldName=\"\" ngoogleEn=\"\" unit=\"\" dataType=\"string\" precision=\"5\" scale=\"\" referenceType=\"2\" defaultValue=\"\" logicPrimaryKey=\"false\" notNull=\"false\" validate=\"true\" index=\"false\" indexType=\"\"><br>");
  997. sb.append(" &lt;reference displayName=\"\" referenceTable=\"BM$_Gender\" storeName=\"\"/&gt;<br>");
  998. sb.append(" &lt;/mdpAttribute&gt;<br>");
  999. break loop;
  1000. } else if (names[i].trim().indexOf("桩号") > -1) {
  1001. sb.append(" &lt;mdpAttribute validate=\"true\" name=\"\" description=\""
  1002. + names[i].trim()
  1003. + "\" unit=\"\" logicPrimaryKey=\"false\" dataType=\"number\" referenceType=\"0\" scale=\"3\" precision=\"18\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/&gt;<br>");
  1004. break loop;
  1005. } else if (names[i].trim().indexOf("代码") > -1) {
  1006. sb.append(" &lt;mdpAttribute validate=\"true\" name=\"_Code\" description=\""
  1007. + names[i].trim()
  1008. + "\" unit=\"\" logicPrimaryKey=\"false\" dataType=\"string\" referenceType=\"0\" scale=\"\" precision=\"\" index=\"false\" indexType=\"\" defaultValue=\"\" notNull=\"false\" \"/&gt;<br>");
  1009. break loop;
  1010. }
  1011. }
  1012. }
  1013. }
  1014. return sb;
  1015. }
  1016. }