001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.hayabusa.taglib;
017
018 import org.opengion.hayabusa.common.HybsSystem;
019 import org.opengion.hayabusa.common.HybsSystemException;
020 import org.opengion.hayabusa.resource.ResourceManager;
021 import org.opengion.hayabusa.resource.GUIInfo;
022 import org.opengion.hayabusa.db.DBColumn;
023 import org.opengion.fukurou.db.Transaction;
024 import org.opengion.fukurou.db.TransactionReal;
025 import org.opengion.fukurou.util.FileUtil;
026 import org.opengion.fukurou.util.ErrorMessage;
027 import org.opengion.fukurou.util.StringUtil;
028 import org.opengion.fukurou.util.Closer ;
029 import org.opengion.fukurou.model.Formatter;
030 import org.opengion.fukurou.model.ArrayDataModel;
031
032 import static org.opengion.fukurou.util.StringUtil.nval ;
033
034 import java.sql.Connection;
035 import java.sql.PreparedStatement;
036 import java.sql.SQLException;
037
038 import java.io.File;
039 import java.io.BufferedReader;
040 import java.io.IOException;
041
042 /**
043 * æŒ?®šã?ファイルを直接ãƒ??タベã?スã«ç™»éŒ²ã™ã‚‹ãƒ??タ入力タグã§ã™ã?
044 *
045 * 通常㮠readTable ãªã©ã¯ã€DBTableModelオブジェクトを介ã—ã¦å…¨ä»¶ãƒ¡ãƒ¢ãƒªã«
046 * ãƒãƒ¼ãƒ‰ã—ã¦ã‹ã‚‰è¡¨ç¤ºã•ã›ã‚‹ç‚ºã€å¤§é‡ãƒ‡ãƒ¼ã‚¿å‡¦ç?Œã§ãã¾ã›ã‚“ã€?
047 * ã“ã?ã‚¿ã‚°ã§ã¯ã€ç›´æŽ¥ãƒ•ァイルをèªã¿å–りãªãŒã‚‰ãƒ??タベã?ス登録ã™ã‚‹ã®ã§
048 * 大é‡ãƒ‡ãƒ¼ã‚¿ã‚’ãƒãƒ?ƒçš?«ç™»éŒ²ã™ã‚‹å ´åˆã«ä½¿ç”¨ã—ã¾ã™ã?
049 *
050 * èªã¿å–るファイルã¯ã€å?é (ã¾ãŸã?実データãŒç¾ã‚Œã‚‹ã¾ã§ã«) #NAME 行ãŒå¿?¦ã§ã™ã?
051 * ã“れã¯ã€ãƒ•ァイルãƒ??ã‚¿ã®ã‚«ãƒ©ãƒ?を指定ã—ã¦ã?¾ã™ã?ã¾ãŸã?columns 属æ?を使用ã™ã‚Œã°ã€?
052 * ファイルã®#NAME 行より優先ã—ã¦(ã¤ã¾ã‚Šå˜åœ¨ã—ã¦ã?ªãã¦ã‚‚良ã?ãƒ??ã‚¿ã®ã‚«ãƒ©ãƒ?ã‚?
053 * æŒ?®šã™ã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã?
054 * ã“ã?#NAME 行ã?ã€ãƒ•ァイルã®ã‚»ãƒ‘レータã¨ç„¡é–¢ä¿‚ã«å¿?šã‚¿ãƒ–区åˆ?‚Šã§ç”¨æ„ã•れã¦ã?¾ã™ã?
055 * ã‚¿ã‚°ã®BODY部ã«ã€å®Ÿè¡Œã™ã‚‹SQLæ–?‚’記述ã—ã¾ã™ã?
056 * ã“ã?SQLæ–??ã€?
057 * INSERT INTO GE41 (CLM,NAME_JA,SYSTEM_ID,FGJ,DYSET)
058 * VALUES ([CLM],[NAME_JA],[SYSTEM_ID],'1','{@USER.YMDH}')
059 * ã¨ã€ã„ã?„Ÿã˜ã§ã€ãƒ•ァイルã‹ã‚‰èªã¿è¾¼ã‚“ã 値ã¯ã€[カラãƒ?]ã«å‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¾ã™ã?
060 * ã‚‚ã¡ã‚ã‚“ã€??常ã®å›ºå®šå?(FGJã«'1'ã‚’ã‚»ãƒ?ƒˆ)ã‚??リクエスト変数(DYSETã®{@USER.YMDH})
061 * ãªã©ã‚‚使用ã§ãã¾ã™ã?
062 *
063 * ※ ã“ã?ã‚¿ã‚°ã¯ã€Transaction ã‚¿ã‚°ã®å¯¾è±¡ã§ã™ã?
064 *
065 * @og.formSample
066 * â—å½¢å¼ï¼?lt;og:directTableInsert filename="[?¥?¥?¥]" ?¥?¥?¥ >INSERT INTO ?¥?¥?¥ </og:directTableInsert >
067 * â—body?šã‚ã‚?EVAL_BODY_BUFFERED:BODYを評価ã—ã?{@XXXX} ã‚’è§£æžã—ã¾ã?
068 *
069 * â—Tag定義??
070 * <og:directTableInsert
071 * fileURL ã€TAG】èªã¿å–りå…?ƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåã‚’æŒ?®šã—ã¾ã?(åˆæœŸå€¤:FILE_URL[=filetemp/])
072 * filename ã€TAG】ファイルを作æ?ã™ã‚‹ã¨ãã?ファイルåã‚’ã‚»ãƒ?ƒˆã—ã¾ã?(åˆæœŸå€¤:FILE_FILENAME[=file.xls])
073 * encode ã€TAG】ファイルを作æ?ã™ã‚‹ã¨ãã?ファイルエンコーãƒ?‚£ãƒ³ã‚°åã‚’ã‚»ãƒ?ƒˆã—ã¾ã?(åˆæœŸå€¤:FILE_ENCODE[=UnicodeLittle])
074 * separator ã€TAG】å¯å¤‰é•·ãƒ•ァイルを作æ?ã™ã‚‹ã¨ãã?é ?›®åŒºåˆ?‚Šæ–?—ã‚’ã‚»ãƒ?ƒˆã—ã¾ã?åˆæœŸå€¤:ã‚¿ãƒ?
075 * displayMsg ã€TAG】query ã®çµæžœã‚’ç”»é¢ä¸Šã«è¡¨ç¤ºã™ã‚‹ãƒ¡ãƒ?‚»ãƒ¼ã‚¸IDを指定ã—ã¾ã?åˆæœŸå€¤:MSG0040[ã€?»¶ç™»éŒ²ã—ã¾ã—ãŸ])
076 * columns ã€TAGã€?NAME 属æ?ã®ä»£ã‚りã¨ãªã‚‹ãƒ•ァイルã®ã‚«ãƒ©ãƒ?ã‚?CSVå½¢å¼ã§æŒ?®šã—ã¾ã?
077 * commitBatch ã€TAG】指定数毎ã«ã‚³ãƒŸãƒƒãƒˆã‚’発行ã—ã¾ã?åˆæœŸå€¤:0 終äº?¾ã§ã‚³ãƒŸãƒƒãƒˆã—ã¾ã›ã‚“)
078 * useColumnAdjust ã€TAG】カラãƒ?¤‰æ›(DBType変æ›)を行ã†ã‹ã©ã?‹ã‚’è¨å®šã—ã¾ã?åˆæœŸå€¤:false)
079 * useColumnCheck ã€TAG】カラãƒ?ƒã‚§ãƒ?‚¯(DBTypeãƒã‚§ãƒ?‚¯)を行ã†ã‹ã©ã?‹ã‚’è¨å®šã—ã¾ã?åˆæœŸå€¤:false)
080 * nullCheck ã€TAG】NULL ãƒã‚§ãƒ?‚¯ã™ã¹ãカラãƒ??をカンマ区åˆ?‚Š(CSVå½¢å¼?ã§æŒ?®šã—ã¾ã?
081 * dbid ã€TAGã€?通常ã¯ä½¿ã?¾ã›ã‚“)検索時ã?DB接続IDを指定ã—ã¾ã?åˆæœŸå€¤:DEFAULT)
082 * skipRowCount ã€TAG】データã®èªã¿é£›ã?ã—ä»¶æ•°ã‚’è¨å®šã—ã¾ã?åˆæœŸå€¤:0)
083 * stopZero ã€TAGã€‘æ¤œç´¢çµæžœãŒï¼ä»¶ã®ã¨ãå?ç?‚’続行ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false[続行ã™ã‚‹])
084 * debug ã€TAG】デãƒãƒƒã‚°æƒ??ã‚’å?力ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)
085 * > ... Body ...
086 * </og:directTableInsert>
087 *
088 * â—使用ä¾?
089 * <og:directTableInsert
090 * dbid = "ORCL" 接続データベã?スID(åˆæœŸå€¤:DEFAULT)
091 * separator = "," ファイルã®åŒºåˆ?‚Šæ–??åˆæœŸå€¤:ã‚¿ãƒ?
092 * fileURL = "{@USER.ID}" èªã¿å–りå…?ƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªå?
093 * filename = "{@filename}" èªã¿å–りå…?ƒ•ァイルå?
094 * encode = "Shift_JIS" èªã¿å–りå…?ƒ•ァイルエンコードå
095 * displayMsg = "MSG0040" 登録完äº?¾Œã?メãƒ?‚»ãƒ¼ã‚¸
096 * columns = "CLM,NAME_JA,LABEL_NAME,KBSAKU,SYSTEM_ID,LANG"
097 * #NAME ã®ä»£ã‚りã«ä½¿ç”¨ã™ã‚‹ã‚«ãƒ©ãƒ??å?
098 * commitBatch = "100" ã“ã?ä»¶æ•°ãšã¤ã‚³ãƒŸãƒƒãƒˆã‚’発è¡?åˆæœŸå€¤:無制é™?
099 * useColumnCheck = "true" カラãƒ?ƒã‚§ãƒ?‚¯ã‚’行ã†ã‹ã©ã?‹(åˆæœŸå€¤:false)
100 * useColumnAdjust = "true" カラãƒ?¤‰æ›ã‚’行ã†ã‹ã©ã?‹(åˆæœŸå€¤:false)
101 * nullCheck = "CLM,SYSTEM_ID" NULLãƒã‚§ãƒ?‚¯ã‚’実行ã—ã¾ã™ã?
102 * >
103 * INSERT INTO GE41
104 * (CLM,NAME_JA,LABEL_NAME,KBSAKU,SYSTEM_ID,LANG,
105 * FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
106 * VALUES
107 * ([CLM],[NAME_JA],[LABEL_NAME],[KBSAKU],[SYSTEM_ID],[LANG],
108 * '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
109 * </og:directTableInsert >
110 *
111 * @og.group ファイル入�
112 *
113 * @version 4.0
114 * @author Kazuhiko Hasegawa
115 * @since JDK5.0,
116 */
117 public class DirectTableInsertTag extends CommonTagSupport {
118 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */
119 private static final String VERSION = "5.7.6.2 (2014/05/16)" ;
120
121 private static final long serialVersionUID = 576220140516L ;
122
123 private static final String TAB_SEPARATOR = "\t" ;
124
125 // 4.0.0.0 (2007/10/10) dbid ã®åˆæœŸå€¤ã‚’ã?"DEFAULT" ã‹ã‚‰ null ã«å¤‰æ›´
126 private String dbid = null;
127 private String separator = TAB_SEPARATOR; // é ?›®åŒºåˆ?‚Šæ–??
128 private String fileURL = HybsSystem.sys( "FILE_URL" ); // 4.0.0 (2005/01/31)
129 private String filename = HybsSystem.sys( "FILE_FILENAME" ); // ファイルå?
130 private String encode = HybsSystem.sys( "FILE_ENCODE" ); // ファイルエンコーãƒ?‚£ãƒ³ã‚° "JISAutoDetect" ,"JIS", "EUC_JP", "MS932", "SJIS" , "Windows-31J" , "Shift_JIS"
131 private String displayMsg = "MSG0040"; // ã€?»¶ç™»éŒ²ã—ã¾ã—ãŸã€?
132 private String[] columns = null;
133 private String[] clmKeys = null; // SQLæ–??[カラãƒ?]é…å?
134 private String sql = null;
135 private int commitBatch = 0; // コミットã™ã‚‹ã¾ã¨ã‚ä»¶æ•°
136 private boolean useColumnCheck = false; // 3.6.0.2 (2004/10/04)
137 private boolean useColumnAdjust = false; // 3.6.0.2 (2004/10/04)
138 private String[] nullCheck = null; // 3.8.0.2 (2005/06/30) nullãƒã‚§ãƒ?‚¯ç¢ºèª?
139 private long dyStart = 0; // 実行時間測定用ã®DIVè¦ç´?‚’出力ã—ã¾ã™ã?
140 private int skipRowCount= 0; // 5.5.7.1 (2012/10/01)
141 private boolean stopZero = false; // 5.7.6.2 (2014/05/16) stopZero属æ?追åŠ?
142
143 /**
144 * Taglibã®é–‹å§‹ã‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doStartTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
145 *
146 * @return 後続å?ç??æŒ?¤º( EVAL_BODY_BUFFERED )
147 */
148 @Override
149 public int doStartTag() {
150 dyStart = System.currentTimeMillis(); // 時間測定用
151 return EVAL_BODY_BUFFERED ; // Body を評価ã™ã‚‹ã€? extends BodyTagSupport æ™?
152 }
153
154 /**
155 * Taglibã®ã‚¿ã‚°æœ¬ä½“を処ç?™ã‚?doAfterBody() ã‚?オーãƒã?ライドã—ã¾ã™ã?
156 *
157 * @og.rev 3.6.0.2 (2004/10/04) SQLæ–?? [カラãƒ? 対応ã¨ãƒ‘ã?サー機è?追åŠ?
158 * @og.rev 3.8.6.3 (2006/11/30) SQL æ–??å‰å¾Œã?スペã?スをå–り除ãã¾ã™ã?
159 *
160 * @return 後続å?ç??æŒ?¤º(SKIP_BODY)
161 */
162 @Override
163 public int doAfterBody() {
164 sql = getBodyString();
165 if( sql == null || sql.length() == 0 ) {
166 String errMsg = "BODY 部ã®ç™»éŒ²ç”¨ Insert/Updateæ–??ã€å¿??ã§ã™ã?";
167 throw new HybsSystemException( errMsg );
168 }
169
170 return SKIP_BODY ; // Body を評価ã—ãªã?
171 }
172
173 /**
174 * Taglibã®çµ‚äº?‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doEndTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
175 *
176 * @og.rev 4.0.0.0 (2007/10/18) メãƒ?‚»ãƒ¼ã‚¸ãƒªã‚½ãƒ¼ã‚¹çµ±å? getResource().getMessage â‡?getResource().getLabel )
177 * @og.rev 5.7.0.3 (2013/11/22) BufferedReaderã®closeã‚’createå†?§è¡Œã†ã‚ˆã†ã«å¤‰æ›´
178 * @og.rev 5.7.6.2 (2014/05/16) stopZero属æ?ã€DB.COUNT ã‚ãƒ¼ã§æ¤œç´¢ä»¶æ•°ã‚’リクエストã«ã‚»ãƒ?ƒˆã™ã‚‹ã€?
179 *
180 * @return 後続å?ç??æŒ?¤º
181 */
182 @Override
183 public int doEndTag() {
184 debugPrint(); // 4.0.0 (2005/02/28)
185
186 BufferedReader pw = getBufferedReader();
187 int executeCount = create( pw );
188
189 // 実行件数ã®è¡¨ç¤º
190 // 4.0.0 (2005/11/30) 出力é?ã®å¤‰æ›´ã€‚ä¸?•ªæœ??ã«å‡ºåŠ›ã—ã¾ã™ã?
191 if( displayMsg != null && displayMsg.length() > 0 ) {
192 String status = executeCount + getResource().getLabel( displayMsg ) ;
193 jspPrint( status + HybsSystem.BR );
194 }
195
196 // 5.7.6.2 (2014/05/16) æ¤œç´¢çµæžœã®ä»¶æ•°ã‚’ã?"DB.COUNT" ã‚ーã§ãƒªã‚¯ã‚¨ã‚¹ãƒˆã«ã‚»ãƒ?ƒˆã™ã‚‹ã€?
197 setRequestAttribute( "DB.COUNT" , String.valueOf( executeCount ) );
198
199 // 5.7.6.2 (2014/05/16) ä»¶æ•°?ä»¶ã‹ã¤ stopZero = true
200 if( executeCount == 0 && stopZero ) { return SKIP_PAGE; }
201
202 // 時間測定用㮠DIV è¦ç´?‚’出åŠ?
203 long dyTime = System.currentTimeMillis()-dyStart;
204 jspPrint( "<div id=\"queryTime\" value=\"" + (dyTime) + "\"></div>" ); // 3.5.6.3 (2004/07/12)
205
206 // 4.0.0 (2005/01/31) ã‚»ã‚ュリãƒ?‚£ãƒã‚§ãƒ?‚¯(ãƒ??タアクセス件数登録)
207 GUIInfo guiInfo = (GUIInfo)getSessionAttribute( HybsSystem.GUIINFO_KEY );
208 if( guiInfo != null ) { guiInfo.addWriteCount( executeCount,dyTime,sql ); }
209
210 return EVAL_PAGE ;
211 }
212
213 /**
214 * タグリブオブジェクトをリリースã—ã¾ã™ã?
215 * ã‚ャãƒ?‚·ãƒ¥ã•れã¦å†åˆ©ç”¨ã•れるã?ã§ã€ãƒ•ィールドã?åˆæœŸè¨å®šã‚’行ã„ã¾ã™ã?
216 *
217 * @og.rev 3.6.0.2 (2004/10/04) useColumnCheck,useColumnAdjust 属æ?追åŠ?
218 * @og.rev 3.8.0.2 (2005/06/30) nullCheck 属æ?追åŠ?
219 * @og.rev 4.0.0.0 (2007/10/10) dbid ã®åˆæœŸå€¤ã‚’ã?"DEFAULT" ã‹ã‚‰ null ã«å¤‰æ›´
220 * @og.rev 5.5.7.1 (2012/10/05) skipRowCount追�
221 * @og.rev 5.7.6.2 (2014/05/16) stopZero属æ?追åŠ?
222 */
223 @Override
224 protected void release2() {
225 super.release2();
226 dbid = null;
227 separator = TAB_SEPARATOR; // é ?›®åŒºåˆ?‚Šæ–??
228 fileURL = HybsSystem.sys( "FILE_URL" ); // 4.0.0 (2005/01/31)
229 filename = HybsSystem.sys( "FILE_FILENAME" ); // ファイルå?
230 encode = HybsSystem.sys( "FILE_ENCODE" ); // ファイルエンコーãƒ?‚£ãƒ³ã‚° "JISAutoDetect" ,"JIS", "EUC_JP", "MS932", "SJIS" , "Windows-31J" , "Shift_JIS"
231 displayMsg = "MSG0040"; // ã€?»¶ç™»éŒ²ã—ã¾ã—ãŸã€?
232 columns = null; // 3.5.4.5 (2004/01/23)
233 useColumnCheck = false; // 3.6.0.2 (2004/10/04)
234 useColumnAdjust = false; // 3.6.0.2 (2004/10/04)
235 nullCheck = null; // 3.8.0.2 (2005/06/30)
236 skipRowCount = 0; // 5.5.7.1 (2012/10/05)
237 stopZero = false; // 5.7.6.2 (2014/05/16) stopZero属æ?追åŠ?
238 }
239
240 /**
241 * BufferedReader よりèªã¿è¾¼ã¿ã€ãƒ‡ãƒ¼ã‚¿ãƒ™ã?ã‚¹ã«æ›¸ãè¾¼ã¿ã¾ã™ã?
242 *
243 * @og.rev 3.6.0.2 (2004/10/04) カラãƒ?‚ªãƒ–ジェクトã?DBType属æ?ã®æ•´åˆæ?ãƒã‚§ãƒ?‚¯
244 * @og.rev 3.8.0.2 (2005/06/30) nullãƒã‚§ãƒ?‚¯ç¢ºèª?
245 * @og.rev 3.8.5.1 (2006/05/08) å–è¾¼ãƒ??ã‚¿ã?name 列より少ãªã??åˆã?対応を追åŠ?
246 * @og.rev 3.8.7.0 (2006/12/15) アクセスãƒã‚°å–å¾—ã?為,ApplicationInfoオブジェクトをè¨å®?
247 * @og.rev 4.0.0.0 (2005/01/31) CheckColumnDataクラス static 化ã?引数ã«ResourceManager追åŠ?
248 * @og.rev 4.0.0.1 (2007/12/03) try ??catch ??finally ã‚’ãã¡ã‚“ã¨è¡Œã†ã€?
249 * @og.rev 5.1.9.0 (2010/08/01) Transaction 対�
250 * @og.rev 5.2.2.0 (2010/11/01)) ""ã§å›²ã‚れã¦ã?‚‹ãƒ??ã‚¿ã«æ”¹è¡ŒãŒå…¥ã£ã¦ã?Ÿå ´åˆã?対å¿?
251 * @og.rev 5.3.7.0 (2011/07/01) TransactionReal ã®å¼•数変更
252 * @og.rev 5.3.8.0 (2011/08/01) pstmt.setObject ã§ã€useParamMetaData ã®åˆ¤å®šã‚’é¿ã‘ã‚‹ãŸã‚ã€pstmt.setString ã§ä»£ç”¨(PostgreSQL対å¿?
253 * @og.rev 5.5.7.1 (2012/10/05) omitFirstLine対�
254 * @og.rev 5.7.0.3 (2013/11/22) BufferedReaderã®close処ç?‚’ã“ã?メソãƒ?ƒ‰å†??finallyã§è¡Œã†
255 *
256 * @param reader BufferedReaderオブジェク�
257 *
258 * @return å–り込ã¿ä»¶æ•°
259 */
260 private int create( final BufferedReader reader ) {
261
262 String[] names = readName( reader ); // ファイルã®ã‚«ãƒ©ãƒ?
263 int nameLen = names.length ; // 3.8.5.1 (2006/05/08) 追�
264
265 ArrayDataModel nmdata = new ArrayDataModel( names );
266 Formatter format = new Formatter( nmdata );
267 format.setFormat( sql.trim() );
268 sql = format.getQueryFormatString();
269 int[] clmNos = format.getClmNos();
270 int clmNosLen = clmNos.length ;
271 clmKeys = format.getClmKeys();
272
273 CheckColumnData checkClass = new CheckColumnData( clmNos,clmKeys,getResource() );
274
275 ArrayDataModel nullData = new ArrayDataModel( names );
276 int[] nullClmNos = nullData.getColumnNos( nullCheck ); // ãƒã‚¤ãƒ³ãƒ‰å¤‰æ•°ã®ã‚¢ãƒ‰ãƒ¬ã‚¹æ±‚ã‚
277
278 // 3.8.0.2 (2005/06/30) nullãƒã‚§ãƒ?‚¯ç¢ºèª?
279 int nullClmNosLen = nullClmNos.length ;
280
281 int executeCount = 0;
282 int commitCount = 0;
283 char sep = separator.charAt(0);
284 boolean errFlag = true;
285 Transaction tran = null; // 5.1.9.0 (2010/08/01) Transaction 対�
286 PreparedStatement pstmt = null ;
287 String[] data = null ;
288 int skip = skipRowCount; // 5.5.7.1 (2012/10/05)
289 try {
290 // 5.1.9.0 (2010/08/01) Transaction 対�
291 TransactionTag tranTag = (TransactionTag)findAncestorWithClass( this,TransactionTag.class );
292 if( tranTag == null ) {
293 tran = new TransactionReal( getApplicationInfo() ); // 5.3.7.0 (2011/07/01) 引数変更
294 }
295 else {
296 tran = tranTag.getTransaction();
297 }
298
299 Connection conn = tran.getConnection( dbid ); // 5.1.9.0 (2010/08/01) Transaction 対�
300 pstmt = conn.prepareStatement( sql );
301 String line ;
302 while((line = reader.readLine()) != null) {
303 if( line.length() == 0 || line.charAt( 0 ) == '#' ) { continue; }
304 else if( skip > 0 ){ skip--; continue;} // 5.5.7.1 (2012/10/05)
305 else {
306 // 5.2.2.0 (2010/11/01) ""ã§å›²ã‚れã¦ã?‚‹ãƒ??ã‚¿ã«æ”¹è¡ŒãŒå…¥ã£ã¦ã?Ÿå ´åˆã?対å¿?
307 int quotCount = StringUtil.countChar( line, '"' );
308 if( quotCount % 2 != 0 ) {
309 String addLine = null;
310 StringBuilder buf = new StringBuilder( line );
311 while(quotCount % 2 != 0 && (addLine = reader.readLine()) != null) {
312 if( line.length() == 0 || line.charAt( 0 ) == '#' ) { continue; }
313 buf.append( HybsSystem.CR ).append( addLine );
314 quotCount += StringUtil.countChar( addLine, '"' );
315 }
316 line = buf.toString();
317 }
318
319 // 3.8.5.1 (2006/05/08) å–è¾¼ãƒ??ã‚¿ã?name 列より少ãªã??åˆã?対応を追åŠ?
320 data = StringUtil.csv2Array( line , sep , nameLen );
321
322 // 3.6.0.2 (2004/10/04) カラãƒ?¤‰æ›
323 if( useColumnAdjust ) {
324 data = checkClass.adjustData( data );
325 }
326
327 // 3.6.0.2 (2004/10/04) カラãƒ?ƒã‚§ãƒ?‚¯
328 if( useColumnCheck ) {
329 ErrorMessage errMsg = checkClass.checkData( executeCount, data );
330 if( !errMsg.isOK() ) {
331 tran.rollback(); // 5.1.9.0 (2010/08/01) Transaction 対�
332 jspPrint( TaglibUtil.makeHTMLErrorTable( errMsg,getResource() ) );
333 return commitCount;
334 }
335 }
336
337 // 3.8.0.2 (2005/06/30) nullãƒã‚§ãƒ?‚¯ç¢ºèª?
338 if( nullClmNosLen > 0 ) {
339 ErrorMessage errMsg = new ErrorMessage( "Null Check Columns Error!" );
340
341 for( int i=0; i<nullClmNosLen; i++ ) {
342 int clm = nullClmNos[i];
343 if( data[clm] == null || data[clm].length() == 0 ) {
344 String label = getResource().getLabel( nullCheck[i] );
345 // ERR0012 : æŒ?®šã?ãƒ??ã‚¿ãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã›ã‚“ã€?NULLエラー)。key={0}
346 errMsg.addMessage( executeCount+1,ErrorMessage.NG,"ERR0012",label );
347 }
348 }
349 if( !errMsg.isOK() ) {
350 tran.rollback(); // 5.1.9.0 (2010/08/01) Transaction 対�
351 jspPrint( TaglibUtil.makeHTMLErrorTable( errMsg,getResource() ) );
352 return commitCount;
353 }
354 }
355
356 for( int i=0; i<clmNosLen; i++ ) {
357 String val = data[clmNos[i]];
358 if( val != null && val.startsWith( "'0" ) ) {
359 val = val.substring( 1 );
360 }
361 pstmt.setString( i+1,val );
362 }
363
364 pstmt.execute();
365 if( commitBatch > 0 && ( executeCount%commitBatch == 0 ) ) {
366 tran.commit(); // 5.1.9.0 (2010/08/01) Transaction 対�
367 commitCount = executeCount;
368 }
369 executeCount++ ;
370 }
371 }
372 tran.commit(); // 5.1.9.0 (2010/08/01) Transaction 対�
373 commitCount = executeCount ;
374 errFlag = false; // エラーã§ã¯ãªã?
375 }
376 catch (IOException ex) {
377 String errMsg = "ファイルèªè¾¼ã¿ã‚¨ãƒ©ãƒ¼[" + reader.toString() + "]"
378 + " 行番å·=[" + executeCount +"]"
379 + " 登録件数=[" + commitCount + "]" ;
380 throw new HybsSystemException( errMsg,ex );
381 }
382 catch (SQLException ex) {
383 String errMsg = "sql=[" + sql + "]" + HybsSystem.CR
384 + "names=[" + StringUtil.array2csv( names ) + "]" + HybsSystem.CR
385 + "vals =[" + StringUtil.array2csv( data ) + "]" + HybsSystem.CR
386 + " 行番å·=[" + executeCount +"]"
387 + " 登録件数=[" + commitCount + "]" + HybsSystem.CR
388 + " errorCode=[" + ex.getErrorCode() + "] State=[" +
389 ex.getSQLState() + "]" + HybsSystem.CR ;
390 throw new HybsSystemException( errMsg,ex );
391 }
392 finally {
393 Closer.stmtClose( pstmt );
394 Closer.ioClose( reader ); // 5.7.0.3 (2013/11/22) finallyã§closeã™ã‚‹ã‚ˆã†ã«å¤‰æ›´
395 if( tran != null ) { // 5.5.2.6 (2012/05/25) findbugs対�
396 tran.close( errFlag ); // 5.1.9.0 (2010/08/01) Transaction 対�
397 }
398 }
399
400 return commitCount;
401 }
402
403 /**
404 * BufferedReader よりã€?NAME 行ã?é ?›®åæƒ…å ±ã‚’èªã¿å–りã¾ã™ã?
405 * ãƒ??タカラãƒ?‚ˆã‚Šå‰ã«ã€??ç›®åæƒ…å ±ã‚’ç¤ºã?"#Name" ãŒå˜åœ¨ã™ã‚‹ä»®å®šã§å–り込ã¿ã¾ã™ã?
406 * ã“ã?行ã?ã€ãƒ•ァイルã®å½¢å¼ã«ç„¡é–¢ä¿‚ã«ã€TAB ã§åŒºåˆ?‚‰ã‚Œã¦ã?¾ã™ã?
407 * #NAME é…å?ã®å…ˆé?(行番å·ã«ã‚ãŸã‚‹å?æ‰?ã¯ã€ROW_NO ã¨ã?†ã‚ーを割り当ã¦ã¾ã™ã?
408 * columns ãŒè¨å®šã•れã¦ã?‚‹å ´åˆã?ã€?NAME 行ã§ã¯ãªãã?columns を優先ã—ã¾ã™ã?
409 *
410 * @og.rev 3.6.0.0 (2004/09/22) #NAME 行ãŒè¦‹ã¤ã‹ã‚‰ãªã??åˆã?ã€ã‚¨ãƒ©ãƒ¼ã¨ã—ã¾ã™ã?
411 * @og.rev 3.6.0.2 (2004/10/04) columns ãŒè¨å®šã•れã¦ã?‚‹å ´åˆã?ã€ãれを返ã—ã¾ã™ã?
412 *
413 * @param reader PrintWriterオブジェク�
414 *
415 * @return カラãƒ?é…å?
416 */
417 private String[] readName( final BufferedReader reader ) {
418 if( columns != null && columns.length > 0 ) {
419 return columns ;
420 }
421
422 try {
423 String line;
424 while((line = reader.readLine()) != null) {
425 if( line.length() == 0 ) { continue; }
426 if( line.charAt(0) == '#' ) {
427 if( line.length() >= 5 &&
428 "#NAME".equalsIgnoreCase( line.substring( 0,5 ) ) ) {
429 String[] rtn = StringUtil.csv2Array( line ,TAB_SEPARATOR.charAt(0) );
430 rtn[0] = "ROW_NO"; // å…ˆé?カラãƒ?«ã‚«ãƒ©ãƒ?を与ãˆã‚‹ã?
431 return rtn ;
432 }
433 else { continue; }
434 }
435 else {
436 String errMsg = "#NAME ãŒè¦‹ã¤ã‹ã‚‹å‰ã«ãƒ??ã‚¿ãŒè¦‹ã¤ã‹ã‚Šã¾ã—ãŸã€? + HybsSystem.CR
437 + " LINE=" + line; // 5.1.8.0 (2010/07/01) errMsg ä¿®æ£
438 throw new HybsSystemException( errMsg );
439 }
440 }
441 }
442 catch (IOException ex) {
443 String errMsg = "ファイルèªè¾¼ã¿ã‚¨ãƒ©ãƒ¼[" + reader.toString() + "]" ;
444 throw new HybsSystemException( errMsg,ex );
445 }
446
447 String errMsg = "#NAME ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸã€?;
448 throw new HybsSystemException( errMsg );
449 }
450
451 /**
452 * BufferedReader ã‚’å–å¾—ã—ã¾ã™ã?
453 *
454 * ã“ã“ã§ã¯ã€ä¸?ˆ¬çš?ªãƒ•ァイル出力をè€??ã—㟠BufferedReader を作æ?ã—ã¾ã™ã?
455 *
456 * @return æŒ?®šã?èªã¿å–り用BufferedReaderオブジェクãƒ?
457 */
458 private BufferedReader getBufferedReader() {
459 if( filename == null ) {
460 String errMsg = "ファイルåãŒã‚»ãƒ?ƒˆã•れã¦ã?¾ã›ã‚“ã€?;
461 throw new HybsSystemException( errMsg );
462 }
463 String directory = HybsSystem.url2dir( fileURL );
464 File file = new File( StringUtil.urlAppend( directory,filename ) );
465
466 BufferedReader out = FileUtil.getBufferedReader( file,encode );
467
468 return out ;
469 }
470
471 /**
472 * ã€TAGã€?通常ã¯ä½¿ã?¾ã›ã‚“)検索時ã?DB接続IDを指定ã—ã¾ã?åˆæœŸå€¤:DEFAULT)ã€?
473 *
474 * @og.tag
475 * 検索時ã?DB接続IDを指定ã—ã¾ã™ã?åˆæœŸå€¤ã¯ã€DEFAULT ã§ã™ã?
476 *
477 * @param id ãƒ??タベã?ス接続ID
478 */
479 public void setDbid( final String id ) {
480 dbid = nval( getRequestParameter( id ),dbid );
481 }
482
483 /**
484 * ã€TAG】å¯å¤‰é•·ãƒ•ァイルを作æ?ã™ã‚‹ã¨ãã?é ?›®åŒºåˆ?‚Šæ–?—ã‚’ã‚»ãƒ?ƒˆã—ã¾ã?åˆæœŸå€¤:ã‚¿ãƒ?ã€?
485 *
486 * @og.tag å¯å¤‰é•·ãƒ•ァイルを作æ?ã™ã‚‹ã¨ãã?é ?›®åŒºåˆ?‚Šæ–?—ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
487 *
488 * @param separator é ?›®åŒºåˆ?‚Šæ–??
489 */
490 public void setSeparator( final String separator ) {
491 this.separator = nval( getRequestParameter( separator ),this.separator );
492 }
493
494 /**
495 * ã€TAG】èªã¿å–りå…?ƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåã‚’æŒ?®šã—ã¾ã?
496 * (åˆæœŸå€¤:FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])ã€?
497 *
498 * @og.tag
499 * ã“ã?属æ?ã§æŒ?®šã•れるãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªã‚ˆã‚Šã€ãƒ•ァイルをèªã¿å–りã¾ã™ã?
500 * æŒ?®šæ–¹æ³•ã?ã€??常㮠fileURL 属æ?ã¨åŒæ§˜ã«ã€å?é ãŒã?'/' (UNIX) ã¾ãŸã?ã€?¼’æ–‡å—ç›®ãŒã?
501 * ":" (Windows)ã®å ´åˆã?ã€æŒ‡å®šã?URLãã?ã¾ã¾ã®ãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã€ãã?§ãªã??åˆã?ã€?
502 * fileURL = "{@USER.ID}" ã¨æŒ?®šã™ã‚‹ã¨ã€FILE_URL 属æ?ã§æŒ?®šã?フォルãƒ??下ã«ã€?
503 * ã•らã«ã€å„個人ID別ã®ãƒ•ォルãƒ??下よりã?èªã¿å–りã¾ã™ã?
504 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])ã€?
505 *
506 * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソãƒ?ƒ‰ã®åˆ©ç”¨
507 * @og.rev 4.0.0.0 (2007/11/20) æŒ?®šã•れãŸãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªåã?æœ?¾ŒãŒ"\"or"/"ã§çµ‚ã‚ã£ã¦ã?ªã??åˆã«ã€?/"ã‚’ä»˜åŠ ã™ã‚‹ã€?
508 *
509 * @param url ファイルURL
510 * @see org.opengion.hayabusa.common.SystemData#FILE_URL
511 */
512 public void setFileURL( final String url ) {
513 String furl = nval( getRequestParameter( url ),null );
514 if( furl != null ) {
515 char ch = furl.charAt( furl.length()-1 );
516 if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
517 fileURL = StringUtil.urlAppend( fileURL,furl );
518 }
519 }
520
521 /**
522 * ã€TAG】ファイルを作æ?ã™ã‚‹ã¨ãã?ファイルåã‚’ã‚»ãƒ?ƒˆã—ã¾ã?
523 * (åˆæœŸå€¤:FILE_FILENAME[={@og.value org.opengion.hayabusa.common.SystemData#FILE_FILENAME}])ã€?
524 *
525 * @og.tag
526 * ファイルを作æ?ã™ã‚‹ã¨ãã?ファイルåã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
527 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®FILE_FILENAME[={@og.value org.opengion.hayabusa.common.SystemData#FILE_FILENAME}])ã€?
528 *
529 * @param filename ファイルå?
530 * @see org.opengion.hayabusa.common.SystemData#FILE_FILENAME
531 */
532 public void setFilename( final String filename ) {
533 this.filename = nval( getRequestParameter( filename ),this.filename );
534 }
535
536 /**
537 * ã€TAG】ファイルを作æ?ã™ã‚‹ã¨ãã?ファイルエンコーãƒ?‚£ãƒ³ã‚°åã‚’ã‚»ãƒ?ƒˆã—ã¾ã?
538 * (åˆæœŸå€¤:FILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
539 *
540 * @og.tag
541 * åˆæœŸå€¤ã¯ã€ã‚·ã‚¹ãƒ?ƒ パラメータ ã® FILE_ENCODE 属æ?ã§ã€è¨å®šã—ã¦ã?¾ã™ã?
542 * Shift_JIS,MS932,Windows-31J,UTF-8,ISO-8859-1,UnicodeLittle?¥?¥?¥
543 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®FILE_ENCODE[={@og.value org.opengion.hayabusa.common.SystemData#FILE_ENCODE}])ã€?
544 *
545 * @param enc ファイルエンコーãƒ?‚£ãƒ³ã‚°å?
546 * @see <a href="http://www.iana.org/assignments/character-sets">IANA Charset Registry</a>
547 * @see org.opengion.hayabusa.common.SystemData#FILE_ENCODE
548 */
549 public void setEncode( final String enc ) {
550 encode = nval( getRequestParameter( enc ),encode );
551 }
552
553 /**
554 * ã€TAG】query ã®çµæžœã‚’ç”»é¢ä¸Šã«è¡¨ç¤ºã™ã‚‹ãƒ¡ãƒ?‚»ãƒ¼ã‚¸IDを指定ã—ã¾ã?åˆæœŸå€¤:MSG0040[ã€?»¶ç™»éŒ²ã—ã¾ã—ãŸ])ã€?
555 *
556 * @og.tag
557 * ã“ã“ã§ã¯ã€æ¤œç´¢çµæžœã®ä»¶æ•°ã‚?™»éŒ²ã•れãŸä»¶æ•°ã‚’ã¾ãšå?力ã—ã€?
558 * ãã?次ã«ã€ã“ã“ã§æŒ?®šã—ãŸãƒ¡ãƒ?‚»ãƒ¼ã‚¸ã‚’リソースã‹ã‚‰å–å¾—ã—ã¦
559 * 表示ã—ã¾ã™ã?
560 * 表示ã•ã›ãŸããªã??åˆã?, displayMsg = "" ã‚’ã‚»ãƒ?ƒˆã—ã¦ãã ã•ã„ã€?
561 * åˆæœŸå€¤ã¯ã€æ¤œç´¢ä»¶æ•°ã‚’表示ã—ã¾ã™ã?
562 * ※ ã“ã?属æ?ã«ã¯ã€ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°({@XXXX})ã¯ä½¿ç”¨ã§ãã¾ã›ã‚“ã€?
563 *
564 * @param id ãƒ?‚£ã‚¹ãƒ—レイã«è¡¨ç¤ºã•ã›ã‚‹ãƒ¡ãƒ?‚»ãƒ¼ã‚¸ ID
565 */
566 public void setDisplayMsg( final String id ) {
567 if( id != null ) { displayMsg = id; }
568 }
569
570 /**
571 * ã€TAGã€?NAME 属æ?ã®ä»£ã‚りã¨ãªã‚‹ãƒ•ァイルã®ã‚«ãƒ©ãƒ?ã‚?CSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
572 *
573 * @og.tag
574 * ãƒ??タファイルã®å…ˆé?行ã«ã€?NAME 行ãŒã‚りã€èªã¿å–ã‚‹ã¹ãファイルã®
575 * カラãƒ?ãŒè¨˜è¿°ã•れã¦ã?¾ã™ã?通常ã¯ã€ã“ã®ã‚«ãƒ©ãƒ?ã‚’å–り込んã§ã€?
576 * å?ƒ‡ãƒ¼ã‚¿åˆ—ã?カラãƒ?‚’æŒ?®šã—ã¾ã™ã?
577 * ã“ã?属æ?ã¯ã€ãƒ•ァイルã«#NAME 行ãŒå˜åœ¨ã—ãªã?他シスãƒ?ƒ ã‹ã‚‰ã®å…¥åŠ›ãƒ•ã‚¡ã‚¤ãƒ«ç?
578 * å ´åˆã«ã€?NAME 属æ?ã®ä»£ã‚りã«ã€ã‚«ãƒ©ãƒ?を外部よりæŒ?®šã—ã¾ã™ã?
579 *
580 * @og.rev 3.8.5.1 (2006/05/08) getCSVParameter ã®ä½¿ç”¨ã‚’䏿¢
581 *
582 * @param clms ファイルã®ã‚«ãƒ©ãƒ?(カンマ区åˆ?‚Šæ–??
583 */
584 public void setColumns( final String clms ) {
585 columns = StringUtil.csv2Array( nval( getRequestParameter( clms ),null ),',' );
586 }
587
588 /**
589 * ã€TAG】指定数毎ã«ã‚³ãƒŸãƒƒãƒˆã‚’発行ã—ã¾ã?åˆæœŸå€¤:0 終äº?¾ã§ã‚³ãƒŸãƒƒãƒˆã—ã¾ã›ã‚“)ã€?
590 *
591 * @og.tag
592 * 通常ã¯ã€å?ã¦ã®å‡¦ç?Œæ£å¸¸ã«çµ‚äº?™ã‚‹ã‹ã€ãªã«ã‚‚ã—ãªã?‹(トランザクション)
593 * を判æ–ã™ã¹ãã§ã€??ä¸ã§ã®ã‚³ãƒŸãƒƒãƒˆã?ã—ã¾ã›ã‚“ã€?
594 * ã—ã‹ã—ã?å ´åˆã«ã‚ˆã£ã¦ã€ä»¶æ•°ãŒç•°å¸¸ã«å¤šã„å ´åˆã‚„ã€å?実行å¯èƒ½ãªå ´åˆã?ã€?
595 * 途ä¸ã§ã‚³ãƒŸãƒƒãƒˆã—ã¦ã€??度ã€å?ç?§ãã‚‹ã‚‚ã?ã?‘ã‚’å?ç?—ã¦ã—ã¾ã?¨ã?†æ–¹æ³•ãŒã‚りã¾ã™ã?
596 * ã¾ãŸã?ãƒãƒ¼ãƒ«ãƒãƒƒã‚¯ã‚¨ãƒªã‚¢ã®é–¢ä¿‚ãªã©ã§ã€ãƒ‡ãƒ¼ã‚¿é‡ãŒå¤šã„å ´åˆã«ã€å?ç?™‚é–“ãŒç•°å¸¸ã«
597 * é•·ããªã‚‹äº‹ãŒã‚ã‚Šã€æŒ‡å®šä»¶æ•°ã”ã¨ã®ã‚³ãƒŸãƒƒãƒˆæ©Ÿè?を用æ„ã—ã¦ã?¾ã™ã?
598 * 0 ã«è¨å®šã™ã‚‹ã¨ã€çµ‚äº?¾ã§ã‚³ãƒŸãƒƒãƒˆã—ã¾ã›ã‚“。å?期å?ã¯ã€? ã§ã™ã?
599 *
600 * @param cmtBat æŒ?®šæ•°æ¯Žã«ã‚³ãƒŸãƒƒãƒˆã‚’発è¡?åˆæœŸå€¤:0)
601 */
602 public void setCommitBatch( final String cmtBat ) {
603 commitBatch = nval( getRequestParameter( cmtBat ),commitBatch );
604 }
605
606 /**
607 * ã€TAG】カラãƒ?ƒã‚§ãƒ?‚¯(DBTypeãƒã‚§ãƒ?‚¯)を行ã†ã‹ã©ã?‹ã‚’è¨å®šã—ã¾ã?åˆæœŸå€¤:false)ã€?
608 *
609 * @og.tag
610 * カラãƒ??æ•´åˆæ?ãƒã‚§ãƒ?‚¯ã‚’行ã†å ´åˆã?ã“ã?属æ?ã‚’è¨å®?true)ã—ã¾ã™ã?
611 * åˆæœŸå€¤ã¯ã€è¡Œã‚ãªã?false)ã§ã™ã?
612 * ãƒã‚§ãƒ?‚¯ã™ã‚‹ã‚«ãƒ©ãƒ??ã€?NAME ã‚?columns ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ?§ã¯ãªãã?
613 * BODY部ã®SQLæ–?§æŒ?®šã•れãŸã‚«ãƒ©ãƒ?( [カラãƒ?] )ã§ã™ã?ã“れã¯ã€ç›´æŽ¥ã€SQLæ–?¸ã«
614 * 記述ã—ã¦ã?‚‹å€¤ã‚??{@XXXX}æ–?—ç‰ã?ã€ãƒã‚§ãƒ?‚¯å‡ºæ¥ãªã?‚ºã§ã™ã?
615 *
616 * @og.rev 3.6.0.2 (2004/10/04) æ–°è¦è¿½åŠ?å–ã‚Šè¾¼ã¿æ™‚å?ãƒã‚§ãƒ?‚¯
617 *
618 * @param flag ãƒã‚§ãƒ?‚¯ã‚’行ã†ã‹ã©ã?‹(true:行ã†/false:行ã‚ãªã?
619 * @see #setUseColumnAdjust( String )
620 */
621 public void setUseColumnCheck( final String flag ) {
622 useColumnCheck = nval( getRequestParameter( flag ),useColumnCheck );
623 }
624
625 /**
626 * ã€TAG】カラãƒ?¤‰æ›(DBType変æ›)を行ã†ã‹ã©ã?‹ã‚’è¨å®šã—ã¾ã?åˆæœŸå€¤:false)ã€?
627 *
628 * @og.tag
629 * カラãƒ??変æ›ã‚’行ã†å ´åˆã?ã“ã?属æ?ã‚’è¨å®?true)ã—ã¾ã™ã?
630 * åˆæœŸå€¤ã¯ã€è¡Œã‚ãªã?false)ã§ã™ã?
631 * 変æ›ã™ã‚‹ã‚«ãƒ©ãƒ??ã€?NAME ã‚?columns ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ?§ã¯ãªãã?
632 * BODY部ã®SQLæ–?§æŒ?®šã•れãŸã‚«ãƒ©ãƒ?[カラãƒ?]ã§ã™ã?ã“れã¯ã€ç›´æŽ¥ã€SQLæ–?¸ã«
633 * 記述ã—ã¦ã?‚‹å€¤ã‚??{@XXXX}æ–?—ç‰ã?ã€å¤‰æ›å‡ºæ¥ãªã?‚ºã§ã™ã?
634 *
635 * @og.rev 3.6.0.2 (2004/10/04) æ–°è¦è¿½åŠ?å–ã‚Šè¾¼ã¿æ™‚変æ›
636 *
637 * @param flag 変æ›ã‚’行ã†ã‹ã©ã?‹(true:行ã†/false:行ã‚ãªã?
638 * @see #setUseColumnCheck( String )
639 */
640 public void setUseColumnAdjust( final String flag ) {
641 useColumnAdjust = nval( getRequestParameter( flag ),useColumnAdjust );
642 }
643
644 /**
645 * ã€TAG】NULL ãƒã‚§ãƒ?‚¯ã™ã¹ãカラãƒ??をカンマ区åˆ?‚Š(CSVå½¢å¼?ã§æŒ?®šã—ã¾ã™ã?
646 *
647 * @og.tag nullCheck="AAA,BBB,CCC,DDD"
648 * åˆ?§£æ–¹æ³•ã?ã€??常ã®ãƒ‘ラメータå–得後ã«ã€CSVåˆ?§£ã—ã¾ã™ã?
649 *
650 * @og.rev 3.8.0.2 (2005/06/30) æ–°è¦è¿½åŠ?
651 * @og.rev 3.8.8.5 (2007/03/09) 通常ã®ãƒ‘ラメータå–得後ã«ã€CSVåˆ?§£ã«æˆ»ã—ã¾ã™ã?
652 *
653 * @param clms カラ�?(CSV形�
654 */
655 public void setNullCheck( final String clms ) {
656 nullCheck = StringUtil.csv2Array( getRequestParameter( clms ) );
657 if( nullCheck.length == 0 ) { nullCheck = null; }
658 }
659
660 /**
661 * ã€TAG】å–ã‚Šè¾¼ã¿æ™‚ã«é™¤å¤–ã™ã‚‹è¡Œã‚’æŒ?®šã—ã¾ã?åˆæœŸå€¤:0)ã€?
662 *
663 * @og.tag
664 * TAB区åˆ?‚Šãƒ?‚ストやEXCELç‰ã?ãƒ??ã‚¿ã®èªã¿å§‹ã‚ã®åˆæœŸå€¤ã‚’指定ã—ã¾ã™ã?
665 * ファイルã®å…ˆé?行ãŒã€?¼è¡Œã¨ã—ã¦ã‚«ã‚¦ãƒ³ãƒˆã—ã¾ã™ã?ã§ã€è¨å®šå?ã¯ã€èªã¿é£›ã?ã?
666 * ä»¶æ•°ã«ãªã‚Šã¾ã™ã?(?‘ã¨æŒ?®šã™ã‚‹ã¨ã€?¼‘ä»¶èªã¿é£›ã?ã—ã??’行目ã‹ã‚‰èªã¿è¾¼ã¿ã¾ã™ã?)
667 * èªã¿é£›ã?ã—ã?ã€ã‚³ãƒ¡ãƒ³ãƒˆè¡Œãªã©ã¯ã€ç„¡è¦–ã—ã¾ã™ã?ã§ã€å®Ÿéš›ã®è¡Œæ•°åˆ?ªã¿é£›ã?ã—ã¾ã™ã?
668 * ?ƒNAME属æ?ã‚??columns 属æ?ã¯ã€æœ‰åйã§ã™ã?
669 *
670 * @og.rev 5.5.7.1 (2012/10/05) æ–°è¦è¿½åŠ?
671 *
672 * @param count å…ˆé?行を無視ã™ã‚‹ã‹ã©ã?‹(true:無視ã™ã‚?false:無視ã—ãªã?
673 */
674 public void setSkipRowCount( final String count ) {
675 skipRowCount = nval( getRequestParameter( count ),skipRowCount );
676 }
677
678 /**
679 * ã€TAGã€‘æ¤œç´¢çµæžœãŒï¼ä»¶ã®ã¨ãå?ç?‚’続行ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false[続行ã™ã‚‹])ã€?
680 *
681 * @og.tag
682 * åˆæœŸå€¤ã¯ã€false(続行ã™ã‚?ã§ã™ã?
683 *
684 * @og.rev 5.7.6.2 (2014/05/16) æ–°è¦è¿½åŠ?
685 *
686 * @param cmd æ¤œç´¢çµæžœãŒï¼ä»¶ã®ã¨ãã?[true:処ç?‚’䏿¢ã™ã‚‹/false:続行ã™ã‚‹]
687 */
688 public void setStopZero( final String cmd ) {
689 stopZero = nval( getRequestParameter( cmd ),stopZero );
690 }
691
692 /**
693 * カラãƒ?¤‰æ›ã€ã‚«ãƒ©ãƒ?ƒã‚§ãƒ?‚¯ã‚’行ã†å†?ƒ¨ã‚¯ãƒ©ã‚¹
694 *
695 * @og.rev 4.0.0.0 (2005/01/31) static クラス化ã?引数ã«ResourceManager追åŠ?
696 * @og.group ファイル入�
697 *
698 * @version 4.0
699 * @author Kazuhiko Hasegawa
700 * @since JDK5.0,
701 */
702 static class CheckColumnData {
703 private final DBColumn[] dbClm ;
704 private final int[] clmChkNo ;
705 private final int len ; // é•·ã•ï¼ã?時ã?ã€ãªã«ã‚‚ã—ãªã??
706 private final ErrorMessage errMsg = new ErrorMessage( "Check Columns Error!" );
707
708 /**
709 * コンストラクター
710 *
711 * @param clmNo カラãƒ?•ªå·é…å?
712 * @param chkClm String[]
713 * @param resource ResourceManager
714 */
715 CheckColumnData( final int[] clmNo, final String[] chkClm,final ResourceManager resource ) {
716 if( clmNo == null || clmNo.length == 0 ||
717 chkClm == null || chkClm.length == 0 ) { // return; } // 何もã—ãªã?
718
719 dbClm = null;
720 clmChkNo = null;
721 len = 0;
722 }
723 else {
724 clmChkNo = clmNo ;
725 len = clmNo.length ;
726 dbClm = new DBColumn[len];
727 for( int i=0; i<len; i++ ) {
728 dbClm[i] = resource.makeDBColumn( chkClm[i] ); // 4.0.0 (2005/01/31)
729 }
730 }
731 }
732
733 /**
734 * 引数ã®ãƒ??ã‚¿ã‚?DBColumn ã§æ£è¦åŒ–(valueSetメソãƒ?ƒ‰çµŒç”±)ã—ã¾ã™ã?
735 *
736 * @param data ?‘行å?ã®ãƒ??ã‚¿é…å?
737 * @return String[]
738 * @see org.opengion.hayabusa.db.DBColumn#valueSet( String )
739 */
740 String[] adjustData( final String[] data ) {
741 if( len == 0 ) { return data; }
742 String[] ajstData = new String[len];
743 for( int i=0; i<len; i++ ) {
744 String val = data[clmChkNo[i]];
745 ajstData[i] = dbClm[i].valueSet( val );
746 }
747 return ajstData ;
748 }
749
750 /**
751 * 引数ã®ãƒ??ã‚¿ã‚?DBColumn ã§æ£è¦åŒ–(valueSetメソãƒ?ƒ‰çµŒç”±)ã—ã¾ã™ã?
752 *
753 * @param row 行番å·
754 * @param data ?‘行å?ã®ãƒ??ã‚¿é…å?
755 * @return ErrorMessage
756 * @see org.opengion.hayabusa.db.DBColumn#valueSet( String )
757 */
758 ErrorMessage checkData( final int row,final String[] data ) {
759 for( int i=0; i<len; i++ ) {
760 String val = data[clmChkNo[i]];
761 errMsg.append( row+1,dbClm[i].valueCheck( val ) );
762 }
763 return errMsg ;
764 }
765 }
766
767 /**
768 * ã“ã?オブジェクトã?æ–?—å?表ç¾ã‚’è¿”ã—ã¾ã™ã?
769 * 基本çš?«ãƒ?ƒãƒ?‚°ç›®çš?«ä½¿ç”¨ã—ã¾ã™ã?
770 *
771 * @return ã“ã?ã‚¯ãƒ©ã‚¹ã®æ–?—å?表ç¾
772 */
773 @Override
774 public String toString() {
775 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
776 .println( "VERSION" ,VERSION )
777 .println( "dbid" ,dbid )
778 .println( "separator" ,separator )
779 .println( "fileURL" ,fileURL )
780 .println( "filename" ,filename )
781 .println( "encode" ,encode )
782 .println( "displayMsg" ,displayMsg )
783 .println( "columns" ,columns )
784 .println( "clmKeys" ,clmKeys )
785 .println( "sql" ,sql )
786 .println( "commitBatch" ,commitBatch )
787 .println( "useColumnCheck" ,useColumnCheck )
788 .println( "useColumnAdjust" ,useColumnAdjust)
789 .println( "nullCheck" ,nullCheck )
790 .println( "dyStart" ,dyStart )
791 .println( "Other..." ,getAttributes().getAttribute() )
792 .fixForm().toString() ;
793 }
794 }