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 static org.opengion.fukurou.util.StringUtil.nval;
019    
020    import java.io.IOException;
021    import java.io.ObjectInputStream;
022    import java.io.ObjectOutputStream;
023    import java.util.Locale;
024    
025    import org.opengion.fukurou.db.DBUtil;
026    import org.opengion.fukurou.db.Transaction;
027    import org.opengion.fukurou.db.TransactionReal;
028    import org.opengion.fukurou.util.ErrorMessage;
029    import org.opengion.fukurou.util.StringUtil;
030    import org.opengion.hayabusa.common.HybsSystem;
031    import org.opengion.hayabusa.common.HybsSystemException;
032    import org.opengion.hayabusa.db.DBColumn;
033    import org.opengion.hayabusa.db.DBEditConfig;
034    import org.opengion.hayabusa.db.DBTableModel;
035    import org.opengion.hayabusa.db.Query;
036    import org.opengion.hayabusa.db.QueryFactory;
037    import org.opengion.hayabusa.resource.GUIInfo;
038    
039    /**
040     * ãƒ??タベã?スの検索を行うタグですã?
041     *
042     * こã?タグのå†?®¹に、SQLæ–?‚’記述しますã? whereタグã€?andタグ を使ã�?�¨引数に応じて
043     * 実行されるSQLæ–?�Œ異なりまã�?使用例参照)ã€?
044     * またã?PL/SQLのSPで検索を行うときもこã?タグを使ã�?�¾すã?
045     * SystemData の USE_SQL_INJECTION_CHECK ã�?true かã?quotCheck 属æ?ã�?true の場合ã?ã€?
046     * ?³?±?¬インジェクション対策用のクォーãƒ?‚£ションチェãƒ?‚¯を行いますã?リクエスト引数に
047     * クォーãƒ?‚£ション(')が含まれると、エラーになりますã?
048     * 同様にUSE_XSS_CHECKがtrueかã?xssCheck属æ?がtrueの場合ã?ã€?
049     * クロスサイトススクリプティング(XSS)対策ã?ためless/greater than signのチェãƒ?‚¯を行いますã?
050     *
051     * ※ こã?タグは、Transaction タグの対象ですã?
052     *
053     * @og.formSample
054     * ●形式ï¼?
055     *       ・<og:query command="NEW" >
056     *              SELECTæ–?
057     *         </og:query>
058     *       ・<og:query command="NEW" names="?¥?¥?¥" queryType="JDBCErrMsg" >
059     *              { call PL/SQL(?,?,?,? ) } 
060     *         </og:query>
061     * ●body?šあã‚?
062     *
063     * ●Tag定義??
064     *   <og:query
065     *       queryType          【TAG】Query を発行する為のクラスID(JDBC,JDBCCallable,JDBCErrMsg,JDBCUpdate)を指定します{@og.doc03Link queryType 初期値:JDBC})
066     *       command            【TAG】コマンãƒ?NEW,RENEW)をセãƒ?ƒˆしまã�?PlsqlUpdateTag,UpdateTag の場合ã?、ENTRY)
067     *       scope              【TAG】キャãƒ?‚·ュする場合ã?スコープ[request/page/session/applicaton]を指定しまã�?初期値:session)
068     *       maxRowCount        【TAGã€?通常は使ã�?�¾せん)ãƒ??タのæœ?¤§読み込み件数を指定しまã�?(初期値:DB_MAX_ROW_COUNT[=1000])(0:[無制限])
069     *       skipRowCount       【TAGã€?通常は使ã�?�¾せん)ãƒ??タの読み始めの初期値を指定しまã�?
070     *       displayMsg         【TAG】検索結果を画面上に表示するメãƒ?‚»ージリソースIDを指定しまã�?(初期値:VIEW_DISPLAY_MSG[=])
071     *       overflowMsg        【TAG】検索ãƒ??タが最大検索数をオーバã?した場合に表示するメãƒ?‚»ージリソースIDを指定しまã�?(初期値:MSG0007[検索結果がã?制限行数をè¶?�ˆましたので、残りはカãƒ?ƒˆされました])
072     *       notfoundMsg        【TAG】検索結果がゼロ件の場合に表示するメãƒ?‚»ージリソースIDを指定しまã�?初期値:MSG0077[対象ãƒ??タはありませんでした])
073     *       names              【TAG】PL/SQLを利用する場合ã?引数にセãƒ?ƒˆすべã�?ãƒ??タの名称をCSV形式でè¤?•°æŒ?®šしまã�?
074     *       stopZero           【TAG】検索結果が0件のときå?ç�?‚’続行するかどã�?�‹[true/false]を指定しまã�?初期値:false[続行する])
075     *       tableId            【TAGã€?通常は使ã�?�¾せん)結果のDBTableModelをã?sessionに登録するときã?キーを指定しまã�?
076     *       dbid               【TAGã€?通常は使ã�?�¾せん)Queryオブジェクトを作æ?する時ã?DB接続IDを指定しまã�?
077     *       trace              【TAG】引数の SQL æ–?‚’ EXPLAIN PLAN を[true:行う/それ以å¤?行わない]を指定しまã�?初期値:false)
078     *       checkNames         【TAG】リクエスト変数の正規化を行うカラãƒ?‚’CSV形式でè¤?•°æŒ?®šしまã�?
079     *       modifyType         【TAG】DB検索時ã? モãƒ?‚£ファイタイプをæŒ?®šします[A:追åŠ?C:更新/D:削除]
080     *       quotCheck          【TAG】リクエスト情報の クォーãƒ?‚£ション(') 存在チェãƒ?‚¯を実施するかどã�?�‹[true/false]を設定しまã�?初期値:USE_SQL_INJECTION_CHECK)
081     *       stopError          【TAG】PLSQL/SQL処ç�?‚¨ラーの時に処ç�?‚’中止するかどã�?�‹[true/false]を設定しまã�?初期値:true)
082     *       xssCheck           【TAG】リクエスト情報の HTMLTag開å§?終äº?–‡å­?><) 存在チェãƒ?‚¯を実施するかどã�?�‹[true/false]を設定しまã�?(初期値:USE_XSS_CHECK[=true])
083     *       mainTrans          【TAGã€?通常使ã�?�¾せん)タグで処ç�?�•れる処ç�?�Œメインとなるトランザクション処ç�?�‹どã�?�‹を指定しまã�?初期値:true)
084     *       caseKey            【TAG】このタグ自体を利用するかどã�?�‹の条件キーを指定しまã�?初期値:null)
085     *       caseVal            【TAG】このタグ自体を利用するかどã�?�‹の条件値を指定しまã�?初期値:null)
086     *       useBeforeHtmlTag   【TAGã€?処ç�?™‚é–?queryTime)などのæƒ??出力[true:有効/false:無効]を指定しまã�?初期値:true)
087     *       debug              【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
088     *   >   ... Body ...
089     *   </og:query>
090     *
091     * ●使用ä¾?
092     *     <og:query command="NEW">
093     *             select PN,YOBI,NMEN,HINM from XX01 where PN = '{@PN}' order by PN
094     *     </og:query>
095     *
096     *          ・検索条件がå?力されたæ™?{@PN}がNOT NULLのとã�?
097     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 where PN = 'AAA' order by PN
098     *          ・検索条件がå?力されなかった時({@PN}がNULLのとã�?
099     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 where PN = '' order by PN
100     *
101     *     <og:query command="NEW">
102     *             select PN,YOBI,NMEN,HINM from XX01
103     *         <og:where>
104     *             <og:and value="PN = '{@PN}%'" />
105     *             <og:and value="YOBI like '{@YOBI}%'" />
106     *         </og:where>
107     *             order by PN
108     *     </og:query>
109     *
110     *          ・検索条件がå?力されたæ™?{@PN}がNOT NULLのとã�?
111     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 PN = 'AAA%' and YOBI like 'BBB%' order by PN
112     *          ・検索条件がå?力されなかった時({@PN}がNULLのとã�? WHERE句がなくなるã?
113     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 order by PN
114     *
115     *        注æ„?WhereTagを使ったå?合ã?下ã?ようにはなりませんã€?
116     *            select PN,YOBI,NMEN,HINM from XX01 PN = '' and YOBI like '%' order by PN
117     *
118     *     <og:query command="NEW">
119     *             select PN,YOBI,NMEN,HINM from XX01 where PN="11111"
120     *         <og:where startKey="and">
121     *             <og:and value="YOBI like '{@PN}%'" />
122     *         </og:where>
123     *             order by PN
124     *     </og:query>
125     *
126     *          ・検索条件がå?力されたæ™?{@YOBI}がNOT NULLのとã�?
127     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 PN = '11111' and YOBI like 'BBB%' order by PN
128     *          ・検索条件がå?力されなかった時({@YOBI}がNULLのとã�? WHERE句がなくなるã?
129     *            作æ?されるSQLæ–?�çselect PN,YOBI,NMEN,HINM from XX01 PN = '11111' order by PN
130     *
131     *     <og:query
132     *          command    = "NEW"
133     *          names      = "SYSTEM_ID,LANG,CLM,NAME_JA,LABEL_NAME,KBSAKU,USER.ID"
134     *          checkNames = "CLM,NAME_JA"
135     *          queryType  = "JDBCErrMsg"
136     *          displayMsg = "">
137     *              {call TYPE3B01.TYPE3B01(?,?,?,?)}
138     *     </og:query>
139     *
140     *          ・queryType に JDBCErrMsg を指定して、PL/SQL をコールできますã?
141     *            引数は、names 属æ?をキーにリクエスト変数から読み込みますã?
142     *          ・checkNames にカラãƒ?��を指定すると、columns.valueSet による
143     *            リクエスト変数の正規化を行いますã?
144     *
145     * @og.group ?¤?¢検索
146     * @og.group ?¤?¢登録
147     *
148     * @version  4.0
149     * @author       Kazuhiko Hasegawa
150     * @since    JDK5.0,
151     */
152    public class QueryTag extends CommonTagSupport {
153            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
154            private static final String VERSION = "5.6.5.3 (2013/06/28)" ;
155    
156            private static final long serialVersionUID = 565320130628L ;
157    
158            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 新è¦?{@value} */
159            public static final String CMD_NEW       = "NEW" ;
160            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 再検索 {@value} */
161            public static final String CMD_RENEW = "RENEW" ;
162            /** command 引数に渡す事ã?出来ã‚?コマンãƒ?リスãƒ? */
163            private static final String[] COMMAND_LIST = new String[] { CMD_NEW , CMD_RENEW };
164    
165            /** エラーメãƒ?‚»ージID {@value} */
166            protected static final String errMsgId   = HybsSystem.ERR_MSG_KEY;
167    
168            private   String        queryType       = null;
169            // 4.0.0.0 (2007/10/10) dbid の初期値をã?"DEFAULT" から null に変更
170    //      private   String        dbid            = "DEFAULT";
171            private   String        dbid            = null ;
172            protected transient DBTableModel        table           = null;
173            protected transient ErrorMessage        errMessage      = null;
174            protected String        tableId         = HybsSystem.TBL_MDL_KEY;
175            protected String        command         = CMD_NEW;
176            protected int           skipRowCount = 0;
177            protected int           maxRowCount     = -1;
178            protected String        sql                     = null;
179            protected int           executeCount = -1;                      // 検索/実行件数
180            protected String        names           = null;
181            protected boolean       outMessage      = true;
182            protected int           errCode         = ErrorMessage.OK;
183            protected boolean       quotCheck       = HybsSystem.sysBool( "USE_SQL_INJECTION_CHECK" );      // 4.0.0 (2005/08/31)
184            private   boolean       trace           = false;                // 4.0.0 (2005/01/31) å»?­¢
185            private   boolean       stopZero        = false;
186            private   String        modifyType      = null;                 // 3.8.5.1 (2006/05/08) modifyType 属æ?を追åŠ?�—ますã?
187    //      private   String        displayMsg      = "MSG0033";    // ã€?»¶検索しましたã€?
188            protected String        displayMsg      = HybsSystem.sys( "VIEW_DISPLAY_MSG" );
189            private   String        overflowMsg     = "MSG0007";    // 検索結果がã?制限行数をè¶?�ˆましたので、残りはカãƒ?ƒˆされましたã€?
190            private   String        notfoundMsg     = "MSG0077";    // 対象ãƒ??タはありませんでしたã€?
191            private   boolean       isMainTrans     = true;                 // 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??見直ã�?
192    
193            // 3.5.4.7 (2004/02/06) 実行時間測定用のDIV要ç´?‚’出力しますã?
194            protected long dyStart = 0;
195            // 4.3.3.0 (2008/09/22) PLSQL/SQL実行エラーの際に、å?ç�?‚’中止するかどã�?�‹ã€?
196            protected boolean stopError             = true;
197    
198            private StringBuilder debugMsg = null;          // 3.5.6.0 (2004/06/18)
199    
200            // 3.8.0.5 (2005/08/20) リクエスト変数の正規化を行いますã?
201            private String                  checkNames      = null;
202    
203            // 3.8.5.3 (2006/08/07) トレース時ã?メãƒ?‚»ージæ–?­—å?を保存しておきますã?
204            private String                  traceMsg        = null;
205    
206            protected boolean       xssCheck        = HybsSystem.sysBool( "USE_XSS_CHECK" );        // 5.0.0.2 (2009/09/15)
207    
208            // 5.3.5.0 (2011/05/01) 処ç�?™‚é–?queryTime)などのæƒ??出力ã?有効/無効を指定しますã?
209            private boolean         useBeforeHtmlTag        = true ;
210    
211            /**
212             * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
213             *
214             * @og.rev 3.5.4.7 (2004/02/06) 実行時間測定用にã€?–‹始時刻を取得しますã?
215             * @og.rev 3.5.6.5 (2004/08/09) 暫定的に、DBTableModelをå?行削除しますã?
216             * @og.rev 3.6.0.0 (2004/09/24) DBTableModel の先行削除は、scope="session" の場合ã?みã€?
217             * @og.rev 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??、DBTableModelが新規作æ?されたå?ç�?�§のみ行うã€?
218             * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
219             *
220             * @return      後続å?ç�??æŒ?¤º
221             */
222            @Override
223            public int doStartTag() {
224                    // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
225                    if( useTag() ) {
226                            dyStart = System.currentTimeMillis();
227                            if( ! check( command, COMMAND_LIST ) ) { return(SKIP_BODY); }
228    
229                            useMainTrans( isMainTrans );                    // 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??見直ã�?
230                            startQueryTransaction( tableId );               // 3.6.0.8 (2004/11/19)
231    
232                            // 3.5.6.5 (2004/08/09) 削除するのは、セãƒ?‚·ョンのオブジェクトでよいã€?
233                            // 3.6.0.0 (2004/09/24) 削除するのは、scope="session" の場合ã?みã€?
234                            if( "session".equals( getScope() ) ) {
235                                    removeSessionAttribute( tableId );
236                                    removeSessionAttribute( HybsSystem.VIEWFORM_KEY );
237                            }
238    
239                            return( EVAL_BODY_BUFFERED );   // Body を評価するã€? extends BodyTagSupport æ™?
240                    }
241                    return ( SKIP_BODY );                           // Body を評価しなã�?
242            }
243    
244            /**
245             * Taglibのタグ本体を処ç�?�™ã‚?doAfterBody() ã‚?オーバã?ライドしますã?
246             *
247             * @og.rev 3.1.1.0 (2003/03/28) ボディのå†?®¹を取得するå?ç�?‚’、CommonTagSupport で行うã€?
248             * @og.rev 3.6.0.8 (2004/11/19) エラー発生時に確実にリリースされるよã�?�« try finally 追åŠ?
249             * @og.rev 3.8.5.3 (2006/08/07) USER.LASTSQL へのSQLæ–??保存ã?、実行前に行っておきますã?
250             * @og.rev 3.8.6.3 (2006/11/30) SQL æ–??前後ã?スペã?スを取り除きますã?
251             * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得ã?為,ApplicationInfoオブジェクトを設å®?
252             * @og.rev 4.0.0.0 (2005/01/31) lang â‡?ResourceManager へ変更
253             * @og.rev 4.0.0.0 (2005/08/31) useQuotCheck() による?³?±?¬インジェクション対ç­?
254             * @og.rev 4.3.4.0 (2008/12/01) GE20(ユーザー定数)へ登録するかã?フラグへの対å¿?
255             * @og.rev 5.0.0.2 (2009/09/15) XSS対å¿?
256             * @og.rev 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??、DBTableModelが新規作æ?されたå?ç�?�§のみ行うã€?
257             * @og.rev 5.1.9.0 (2010/08/01) TransactionTag 対応ã?上位に TransactionTag があれã?、そこからConnection をもらうã€?
258             * @og.rev 5.3.6.0 (2011/06/01) é›?¨ˆã?合計などのEdit機è?に対応しますã?
259             * @og.rev 5.3.7.0 (2011/07/01) TransactionReal の引数変更
260             * @og.rev 5.3.7.0 (2011/07/01) PL/SQLかつscope="request"で正しく出力するためqueryType,namesも保存するã?
261             * @og.rev 5.3.8.0 (2011/08/01) Transaction発生ç®?‰€でclose()
262             * @og.rev 5.5.3.4 (2012/06/19) trace 時ã?、実際の検索処ç�?‚’行わなã�?§˜に変更ã€?
263             * @og.rev 5.6.5.3 (2013/06/28) LASTQUERYTYPE â‡?LASTSQLTYPE 変更ã€?
264             *
265             * @return      後続å?ç�??æŒ?¤º(SKIP_BODY)
266             */
267            @Override
268            public int doAfterBody() {
269    
270                    // 4.0.0 (2005/08/31) useQuotCheck() による?³?±?¬インジェクション対ç­?
271                    useQuotCheck( quotCheck );
272                    // 5.0.0.2 (2009/09/15) XSS対ç­?
273                    useXssCheck( xssCheck );
274    
275                    sql = getBodyString().trim();
276    
277                    // 3.2.1.0 (2003/05/28) æœ?µ‚S?±?¬æ–?‚’、UserInfo に、キャãƒ?‚·ュしておくã€?
278    //              setUserInfo( "LASTSQL", sql );
279                    // 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??見直ã�?
280                    if( isMainTrans ) {
281                            setUserInfo( "LASTSQL", sql, false );
282                            // 5.3.7.0 (2011/07/01) PL/SQLかつscope="request"で正しく出力するためqueryType,namesも保存するã?
283    //                      setUserInfo( "LASTQUERYTYPE", queryType, false );
284                            setUserInfo( "LASTSQLTYPE", queryType, false );                         // 5.6.5.3 (2013/06/28)
285                            setUserInfo( "LASTNAMES", names, false );
286                    }
287    
288                    Query query = QueryFactory.newInstance( queryType );
289                    Transaction tran = null;
290                    try {
291                            if( maxRowCount < 0 ) {
292                                    maxRowCount     = sysInt( "DB_MAX_ROW_COUNT" );
293                            }
294    
295                            // 5.1.9.0 (2010/08/01) TransactionTag 対å¿?
296    //                      final Transaction tran ;
297                            TransactionTag tranTag = (TransactionTag)findAncestorWithClass( this,TransactionTag.class );
298                            if( tranTag == null ) {
299    //                              tran = new TransactionReal( dbid,getApplicationInfo() );
300                                    tran = new TransactionReal( getApplicationInfo() );             // 5.3.7.0 (2011/07/01) 引数変更
301                            }
302                            else {
303                                    tran = tranTag.getTransaction();
304                            }
305                            query.setTransaction( dbid,tran );      // 5.1.9.0 (2010/08/01) TransactionTag 対å¿?
306    
307                            query.setSkipRowCount( skipRowCount );
308                            query.setMaxRowCount( maxRowCount );
309    //                      query.setConnectionID( dbid );
310                            query.setResourceManager( getResource() );      // 4.0.0 (2005/01/31)
311    
312                            if( trace ) {
313    //                              traceMsg = traceQuery( sql );
314                                    traceMsg = traceQuery( sql,tran );              // 5.1.9.0 (2010/08/01) TransactionTag 対å¿?
315                                    // 5.5.3.4 (2012/06/19) trace 時ã?、実際の検索処ç�?‚’行わなã�?§˜に変更
316    //                              query.setMaxRowCount( 1 );
317                                    return(SKIP_BODY);
318                            }
319                            query.setStatement( sql );
320    //                      query.setApplicationInfo( getApplicationInfo() );       // 3.8.7.0 (2006/12/15)
321    
322                            // 5.3.6.0 (2011/06/01) é›?¨ˆã?合計などのEdit機è?に対応しますã?
323                            if( isMainTrans ) {
324                                    String guikey = getGUIInfoAttri( "KEY" );
325                                    String editName = getRequestValue( "editName" );
326                                    DBEditConfig config = getUser().getEditConfig( guikey, editName );
327                                    if( config != null ) {
328                                            query.setEditConfig( config );
329                                    }
330                            }
331    
332                            execute( query );
333    
334                            executeCount = query.getExecuteCount();
335                            if( errCode < ErrorMessage.NG && executeCount >= 0 ) {            // 異常以外ã?場å�?
336                                    table = query.getDBTableModel();
337                                    // 3.8.5.1 (2006/05/08) modifyType 属æ?を追åŠ?�—ますã?
338                                    if( modifyType != null ) {
339                                            for( int row=0; row<executeCount; row++ ) {
340                                                    table.setModifyType( row,modifyType );
341                                            }
342                                    }
343                            }
344                    }
345                    finally {
346    //                      if( query != null ) { query.close(); }
347                            QueryFactory.close( query );
348                            if( tran != null ) { tran.close(); }            // 5.3.8.0 (2011/08/01) Transaction発生ç®?‰€でclose()
349                    }
350                    return(SKIP_BODY);
351            }
352    
353            /**
354             * Taglibの終äº?‚¿グが見つかったときに処ç�?�™ã‚?doEndTag() ã‚?オーバã?ライドしますã?
355             *
356             * @og.rev 2.0.0.8 (2002/10/09) command="NEW" のときã?み、displayMsg を表示させますã?
357             * @og.rev 2.1.1.4 (2002/11/25) ãƒ?ƒ�ãƒ?‚°時にæœ?µ‚SQLをユーザーæƒ??をセãƒ?ƒˆするように変更ã€?
358             * @og.rev 2.1.2.1 (2002/11/27) ErrorMessage をクリアしなã�?‚ˆã�?�«変更ã€?
359             * @og.rev 3.1.1.0 (2003/03/28) JspWriter オブジェクトã?使用ç®?‰€をã?jspPrint() を使用するように変更ã€?
360             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
361             * @og.rev 3.2.1.0 (2003/05/28) æœ?µ‚S?±?¬æ–?‚’、UserInfo に、キャãƒ?‚·ュしておくã€?
362             * @og.rev 3.3.3.3 (2003/08/06) 検索結果の件数をã?"DB.COUNT" キーでリクエストにセãƒ?ƒˆするã€?
363             * @og.rev 3.3.3.3 (2003/08/06) 検索結果をã?"DB.ERR_CODE" キーでリクエストにセãƒ?ƒˆするã€?
364             * @og.rev 3.5.4.7 (2004/02/06) 実行時間測定用のDIV要ç´?‚’出力しておきますã?
365             * @og.rev 3.5.4.9 (2004/02/25) 警告時に停止してã�?�¾したがã?継続å?ç�?�•せますã?
366             * @og.rev 3.5.5.0 (2004/03/12) ErrorMessage オブジェクトを、query がæ?功した時にもクリアするように変更
367             * @og.rev 3.5.5.2 (2004/04/02) TaglibUtil.makeHTMLErrorTable メソãƒ?ƒ‰を利用
368             * @og.rev 3.5.5.8 (2004/05/20) ErrorMessage オブジェクトを、コマンドが NEW の場合ã?み、クリア
369             * @og.rev 3.5.6.0 (2004/06/18) debugMsg 属æ?をå?力するよã�?�«修正しますã?
370             * @og.rev 3.6.0.8 (2004/11/19) DBTableModel をセーブする時に、トランザクションチェãƒ?‚¯を行いますã?
371             * @og.rev 3.8.5.3 (2006/08/07) USER.LASTSQL へのSQLæ–??保存ã?、実行前に行っておきますã?
372             * @og.rev 4.0.0.0 (2006/11/14) notfoundMsg 属æ?を追åŠ??displayMsg は、VIEW_USE_DISPLAY_MSG で制御
373             * @og.rev 4.0.0.0 (2007/10/18) メãƒ?‚»ージリソース統å�? getResource().getMessage > getResource().getLabel )
374             * @og.rev 4.3.3.0 (2008/09/22) 属æ? stopError の設定により、JSP処ç�?‚’中止するかどã�?�‹を制御しますã?
375             * @og.rev 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
376             * @og.rev 5.3.5.0 (2011/05/01) 処ç�?™‚é–?queryTime)などのæƒ??出力ã?有効/無効を指定しますã?
377             * @og.rev 5.5.0.3 (2012/03/13) オーバã?フローメãƒ?‚»ージが存在しなã�?�¨きã?、何もしなã�??(改行も入れなã�?
378             * @og.rev 5.5.3.4 (2012/06/19) trace 時ã?、実際の検索処ç�?‚’行わなã�?§˜に変更ã€?
379             * @og.rev 5.6.3.0 (2013/04/01) エラー時メãƒ?‚»ージ変更
380             *
381             * @return      後続å?ç�??æŒ?¤º
382             */
383            @Override
384            public int doEndTag() {
385                    debugPrint();           // 4.0.0 (2005/02/28)
386                    // 5.2.2.0 (2010/11/01) caseKey 、caseVal 属æ?対å¿?
387                    if( !useTag() ) { return(EVAL_PAGE); }
388    
389                    if( trace ) {
390                            jspPrint( traceMsg );
391                            return (SKIP_PAGE);             // 5.5.3.4 (2012/06/19) trace 時ã?、実際の検索処ç�?‚’行わなã�?§˜に変更ã€?
392                    }
393    
394                    String label  = "";                             // 4.0.0 (2005/11/30) 検索しなかったå?合ã?
395                    if( check( command, COMMAND_LIST ) ) {
396                            StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL );
397    
398                            // 実行件数の表示 command="NEW" のときã?み、displayMsg を表示させますã?
399                            // 4.0.0 (2005/11/30) 出力é?の変更。ä¸?•ªæœ??に出力しますã?
400    //                      boolean useStatusBar = HybsSystem.sysBool( "VIEW_USE_DISPLAY_MSG" );
401                            if( CMD_NEW.equals( command ) ) {
402    //                              if( useStatusBar && executeCount > 0 && displayMsg != null && displayMsg.length() > 0 ) {
403                                    if( executeCount > 0 && displayMsg != null && displayMsg.length() > 0 ) {
404                                            buf.append( executeCount );
405    //                                      buf.append( getResource().getMessage( displayMsg ) );
406                                            buf.append( getResource().getLabel( displayMsg ) );
407                                            buf.append( HybsSystem.BR );
408                                    }
409                                    else if( executeCount == 0 && notfoundMsg != null && notfoundMsg.length() > 0 ) {
410    //                                      buf.append( getResource().getMessage( notfoundMsg ) );
411                                            buf.append( getResource().getLabel( notfoundMsg ) );
412                                            buf.append( HybsSystem.BR );
413                                    }
414                            }
415    
416                            // 3.3.3.3 (2003/08/06) 検索結果の件数をã?"DB.COUNT" キーでリクエストにセãƒ?ƒˆするã€?
417                            setRequestAttribute( "DB.COUNT"   , String.valueOf( executeCount ) );
418                            // 3.3.3.3 (2003/08/06) 検索結果をã?"DB.ERR_CODE" キーでリクエストにセãƒ?ƒˆするã€?
419                            setRequestAttribute( "DB.ERR_CODE", String.valueOf( errCode ) );
420    
421                            // オーバã?フロー時ã?メãƒ?‚»ージを表示
422    //                      if( table != null && table.isOverflow() ) {
423                            // 5.5.0.3 (2012/03/09) オーバã?フローメãƒ?‚»ージが存在しなã�?�¨きã?、何もしなã�??(改行も入れなã�?
424                            if( table != null && table.isOverflow() && overflowMsg != null && overflowMsg.length() > 0  ) {
425    //                              buf.append( getResource().getMessage( overflowMsg ) );
426                                    buf.append( getResource().getLabel( overflowMsg ) );
427                                    buf.append( HybsSystem.BR );
428                            }
429    
430                            // 3.5.5.2 (2004/04/02) TaglibUtil.makeHTMLErrorTable メソãƒ?ƒ‰を利用
431                            String err = TaglibUtil.makeHTMLErrorTable( errMessage,getResource() );
432                            if( err != null && err.length() > 0 ) {
433                                    buf.append( err );
434                                    setSessionAttribute( errMsgId,errMessage );
435                            }
436                            else if( CMD_NEW.equals( command ) ) {          // 3.5.5.8 (2004/05/20)
437                                    removeSessionAttribute( errMsgId );
438                            }
439                            label = buf.toString();
440    
441                            if( table != null && ! commitTableObject( tableId, table ) ) {
442                                    // 3.6.0.8 (2004/11/19) トランザクションチェãƒ?‚¯を行いますã?
443                                    // jspPrint( "QueryTag Query処ç�?�Œ割り込まれましたã€?BTableModel は登録しませんã€? );
444                                    
445                                    // 5.6.4.0 (2013/04/01) リソースから出力するよã�?�«対å¿?
446                                    ErrorMessage errMsgObj = new ErrorMessage( "QueryTag Query Error!" );
447                                    errMsgObj.addMessage( 0,ErrorMessage.NG,"ERR0041" );
448                                    jspPrint( TaglibUtil.makeHTMLErrorTable( errMsgObj,getResource() ) );
449                                    
450                                    return (SKIP_PAGE);
451                            }
452                    }
453    
454                    jspPrint( label );
455    
456                    // 3.5.4.9 (2004/02/25) 警告時に停止してã�?�¾したがã?継続å?ç�?�•せますã?
457    //              int rtnCode = EVAL_PAGE;
458                    final int rtnCode ;
459                    if( errCode >= ErrorMessage.NG )  {  // 異常
460                            if( stopError ) {                               // 4.3.3.0 (2008/09/22) 属æ? stopError の設定により、å?ç�?‚’中止するかを判断しますã?
461                                    rtnCode = SKIP_PAGE;
462                            }
463                            else {
464                                    rtnCode = EVAL_PAGE;
465                            }
466                    }
467                    else {
468                            // 件数?�件かつ stopZero = true
469                            if( executeCount == 0 && stopZero )     {
470                                    rtnCode = SKIP_PAGE;
471                            }
472                            else {
473                                    rtnCode = EVAL_PAGE;
474                            }
475                    }
476    
477                    // 3.5.4.7 (2004/02/06)
478                    long dyTime = System.currentTimeMillis()-dyStart;
479    
480                    // 5.3.5.0 (2011/05/01) 処ç�?™‚é–?queryTime)などのæƒ??出力ã?有効/無効を指定しますã?
481                    if( useBeforeHtmlTag ) {
482                            jspPrint( "<div id=\"queryTime\" value=\"" + (dyTime) + "\"></div>" );      // 3.5.6.3 (2004/07/12)
483                    }
484    
485                    // 4.0.0 (2005/01/31) セキュリãƒ?‚£チェãƒ?‚¯(ãƒ??タアクセス件数登録)
486                    GUIInfo guiInfo = (GUIInfo)getSessionAttribute( HybsSystem.GUIINFO_KEY );
487                    if( guiInfo != null ) { guiInfo.addReadCount( executeCount,dyTime,sql ); }
488    
489                    return( rtnCode );
490            }
491    
492            /**
493             * タグリブオブジェクトをリリースしますã?
494             * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
495             *
496             * @og.rev 2.0.0.4 (2002/09/27) カスタãƒ?‚¿グの release() メソãƒ?ƒ‰をã?追åŠ?
497             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
498             * @og.rev 3.5.4.7 (2004/02/06) 実行時間測定用に、dyStart を追åŠ?�—ますã?
499             * @og.rev 3.5.6.0 (2004/06/18) debugMsg 属æ?を追åŠ?�—ますã?
500             * @og.rev 3.8.0.5 (2005/08/20) checkNames 属æ?を追åŠ?�—ますã?
501             * @og.rev 3.8.5.1 (2006/05/08) modifyType 属æ?を追åŠ?�—ますã?
502             * @og.rev 3.8.5.1 (2006/05/08) traceMsg 属æ?(トレース時ã?メãƒ?‚»ージæ–?­—å?)を追åŠ?�—ますã?
503             * @og.rev 4.0.0.0 (2005/08/31) quotCheck 属æ?の追åŠ?
504             * @og.rev 4.0.0.0 (2007/10/10) dbid の初期値をã?"DEFAULT" から null に変更
505             * @og.rev 4.3.3.0 (2008/09/22) stopError 属æ?の追åŠ?
506             * @og.rev 5.0.0.2 (2009/09/15) XSS対å¿?
507             * @og.rev 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??、DBTableModelが新規作æ?されたå?ç�?�§のみ行うã€?
508             * @og.rev 5.3.5.0 (2011/05/01) 処ç�?™‚é–?queryTime)などのæƒ??出力ã?有効/無効を指定しますã?
509             *
510             */
511            @Override
512            protected void release2() {
513                    super.release2();
514                    tableId                 = HybsSystem.TBL_MDL_KEY;
515                    queryType               = null;
516    //              dbid                    = "DEFAULT";
517                    dbid                    = null;
518                    command                 = CMD_NEW;
519                    skipRowCount    = 0;
520                    maxRowCount             = -1;
521                    table                   = null;
522                    sql                             = null;
523    //              displayMsg              = "MSG0033";    // ã€?»¶検索しましたã€?
524                    displayMsg              = HybsSystem.sys( "VIEW_DISPLAY_MSG" );
525                    overflowMsg             = "MSG0007";    // 検索結果がã?制限行数をè¶?�ˆましたので、残りはカãƒ?ƒˆされましたã€?
526                    notfoundMsg             = "MSG0077";    // 対象ãƒ??タはありませんでしたã€?
527                    executeCount    = -1;                   // 検索/実行件数
528                    names                   = null;
529                    outMessage              = true;
530                    trace                   = false;
531                    errCode                 = ErrorMessage.OK;
532                    errMessage              = null;
533                    stopZero                = false;
534                    stopError               = true;                 // 4.3.3.0 (2008/09/22)
535                    dyStart                 = 0;
536                    debugMsg                = null;                 // 3.5.6.0 (2004/06/18)
537                    checkNames              = null;                 // 3.8.0.5 (2005/08/20)
538                    quotCheck               = HybsSystem.sysBool( "USE_SQL_INJECTION_CHECK" );      // 4.0.0 (2005/08/31)
539                    modifyType      = null;                 // 3.8.5.1 (2006/05/08)
540                    traceMsg                = null;                 // 3.8.5.3 (2006/08/07)
541                    xssCheck                = HybsSystem.sysBool( "USE_XSS_CHECK" );        // 5.0.0.2 (2009/09/15)
542                    isMainTrans             = true;                 // 5.1.6.0 (2010/05/01) DBLastSqlの処ç�??見直ã�?
543                    useBeforeHtmlTag        = true ;        // 5.3.5.0 (2011/05/01)
544            }
545    
546            /**
547             * Query を実行しますã?
548             *
549             * @og.rev 2.1.2.3 (2002/12/02) ãƒ??タベã?ス更新時に、更新フラグをセãƒ?ƒˆするように変更
550             * @og.rev 3.4.0.0 (2003/09/01) 登録エラー時ã?キーと値を表示するように変更ã€?
551             * @og.rev 3.5.6.0 (2004/06/18) ãƒ?ƒ�ãƒ?‚°æƒ??出力用に、printDebug メソãƒ?ƒ‰を追åŠ??
552             * @og.rev 3.6.1.0 (2005/01/05) エラーコードによる commit/rollback の判断追åŠ?
553             * @og.rev 5.3.7.0 (2011/07/01) nameの判定にゼロæ–?­—å?を付加
554             *
555             * @param       query オブジェクãƒ?
556             */
557            protected void execute( final Query query ) {
558                    String[] nameArray = null;
559                    String[] values    = null;
560                    try {
561    //                      if( names == null ) {
562                            if( names == null || names.length() == 0 ) {
563                                    query.execute();
564                            }
565                            else {
566                                    nameArray = StringUtil.csv2Array( names );
567                                    values = getRequest( nameArray );
568                                    // 3.5.6.0 (2004/06/18) ãƒ?ƒ�ãƒ?‚°æƒ??出力用
569                                    if( isDebug() ) { printDebug( nameArray,values ); }
570                                    query.execute( values );
571                            }
572                            errCode = query.getErrorCode();
573                            errMessage = query.getErrorMessage();
574                            // 3.6.1.0 (2005/01/05) エラーコードによる commit/rollback の判断追åŠ?
575    //                      if( query.getUpdateFlag() ) {
576                            if( query.isUpdate() ) {
577                                    if( errCode < ErrorMessage.NG ) {            // 異常以下ã?場å�?
578                                            query.commit();
579                                    }
580                                    else {
581                                            query.rollback();
582                                    }
583                            }
584                    }
585                    catch( HybsSystemException ex ) {
586                            query.rollback();
587    
588                            // 4.0.0 (2005/02/28) エラー時ã?表示とãƒ?ƒ�ãƒ?‚°時ã?表示を統ä¸?�™るã?
589                            String errMsg = "DATABASE ERROR! " + HybsSystem.CR ;
590                            if( nameArray != null ) {
591                                    printDebug( nameArray,values );
592                                    errMsg += debugMsg;
593                            }
594                            throw new HybsSystemException( errMsg,ex );             // 3.5.5.4 (2004/04/15) 引数の並びé ?¤‰更
595                    }
596                    finally {
597                            if( query != null ) { query.close(); }
598                    }
599            }
600    
601            /**
602             * ãƒ?ƒ�ãƒ?‚°用にã€??列データを書きå?しますã?
603             *
604             * @og.rev 3.5.6.0 (2004/06/18) 新規追åŠ?
605             *
606             * @param       nms     引数 names の配å?ãƒ??タ
607             * @param       vals    names に対応するリクエスト情報の配å?
608             */
609            private void printDebug( final String[] nms,final String[] vals ) {
610                    if( debugMsg == null ) { debugMsg = new StringBuilder(); }
611    
612                    debugMsg.append( "  names=[" );
613                    debugMsg.append( StringUtil.array2csv( nms ) );
614                    debugMsg.append( "]" );
615                    debugMsg.append( HybsSystem.CR );
616                    debugMsg.append( "  values=[" );
617                    debugMsg.append( StringUtil.array2csv( vals ) );
618                    debugMsg.append( "]" );
619                    debugMsg.append( HybsSystem.CR );
620            }
621    
622            /**
623             * 名称配å?をå?に、リクエスト情報のãƒ??タを取得しますã?
624             * checkNames 属æ?に設定されてã�?‚‹カラãƒ?�Œあれば、å?を正規化しますã?
625             *
626             * @og.rev 3.8.0.5 (2005/08/20) リクエスト変数の正規化(checkNames)対å¿?
627             *
628             * @param       nameArray       キーとなる名称の配å?
629             *
630             * @return      そã?リクエスト情報の配å?
631             */
632            protected String[] getRequest( final String[] nameArray ) {
633                    String[] rtn = new String[nameArray.length];
634    
635                    for( int i=0; i<rtn.length; i++ ) {
636                            rtn[i] = getRequestValue( nameArray[i] );
637    
638                            // 3.8.0.5 (2005/08/20) checkNames がありã?rtn[i] があるå?合ã?
639                            if( checkNames != null && checkNames.length() > 0 && rtn[i].length() > 0 ) {
640                                    if( ( "," + checkNames + "," ).indexOf( "," + nameArray[i] + "," ) >= 0 ) {
641                                            DBColumn dbColumn = getDBColumn( nameArray[i] );
642                                            String val = dbColumn.valueSet( rtn[i] );
643                                            if( val != null ) { rtn[i] = val; }
644                                    }
645                            }
646                    }
647    
648                    return rtn;
649            }
650    
651            /**
652             * 【TAGã€?通常は使ã�?�¾せん)ãƒ??タの読み始めの初期値を指定しますã?
653             *
654             * @og.tag
655             * ãƒ??タベã?ス自体ã?検索は,æŒ?®šされたSQLの全件を検索しますが,
656             * DBTableModelのãƒ??タとしては、スキãƒ??件数åˆ??登録されませんã€?
657             * サーバã?のメモリè³?º�と応答時間ã?確保ã?為ですã?
658             *
659             * @param       count 読み始めの初期値
660             */
661            public void setSkipRowCount( final String count ) {
662                    skipRowCount = nval( getRequestParameter( count ),skipRowCount );
663            }
664    
665            /**
666             * 【TAGã€?通常は使ã�?�¾せん)ãƒ??タのæœ?¤§読み込み件数を指定しまã�?
667             *              (初期値:DB_MAX_ROW_COUNT[={@og.value org.opengion.hayabusa.common.SystemData#DB_MAX_ROW_COUNT}])ã€?
668             *
669             * @og.tag
670             * ãƒ??タベã?ス自体ã?検索は,æŒ?®šされたSQLの全件を検索しますが,
671             * DBTableModelのãƒ??タとして登録するæœ?¤§件数をこの値に設定しますã?
672             * サーバã?のメモリè³?º�と応答時間ã?確保ã?為ですã?
673             * 0 をセãƒ?ƒˆすると、無制é™?Integer.MAX_VALUE)になりますã?
674             * (初期値:ユーザー定数のDB_MAX_ROW_COUNT[={@og.value org.opengion.hayabusa.common.SystemData#DB_MAX_ROW_COUNT}])ã€?
675             *
676             * @og.rev 5.5.8.5 (2012/11/27) 0を無制限として処ç�?�—ますã?
677             *
678             * @param       count æœ?¤§読み込み件数
679             * @see         org.opengion.hayabusa.common.SystemData#DB_MAX_ROW_COUNT
680             */
681            public void setMaxRowCount( final String count ) {
682                    maxRowCount = nval( getRequestParameter( count ),maxRowCount );
683                    if( maxRowCount == 0 ) { maxRowCount = Integer.MAX_VALUE ; }            // 5.5.8.5 (2012/11/27)
684            }
685    
686            /**
687             * 【TAGã€?通常は使ã�?�¾せん)結果のDBTableModelをã?sessionに登録するときã?キーを指定しまã�?初期値:HybsSystem.TBL_MDL_KEY)ã€?
688             *
689             * @og.tag
690             * 検索結果より、DBTableModelオブジェクトを作æ?しますã?これをã?以下ã?view 等ã?タグに
691             * 渡すå?合にã€??常は、session を利用しますã?そã?場合ã?登録キーですã?
692             * query タグを同時に実行して、結果を求めるå?合ã?同ä¸?ƒ¡モリに配置される為ã€?
693             * こã? tableId 属æ?を利用して、メモリ空間をåˆ?�‘ますã?
694             * 初期値は、HybsSystem.TBL_MDL_KEY (={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY})ですã?
695             *
696             * @param       id sessionに登録する時ã? ID
697             */
698            public void setTableId( final String id ) {
699                    tableId   = nval( getRequestParameter( id ),tableId );  // 3.8.0.9 (2005/10/17)
700            }
701    
702            /**
703             * 【TAG】Query を発行する為のクラスID(JDBC,JDBCCallable,JDBCErrMsg,JDBCUpdate)を指定しまã�?{@og.doc03Link queryType 初期値:JDBC})ã€?
704             *
705             * @og.tag
706             * 検索を実行する手段は、Query インターフェースの実è£?‚¯ラスになりますã?
707             * こã?タグでは、Query.execute( String[] ) メソãƒ?ƒ‰が呼ばれますã?
708             * 例えば、ストアドã?ロシージャ等を実行するå?合に、queryType="JDBCErrMsg"
709             * を指定することができますã?
710             * 初期値はã€?JDBC" ですã?
711             * queryType は、シスãƒ?ƒ リソースの Query_**** 宣è¨?? **** を与えますã?
712             * これらã?、Query インターフェースを継承したサブクラスであるå¿?¦�がありますã?
713             * 標準で、org.opengion.hayabusa.db 以下ã? Query_**** クラスがã?Query_**** 宣è¨?と
714             * して、定義されてã�?�¾すã?
715             * 属æ?クラス定義の {@link org.opengion.hayabusa.db.Query Query} を参照願いますã?
716             * {@og.doc03Link queryType Query_**** クラス}
717             *
718             * @param       id Query を発行する為の実クラス ID
719             * @see         org.opengion.hayabusa.db.Query  Queryのサブクラス
720             * @see         org.opengion.hayabusa.db.Query#execute( String[] )
721             */
722            public void setQueryType( final String id ) {
723                    queryType = getRequestParameter( id );
724            }
725    
726            /**
727             * 【TAGã€?通常は使ã�?�¾せん)Queryオブジェクトを作æ?する時ã?DB接続IDを指定しますã?
728             *
729             * @og.tag
730             * Queryオブジェクトを作æ?する時ã?DB接続IDを指定しますã?
731             * これは、シスãƒ?ƒ リソースで、DEFAULT_DB_URL 等でæŒ?®šしてã�?‚‹ ãƒ??タベã?ス接続å?
732             * æƒ??に、XX_DB_URL を定義することでã€?dbid="XX" とすると、この 接続å?を使用して
733             * ãƒ??タベã?スにアクセスできますã?
734             *
735             * @param       id ãƒ??タベã?ス接続ID
736             */
737            public void setDbid( final String id ) {
738                    dbid = nval( getRequestParameter( id ),dbid );
739            }
740    
741            /**
742             * 【TAG】コマンãƒ?NEW,RENEW)をセãƒ?ƒˆしまã�?PlsqlUpdateTag,UpdateTag の場合ã?、ENTRY)ã€?
743             *
744             * @og.tag
745             * コマンドã?,HTMLから(get/post)æŒ?®šされますã?で,CMD_xxx で設定される
746             * フィールド定数値のã�?�¥れかをã?æŒ?®šできますã?
747             *
748             * @param       cmd コマンãƒ?public static final 宣è¨?�•れてã�?‚‹æ–?­—å?)
749             * @see         <a href="{&#064;docRoot}/constant-values.html#org.opengion.hayabusa.taglib.QueryTag.CMD_NEW">コマンド定数</a>
750             */
751            public void setCommand( final String cmd ) {
752                    String cmd2 = getRequestParameter( cmd );
753                    if( cmd2 != null && cmd2.length() >= 0 ) { command = cmd2.toUpperCase(Locale.JAPAN); }
754            }
755    
756            /**
757             * 【TAG】検索結果が0件のときå?ç�?‚’続行するかどã�?�‹[true/false]を指定しまã�?初期値:false[続行する])ã€?
758             *
759             * @og.tag
760             * 初期値は、false(続行すã‚?ですã?
761             *
762             * @param  cmd 検索結果が0件のときã?[true:処ç�?‚’中止する/false:続行する]
763             */
764            public void setStopZero( final String cmd ) {
765                    stopZero = nval( getRequestParameter( cmd ),stopZero );
766            }
767    
768            /**
769             * 【TAG】検索結果を画面上に表示するメãƒ?‚»ージリソースIDを指定しまã�?
770             *              (初期値:VIEW_DISPLAY_MSG[={@og.value org.opengion.hayabusa.common.SystemData#VIEW_DISPLAY_MSG}])ã€?
771             *
772             * @og.tag
773             * ここでは、検索結果の件数ã‚?™»録された件数をまずå?力しã€?
774             * そã?次に、ここでæŒ?®šしたメãƒ?‚»ージをリソースから取得して表示しますã?
775             * 件数を表示させたい場合ã?、displayMsg = "MSG0033"[ã€?»¶検索しました] をセãƒ?ƒˆしてくださいã€?
776             * 表示させたくなã�??合ã?, displayMsg = "" をセãƒ?ƒˆしてくださいã€?
777             * (初期値:シスãƒ?ƒ 定数のVIEW_DISPLAY_MSG[={@og.value org.opengion.hayabusa.common.SystemData#VIEW_DISPLAY_MSG}])ã€?
778             *
779             * @param       id ãƒ?‚£スプレイに表示させるメãƒ?‚»ージ ID
780             * @see         org.opengion.hayabusa.common.SystemData#VIEW_DISPLAY_MSG
781             */
782            public void setDisplayMsg( final String id ) {
783                    String ids = getRequestParameter( id );
784                    if( ids != null ) { displayMsg = ids; }
785            }
786    
787            /**
788             * 【TAG】検索ãƒ??タが最大検索数をオーバã?した場合に表示するメãƒ?‚»ージリソースIDを指定しまã�?
789             *              (初期値:MSG0007[検索結果がã?制限行数をè¶?�ˆましたので、残りはカãƒ?ƒˆされました])ã€?
790             *
791             * @og.tag
792             * 検索結果がã?maxRowCount で設定された値より多い場合ã?何らかã?ãƒ??タは検索されã�?
793             * åˆ?‚Š捨てられたことになりますã?
794             * ここでは、displayMsg を表示した後ã?å¿?¦�に応じて、このメãƒ?‚»ージを表示しますã?
795             * 表示させたくなã�??合ã?, overflowMsg = "" をセãƒ?ƒˆしてくださいã€?
796             * 初期値は、MSG0007[検索結果がã?制限行数をè¶?�ˆましたので、残りはカãƒ?ƒˆされました]ですã?
797             *
798             * @param       id ãƒ?‚£スプレイに表示させるメãƒ?‚»ージ ID
799             */
800            public void setOverflowMsg( final String id ) {
801                    String ids = getRequestParameter( id );
802                    if( ids != null ) { overflowMsg = ids; }
803            }
804    
805            /**
806             * 【TAG】検索結果がゼロ件の場合に表示するメãƒ?‚»ージリソースIDを指定しまã�?初期値:MSG0077[対象ãƒ??タはありませんでした])ã€?
807             *
808             * @og.tag
809             * ここでは、検索結果がゼロ件の場合ã?み、特別なメãƒ?‚»ージを表示させますã?
810             * 従来は、displayMsg と兼用で、ã?0ã€?»¶検索しました』とã�?�†表示でしたがã?
811             * displayMsg の初期表示は、OFF になりましたので、ゼロ件の場合ã?み別に表示させますã?
812             * 表示させたくなã�??合ã?, notfoundMsg = "" をセãƒ?ƒˆしてくださいã€?
813             * 初期値は、MSG0077[対象ãƒ??タはありませんでした]ですã?
814             *
815             * @param       id ãƒ?‚£スプレイに表示させるメãƒ?‚»ージ ID
816             */
817            public void setNotfoundMsg( final String id ) {
818                    String ids = getRequestParameter( id );
819                    if( ids != null ) { notfoundMsg = ids; }
820            }
821    
822            /**
823             * 【TAG】PL/SQLを利用する場合ã?引数にセãƒ?ƒˆすべã�?ãƒ??タの名称をCSV形式でè¤?•°æŒ?®šしますã?
824             *
825             * @og.tag
826             * è¤?•°ある場合ã?、カンマ区åˆ?‚Šæ–?­—で渡しますã?
827             * names 属æ?は、queryType に応じて設定可否が異なりますã?で、ご注意くã�?�•ã�??
828             * names なし:JDBC,JDBCUpdate
829             * names あり?šJDBCCallable,JDBCErrMsg,JDBCUpdate
830             * (JDBCUpdateは、names 属æ?のあり/なし両方に対応してã�?�¾すã?)
831             *
832             * @og.rev 3.0.1.3 (2003/03/11) names 属æ?に null で渡すå?合ã?バグを修正
833             *
834             * @param       nm 引数の名称(è¤?•°ある場合ã?、カンマ区åˆ?‚Šæ–?­?
835             */
836            public void setNames( final String nm ) {
837                    names = nval( getRequestParameter( nm ),names );
838            }
839    
840            /**
841             * 【TAG】検索結果のメãƒ?‚»ージを表示する/しない[true/false]を指定しまã�?初期値:true)ã€?
842             *
843             * @og.tag
844             * 初期値は、表示する?štrue ですã?
845             *
846             * @param       flag  [true:表示する/それ以å¤?含めない]
847             */
848            public void setOutMessage( final String flag ) {
849                    outMessage = nval( getRequestParameter( flag ),outMessage );
850            }
851    
852            /**
853             * 【TAG】引数の SQL æ–?‚’ EXPLAIN PLAN を[true:行う/それ以å¤?行わない]を指定しまã�?初期値:false)ã€?
854             *
855             * @og.tag
856             *
857             * ここでは、以下ã?処ç�?‚’行いますã?
858             * ?‘.引数の SQL æ–?‚’画面に表示しますã?
859             * ?’.引数の SQL æ–?‚’ EXPLAIN PLAN した結果をã?画面に表示しますã?
860             * なおã?以前ã?、セãƒ?‚·ョンのトレースを行ってã�?�¾したがã?そã?機è?は、å»?­¢ã�?�Ÿしますã?
861             * 初期値は、行わなã�?¼šfalse ですã?
862             *
863             * @param       flag トレース [true:行う/それ以å¤?行わない]
864             */
865            public void setTrace( final String flag ) {
866                    trace = nval( getRequestParameter( flag ),trace );
867            }
868    
869            /**
870             * 【TAG】リクエスト変数の正規化を行うカラãƒ?‚’CSV形式でè¤?•°æŒ?®šしますã?
871             *
872             * @og.tag
873             * PL/SQLを利用する場合ã?引数にセãƒ?ƒˆすべã�?ãƒ??タをã?リクエスト変数の
874             * 値そã?ままではなくã?カラãƒ?‚ªブジェクトã? valueSet メソãƒ?ƒ‰経由で正規化
875             * した値を使用するようにしますã?
876             *
877             * @og.rev 3.8.0.5 (2005/08/20) 新規追åŠ?
878             *
879             * @param       nm リクエスト変数の正規化を行うカラãƒ?
880             */
881            public void setCheckNames( final String nm ) {
882                    checkNames = nval( getRequestParameter( nm ),checkNames );
883            }
884    
885            /**
886             * 【TAG】DB検索時ã? モãƒ?‚£ファイタイプをæŒ?®šします[A:追åŠ?C:更新/D:削除]ã€?
887             *
888             * @og.tag
889             * DB検索時に、そのãƒ??タをA(追åŠ?、C(更新)、D(削除)のモãƒ?‚£ファイタイプを
890             * つけた状態にしますã?
891             * そã?状態で、そのまま、update する事が可能になりますã?
892             *
893             * @og.rev 3.8.5.1 (2006/05/08) 新規追åŠ?
894             *
895             * @param   type DB検索時ã? モãƒ?‚£ファイタイãƒ?[A:追åŠ?C:更新/D:削除]
896             */
897            public void setModifyType( final String type ) {
898                    modifyType = nval( getRequestParameter( type ),modifyType );
899            }
900    
901            /**
902             * 【TAG】リクエスト情報の クォーãƒ?‚£ション(') 存在チェãƒ?‚¯を実施するかどã�?�‹[true/false]を設定しまã�?
903             *              (初期値:USE_SQL_INJECTION_CHECK[={@og.value org.opengion.hayabusa.common.SystemData#USE_SQL_INJECTION_CHECK}])ã€?
904             *
905             * @og.tag
906             * ?³?±?¬インジェクション対策ã?ä¸?�¤として、暫定的ではありますが、SQLのパラメータに
907             * 渡す文字å?にクォーãƒ?‚£ション(') を許さなã�?¨­定にすれば、ある程度は防止できますã?
908             * 数字タイプã?引数にはã€?or 5=5 などのクォーãƒ?‚£ションを使用しなã�?‚³ードを埋めてもã?
909             * 数字チェãƒ?‚¯で検å?可能ですã?æ–?­—タイプã?場合ã?、å¿?�š (')をã?ずしてã€?
910             * ' or 'A' like 'A のような形式になる為ã€?')チェãƒ?‚¯ã�?�‘でも有効ですã?
911             * (') が含まれてã�?�Ÿエラーにする(true)?�かノã?チェãƒ?‚¯ã�?false)を指定しますã?
912             * 初期値は、SystemData#USE_SQL_INJECTION_CHECK ですã?
913             *
914             * @og.rev 4.0.0.0 (2005/08/31) 新規追åŠ?
915             *
916             * @param   flag クォーãƒ?‚£ションチェãƒ?‚¯ [true:する/それ以å¤?しない]
917             */
918            public void setQuotCheck( final String flag ) {
919                    quotCheck = nval( getRequestParameter( flag ),quotCheck );
920            }
921    
922            /**
923             * 【TAG】リクエスト情報の HTMLTag開å§?終äº?–‡å­?&gt;&lt;) 存在チェãƒ?‚¯を実施するかどã�?�‹[true/false]を設定しまã�?
924             *              (初期値:USE_XSS_CHECK[={@og.value org.opengion.hayabusa.common.SystemData#USE_XSS_CHECK}])ã€?
925             *
926             * @og.tag
927             * クロスサイトスクリプティング(XSS)対策ã?ä¸?’°としてless/greater than signにつã�?�¦のチェãƒ?‚¯を行いますã?
928             * (&gt;&lt;) が含まれてã�?�Ÿエラーにする(true)?�かノã?チェãƒ?‚¯ã�?false)を指定しますã?
929             * (初期値:シスãƒ?ƒ 定数のUSE_XSS_CHECK[={@og.value org.opengion.hayabusa.common.SystemData#USE_XSS_CHECK}])
930             *
931             * @og.rev 5.0.0.2 (2009/09/15) 新規追åŠ?
932             *
933             * @param       flag    XSSチェãƒ?‚¯ [true:する/false:しない]
934             * @see         org.opengion.hayabusa.common.SystemData#USE_XSS_CHECK
935             */
936            public void setXssCheck( final String flag ) {
937                    xssCheck = nval( getRequestParameter( flag ),xssCheck );
938            }
939    
940            /**
941             * 【TAG】PLSQL/SQL処ç�?‚¨ラーの時に処ç�?‚’中止するかどã�?�‹[true/false]を設定しまã�?初期値:true)ã€?
942             *
943             * @og.tag
944             * false(中止しなã�?に設定するå?合ã?後続å?ç�?�§は、{&#064;DB.ERR_CODE}の値によりã€?
945             * PLSQL/SQLの異常/正常終äº?�«よってåˆ?²�å?ç�??可能となりますã?
946             * 初期値は、true(中止する)ですã?
947             *
948             * @og.rev 4.3.3.0 (2008/09/22) 新規追åŠ?
949             *
950             * @param   flag  [true:中止する/false:中止しない]
951             */
952            public void setStopError( final String flag ) {
953                    stopError = nval( getRequestParameter( flag ),stopError );
954            }
955    
956            /**
957             * 引数の SQL æ–?‚’ EXPLAIN PLAN しますã?
958             *
959             * ここでは、以下ã?処ç�?‚’行いますã?
960             * ?‘.引数の SQL æ–?‚’画面に表示しますã?
961             * ?’.引数の SQL æ–?‚’ EXPLAIN PLAN した結果をã?画面に表示しますã?
962             * なおã?こã?処ç�??、ORACLE 専用処ç�?�§すã?
963             *
964             * @og.rev 3.8.5.3 (2006/08/07) 新規追åŠ?
965             * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得ã?為,ApplicationInfoオブジェクトを設å®?
966             * @og.rev 5.1.9.0 (2010/08/01) Transaction 対応しますã?
967             * @og.rev 5.5.3.4 (2012/06/19) getUserInfo は、キー部åˆ?� けで処ç�?�—ますã?
968             *
969             * @param   sql         EXPLAIN PLANするSQL æ–?
970             * @param   tran        Transactionオブジェクãƒ?
971             *
972             * @return トレース結果のæ–?­—å?
973             */
974    //      private String traceQuery( final String sql ) {
975            private String traceQuery( final String sql , final Transaction tran ) {
976    //              ApplicationInfo appInfo = getApplicationInfo();
977    
978    //              String userId = getUserInfo( "USER.ID" ) ;
979                    String userId = getUserInfo( "ID" ) ;                   // 5.5.3.4 (2012/06/19) getUserInfo は、キー部åˆ?� けで処ç�?�—ますã?
980    
981                    String[] arg1 = new String[] { userId };
982    //              DBUtil.dbExecute( "DELETE FROM PLAN_TABLE WHERE STATEMENT_ID = ?",arg1,appInfo,dbid );
983                    DBUtil.dbExecute( "DELETE FROM PLAN_TABLE WHERE STATEMENT_ID = ?",arg1,tran,dbid );             // 5.1.9.0 (2010/08/01)
984    
985                    String explan1 = "EXPLAIN PLAN SET STATEMENT_ID = '" + userId + "' FOR " + sql ;
986    //              DBUtil.dbExecute( explan1,null,appInfo,dbid );
987                    DBUtil.dbExecute( explan1,null,tran,dbid );             // 5.1.9.0 (2010/08/01)
988    
989                    String[] arg2 = new String[] { userId,userId,userId };
990    //              String explan2 = "SELECT LEVEL,LPAD(' ',LEVEL,' ') || RTRIM( OPERATION ) || ' ' ||"
991    //                                              + " RTRIM( OPTIONS )   || ' ' || RTRIM( OBJECT_NAME )"
992    //                                              + " FROM PLAN_TABLE"
993    //                                              + " WHERE STATEMENT_ID = ?"
994    //                                              + " CONNECT BY PRIOR ID = PARENT_ID"
995    //                                              + "         AND STATEMENT_ID = ?"
996    //                                              + " START WITH ID = 0"
997    //                                              + "         AND STATEMENT_ID = ?" ;
998                    String explan2 = "select LEVEL as LVL"
999                                                            + ",lpad(' ',LEVEL,' ') || rtrim( OPERATION ) || ' ' || rtrim( OPTIONS ) || ' ' || rtrim( OBJECT_NAME ) as EXECUTION_PLAN"
1000                                                            + ",OBJECT_NAME                 as OBJ_NAME"
1001                                                            + ",DECODE(INSTR(OBJECT_TYPE,' '),0,OBJECT_TYPE,SUBSTR(OBJECT_TYPE,1,INSTR(OBJECT_TYPE,' ')-1)) as OBJ_TYPE"
1002                                                            + ",OPTIMIZER                   as OPT"
1003                                                            + ",COST                                as CST"
1004                                                            + ",CARDINALITY                 as CARD"
1005                                                            + ",BYTES                               as BYTE"
1006                                                            + ",ACCESS_PREDICATES   as ACCS"
1007                                                            + ",FILTER_PREDICATES   as FILTER"
1008                                                    + " from PLAN_TABLE"
1009                                                    + " where STATEMENT_ID = ?"
1010                                                    + " start with ID = 0"
1011                                                    + "       and STATEMENT_ID = ?"
1012                                                    + " connect by prior ID = PARENT_ID"
1013                                                    + "       and STATEMENT_ID = ?" ;
1014    //              String[][] plan = DBUtil.dbExecute( explan2,arg2,appInfo,dbid );
1015    //              String[][] plan = DBUtil.dbExecute( explan2,arg2,tran,dbid );                   // 5.1.9.0 (2010/08/01)
1016    
1017    //              StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
1018    //              buf.append( "<pre>" ).append( sql ).append( "</pre>" ).append( HybsSystem.BR );
1019    //              buf.append( "<table>" );
1020    //              buf.append( "<tr  class=\"row_h\"><th>LEVEL</th><th>EXECUTION_PLAN</th></tr>" );
1021    //              for( int i=0; i<plan.length; i++ ) {
1022    //                      buf.append( "<tr class=\"row_" ).append( i%2 ).append( "\">" );
1023    //                      buf.append( "<td>" ).append( plan[i][0] ).append( "</td>" );
1024    //                      buf.append( "<td><pre>" ).append( plan[i][1] ).append( "</td></tr>" );
1025    //              }
1026    //              buf.append( "</table>" ).append( HybsSystem.BR );
1027    
1028                    String[][] plan = DBUtil.dbExecute( explan2,arg2,tran,dbid,true );                      // 5.5.3.4 (2012/06/19) ヘッãƒ??æƒ??も同時に取得するã?
1029    
1030                    StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
1031                    buf.append( "<pre>" ).append( sql ).append( "</pre>" ).append( HybsSystem.BR );
1032                    buf.append( "<table>" );
1033                    // 1行目のヘッãƒ??の出åŠ?
1034                    int colsize = plan[0].length;
1035                    buf.append( "<tr class=\"row_h\">" );
1036                    for( int j=0; j<colsize; j++ ) {
1037                            buf.append( "<th>" ).append( plan[0][j] ).append( "</th>" );
1038                    }
1039                    buf.append( "</tr>" );
1040    
1041                    for( int i=1; i<plan.length; i++ ) {
1042                            buf.append( "<tr class=\"row_" ).append( i%2 ).append( "\">" );
1043                            for( int j=0; j<colsize; j++ ) {
1044                                    if( j==1 ) {
1045                                            buf.append( "<td><pre>" ).append( plan[i][1] ).append( "</pre></td>" );
1046                                    }
1047                                    else {
1048                                            buf.append( "<td>" ).append( plan[i][j] ).append( "</td>" );
1049                                    }
1050                            }
1051                            buf.append( "</tr>" );
1052                    }
1053                    buf.append( "</table>" ).append( HybsSystem.BR );
1054                    return buf.toString();
1055            }
1056    
1057            /**
1058             * 【TAGã€?通常使ã�?�¾せん)タグで処ç�?�•れる処ç�?�Œメインとなるトランザクション処ç�?�‹どã�?�‹を指定しまã�?初期値:true)ã€?
1059             *
1060             * @og.tag
1061             * こã?値は、ファイルãƒ?‚¦ンロードå?ç�?�«影響しますã?こã?値がtrueにæŒ?®šされた時にcommitされたDBTableModelã�?
1062             * ファイルãƒ?‚¦ンロードã?対象の表になりますã?
1063             *
1064             * こã?パラメーターはã€??常、各タグにより実è£?�•れã?ユーザーが指定するå¿?¦�ã?ありませんã€?
1065             * ä½?�—ã€?つのJSPå†?�§DBTableModelがè¤?•°生æ?されるå?合に、前に処ç�?�—たDBTableModelにつã�?�¦ファイルãƒ?‚¦ンロードをさせたい
1066             * 場合ã?、後ろでDBTableModelを生成するタグで、æ?示çš?�«こã?値をfalseにæŒ?®šすることで、ファイルãƒ?‚¦ンロードå?ç�??対象から
1067             * 除外することができますã?
1068             *
1069             * @og.rev 5.1.6.0 (2010/05/01) 新規作æ?
1070             *
1071             * @param  flag メイントランザクションかどã�?�‹
1072             */
1073            public void setMainTrans( final String flag ) {
1074                    isMainTrans = nval( getRequestParameter( flag ),isMainTrans );
1075            }
1076    
1077            /**
1078             * 【TAGã€?処ç�?™‚é–?queryTime)などのæƒ??出力[true:有効/false:無効]を指定しまã�?初期値:true)ã€?
1079             *
1080             * @og.tag
1081             * Query で、検索する場合に、å?ç�?™‚é–?queryTime)などのæƒ??をå?力してã�?�¾すがã€?
1082             * ViewForm で、CustomData などの 非HTML表示ビューを使用する場合ã?ãƒ??タとしてã€?
1083             * 紛れ込んでしまã�?�Ÿめã?出力を抑制するå¿?¦�がありますã?
1084             * true(有効)にすると、これらのHTMLがå?力されますã?false にすると、å?力されませんã€?
1085             * 初期値は、true(有効) ですã?
1086             *
1087             * @og.rev 5.3.5.0 (2011/05/01) 新規追åŠ?
1088             *
1089             * @param  useTag  æƒ??出力ã?有効/無効を指å®?[true:有効/false:無効]
1090             */
1091            public void setUseBeforeHtmlTag( final String useTag ) {
1092                    useBeforeHtmlTag = nval( getRequestParameter( useTag ),useBeforeHtmlTag );
1093            }
1094    
1095            /**
1096             * シリアライズ用のカスタãƒ?‚·リアライズ書き込みメソãƒ?ƒ‰
1097             *
1098             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
1099             * @serialData
1100             *
1101             * @param       strm    ObjectOutputStreamオブジェクãƒ?
1102             */
1103            private void writeObject( final ObjectOutputStream strm ) throws IOException {
1104                    strm.defaultWriteObject();
1105            }
1106    
1107            /**
1108             * シリアライズ用のカスタãƒ?‚·リアライズ読み込みメソãƒ?ƒ‰
1109             *
1110             * ここでは、transient 宣è¨?�•れたå†?ƒ¨変数のå†??初期化がå¿?¦�なフィールドã?み設定しますã?
1111             *
1112             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
1113             * @serialData
1114             *
1115             * @param       strm    ObjectInputStreamオブジェクãƒ?
1116             * @see #release2()
1117             */
1118            private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
1119                    strm.defaultReadObject();
1120            }
1121    
1122            /**
1123             * こã?オブジェクトã?æ–?­—å?表現を返しますã?
1124             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
1125             *
1126             * @return こã?クラスのæ–?­—å?表現
1127             */
1128            @Override
1129            public String toString() {
1130                    return sql ;
1131    
1132            //      return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
1133            //                      .println( "VERSION"                     ,VERSION                )
1134            //                      .println( "tableId"                     ,tableId                )
1135            //                      .println( "queryType"           ,queryType              )
1136            //                      .println( "dbid"                        ,dbid                   )
1137            //                      .println( "command"                     ,command                )
1138            //                      .println( "skipRowCount"        ,skipRowCount   )
1139            //                      .println( "maxRowCount"         ,maxRowCount    )
1140            //                      .println( "sql"                         ,sql                    )
1141            //                      .println( "displayMsg"          ,displayMsg             )
1142            //                      .println( "overflowMsg"         ,overflowMsg    )
1143            //                      .println( "executeCount"        ,executeCount   )
1144            //                      .println( "names"                       ,names                  )
1145            //                      .println( "outMessage"          ,outMessage             )
1146            //                      .println( "trace"                       ,trace                  )
1147            //                      .println( "errCode"                     ,errCode                )
1148            //                      .println( "stopZero"            ,stopZero               )
1149            //                      .println( "quotCheck"           ,quotCheck              )
1150            //                      .println( "dyStart"                     ,dyStart                )
1151            //                      .println( "checkNames"          ,checkNames             )
1152            //                      .println( "Other..."            ,getAttributes().getAttribute() )
1153            //                      .fixForm().toString() ;
1154            }
1155    }