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