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
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
;
19 import com
.hangum
.tadpole
.engine
.query
.dao
.system
.UserDBDAO
;
22 * java.sql.ResultSet을 TableViewer에 보여주기 위한 DAO.
27 public class ResultSetUtilDTO
{
32 private UserDBDAO userDB
;
37 private String reqQuery
;
40 * column 이름. <columnIndex, name>
42 private Map
<Integer
, String
> columnName
= new HashMap
<Integer
, String
>();
45 * column label 이름. <columnIndex, name>
47 private Map
<Integer
, String
> columnLabelName
= new HashMap
<Integer
, String
>();
50 * column of table name <columnIndex, name>
52 private Map
<Integer
, String
> columnTableName
= new HashMap
<Integer
, String
>();
55 * column type <columnIndex, java.sql.Type>
57 private Map
<Integer
, Integer
> columnType
= new HashMap
<Integer
, Integer
>();
62 * result map is schema, table, column
64 // private Map<Integer, Map> columnMetaData = new HashMap<Integer, Map>();
67 * data <columnIndex, data>
69 private TadpoleResultSet dataList
= null;//new TadpoleResultSet();
74 * ex) mysql의 Show status, show profile 정보를 입력한다.
76 protected Map
<String
, Object
> mapExtendResult
= new HashMap
<String
, Object
>();
81 public ResultSetUtilDTO() {
86 * @param statementType
89 * @param mapColumnType
90 * @param sourceDataList
92 public ResultSetUtilDTO(
95 Map
<Integer
, String
> columnName
,
96 Map
<Integer
, String
> columnTableName
,
97 Map
<Integer
, Integer
> columnType
,
98 TadpoleResultSet dataList
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 * 메인에디터에서 보여주기위한 정보를 만듭니다.
112 * @param isShowRownum
115 * @param isResultComma
116 * @param intLastIndex
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
;
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();
135 dataList
= ResultSetUtils
.getResultToList(userDB
, isShowRownum
, rs
, limitCount
, intLastIndex
);
138 // columnMetaData = ResultSetUtils.getColumnTableColumnName(userDB, rs.getMetaData());
145 public UserDBDAO
getUserDB() {
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() {
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() {
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() {
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() {
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;
220 // public void setColumnMetaData(Map<Integer, Map> columnMetaData) {
221 // this.columnMetaData = columnMetaData;
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
;
256 public Map
<String
, Object
> getMapExtendResult() {
257 return mapExtendResult
;
262 * @param mapExtendResult
264 public void setMapExtendResult(String key
, Object obj
) {
265 this.mapExtendResult
.put(key
, obj
);