Révision | 5542ffa991cb80f534f88b3ad7d1a336f2ac45dc (tree) |
---|---|
l'heure | 2017-01-26 08:28:35 |
Auteur | kuboryu <kuboryu@yaho...> |
Commiter | kuboryu |
20170126
@@ -73,6 +73,7 @@ public class DataAccessObjects{ | ||
73 | 73 | private String tbName = null; |
74 | 74 | private String nullMark = ""; |
75 | 75 | private String lnSprtr = System.getProperty("line.separator"); |
76 | + private String delimiter = "\t"; | |
76 | 77 | private char singleByteChr = '*'; |
77 | 78 | private char doubleByteChr = '*'; |
78 | 79 | private String maskPtn = "ALT"; |
@@ -299,6 +300,16 @@ public class DataAccessObjects{ | ||
299 | 300 | |
300 | 301 | public void setPropVal(String[] _prop_val) throws Exception{ |
301 | 302 | prop_val = _prop_val; |
303 | + if(!CmnUtils.isEmpty(prop_val[LINESEP]))lnSprtr = CmnUtils.getLineSeparator(prop_val[LINESEP]); | |
304 | + if(!CmnUtils.isEmpty(prop_val[NULLMARK]))nullMark = prop_val[NULLMARK]; | |
305 | + if(!CmnUtils.isEmpty(prop_val[QUOTATION]) && prop_val[QUOTATION].toUpperCase().equals("N"))isQuotation = false; | |
306 | + if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))isInclMaskCols = true; | |
307 | + if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))isExclMaskCols = true; | |
308 | + if(isInclMaskCols || isExclMaskCols)isMask = true; | |
309 | + if(!CmnUtils.isEmpty(prop_val[SBYTEMASKCHR]))singleByteChr = prop_val[SBYTEMASKCHR].charAt(0); | |
310 | + if(!CmnUtils.isEmpty(prop_val[DBYTEMASKCHR]))doubleByteChr = prop_val[DBYTEMASKCHR].charAt(0); | |
311 | + if(!CmnUtils.isEmpty(prop_val[MASKPTN]))maskPtn = prop_val[MASKPTN]; | |
312 | + if(!CmnUtils.isEmpty(prop_val[DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[DELIMITER]); | |
302 | 313 | } |
303 | 314 | |
304 | 315 | public ResultSet getResultSet() throws Exception{ |
@@ -329,14 +340,10 @@ public class DataAccessObjects{ | ||
329 | 340 | } |
330 | 341 | } |
331 | 342 | |
332 | - public void getRecordToPrint(PrintWriter _pw, String _splt, boolean _isQuotation, boolean _isMask, int _firstCol, int _lastCol) throws Exception{ | |
343 | + public void getRecordToPrint(PrintWriter _pw, int _firstCol, int _lastCol) throws Exception{ | |
333 | 344 | try { |
334 | 345 | CmnUtils.debugPrint("Start get Record to Print"); |
335 | - isQuotation = _isQuotation; | |
336 | - isMask = _isMask; | |
337 | 346 | recCount = 0; |
338 | - if(!CmnUtils.isEmpty(prop_val[LINESEP]))lnSprtr = CmnUtils.getLineSeparator(prop_val[LINESEP]); | |
339 | - if(!CmnUtils.isEmpty(prop_val[NULLMARK]))nullMark = prop_val[NULLMARK]; | |
340 | 347 | |
341 | 348 | while (rst.next()) { |
342 | 349 | colString = null; |
@@ -362,15 +369,15 @@ public class DataAccessObjects{ | ||
362 | 369 | |
363 | 370 | } else if (i == _lastCol){ |
364 | 371 | if(isQuotation){ |
365 | - _pw.print("\"" + _splt + "\"" + colString + "\"" + lnSprtr); | |
372 | + _pw.print("\"" + delimiter + "\"" + colString + "\"" + lnSprtr); | |
366 | 373 | } else { |
367 | - _pw.print(_splt + colString + lnSprtr); | |
374 | + _pw.print(delimiter + colString + lnSprtr); | |
368 | 375 | } |
369 | 376 | } else { |
370 | 377 | if(isQuotation){ |
371 | - _pw.print("\"" + _splt + "\"" + colString); | |
378 | + _pw.print("\"" + delimiter + "\"" + colString); | |
372 | 379 | } else { |
373 | - _pw.print(_splt + colString); | |
380 | + _pw.print(delimiter + colString); | |
374 | 381 | } |
375 | 382 | } |
376 | 383 |
@@ -393,15 +400,15 @@ public class DataAccessObjects{ | ||
393 | 400 | } |
394 | 401 | } else if (i == _lastCol){ |
395 | 402 | if(isQuotation){ |
396 | - _pw.print("\"" + _splt + "\"" + nullMark + "\"" + lnSprtr); | |
403 | + _pw.print("\"" + delimiter + "\"" + nullMark + "\"" + lnSprtr); | |
397 | 404 | } else { |
398 | - _pw.print(_splt + nullMark + lnSprtr); | |
405 | + _pw.print(delimiter + nullMark + lnSprtr); | |
399 | 406 | } |
400 | 407 | } else { |
401 | 408 | if(isQuotation){ |
402 | - _pw.print("\"" + _splt + "\"" + nullMark); | |
409 | + _pw.print("\"" + delimiter + "\"" + nullMark); | |
403 | 410 | } else { |
404 | - _pw.print(_splt + nullMark); | |
411 | + _pw.print(delimiter + nullMark); | |
405 | 412 | } |
406 | 413 | } |
407 | 414 | } |
@@ -434,13 +441,6 @@ public class DataAccessObjects{ | ||
434 | 441 | Clob colClob = null; |
435 | 442 | ByteArrayOutputStream baos = null; |
436 | 443 | InputStream is = null; |
437 | - if(!CmnUtils.isEmpty(prop_val[QUOTATION]) && prop_val[QUOTATION].toUpperCase().equals("N"))isQuotation = false; | |
438 | - if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))isInclMaskCols = true; | |
439 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))isExclMaskCols = true; | |
440 | - if(isInclMaskCols || isExclMaskCols)isMask = true; | |
441 | - if(!CmnUtils.isEmpty(prop_val[SBYTEMASKCHR]))singleByteChr = prop_val[SBYTEMASKCHR].charAt(0); | |
442 | - if(!CmnUtils.isEmpty(prop_val[DBYTEMASKCHR]))doubleByteChr = prop_val[DBYTEMASKCHR].charAt(0); | |
443 | - if(!CmnUtils.isEmpty(prop_val[MASKPTN]))maskPtn = prop_val[MASKPTN]; | |
444 | 444 | |
445 | 445 | if (CmnUtils.isColString(_colTypeName)) { |
446 | 446 | colString = _rst.getString(_rec_cnt); |
@@ -34,6 +34,7 @@ public class RapideLoader{ | ||
34 | 34 | private String url = null; |
35 | 35 | private String driver = null; |
36 | 36 | private String sql_table_list = null; |
37 | + private String sql_table_key_list = null; | |
37 | 38 | private static final int DB_TYPE_ORACLE = 0; |
38 | 39 | private static final int DB_TYPE_SQLSERVER = 1; |
39 | 40 | private static final int DB_TYPE_DB2 = 2; |
@@ -44,9 +45,42 @@ public class RapideLoader{ | ||
44 | 45 | private static final int MASK_PTN_ALL = 0; |
45 | 46 | private static final int MASK_PTN_ALT = 1; |
46 | 47 | private static final int MASK_PTN_EDGE = 2; |
48 | + private static final int D_USER = 0; | |
49 | + private static final int D_PASS = 1; | |
50 | + private static final int D_URL = 2; | |
51 | + private static final int D_DRIVER = 3; | |
52 | + private static final int D_OUTPUT = 4; | |
53 | + private static final int D_INPUT = 5; | |
54 | + private static final int D_LINESEP = 6; | |
55 | + private static final int D_INLINESEP = 7; | |
56 | + private static final int D_FILENCODE = 8; | |
57 | + private static final int D_NULLMARK = 9; | |
58 | + private static final int D_DELIMITER = 10; | |
59 | + private static final int D_TBLSQL = 11; | |
60 | + private static final int D_TBLKEYSQL = 12; | |
61 | + private static final int D_ORDER = 13; | |
62 | + private static final int D_QUOTATION = 14; | |
63 | + private static final int D_BATCOUNT = 15; | |
64 | + private static final int D_INCLTAB = 16; | |
65 | + private static final int D_EXCLTAB = 17; | |
66 | + private static final int D_INCLCOL = 18; | |
67 | + private static final int D_EXCLCOL = 19; | |
68 | + private static final int D_INCLCOLMASK = 20; | |
69 | + private static final int D_EXCLCOLMASK = 21; | |
70 | + private static final int D_SBYTEMASKCHR = 22; | |
71 | + private static final int D_DBYTEMASKCHR = 23; | |
72 | + private static final int D_MASKPTN = 24; | |
73 | + private static final int D_PROPFILE = 25; | |
74 | + private static final int KEYS = 26; | |
75 | + private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm", | |
76 | + "dm","ts","tks","od","qt","bc","it","et","ic","ec", | |
77 | + "icm","ecm","smc","dmc","mp","pf"}; | |
78 | + | |
79 | + private String [] prop_val = new String[KEYS]; | |
47 | 80 | private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"}; |
48 | - private String propFile = "RapideLoader.properties"; | |
49 | - private static String [] arySql_table_list = { | |
81 | + private static final String DEFAULT_IN_FOLDER = "input"; | |
82 | + private static final String DEFAULT_PROP_FILE = "RapideLoader.properties"; | |
83 | + private static String [] sql_table_list_array = { | |
50 | 84 | "select " |
51 | 85 | + " table_name " |
52 | 86 | + " from user_tables " |
@@ -57,6 +91,41 @@ public class RapideLoader{ | ||
57 | 91 | + " order by name" |
58 | 92 | }; |
59 | 93 | |
94 | + private boolean isLob = false; | |
95 | + private boolean isContinue = false; | |
96 | + private String nullMark = ""; | |
97 | + private boolean isOrder = false; | |
98 | + private boolean isQuotation = true; | |
99 | + private int batchCount = 1000; | |
100 | + private boolean isInclTables = false; | |
101 | + private boolean isExclTables = false; | |
102 | + private boolean isInclCols = false; | |
103 | + private boolean isExclCols = false; | |
104 | + private boolean isMask = false; | |
105 | + private boolean isInclColsMask = false; | |
106 | + private boolean isExclColsMask = false; | |
107 | + private String delimiter = "\t"; | |
108 | + private String lineSeparator = System.getProperty("line.separator"); | |
109 | + private String inColLineSeparator = System.getProperty("line.separator"); | |
110 | + private String outFolder = null; | |
111 | + private String inFolder = null; | |
112 | + private String inclTables = null; | |
113 | + private String exclTables = null; | |
114 | + private String inclCols = null; | |
115 | + private String exclCols = null; | |
116 | + private String inclColsMask = null; | |
117 | + private String exclColsMask = null; | |
118 | + private String [] inclTablesArray = null; | |
119 | + private String [] exclTablesArray = null; | |
120 | + private String [] inclColsArray = null; | |
121 | + private String [] exclColsArray = null; | |
122 | + private String [] inclColsMaskArray = null; | |
123 | + private String [] exclColsMaskArray = null; | |
124 | + private char singleByteMaskChar = '*'; | |
125 | + private char doubleByteMaskChar = '\u25A0'; | |
126 | + private String maskPattern = "ALT"; | |
127 | + private String fileEncoding = System.getProperty("file.encoding"); | |
128 | + | |
60 | 129 | public static void main(String args[]){ |
61 | 130 | try { |
62 | 131 | if (args.length > 0){ |
@@ -72,22 +141,17 @@ public class RapideLoader{ | ||
72 | 141 | } |
73 | 142 | |
74 | 143 | private void getProperties(String _propFile) throws Exception{ |
75 | - InputStream is = null; | |
144 | + BufferedReader br = null; | |
76 | 145 | Properties prop = null; |
77 | 146 | try { |
78 | 147 | prop = new Properties(); |
79 | - is = RapideLoader.class.getClassLoader().getResourceAsStream(_propFile); | |
80 | - prop.load(is); | |
81 | - driver = prop.getProperty(database + "." + "driver"); | |
82 | - user = prop.getProperty(database + "." + "user"); | |
83 | - pass = prop.getProperty(database + "." + "pass"); | |
84 | - url = prop.getProperty(database + "." + "url"); | |
85 | - CmnUtils.debugPrint("driver=" + driver); | |
86 | - CmnUtils.debugPrint("user=" + user); | |
87 | - CmnUtils.debugPrint("pass=" + pass); | |
88 | - CmnUtils.debugPrint("url=" + url); | |
89 | - is.close(); | |
90 | - is = null; | |
148 | + br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8")); | |
149 | + prop.load(br); | |
150 | + for(int i=0;i<KEYS;i++){ | |
151 | + prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]); | |
152 | + } | |
153 | + br.close(); | |
154 | + br = null; | |
91 | 155 | } catch (NullPointerException e) { |
92 | 156 | throw new Exception("Property File (" + _propFile +") Not Found"); |
93 | 157 | } catch (IOException e) { |
@@ -95,9 +159,9 @@ public class RapideLoader{ | ||
95 | 159 | } |
96 | 160 | finally{ |
97 | 161 | try { |
98 | - if (is != null) { | |
99 | - is.close(); | |
100 | - is = null; | |
162 | + if (br != null) { | |
163 | + br.close(); | |
164 | + br = null; | |
101 | 165 | } |
102 | 166 | } |
103 | 167 | catch (IOException e) { |
@@ -106,6 +170,7 @@ public class RapideLoader{ | ||
106 | 170 | } |
107 | 171 | } |
108 | 172 | |
173 | + | |
109 | 174 | RapideLoader(String _database) throws Exception{ |
110 | 175 | super(); |
111 | 176 | database = _database; |
@@ -119,6 +184,15 @@ public class RapideLoader{ | ||
119 | 184 | String sql_load = null; |
120 | 185 | String sql_insert = null; |
121 | 186 | int dbType = DB_TYPE_UNKNOWN; |
187 | + String strLine = null; | |
188 | + String strMltLine = null; | |
189 | + String tbName = null; | |
190 | + String [] flName = null; | |
191 | + String [] colData = null; | |
192 | + String [] colName = null; | |
193 | + String [] colTypeName = null; | |
194 | + Integer [] isNullable = null; | |
195 | + Boolean [] colIncl = null; | |
122 | 196 | |
123 | 197 | File fldr = null; |
124 | 198 | ArrayList<String> alData = null; |
@@ -128,71 +202,64 @@ public class RapideLoader{ | ||
128 | 202 | ArrayList<Boolean> alColMask = null; |
129 | 203 | ArrayList<Boolean> alColIncl = null; |
130 | 204 | |
131 | - int batchCount = 1000; | |
132 | 205 | int tb_count = 0; |
133 | 206 | int tb_col_count = 0; |
134 | 207 | int fl_col_count = 0; |
135 | 208 | |
136 | - String nullMark = ""; | |
137 | - String strLine = null; | |
138 | - String strMltLine = null; | |
139 | - String tbName = null; | |
140 | - String [] flName = null; | |
141 | - String [] colData = null; | |
142 | - String [] colName = null; | |
143 | - String [] colTypeName = null; | |
144 | - Integer [] isNullable = null; | |
145 | - Boolean [] colIncl = null; | |
146 | - String sprtr = CmnUtils.getSeparator("sprtr", "\t"); | |
147 | - String lnSprtr = CmnUtils.getLineSeparator("lnSprtr", System.getProperty("line.separator")); | |
148 | - String inColLnSprtr = CmnUtils.getLineSeparator("inColLnSprtr", System.getProperty("line.separator")); | |
149 | - String inclTables = System.getProperty("inclTables"); | |
150 | - String exclTables = System.getProperty("exclTables"); | |
151 | - String inclCols = System.getProperty("inclCols"); | |
152 | - String exclCols = System.getProperty("exclCols"); | |
153 | - String inclMaskCols = System.getProperty("inclMaskCols"); | |
154 | - String exclMaskCols = System.getProperty("exclMaskCols"); | |
155 | - String [] aryInclTables = CmnUtils.getSystemProperty("inclTables"); | |
156 | - String [] aryExclTables = CmnUtils.getSystemProperty("exclTables"); | |
157 | - String [] aryInclMaskCols = CmnUtils.getSystemProperty("inclMaskCols"); | |
158 | - String [] aryExclMaskCols = CmnUtils.getSystemProperty("exclMaskCols"); | |
159 | - String [] aryInclCols = CmnUtils.getSystemProperty("inclCols"); | |
160 | - String [] aryExclCols = CmnUtils.getSystemProperty("exclCols"); | |
161 | 209 | |
162 | - boolean isLob = false; | |
163 | - boolean isContinue = false; | |
164 | - boolean isQuotation = CmnUtils.getSystemProperty("quotation", true); | |
165 | - boolean isInclTables = CmnUtils.getSystemProperty("inclTables", false); | |
166 | - boolean isExclTables = CmnUtils.getSystemProperty("exclTables", false); | |
167 | - boolean isInclCols = CmnUtils.getSystemProperty("inclCols", false); | |
168 | - boolean isExclCols = CmnUtils.getSystemProperty("exclCols", false); | |
169 | - boolean isInclMaskCols = CmnUtils.getSystemProperty("inclMaskCols", false); | |
170 | - boolean isExclMaskCols = CmnUtils.getSystemProperty("exclMaskCols", false); | |
171 | - boolean isMask = CmnUtils.getSystemProperty("inclMaskCols", false) || CmnUtils.getSystemProperty("exclMaskCols", false); | |
172 | - String defaultFldr = "input"; | |
173 | - String inFldr = System.getProperty("input"); | |
174 | - char hankakuMask = CmnUtils.getSystemProperty("hankakuMask", '*'); | |
175 | - char zenkakuMask = CmnUtils.getSystemProperty("zenkakuMask", '*'); | |
176 | - String maskPtn = CmnUtils.getSystemProperty("maskPtn", MASK_PTN[MASK_PTN_ALT]); | |
177 | - String fileEncoding = CmnUtils.getSystemProperty("fileEncoding", System.getProperty("file.encoding")); | |
178 | 210 | |
179 | - if(System.getProperty("batchCount")!=null){ | |
180 | - batchCount = Integer.parseInt(System.getProperty("batchCount")); | |
181 | - } | |
182 | 211 | |
183 | 212 | if(database != null){ |
184 | - if(System.getProperty("propFile") != null){ | |
185 | - getProperties(System.getProperty("propFile")); | |
213 | + if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){ | |
214 | + getProperties(System.getProperty(prop_val[D_PROPFILE])); | |
186 | 215 | } else { |
187 | - getProperties(propFile); | |
216 | + getProperties(DEFAULT_PROP_FILE); | |
188 | 217 | } |
189 | - } else { | |
190 | - user = System.getProperty("user"); | |
191 | - pass = System.getProperty("pass"); | |
192 | - url = System.getProperty("url"); | |
193 | - driver = System.getProperty("driver"); | |
194 | - | |
195 | 218 | } |
219 | + | |
220 | + for(int i=0;i<KEYS;i++){ | |
221 | + if(System.getProperty(PROP_KEY[i])!=null)prop_val[i] = System.getProperty(PROP_KEY[i]); | |
222 | + CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]); | |
223 | + } | |
224 | + | |
225 | + if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER]; | |
226 | + if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS]; | |
227 | + if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL]; | |
228 | + if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER]; | |
229 | + if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT]; | |
230 | + if(!CmnUtils.isEmpty(prop_val[D_INPUT]))inFolder = prop_val[D_INPUT]; | |
231 | + if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]); | |
232 | + if(!CmnUtils.isEmpty(prop_val[D_INLINESEP]))inColLineSeparator = CmnUtils.getLineSeparator(prop_val[D_INLINESEP]); | |
233 | + if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE]; | |
234 | + if(!CmnUtils.isEmpty(prop_val[D_NULLMARK]))nullMark = prop_val[D_NULLMARK]; | |
235 | + if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]); | |
236 | + if(!CmnUtils.isEmpty(prop_val[D_TBLSQL]))sql_table_list = prop_val[D_TBLSQL]; | |
237 | + if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL]))sql_table_key_list = prop_val[D_TBLKEYSQL]; | |
238 | + if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true; | |
239 | + if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false; | |
240 | + if(!CmnUtils.isEmpty(prop_val[D_BATCOUNT]))batchCount = Integer.parseInt(prop_val[D_BATCOUNT]); | |
241 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true; | |
242 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true; | |
243 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true; | |
244 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true; | |
245 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true; | |
246 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true; | |
247 | + if(isInclColsMask || isExclColsMask)isMask = true; | |
248 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase(); | |
249 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase(); | |
250 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase(); | |
251 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase(); | |
252 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMask = prop_val[D_INCLCOLMASK].toUpperCase(); | |
253 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMask = prop_val[D_EXCLCOLMASK].toUpperCase(); | |
254 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase()); | |
255 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase()); | |
256 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase()); | |
257 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase()); | |
258 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase()); | |
259 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase()); | |
260 | + if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0); | |
261 | + if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0); | |
262 | + if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN]; | |
196 | 263 | |
197 | 264 | if(user == null){ |
198 | 265 | throw new Exception("user is null"); |
@@ -212,10 +279,10 @@ public class RapideLoader{ | ||
212 | 279 | } |
213 | 280 | |
214 | 281 | if (dbType != DB_TYPE_UNKNOWN){ |
215 | - if(System.getProperty("sql_table_list") != null){ | |
216 | - sql_table_list = System.getProperty("sql_table_list"); | |
282 | + if(!CmnUtils.isEmpty(prop_val[D_TBLSQL])){ | |
283 | + sql_table_list = prop_val[D_TBLSQL]; | |
217 | 284 | } else { |
218 | - sql_table_list = arySql_table_list[dbType]; | |
285 | + sql_table_list = sql_table_list_array[dbType]; | |
219 | 286 | } |
220 | 287 | } else { |
221 | 288 | throw new Exception("dbtype unknown"); |
@@ -226,18 +293,18 @@ public class RapideLoader{ | ||
226 | 293 | conn = dao.connect(); |
227 | 294 | conn.setAutoCommit(false); |
228 | 295 | |
229 | - if(inFldr != null){ | |
230 | - fldr = new File(inFldr); | |
296 | + if(inFolder != null){ | |
297 | + fldr = new File(inFolder); | |
231 | 298 | } else { |
232 | 299 | if (database != null){ |
233 | - fldr = new File(defaultFldr + "/" + database.toUpperCase()); | |
300 | + fldr = new File(DEFAULT_IN_FOLDER + "/" + database.toUpperCase()); | |
234 | 301 | } else { |
235 | - fldr = new File(defaultFldr + "/" + DB_TYPE_NAME[dbType].toUpperCase()); | |
302 | + fldr = new File(DEFAULT_IN_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase()); | |
236 | 303 | } |
237 | 304 | } |
238 | 305 | CmnUtils.infoPrint("-->対象データベース='" + database.toUpperCase() + "'"); |
239 | 306 | CmnUtils.infoPrint("-->入力元='" + fldr + "'"); |
240 | - CmnUtils.infoPrint("-->区切り文字='" + sprtr + "'"); | |
307 | + CmnUtils.infoPrint("-->区切り文字='" + delimiter + "'"); | |
241 | 308 | CmnUtils.infoPrint("-->バッチカウント=" + batchCount); |
242 | 309 | CmnUtils.infoPrint("-->引用句=" + CmnUtils.getYesNo(isQuotation)); |
243 | 310 | if(isInclTables)CmnUtils.infoPrint("-->対象テーブル='" + inclTables.toUpperCase() + "'"); |
@@ -246,11 +313,11 @@ public class RapideLoader{ | ||
246 | 313 | if(isExclCols)CmnUtils.infoPrint("-->除外カラム='" + exclCols.toUpperCase() + "'"); |
247 | 314 | CmnUtils.infoPrint("-->マスキング=" + CmnUtils.getYesNo(isMask)); |
248 | 315 | if(isMask){ |
249 | - CmnUtils.infoPrint("-->マスクキングパターン=" + maskPtn.toUpperCase()); | |
250 | - if(isInclMaskCols)CmnUtils.infoPrint("-->マスク対象カラム='" + inclMaskCols.toUpperCase() + "'"); | |
251 | - if(isExclMaskCols)CmnUtils.infoPrint("-->マスク除外カラム='" + exclMaskCols.toUpperCase() + "'"); | |
252 | - CmnUtils.infoPrint("-->半角マスク文字='" + hankakuMask + "'"); | |
253 | - CmnUtils.infoPrint("-->全角マスク文字='" + zenkakuMask + "'"); | |
316 | + CmnUtils.infoPrint("-->マスクキングパターン=" + maskPattern.toUpperCase()); | |
317 | + if(isInclColsMask)CmnUtils.infoPrint("-->マスク対象カラム='" + inclColsMask.toUpperCase() + "'"); | |
318 | + if(isExclColsMask)CmnUtils.infoPrint("-->マスク除外カラム='" + exclColsMask.toUpperCase() + "'"); | |
319 | + CmnUtils.infoPrint("-->半角マスク文字='" + singleByteMaskChar + "'"); | |
320 | + CmnUtils.infoPrint("-->全角マスク文字='" + doubleByteMaskChar + "'"); | |
254 | 321 | } |
255 | 322 | CmnUtils.infoPrint("データロードを開始しました。"); |
256 | 323 |
@@ -270,14 +337,14 @@ public class RapideLoader{ | ||
270 | 337 | TABLE_LOOP: |
271 | 338 | for(int i=0;i<alData.size();i++){ |
272 | 339 | if(tbName.equals(alData.get(i))){ |
273 | - if(isInclTables && !CmnUtils.isMatch(aryInclTables,tbName.toUpperCase())){ | |
340 | + if(isInclTables && !CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase())){ | |
274 | 341 | CmnUtils.debugPrint("inclTables=" + inclTables); |
275 | - CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(aryInclTables,tbName.toUpperCase())); | |
342 | + CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(inclTablesArray,tbName.toUpperCase())); | |
276 | 343 | continue; |
277 | 344 | } |
278 | - if(isExclTables && CmnUtils.isMatch(aryExclTables,tbName.toUpperCase())){ | |
345 | + if(isExclTables && CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase())){ | |
279 | 346 | CmnUtils.debugPrint("exclTables=" + exclTables); |
280 | - CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(aryExclTables,tbName.toUpperCase())); | |
347 | + CmnUtils.debugPrint("table=" + tbName + "," +CmnUtils.isMatch(exclTablesArray,tbName.toUpperCase())); | |
281 | 348 | continue; |
282 | 349 | } |
283 | 350 | br = new BufferedReader(new InputStreamReader(new FileInputStream(fldr + "/" + alData.get(i) + "." + flName[1]), fileEncoding)); |
@@ -309,9 +376,9 @@ public class RapideLoader{ | ||
309 | 376 | while((strLine=br.readLine()) != null){ |
310 | 377 | if (fl_rec_count == 0){ |
311 | 378 | if(isQuotation){ |
312 | - colData = CmnUtils.split(strLine,"\"" + sprtr + "\""); | |
379 | + colData = CmnUtils.split(strLine,"\"" + delimiter + "\""); | |
313 | 380 | } else { |
314 | - colData = CmnUtils.split(strLine,sprtr); | |
381 | + colData = CmnUtils.split(strLine,delimiter); | |
315 | 382 | } |
316 | 383 | fl_col_count = colData.length; |
317 | 384 | fl_col_seq = new int[colData.length]; |
@@ -324,16 +391,16 @@ public class RapideLoader{ | ||
324 | 391 | if( |
325 | 392 | (isInclCols && |
326 | 393 | !isExclCols && |
327 | - CmnUtils.isMatch(aryInclCols, tbName.toUpperCase(), colName[l].toUpperCase()) | |
394 | + CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) | |
328 | 395 | ) || |
329 | 396 | (isInclCols && |
330 | 397 | isExclCols && |
331 | - CmnUtils.isMatch(aryInclCols, tbName.toUpperCase(), colName[l].toUpperCase()) && | |
332 | - !CmnUtils.isMatch(aryExclCols, tbName.toUpperCase(), colName[l].toUpperCase()) | |
398 | + CmnUtils.isMatch(inclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) && | |
399 | + !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) | |
333 | 400 | ) || |
334 | 401 | (!isInclCols && |
335 | 402 | isExclCols && |
336 | - !CmnUtils.isMatch(aryExclCols, tbName.toUpperCase(), colName[l].toUpperCase()) | |
403 | + !CmnUtils.isMatch(exclColsArray, tbName.toUpperCase(), colName[l].toUpperCase()) | |
337 | 404 | ) |
338 | 405 | ){ |
339 | 406 | CmnUtils.debugPrint("対象カラム=" + colName[l].toUpperCase()); |
@@ -398,9 +465,9 @@ public class RapideLoader{ | ||
398 | 465 | } |
399 | 466 | } else { |
400 | 467 | if(isQuotation){ |
401 | - colData = CmnUtils.split(strLine,"\"" + sprtr + "\""); | |
468 | + colData = CmnUtils.split(strLine,"\"" + delimiter + "\""); | |
402 | 469 | } else { |
403 | - colData = CmnUtils.split(strLine,sprtr); | |
470 | + colData = CmnUtils.split(strLine,delimiter); | |
404 | 471 | } |
405 | 472 | if(colData.length == fl_col_count){ |
406 | 473 | if(!strMltLine.equals("")){ |
@@ -424,11 +491,11 @@ public class RapideLoader{ | ||
424 | 491 | strMltLine += strLine; |
425 | 492 | isContinue = true; |
426 | 493 | } else { |
427 | - strMltLine += inColLnSprtr + strLine; | |
494 | + strMltLine += inColLineSeparator + strLine; | |
428 | 495 | if(isQuotation){ |
429 | - colData = CmnUtils.split(strMltLine,"\"" + sprtr + "\""); | |
496 | + colData = CmnUtils.split(strMltLine,"\"" + delimiter + "\""); | |
430 | 497 | } else { |
431 | - colData = CmnUtils.split(strMltLine,sprtr); | |
498 | + colData = CmnUtils.split(strMltLine,delimiter); | |
432 | 499 | } |
433 | 500 | if(colData.length == fl_col_count){ |
434 | 501 | isContinue = false; |
@@ -465,33 +532,33 @@ public class RapideLoader{ | ||
465 | 532 | if (CmnUtils.isColString(colTypeName[tb_col_seq[j]])){ |
466 | 533 | if(isMask){ |
467 | 534 | if( |
468 | - (isInclMaskCols && | |
469 | - !isExclMaskCols && | |
470 | - CmnUtils.isMatch(aryInclMaskCols,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) | |
535 | + (isInclColsMask && | |
536 | + !isExclColsMask && | |
537 | + CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) | |
471 | 538 | ) || |
472 | - (isInclMaskCols && | |
473 | - isExclMaskCols && | |
474 | - CmnUtils.isMatch(aryInclMaskCols,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) && | |
475 | - !CmnUtils.isMatch(aryExclMaskCols,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase()) | |
539 | + (isInclColsMask && | |
540 | + isExclColsMask && | |
541 | + CmnUtils.isMatch(inclColsMaskArray,tbName.toUpperCase(), colName[tb_col_seq[j]].toUpperCase()) && | |
542 | + !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase()) | |
476 | 543 | ) || |
477 | - (!isInclMaskCols && | |
478 | - isExclMaskCols && | |
479 | - !CmnUtils.isMatch(aryExclMaskCols,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase()) | |
544 | + (!isInclColsMask && | |
545 | + isExclColsMask && | |
546 | + !CmnUtils.isMatch(exclColsMaskArray,tbName.toUpperCase(),colName[tb_col_seq[j]].toUpperCase()) | |
480 | 547 | ) |
481 | 548 | ){ |
482 | 549 | StringBuffer sb = new StringBuffer(); |
483 | 550 | for(int l=0;l<colData[fl_col_seq[j]].length();l++){ |
484 | - if((maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) && | |
551 | + if((maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALT]) && | |
485 | 552 | (l % 2) == 1) || |
486 | - (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) && | |
553 | + (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_EDGE]) && | |
487 | 554 | !(l == 0 || j == colData[fl_col_seq[j]].length() - 1) || |
488 | - (maskPtn.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL])) | |
555 | + (maskPattern.toUpperCase().equals(MASK_PTN[MASK_PTN_ALL])) | |
489 | 556 | ) |
490 | 557 | ){ |
491 | 558 | if(CmnUtils.isHankaku(colData[fl_col_seq[j]].charAt(l))){ |
492 | - sb.append(hankakuMask); | |
559 | + sb.append(singleByteMaskChar); | |
493 | 560 | } else { |
494 | - sb.append(zenkakuMask); | |
561 | + sb.append(doubleByteMaskChar); | |
495 | 562 | } |
496 | 563 | } else { |
497 | 564 | sb.append(colData[fl_col_seq[j]].charAt(l)); |
@@ -34,78 +34,87 @@ public class RapideUnloader{ | ||
34 | 34 | private String user = null; |
35 | 35 | private String pass = null; |
36 | 36 | private String url = null; |
37 | - private String sql_table_list; | |
37 | + private String sql_table_key_list; | |
38 | 38 | private static final int DB_TYPE_ORACLE = 0; |
39 | 39 | private static final int DB_TYPE_SQLSERVER = 1; |
40 | 40 | private static final int DB_TYPE_DB2 = 2; |
41 | 41 | private static final int DB_TYPE_MYSQL = 3; |
42 | 42 | private static final int DB_TYPE_POSTGRESQL = 4; |
43 | 43 | private static final int DB_TYPE_UNKNOWN = -1; |
44 | - private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"}; | |
45 | 44 | private static final int MASK_PTN_ALL = 0; |
46 | 45 | private static final int MASK_PTN_ALT = 1; |
47 | 46 | private static final int MASK_PTN_EDGE = 2; |
48 | - private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"}; | |
49 | - private static final int USER = 0; | |
50 | - private static final int PASS = 1; | |
51 | - private static final int URL = 2; | |
52 | - private static final int DRIVER = 3; | |
53 | - private static final int OUTPUT = 4; | |
54 | - private static final int INPUT = 5; | |
55 | - private static final int LINESEP = 6; | |
56 | - private static final int INLINESEP = 7; | |
57 | - private static final int FILENCODE = 8; | |
58 | - private static final int NULLMARK = 9; | |
59 | - private static final int DELIMITER = 10; | |
60 | - private static final int TBLSQL = 11; | |
61 | - private static final int TBLKEYSQL = 12; | |
62 | - private static final int ORDER = 13; | |
63 | - private static final int QUOTATION = 14; | |
64 | - private static final int BATCOUNT = 15; | |
65 | - private static final int INCLTAB = 16; | |
66 | - private static final int EXCLTAB = 17; | |
67 | - private static final int INCLCOL = 18; | |
68 | - private static final int EXCLCOL = 19; | |
69 | - private static final int INCLCOLMASK = 20; | |
70 | - private static final int EXCLCOLMASK = 21; | |
71 | - private static final int SBYTEMASKCHR = 22; | |
72 | - private static final int DBYTEMASKCHR = 23; | |
73 | - private static final int MASKPTN = 24; | |
74 | - private static final int PROPFILE = 25; | |
75 | - private static final String [] PROP_KEY = { | |
76 | - "us", | |
77 | - "pw", | |
78 | - "url", | |
79 | - "dr", | |
80 | - "out", | |
81 | - "in", | |
82 | - "ls", | |
83 | - "ils", | |
84 | - "fe", | |
85 | - "nm", | |
86 | - "dm", | |
87 | - "ts", | |
88 | - "tks", | |
89 | - "od", | |
90 | - "qt", | |
91 | - "bc", | |
92 | - "it", | |
93 | - "et", | |
94 | - "ic", | |
95 | - "ec", | |
96 | - "icm", | |
97 | - "ecm", | |
98 | - "smc", | |
99 | - "dmc", | |
100 | - "mp", | |
101 | - "pf" | |
102 | - }; | |
47 | + private static final int D_USER = 0; | |
48 | + private static final int D_PASS = 1; | |
49 | + private static final int D_URL = 2; | |
50 | + private static final int D_DRIVER = 3; | |
51 | + private static final int D_OUTPUT = 4; | |
52 | + private static final int D_INPUT = 5; | |
53 | + private static final int D_LINESEP = 6; | |
54 | + private static final int D_INLINESEP = 7; | |
55 | + private static final int D_FILENCODE = 8; | |
56 | + private static final int D_NULLMARK = 9; | |
57 | + private static final int D_DELIMITER = 10; | |
58 | + private static final int D_TBLSQL = 11; | |
59 | + private static final int D_TBLKEYSQL = 12; | |
60 | + private static final int D_ORDER = 13; | |
61 | + private static final int D_QUOTATION = 14; | |
62 | + private static final int D_BATCOUNT = 15; | |
63 | + private static final int D_INCLTAB = 16; | |
64 | + private static final int D_EXCLTAB = 17; | |
65 | + private static final int D_INCLCOL = 18; | |
66 | + private static final int D_EXCLCOL = 19; | |
67 | + private static final int D_INCLCOLMASK = 20; | |
68 | + private static final int D_EXCLCOLMASK = 21; | |
69 | + private static final int D_SBYTEMASKCHR = 22; | |
70 | + private static final int D_DBYTEMASKCHR = 23; | |
71 | + private static final int D_MASKPTN = 24; | |
72 | + private static final int D_PROPFILE = 25; | |
103 | 73 | private static final int KEYS = 26; |
74 | + private static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "DB2", "MYSQL", "POSTGRESQL"}; | |
75 | + private static final String [] MASK_PTN = {"ALL", "ALT", "EDGE"}; | |
76 | + private static final String [] PROP_KEY = { "us","pw","url","dr","out","in","ls","ils","fe","nm", | |
77 | + "dm","ts","tks","od","qt","bc","it","et","ic","ec", | |
78 | + "icm","ecm","smc","dmc","mp","pf"}; | |
79 | + private static final String DEFAULT_FOLDER = "output"; | |
80 | + private static final String DEFAULT_PROP_FILE = "RapideLoader.properties"; | |
81 | + | |
82 | + private String nullMark = ""; | |
83 | + private boolean isOrder = false; | |
84 | + private boolean isQuotation = true; | |
85 | + private boolean isInclTables = false; | |
86 | + private boolean isExclTables = false; | |
87 | + private boolean isInclCols = false; | |
88 | + private boolean isExclCols = false; | |
89 | + private boolean isMask = false; | |
90 | + private boolean isInclColsMask = false; | |
91 | + private boolean isExclColsMask = false; | |
92 | + private String delimiter = "\t"; | |
93 | + private String lineSeparator = System.getProperty("line.separator"); | |
94 | + private String inColLineSeparator = System.getProperty("line.separator"); | |
95 | + private String outFolder = null; | |
96 | + private String inFolder = null; | |
97 | + private String inclTables = null; | |
98 | + private String exclTables = null; | |
99 | + private String inclCols = null; | |
100 | + private String exclCols = null; | |
101 | + private String inclMaskCols = null; | |
102 | + private String exclMaskCols = null; | |
103 | + private String [] inclTablesArray = null; | |
104 | + private String [] exclTablesArray = null; | |
105 | + private String [] inclColsArray = null; | |
106 | + private String [] exclColsArray = null; | |
107 | + private String [] inclColsMaskArray = null; | |
108 | + private String [] exclColsMaskArray = null; | |
109 | + private char singleByteMaskChar = '*'; | |
110 | + private char doubleByteMaskChar = '\u25A0'; | |
111 | + private String maskPattern = "ALT"; | |
112 | + private String fileEncoding = System.getProperty("file.encoding"); | |
113 | + | |
104 | 114 | private String [] prop_val = new String[KEYS]; |
105 | 115 | |
106 | - private String propFile = "RapideLoader.properties"; | |
107 | 116 | |
108 | - private static String [] arySql_table_list = { | |
117 | + private static String [] sql_table_key_list_array = { | |
109 | 118 | "select " |
110 | 119 | + "a.table_name," |
111 | 120 | + "d.column_name " |
@@ -162,7 +171,7 @@ public class RapideUnloader{ | ||
162 | 171 | Properties prop = null; |
163 | 172 | try { |
164 | 173 | prop = new Properties(); |
165 | - br = new BufferedReader(new InputStreamReader(new FileInputStream(_propFile), "UTF-8")); | |
174 | + br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(_propFile), "UTF-8")); | |
166 | 175 | prop.load(br); |
167 | 176 | for(int i=0;i<KEYS;i++){ |
168 | 177 | prop_val[i] = prop.getProperty(database + "." +PROP_KEY[i]); |
@@ -208,41 +217,13 @@ public class RapideUnloader{ | ||
208 | 217 | int tb_count = 0; |
209 | 218 | int tb_col_count = 0; |
210 | 219 | |
211 | - boolean isOrder = false; | |
212 | - boolean isQuotation = true; | |
213 | - boolean isInclTables = false; | |
214 | - boolean isExclTables = false; | |
215 | - boolean isInclCols = false; | |
216 | - boolean isExclCols = false; | |
217 | - boolean isMask = false; | |
218 | - boolean isInclMaskCols = false; | |
219 | - boolean isExclMaskCols = false; | |
220 | - String dlmtr = "\t"; | |
221 | - String lnSprtr = System.getProperty("line.separator"); | |
222 | - String defaultFldr = "output"; | |
223 | - String outFldr = null; | |
224 | - String inclTables = null; | |
225 | - String exclTables = null; | |
226 | - String inclCols = null; | |
227 | - String exclCols = null; | |
228 | - String inclMaskCols = null; | |
229 | - String exclMaskCols = null; | |
230 | - String [] aryInclTables = null; | |
231 | - String [] aryExclTables = null; | |
232 | - String [] aryInclMaskCols = null; | |
233 | - String [] aryExclMaskCols = null; | |
234 | - String [] aryInclCols = null; | |
235 | - String [] aryExclCols = null; | |
236 | - char SingleByteChr = '*'; | |
237 | - char DoubleByteChr = '*'; | |
238 | - String maskPtn = "ALT"; | |
239 | - String fileEncoding = System.getProperty("file.encoding"); | |
220 | + | |
240 | 221 | |
241 | 222 | if(database != null){ |
242 | - if(System.getProperty("pf") != null){ | |
243 | - getProperties(System.getProperty("pf")); | |
223 | + if(!CmnUtils.isEmpty(prop_val[D_PROPFILE])){ | |
224 | + getProperties(System.getProperty(prop_val[D_PROPFILE])); | |
244 | 225 | } else { |
245 | - getProperties(propFile); | |
226 | + getProperties(DEFAULT_PROP_FILE); | |
246 | 227 | } |
247 | 228 | } |
248 | 229 |
@@ -251,38 +232,38 @@ public class RapideUnloader{ | ||
251 | 232 | CmnUtils.debugPrint(PROP_KEY[i] + "=" + prop_val[i]); |
252 | 233 | } |
253 | 234 | |
254 | - if(!CmnUtils.isEmpty(prop_val[USER]))user = prop_val[USER]; | |
255 | - if(!CmnUtils.isEmpty(prop_val[PASS]))pass = prop_val[PASS]; | |
256 | - if(!CmnUtils.isEmpty(prop_val[URL]))url = prop_val[URL]; | |
257 | - if(!CmnUtils.isEmpty(prop_val[DRIVER]))driver = prop_val[DRIVER]; | |
258 | - if(!CmnUtils.isEmpty(prop_val[ORDER]) && prop_val[ORDER].toUpperCase().equals("Y"))isOrder = true; | |
259 | - if(!CmnUtils.isEmpty(prop_val[QUOTATION]) && prop_val[QUOTATION].toUpperCase().equals("N"))isQuotation = false; | |
260 | - if(!CmnUtils.isEmpty(prop_val[INCLTAB]))isInclTables = true; | |
261 | - if(!CmnUtils.isEmpty(prop_val[EXCLTAB]))isExclTables = true; | |
262 | - if(!CmnUtils.isEmpty(prop_val[INCLCOL]))isInclCols = true; | |
263 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOL]))isExclCols = true; | |
264 | - if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))isInclMaskCols = true; | |
265 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))isExclMaskCols = true; | |
266 | - if(isInclMaskCols || isExclMaskCols)isMask = true; | |
267 | - if(!CmnUtils.isEmpty(prop_val[DELIMITER]))dlmtr = CmnUtils.getDelimiter(prop_val[DELIMITER]); | |
268 | - if(!CmnUtils.isEmpty(prop_val[LINESEP]))lnSprtr = CmnUtils.getLineSeparator(prop_val[LINESEP]); | |
269 | - if(!CmnUtils.isEmpty(prop_val[OUTPUT]))outFldr = prop_val[OUTPUT]; | |
270 | - if(!CmnUtils.isEmpty(prop_val[INCLTAB]))inclTables = prop_val[INCLTAB].toUpperCase(); | |
271 | - if(!CmnUtils.isEmpty(prop_val[EXCLTAB]))exclTables = prop_val[EXCLTAB].toUpperCase(); | |
272 | - if(!CmnUtils.isEmpty(prop_val[INCLCOL]))inclCols = prop_val[INCLCOL].toUpperCase(); | |
273 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOL]))exclCols = prop_val[EXCLCOL].toUpperCase(); | |
274 | - if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))inclMaskCols = prop_val[INCLCOLMASK].toUpperCase(); | |
275 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))exclMaskCols = prop_val[EXCLCOLMASK].toUpperCase(); | |
276 | - if(!CmnUtils.isEmpty(prop_val[INCLTAB]))aryInclTables = CmnUtils.splitCsv(prop_val[INCLTAB].toUpperCase()); | |
277 | - if(!CmnUtils.isEmpty(prop_val[EXCLTAB]))aryExclTables = CmnUtils.splitCsv(prop_val[EXCLTAB].toUpperCase()); | |
278 | - if(!CmnUtils.isEmpty(prop_val[INCLCOL]))aryInclCols = CmnUtils.splitCsv(prop_val[INCLCOL].toUpperCase()); | |
279 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOL]))aryExclCols = CmnUtils.splitCsv(prop_val[EXCLCOL].toUpperCase()); | |
280 | - if(!CmnUtils.isEmpty(prop_val[INCLCOLMASK]))aryInclMaskCols = CmnUtils.splitCsv(prop_val[INCLCOLMASK].toUpperCase()); | |
281 | - if(!CmnUtils.isEmpty(prop_val[EXCLCOLMASK]))aryExclMaskCols = CmnUtils.splitCsv(prop_val[EXCLCOLMASK].toUpperCase()); | |
282 | - if(!CmnUtils.isEmpty(prop_val[SBYTEMASKCHR]))SingleByteChr = prop_val[SBYTEMASKCHR].charAt(0); | |
283 | - if(!CmnUtils.isEmpty(prop_val[DBYTEMASKCHR]))DoubleByteChr = prop_val[DBYTEMASKCHR].charAt(0); | |
284 | - if(!CmnUtils.isEmpty(prop_val[MASKPTN]))maskPtn = prop_val[MASKPTN]; | |
285 | - if(!CmnUtils.isEmpty(prop_val[FILENCODE]))fileEncoding = prop_val[FILENCODE]; | |
235 | + if(!CmnUtils.isEmpty(prop_val[D_USER]))user = prop_val[D_USER]; | |
236 | + if(!CmnUtils.isEmpty(prop_val[D_PASS]))pass = prop_val[D_PASS]; | |
237 | + if(!CmnUtils.isEmpty(prop_val[D_URL]))url = prop_val[D_URL]; | |
238 | + if(!CmnUtils.isEmpty(prop_val[D_DRIVER]))driver = prop_val[D_DRIVER]; | |
239 | + if(!CmnUtils.isEmpty(prop_val[D_ORDER]) && prop_val[D_ORDER].toUpperCase().equals("Y"))isOrder = true; | |
240 | + if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]) && prop_val[D_QUOTATION].toUpperCase().equals("N"))isQuotation = false; | |
241 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))isInclTables = true; | |
242 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))isExclTables = true; | |
243 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))isInclCols = true; | |
244 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))isExclCols = true; | |
245 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))isInclColsMask = true; | |
246 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))isExclColsMask = true; | |
247 | + if(isInclColsMask || isExclColsMask)isMask = true; | |
248 | + if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))delimiter = CmnUtils.getDelimiter(prop_val[D_DELIMITER]); | |
249 | + if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))lineSeparator = CmnUtils.getLineSeparator(prop_val[D_LINESEP]); | |
250 | + if(!CmnUtils.isEmpty(prop_val[D_OUTPUT]))outFolder = prop_val[D_OUTPUT]; | |
251 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTables = prop_val[D_INCLTAB].toUpperCase(); | |
252 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTables = prop_val[D_EXCLTAB].toUpperCase(); | |
253 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclCols = prop_val[D_INCLCOL].toUpperCase(); | |
254 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclCols = prop_val[D_EXCLCOL].toUpperCase(); | |
255 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclMaskCols = prop_val[D_INCLCOLMASK].toUpperCase(); | |
256 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclMaskCols = prop_val[D_EXCLCOLMASK].toUpperCase(); | |
257 | + if(!CmnUtils.isEmpty(prop_val[D_INCLTAB]))inclTablesArray = CmnUtils.splitCsv(prop_val[D_INCLTAB].toUpperCase()); | |
258 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLTAB]))exclTablesArray = CmnUtils.splitCsv(prop_val[D_EXCLTAB].toUpperCase()); | |
259 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOL]))inclColsArray = CmnUtils.splitCsv(prop_val[D_INCLCOL].toUpperCase()); | |
260 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOL]))exclColsArray = CmnUtils.splitCsv(prop_val[D_EXCLCOL].toUpperCase()); | |
261 | + if(!CmnUtils.isEmpty(prop_val[D_INCLCOLMASK]))inclColsMaskArray = CmnUtils.splitCsv(prop_val[D_INCLCOLMASK].toUpperCase()); | |
262 | + if(!CmnUtils.isEmpty(prop_val[D_EXCLCOLMASK]))exclColsMaskArray = CmnUtils.splitCsv(prop_val[D_EXCLCOLMASK].toUpperCase()); | |
263 | + if(!CmnUtils.isEmpty(prop_val[D_SBYTEMASKCHR]))singleByteMaskChar = prop_val[D_SBYTEMASKCHR].charAt(0); | |
264 | + if(!CmnUtils.isEmpty(prop_val[D_DBYTEMASKCHR]))doubleByteMaskChar = prop_val[D_DBYTEMASKCHR].charAt(0); | |
265 | + if(!CmnUtils.isEmpty(prop_val[D_MASKPTN]))maskPattern = prop_val[D_MASKPTN]; | |
266 | + if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))fileEncoding = prop_val[D_FILENCODE]; | |
286 | 267 | |
287 | 268 | if(user == null){ |
288 | 269 | throw new Exception("user is null"); |
@@ -302,10 +283,10 @@ public class RapideUnloader{ | ||
302 | 283 | } |
303 | 284 | |
304 | 285 | if (dbType != DB_TYPE_UNKNOWN){ |
305 | - if(!CmnUtils.isEmpty(prop_val[TBLKEYSQL])){ | |
306 | - sql_table_list = prop_val[TBLKEYSQL]; | |
286 | + if(!CmnUtils.isEmpty(prop_val[D_TBLKEYSQL])){ | |
287 | + sql_table_key_list = prop_val[D_TBLKEYSQL]; | |
307 | 288 | } else { |
308 | - sql_table_list = arySql_table_list[dbType]; | |
289 | + sql_table_key_list = sql_table_key_list_array[dbType]; | |
309 | 290 | } |
310 | 291 | } else { |
311 | 292 | throw new Exception("dbtype unknown"); |
@@ -316,39 +297,39 @@ public class RapideUnloader{ | ||
316 | 297 | try { |
317 | 298 | conn = dao.connect(); |
318 | 299 | |
319 | - if(outFldr != null){ | |
320 | - fldr = new File(outFldr); | |
300 | + if(outFolder != null){ | |
301 | + fldr = new File(outFolder); | |
321 | 302 | } else { |
322 | 303 | if(database != null){ |
323 | - fldr = new File(defaultFldr + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm()); | |
304 | + fldr = new File(DEFAULT_FOLDER + "/" + database.toUpperCase() + "_" + CmnUtils.getYmdhm()); | |
324 | 305 | } else { |
325 | - fldr = new File(defaultFldr + "/" + DB_TYPE_NAME[dbType].toUpperCase() + "_" + CmnUtils.getYmdhm()); | |
306 | + fldr = new File(DEFAULT_FOLDER + "/" + DB_TYPE_NAME[dbType].toUpperCase() + "_" + CmnUtils.getYmdhm()); | |
326 | 307 | } |
327 | 308 | fldr.mkdir(); |
328 | 309 | } |
329 | 310 | |
330 | 311 | if(database!=null)CmnUtils.infoPrint("-->Database='" + database.toUpperCase() + "'"); |
331 | 312 | CmnUtils.infoPrint("-->Output='" + fldr + "'"); |
332 | - if(!CmnUtils.isEmpty(prop_val[DELIMITER]))CmnUtils.infoPrint("-->Delimiter='" + prop_val[DELIMITER] + "'"); | |
333 | - if(!CmnUtils.isEmpty(prop_val[LINESEP]))CmnUtils.infoPrint("-->LineSeparator='" + prop_val[LINESEP] + "'"); | |
334 | - if(!CmnUtils.isEmpty(prop_val[FILENCODE]))CmnUtils.infoPrint("-->FileEncoding='" + prop_val[FILENCODE] + "'"); | |
335 | - if(!CmnUtils.isEmpty(prop_val[QUOTATION]))CmnUtils.infoPrint("-->Quotation=" + CmnUtils.getYesNo(isQuotation)); | |
336 | - if(!CmnUtils.isEmpty(prop_val[ORDER]))CmnUtils.infoPrint("-->Sort=" + CmnUtils.getYesNo(isOrder)); | |
313 | + if(!CmnUtils.isEmpty(prop_val[D_DELIMITER]))CmnUtils.infoPrint("-->Delimiter='" + prop_val[D_DELIMITER] + "'"); | |
314 | + if(!CmnUtils.isEmpty(prop_val[D_LINESEP]))CmnUtils.infoPrint("-->LineSeparator='" + prop_val[D_LINESEP] + "'"); | |
315 | + if(!CmnUtils.isEmpty(prop_val[D_FILENCODE]))CmnUtils.infoPrint("-->FileEncoding='" + prop_val[D_FILENCODE] + "'"); | |
316 | + if(!CmnUtils.isEmpty(prop_val[D_QUOTATION]))CmnUtils.infoPrint("-->Quotation=" + CmnUtils.getYesNo(isQuotation)); | |
317 | + if(!CmnUtils.isEmpty(prop_val[D_ORDER]))CmnUtils.infoPrint("-->Sort=" + CmnUtils.getYesNo(isOrder)); | |
337 | 318 | if(isInclTables)CmnUtils.infoPrint("-->Include Tables='" + inclTables.toUpperCase() + "'"); |
338 | 319 | if(isExclTables)CmnUtils.infoPrint("-->Exclude Tables='" + exclTables.toUpperCase() + "'"); |
339 | 320 | if(isInclCols)CmnUtils.infoPrint("-->Include Columns='" + inclCols.toUpperCase() + "'"); |
340 | 321 | if(isExclCols)CmnUtils.infoPrint("-->Exclude Columns='" + exclCols.toUpperCase() + "'"); |
341 | 322 | if(isMask){ |
342 | 323 | CmnUtils.infoPrint("-->Masking=" + CmnUtils.getYesNo(isMask)); |
343 | - CmnUtils.infoPrint("-->Masking Pattern=" + maskPtn.toUpperCase()); | |
344 | - if(isInclMaskCols)CmnUtils.infoPrint("-->Masking Columns='" + inclMaskCols.toUpperCase() + "'"); | |
345 | - if(isExclMaskCols)CmnUtils.infoPrint("-->Exclude Masking Columns='" + exclMaskCols.toUpperCase() + "'"); | |
346 | - CmnUtils.infoPrint("-->Single Byte Mask Char='" + SingleByteChr + "'"); | |
347 | - CmnUtils.infoPrint("-->Double Byte Mask Char='" + DoubleByteChr + "'"); | |
324 | + CmnUtils.infoPrint("-->Masking Pattern=" + maskPattern.toUpperCase()); | |
325 | + if(isInclColsMask)CmnUtils.infoPrint("-->Masking Columns='" + inclMaskCols.toUpperCase() + "'"); | |
326 | + if(isExclColsMask)CmnUtils.infoPrint("-->Exclude Masking Columns='" + exclMaskCols.toUpperCase() + "'"); | |
327 | + CmnUtils.infoPrint("-->Single Byte Mask Char='" + singleByteMaskChar + "'"); | |
328 | + CmnUtils.infoPrint("-->Double Byte Mask Char='" + doubleByteMaskChar + "'"); | |
348 | 329 | } |
349 | 330 | CmnUtils.infoPrint("Start DataUnload ---------------------------------------------"); |
350 | 331 | |
351 | - dao.select(sql_table_list); | |
332 | + dao.select(sql_table_key_list); | |
352 | 333 | alData = dao.getArrayList(); |
353 | 334 | tb_count = dao.getColumnCount(); |
354 | 335 | orders = 0; |
@@ -357,16 +338,16 @@ public class RapideUnloader{ | ||
357 | 338 | for(int i=0;i<alData.size();i++){ |
358 | 339 | if ((i+1) % tb_count == 1){ |
359 | 340 | if ((i + 2 <alData.size()) && (!alData.get(i).equals(alData.get(i+2))) || (i + 2 == alData.size())) { |
360 | - if(isInclTables && !CmnUtils.isMatch(aryInclTables,alData.get(i).toUpperCase())){ | |
341 | + if(isInclTables && !CmnUtils.isMatch(inclTablesArray,alData.get(i).toUpperCase())){ | |
361 | 342 | CmnUtils.debugPrint("inclTables=" + inclTables); |
362 | - CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(aryInclTables,alData.get(i).toUpperCase())); | |
343 | + CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(inclTablesArray,alData.get(i).toUpperCase())); | |
363 | 344 | orders = 0; |
364 | 345 | order_columns = ""; |
365 | 346 | continue; |
366 | 347 | } |
367 | - if(isExclTables && CmnUtils.isMatch(aryExclTables,alData.get(i).toUpperCase())){ | |
348 | + if(isExclTables && CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase())){ | |
368 | 349 | CmnUtils.debugPrint("exclTables=" + exclTables); |
369 | - CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(aryExclTables,alData.get(i).toUpperCase())); | |
350 | + CmnUtils.debugPrint("table=" + alData.get(i) + "," +CmnUtils.isMatch(exclTablesArray,alData.get(i).toUpperCase())); | |
370 | 351 | orders = 0; |
371 | 352 | order_columns = ""; |
372 | 353 | continue; |
@@ -403,18 +384,18 @@ public class RapideUnloader{ | ||
403 | 384 | if(CmnUtils.isColString(alColTypeName.get(j))){ |
404 | 385 | if(isMask){ |
405 | 386 | if( |
406 | - (isInclMaskCols && | |
407 | - !isExclMaskCols && | |
408 | - CmnUtils.isMatch(aryInclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
387 | + (isInclColsMask && | |
388 | + !isExclColsMask && | |
389 | + CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
409 | 390 | ) || |
410 | - (isInclMaskCols && | |
411 | - isExclMaskCols && | |
412 | - CmnUtils.isMatch(aryInclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) && | |
413 | - !CmnUtils.isMatch(aryExclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
391 | + (isInclColsMask && | |
392 | + isExclColsMask && | |
393 | + CmnUtils.isMatch(inclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) && | |
394 | + !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
414 | 395 | ) || |
415 | - (!isInclMaskCols && | |
416 | - isExclMaskCols && | |
417 | - !CmnUtils.isMatch(aryExclMaskCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
396 | + (!isInclColsMask && | |
397 | + isExclColsMask && | |
398 | + !CmnUtils.isMatch(exclColsMaskArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
418 | 399 | ) |
419 | 400 | ){ |
420 | 401 | CmnUtils.debugPrint("Mask Column=" + alColName.get(j).toUpperCase()); |
@@ -432,16 +413,16 @@ public class RapideUnloader{ | ||
432 | 413 | if( |
433 | 414 | (isInclCols && |
434 | 415 | !isExclCols && |
435 | - CmnUtils.isMatch(aryInclCols,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) | |
416 | + CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) | |
436 | 417 | ) || |
437 | 418 | (isInclCols && |
438 | 419 | isExclCols && |
439 | - CmnUtils.isMatch(aryInclCols,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) && | |
440 | - !CmnUtils.isMatch(aryExclCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
420 | + CmnUtils.isMatch(inclColsArray,alData.get(i).toUpperCase(), alColName.get(j).toUpperCase()) && | |
421 | + !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
441 | 422 | ) || |
442 | 423 | (!isInclCols && |
443 | 424 | isExclCols && |
444 | - !CmnUtils.isMatch(aryExclCols,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
425 | + !CmnUtils.isMatch(exclColsArray,alData.get(i).toUpperCase(),alColName.get(j).toUpperCase()) | |
445 | 426 | ) |
446 | 427 | ){ |
447 | 428 | CmnUtils.debugPrint("column=" + alColName.get(j).toUpperCase()); |
@@ -489,29 +470,29 @@ public class RapideUnloader{ | ||
489 | 470 | } |
490 | 471 | if (firstCol == lastCol){ |
491 | 472 | if(isQuotation){ |
492 | - pw.print("\"" + lnSprtr); | |
473 | + pw.print("\"" + lineSeparator); | |
493 | 474 | } else { |
494 | - pw.print("" + lnSprtr); | |
475 | + pw.print("" + lineSeparator); | |
495 | 476 | } |
496 | 477 | } else { |
497 | 478 | if (j==lastCol){ |
498 | 479 | if(isQuotation){ |
499 | - pw.print("\"" + lnSprtr); | |
480 | + pw.print("\"" + lineSeparator); | |
500 | 481 | } else { |
501 | - pw.print("" + lnSprtr); | |
482 | + pw.print("" + lineSeparator); | |
502 | 483 | } |
503 | 484 | } else { |
504 | 485 | if(colIncl[j]){ |
505 | 486 | if(isQuotation){ |
506 | - pw.print("\"" + dlmtr + "\""); | |
487 | + pw.print("\"" + delimiter + "\""); | |
507 | 488 | } else { |
508 | - pw.print(dlmtr); | |
489 | + pw.print(delimiter); | |
509 | 490 | } |
510 | 491 | } |
511 | 492 | } |
512 | 493 | } |
513 | 494 | } |
514 | - dao.getRecordToPrint(pw,dlmtr,isQuotation,isMask,firstCol,lastCol); | |
495 | + dao.getRecordToPrint(pw,firstCol,lastCol); | |
515 | 496 | dao.closeRecordSet(); |
516 | 497 | pw.close(); |
517 | 498 | pw = null; |