af273eca5dfd262033054f1a731b2b2b1c454441.svn-base 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. package com.persistence.service;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.OutputStream;
  5. import java.io.Reader;
  6. import java.io.Writer;
  7. import java.sql.Connection;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. import java.util.Map;
  11. import javax.servlet.http.HttpServletRequest;
  12. import com.persistence.service.assitant.DataObject;
  13. import com.persistence.service.assitant.Field;
  14. import com.persistence.service.exception.PersistenceException;
  15. import com.persistence.service.exception.TransformTypeException;
  16. import com.sysmodel.datamodel.xmlmodel.DataContent;
  17. import com.sysmodel.datamodel.xmlmodel.PropertyValue;
  18. import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
  19. import com.sysmodel.datamodel.xmlmodel.able.Template;
  20. import net.sf.json.JSONObject;
  21. import org.w3c.dom.Document;
  22. public interface SysPersistence{
  23. /**
  24. * @return 默认数据库连接
  25. */
  26. public Connection getConnection();
  27. /**
  28. * @return 默认数据库连接
  29. */
  30. public Connection getConnection(int claasid);
  31. /**
  32. * 添加数据 如果添加成功返回主键
  33. */
  34. public String addObjectData(DataObject dataobject) throws TransformTypeException,
  35. PersistenceException;
  36. /**
  37. * 更新数据
  38. */
  39. public boolean updateObjectData(DataObject dataobject) throws TransformTypeException,
  40. PersistenceException;
  41. /**
  42. * 查询数据,不包括lob数据
  43. */
  44. public DataObject searchObjectData(String objectID, int classid) throws PersistenceException;
  45. /**
  46. * 查询数据,不包括lob数据
  47. *
  48. * @param objectID
  49. * 纪录ID
  50. * @param classid
  51. * 所在表ID
  52. * @param objectIDName
  53. * 纪录id所在字段英文名
  54. * @return
  55. * @throws PersistenceException
  56. */
  57. public DataObject searchObjectData(String objectID, int classid, String objectIDName)
  58. throws PersistenceException;
  59. /**
  60. * 根据条件查询数据,只查询该表数据
  61. *
  62. * @param SQLcondition
  63. * where 后面查询条件
  64. * @return 返回数据集合,每个对象为DataObject
  65. */
  66. public ArrayList<DataObject> searchAllData(int classid, String SQLcondition)
  67. throws TransformTypeException, PersistenceException;
  68. /**
  69. * 根据条件查询数据,只查询该表数据
  70. *
  71. * @param condition
  72. * 每个对象是Field,blob,clob类型不能作为条件
  73. * @return 返回数据集合,每个对象为DataObject
  74. */
  75. public ArrayList<DataObject> searchAllData(int classid, List<Field> condition)
  76. throws TransformTypeException, PersistenceException;
  77. /**
  78. * 根据主键删除数据,如果存在主从关系,子表数据也会删除 真删除
  79. */
  80. public boolean deleteData(String objectID, int classid) throws PersistenceException;
  81. /**
  82. * 根据主键删除数据,如果存在主从关系,子表数据也会删除
  83. *
  84. * @param objectID
  85. * @param classid
  86. * @param isreal
  87. * @return
  88. * @throws PersistenceException
  89. * 当isreal 为FALSE时,假删除:调用这个方法时,数据库中必须有列字段is_Del
  90. */
  91. public boolean deleteData(String objectID, int classid, boolean isreal)
  92. throws PersistenceException;
  93. public void storeBlob(int classid, String objectID, String attributeName, InputStream is)
  94. throws TransformTypeException, PersistenceException;
  95. public void storeClob(int classid, String objectID, String attributeName, Reader reader)
  96. throws TransformTypeException, PersistenceException;
  97. public void readBlobToOutputStream(int classid, String objectID, String attributeName,
  98. OutputStream os) throws TransformTypeException, PersistenceException;
  99. public void readClobToWriter(int classid, String objectID, String attributeName, Writer writer)
  100. throws TransformTypeException, PersistenceException;
  101. /**
  102. * 返回数据库时间 格式:yyyy-MM-dd HH:mm:ss
  103. */
  104. public String getDataBaseTime() throws PersistenceException;
  105. /**
  106. * 结果集中每个对象是字符串数组,内容是sql语句的查询字段
  107. */
  108. public ArrayList<String[]> getSearchResult(int classid, String sql) throws PersistenceException;
  109. /**
  110. * 结果集中每个对象是字符串数组,内容是sql语句的查询字段
  111. */
  112. public ArrayList<Map<String, String>> getSearchResultToMap(int classid, String sql)
  113. throws PersistenceException;
  114. /**
  115. * 执行sql语句,返回执行结果
  116. */
  117. public int executeUpdateSQL(int classid, String sql) throws PersistenceException;
  118. /**
  119. * 批量执行sql语句,返回执行结果
  120. */
  121. public int[] executeUpdateSQL(int classid, ArrayList<String> sql) throws PersistenceException;
  122. /**
  123. * 返回数值运算函数结果
  124. */
  125. public int getFunctionNumber(int classid, String sql) throws PersistenceException;
  126. /**
  127. * 分页查询数据,常量编码值没有转换成相应描述
  128. *
  129. * @param intPageSize
  130. * 每页中记录个数
  131. * @param intCurrentPage
  132. * 当前页数
  133. * @return ArrayList集合中每个对象是字符串数组,内容是sql语句的查询字段
  134. */
  135. public ArrayList<String[]> searchPageResult(int classid, String sql, int intPageSize,
  136. int intCurrentPage) throws PersistenceException;
  137. // 常量表操作方法 begin
  138. /**
  139. * @param codeName
  140. * 常量名称
  141. * @param listPropertyValue
  142. * PropertyValue的集合
  143. */
  144. public boolean insertConstant(String codeName, ArrayList<PropertyValue> listPropertyValue)
  145. throws TransformTypeException, PersistenceException;
  146. /**
  147. * @param codeName
  148. * 常量名称
  149. * @param listPropertyValue
  150. * PropertyValue的集合
  151. */
  152. public boolean updateConstant(String codeName, ArrayList<PropertyValue> listPropertyValue)
  153. throws TransformTypeException, PersistenceException;
  154. /**
  155. * @param codeName
  156. * 常量名称
  157. * @param keyID
  158. * 主键值
  159. */
  160. public boolean deleteConstant(String codeName, String keyID) throws PersistenceException;
  161. /**
  162. * @param codeName
  163. * 常量名称
  164. * @param keyID
  165. * 主键值
  166. * @return PropertyValue的集合
  167. */
  168. public ArrayList<PropertyValue> searchConstant(String codeName, String keyID)
  169. throws PersistenceException;
  170. /**
  171. * @param codeName
  172. * 常量名称
  173. * @param keyID
  174. * 主键值
  175. * @return DataContent 的集合
  176. */
  177. public ArrayList<DataContent> searchDataContentByMdpConstant(MdpConstant constant)
  178. throws PersistenceException;
  179. public ArrayList<DataContent> searchDataContentByTemplate(Template template)
  180. throws PersistenceException;
  181. // 常量表操作方法 end
  182. /**
  183. * 构造出DataObject从HttpServletRequest
  184. */
  185. public DataObject generalDataObject(int classid, HttpServletRequest request);
  186. /**
  187. * 构造出DataObject从HttpServletRequest '-' 分割的字段
  188. */
  189. public DataObject generalDataObjectBySplit(int classid, HttpServletRequest request);
  190. // ---------------------------------------------------------------------
  191. /**
  192. * 2007.11.13 孙志刚新增通过 构造出XmlDocument从HttpServletRequest
  193. *
  194. * @throws IOException
  195. */
  196. public Document generalXmlDocument(HttpServletRequest request);
  197. /**
  198. * 构造出DataObject从xMLdOC
  199. */
  200. public DataObject generalDataObject(int classid, Document xmlDoc);
  201. public DataObject generalDataObjectJson(JSONObject JSONObject);
  202. public ArrayList<Map<String, String>> getPagingSearchResultToMap(int classid, String sql,
  203. String firstPageNum, String lastPageNum) throws PersistenceException;
  204. /**
  205. * 根据sql条件、及分页条件进行查询,只查询该表数据 吴潇 2009-12-25
  206. *
  207. * @param SQLcondition
  208. * where 后面查询条件
  209. * @return 返回数据集合,每个对象为DataObject
  210. */
  211. public ArrayList<DataObject> getPagingSearchResultToDataObject(int classid, String sql,
  212. String firstPageNum, String lastPageNum) throws PersistenceException;
  213. // --------------------------------------------------------------
  214. /**
  215. * 添加子表数据,返回主键
  216. */
  217. public String addChildData(DataObject dataobject, String parentid)
  218. throws TransformTypeException, PersistenceException;
  219. /**
  220. * 根据parentid删除子表数据
  221. */
  222. public boolean deleteChildData(int classid, String parentid) throws PersistenceException;
  223. /**
  224. * 根据parentid删除子表数据
  225. *
  226. * @param classid
  227. * @param parentid
  228. * @param isreal
  229. * @return
  230. * @throws PersistenceException
  231. */
  232. public boolean deleteChildData(int classid, String parentid, boolean isreal)
  233. throws PersistenceException;
  234. /**
  235. * 构造出DataObject从Uploader 带文件上传页面生成DataObject的方法
  236. */
  237. // public DataObject generalDataObjectByUploader(int classid,Uploader
  238. // myUploader);
  239. /* *//**
  240. * 查询数据,不包括lob数据 适用于存储数据库时FD_OBJECTID 前几位为DATAMODEL中CLASSID情况
  241. * 建议尽量不要使用此方法
  242. */
  243. /*
  244. * public DataObject searchObjectData(String objectID) throws
  245. * PersistenceException;
  246. */
  247. }