- 1.7.6 초기 코드
[Tadpole.git] / com.hangum.tadpole.commons.sql / src / com / hangum / tadpole / engine / sql / util / resultset / ResultSetUtilDTO.java
blob792088a7edd472bf582e1b4f1b823d993e4fa043
1 /*******************************************************************************
2 * Copyright (c) 2013 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7 *
8 * Contributors:
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com.hangum.tadpole.engine.sql.util.resultset;
13 import java.sql.ResultSet;
14 import java.sql.SQLException;
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
19 import com.hangum.tadpole.engine.query.dao.system.UserDBDAO;
21 /**
22 * java.sql.ResultSet을 TableViewer에 보여주기 위한 DAO.
24 * @author hangum
27 public class ResultSetUtilDTO {
29 /**
30 * userDB dao
32 private UserDBDAO userDB;
34 /**
35 * 요청 쿼리
37 private String reqQuery;
39 /**
40 * column 이름. <columnIndex, name>
42 private Map<Integer, String> columnName = new HashMap<Integer, String>();
44 /**
45 * column label 이름. <columnIndex, name>
47 private Map<Integer, String> columnLabelName = new HashMap<Integer, String>();
49 /**
50 * column of table name <columnIndex, name>
52 private Map<Integer, String> columnTableName = new HashMap<Integer, String>();
54 /**
55 * column type <columnIndex, java.sql.Type>
57 private Map<Integer, Integer> columnType = new HashMap<Integer, Integer>();
59 /**
60 * column metadata
62 * result map is schema, table, column
64 // private Map<Integer, Map> columnMetaData = new HashMap<Integer, Map>();
66 /**
67 * data <columnIndex, data>
69 private TadpoleResultSet dataList = null;//new TadpoleResultSet();
71 /**
72 * extension 결과를 정의한다.
74 * ex) mysql의 Show status, show profile 정보를 입력한다.
76 protected Map<String, Object> mapExtendResult = new HashMap<String, Object>();
78 /**
81 public ResultSetUtilDTO() {
84 /**
86 * @param statementType
87 * @param userDB
88 * @param mapColumns
89 * @param mapColumnType
90 * @param sourceDataList
92 public ResultSetUtilDTO(
93 UserDBDAO userDB,
94 String reqQuery,
95 Map<Integer, String> columnName,
96 Map<Integer, String> columnTableName,
97 Map<Integer, Integer> columnType,
98 TadpoleResultSet dataList
99 ) {
100 this.userDB = userDB;
101 this.reqQuery = reqQuery;
102 this.columnName = columnName;
103 this.columnTableName = columnTableName;
104 this.columnType = columnType;
105 this.dataList = dataList;
109 * 메인에디터에서 보여주기위한 정보를 만듭니다.
111 * @param userDB
112 * @param isShowRownum
113 * @param rs
114 * @param limitCount
115 * @param isResultComma
116 * @param intLastIndex
117 * @throws Exception
119 public ResultSetUtilDTO(
120 final UserDBDAO userDB,
121 final String reqQuery,
122 final boolean isShowRownum, final ResultSet rs, final int limitCount, int intLastIndex) throws SQLException {
123 this.userDB = userDB;
124 this.reqQuery = reqQuery;
126 if(rs != null) {
127 columnTableName = ResultSetUtils.getColumnTableName(userDB, isShowRownum, rs);
128 columnName = ResultSetUtils.getColumnName(userDB, columnTableName, isShowRownum, rs);
129 columnLabelName = ResultSetUtils.getColumnLabelName(userDB, columnTableName, isShowRownum, rs);
130 columnType = ResultSetUtils.getColumnType(isShowRownum, rs.getMetaData());
132 if(isShowRownum && (columnName.size() == 1)) {
133 dataList = new TadpoleResultSet();
134 } else {
135 dataList = ResultSetUtils.getResultToList(userDB, isShowRownum, rs, limitCount, intLastIndex);
138 // columnMetaData = ResultSetUtils.getColumnTableColumnName(userDB, rs.getMetaData());
143 * @return the userDB
145 public UserDBDAO getUserDB() {
146 return userDB;
150 * @param userDB the userDB to set
152 public void setUserDB(UserDBDAO userDB) {
153 this.userDB = userDB;
157 * @return the reqQuery
159 public String getReqQuery() {
160 return reqQuery;
164 * @param reqQuery the reqQuery to set
166 public void setReqQuery(String reqQuery) {
167 this.reqQuery = reqQuery;
171 * @return the columnName
173 public Map<Integer, String> getColumnName() {
174 return columnName;
178 * @param columnName the columnName to set
180 public void setColumnName(Map<Integer, String> columnName) {
181 this.columnName = columnName;
185 * @return the columnType
187 public Map<Integer, Integer> getColumnType() {
188 return columnType;
192 * @param columnType the columnType to set
194 public void setColumnType(Map<Integer, Integer> columnType) {
195 this.columnType = columnType;
199 * @return the dataList
201 public final TadpoleResultSet getDataList() {
202 return dataList;
206 * @param dataList the dataList to set
208 public final void setDataList(TadpoleResultSet dataList) {
209 this.dataList = dataList;
212 public void addDataAll(List<Map<Integer, Object>> resultToList) {
213 this.dataList.getData().addAll(resultToList);
216 // public Map<Integer, Map> getColumnMetaData() {
217 // return columnMetaData;
218 // }
220 // public void setColumnMetaData(Map<Integer, Map> columnMetaData) {
221 // this.columnMetaData = columnMetaData;
222 // }
225 * @return the columnTableName
227 public Map<Integer, String> getColumnTableName() {
228 return columnTableName;
232 * @param columnTableName the columnTableName to set
234 public void setColumnTableName(Map<Integer, String> columnTableName) {
235 this.columnTableName = columnTableName;
239 * @return the columnLabelName
241 public Map<Integer, String> getColumnLabelName() {
242 return columnLabelName;
246 * @param columnLabelName the columnLabelName to set
248 public void setColumnLabelName(Map<Integer, String> columnLabelName) {
249 this.columnLabelName = columnLabelName;
253 * 확장 결과를 가져온다.
254 * @return
256 public Map<String, Object> getMapExtendResult() {
257 return mapExtendResult;
261 * 확장 결과를 설정한다.
262 * @param mapExtendResult
264 public void setMapExtendResult(String key, Object obj) {
265 this.mapExtendResult.put(key, obj);