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 */
016package org.opengion.hayabusa.taglib;
017
018import java.util.ArrayList;
019import java.util.List;
020import java.util.Set;                                                                                   // 6.4.3.4 (2016/03/11)
021import java.util.regex.Pattern;                                                                 // 7.0.1.8 (2019/01/28)
022
023import org.opengion.fukurou.util.ErrorMessage;
024import org.opengion.fukurou.util.ToString;                                              // 6.1.1.0 (2015/01/17)
025import org.opengion.fukurou.util.ArraySet;                                              // 6.4.3.4 (2016/03/11)
026import org.opengion.hayabusa.common.HybsSystem;
027import org.opengion.hayabusa.common.HybsSystemException;
028import org.opengion.hayabusa.db.DBTableModel;
029import org.opengion.hayabusa.db.Query;
030import org.opengion.hayabusa.resource.GUIInfo;
031
032import static org.opengion.fukurou.util.StringUtil.nval;
033import static org.opengion.fukurou.system.HybsConst.BR;                 // 6.1.0.0 (2014/12/26) refactoring
034
035/**
036 * SQL文を直接指定して、データベースに追加/更新/削除を行います(queryType="JDBCTableUpdate")。
037 *
038 * 存在チェックを行う場合は、tableExist タグと併用してください。
039 * 複雑な処理が必要な場合は、従来より使用しています、PLSQLをCALLする、
040 * plsqlUpdateタグを使用してください。
041 * また、tableUpdateParam タグを使用する事で、テーブル名とsqlTypeの指定で動的に
042 * SQL文を自動生成できます。これにより、追加、更新、削除やテーブルに関して、
043 * 単一のJSP画面ですべて対応できるようになります。
044 *
045 * ※ このタグは、Transaction タグの対象です。
046 *
047 * @og.formSample
048 * ●形式:<og:tableUpdate command="…" names="…" queryType="JDBCTableUpdate" >
049 *             {@SQL}
050 *         </og:update>
051 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します)
052 *
053 * ●Tag定義:
054 *   <og:tableUpdate
055 *       queryType          【TAG】Query を発行する為のクラスIDを指定します({@og.doc03Link queryType 初期値:JDBCTableUpdate})
056 *       sqlType            【TAG】BODY部に書かれている Param の SQLタイプを指定します
057 *       command            【TAG】コマンド (NEW,RENEW)をセットします(PlsqlUpdateTag,UpdateTag の場合は、ENTRY)
058 *       scope              【TAG】キャッシュする場合のスコープ[request/page/session/application]を指定します(初期値:session)
059 *       displayMsg         【TAG】検索結果を画面上に表示するメッセージリソースIDを指定します (初期値:VIEW_DISPLAY_MSG[=])
060 *       resourceType       【特殊】クリアするリソースの種類[GEA03/GEA04/GEA08]を指定します
061 *       conditionKey       【TAG】条件判定するカラムIDを指定します(初期値:null)
062 *       conditionList      【TAG】条件判定する値のリストを、"|"で区切って登録します(初期値:無条件) 7.0.1.8 (2019/01/28) 正規表現に変更
063 *       tableId            【TAG】(通常は使いません)結果のDBTableModelを、sessionに登録するときのキーを指定します
064 *       dbid               【TAG】(通常は使いません)Queryオブジェクトを作成する時のDB接続IDを指定します
065 *       selectedAll        【TAG】データを全件選択済みとして処理するかどうか[true/false]を指定します(初期値:false)
066 *       commitTableModel   【特殊】SQL実行後に結果をDBTableModelに反映させるかどうか[true/false]を指定します(初期値:true)
067 *       followCdkh         【TAG】DBTableModelの改廃Cに従って処理を行うかを指定します
068 *       quotCheck          【TAG】リクエスト情報の シングルクォート(') 存在チェックを実施するかどうか[true/false]を設定します(初期値:false)
069 *       useTimeView        【TAG】処理時間を表示する TimeView を表示するかどうかを指定します
070 *                                                                              (初期値:VIEW_USE_TIMEBAR[={@og.value SystemData#VIEW_USE_TIMEBAR}])。
071 *       useSLabel          【TAG】7.0.7.0 (2019/12/13) エラーメッセージにSLABELを利用するかどうか[true/false]を指定します(初期値:false)
072 *       caseKey            【TAG】このタグ自体を利用するかどうかの条件キーを指定します(初期値:null)
073 *       caseVal            【TAG】このタグ自体を利用するかどうかの条件値を指定します(初期値:null)
074 *       caseNN             【TAG】指定の値が、null/ゼロ文字列 でない場合(Not Null=NN)は、このタグは使用されます(初期値:判定しない)
075 *       caseNull           【TAG】指定の値が、null/ゼロ文字列 の場合は、このタグは使用されます(初期値:判定しない)
076 *       caseIf             【TAG】指定の値が、true/TRUE文字列の場合は、このタグは使用されます(初期値:判定しない)
077 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
078 *   >   ... Body ...
079 *   </og:tableUpdate>
080 *
081 * ●使用例
082 *    ・QUERYを他のJSPから渡す場合
083 *    【copy.jsp】
084 *        <og:hidden name="SQL" >
085 *          INSERT INTO GE41
086 *               (CLM,NAME_JA,LABEL_NAME,KBSAKU,SYSTEM_ID,LANG,
087 *               FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
088 *          VALUES
089 *               ([CLM],[NAME_JA],[LABEL_NAME],[KBSAKU],[SYSTEM_ID],[LANG],
090 *               '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
091 *        </og:value>
092 *
093 *    【entry.jsp】
094 *        <og:tableUpdate
095 *            command   = "{@command}"
096 *            queryType = "JDBCTableUpdate"
097 *        {@SQL}
098 *        </og:tableUpdate>
099 *
100 *    ・tableUpdateParamを使用する場合
101 *    【entry.jsp】
102 *        <og:tableUpdate
103 *            command   = "{@command}"
104 *            queryType = "JDBCTableUpdate"
105 *            sqlType   = "{@sqlType}"        // tableUpdateParam の sqlType と一致
106 *        >
107 *            <og:tableUpdateParam
108 *                sqlType     = "{@sqlType}"       // INSERT,COPY,UPDATE,MODIFY,DELETE
109 *                table       = "{@TABLE_NAME}"    // 処理対象のテーブル名
110 *                names       = "{@names}"         // 処理対象のカラム名
111 *                omitNames   = "{@omitNames}"     // 処理対象外のカラム名
112 *                where       = "{@where}"         // 処理対象を特定するキー
113 *                constKeys   = "{@constKeys}"     // 処理カラム名の中の固定情報カラム名
114 *                constVals   = "{@constVals}"     // 処理カラム名の中の固定情報設定値
115 *            />
116 *        </og:tableUpdate>
117 *
118 *    ・処理の可否を指定する場合
119 *    【entry.jsp】
120 *        <og:tableUpdate
121 *            command   = "{@command}"
122 *            queryType = "JDBCTableUpdate"
123 *            conditionKey  ="…"      : 条件判定するカラムIDを指定(初期値は columnId )
124 *            conditionList ="…"      : 条件判定する値のリストを、"|"で区切って登録(初期値は、無条件)
125 *        {@SQL}
126 *        </og:tableUpdate>
127 *
128 * @og.rev 3.8.8.0 (2007/12/22) 新規作成
129 * @og.group DB登録
130 *
131 * @version  4.0
132 * @author   Kazuhiko Hasegawa
133 * @since    JDK5.0,
134 */
135public class TableUpdateTag extends QueryTag {
136        /** このプログラムのVERSION文字列を設定します。   {@value} */
137        private static final String VERSION = "7.0.7.0 (2019/12/13)" ;
138        private static final long serialVersionUID = 707020191213L ;
139
140        /** command 引数に渡す事の出来る コマンド  登録{@value} */
141        public static final String CMD_ENTRY  = "ENTRY" ;
142        // 6.4.3.4 (2016/03/11) String配列 から、Setに置き換えます。
143        private static final Set<String> COMMAND_SET = new ArraySet<>( CMD_ENTRY );
144
145        // 処理を行う、リソースの種類を指定します。(GEA03,GEA04,GEA08 のどれか)
146        private String  sqlType                 ;                       // INSERT,COPY,UPDATE,MODIFY,DELETE
147        private String  resourceType    ;
148        private int             resTypeColNo    = -1;
149        private String  conditionKey    ;                       // 条件判定するカラムIDを指定(初期値は columnId )
150        private String  conditionList   ;                       // 条件判定する値のリストを、"|"で区切って登録(初期値は、無条件) 7.0.1.8 (2019/01/28) 正規表現に変更
151        private boolean selectedAll             ;
152        private boolean commitTableModel= true;         // 4.0.2.0 (2007/12/25)
153        private boolean followCdkh              ;                       // 4.3.2.0 (2008/09/09).
154        private boolean quotCheck               ;                       // 5.1.7.0 (2010/06/01) quotCheckを指定できるようにする。※但し、初期値はfalse固定。タイミングを見て修正要
155
156        /**
157         * デフォルトコンストラクター
158         *
159         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
160         */
161        public TableUpdateTag() { super(); }            // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
162
163        /**
164         * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
165         *
166         * @og.rev 4.0.0.0 (2007/11/14) 0件の場合でもstartQueryTransactionを通すように変更
167         * @og.rev 5.1.7.0 (2010/06/01) quotCheckを指定できるようにする。※但し、初期値はfalse固定。
168         * @og.rev 6.3.4.0 (2015/08/01) caseKey,caseVal,caseNN,caseNull,caseIf 属性対応
169         *
170         * @return      後続処理の指示( EVAL_BODY_BUFFERED )
171         */
172        @Override
173        public int doStartTag() {
174                if( !useTag() ) { return SKIP_BODY ; }  // 6.3.4.0 (2015/08/01)
175                dyStart = System.currentTimeMillis();
176
177                table = (DBTableModel)getObject( tableId );
178                startQueryTransaction( tableId );               // 4.0.0.0 (2007/11/14) 0件の場合でもdoEndでPAGE_SKIPしないように位置変更。
179                if( table == null || table.getRowCount() == 0 ||
180                        ! check( command, COMMAND_SET ) ) { return SKIP_BODY ; }
181                super.quotCheck = quotCheck;
182
183                return EVAL_BODY_BUFFERED ;     // Body を評価する。( extends BodyTagSupport 時)
184        }
185
186        /**
187         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
188         *
189         * @og.rev 4.0.0.0 (2007/10/18) メッセージリソース統合( getResource().getMessage ⇒ getResource().getLabel )
190         * @og.rev 6.3.4.0 (2015/08/01) caseKey,caseVal,caseNN,caseNull,caseIf 属性対応
191         * @og.rev 6.4.1.2 (2016/01/22) QueryTag.errMsgId  → QueryTag.ERR_MSG_ID  refactoring
192         * @og.rev 6.9.9.0 (2018/08/20) 「ERR0041:検索処理中に割り込みの検索要求がありました」エラーを、標準のErrorMessageに追加するようにします。
193         * @og.rev 7.0.7.0 (2019/12/13) useSLabel 属性を追加。
194         *
195         * @return      後続処理の指示
196         */
197        @Override
198        public int doEndTag() {
199                debugPrint();
200                if( !useTag() ) { return EVAL_PAGE ; }  // 6.3.4.0 (2015/08/01)
201
202                String label  = "";                             // 4.0.0 (2005/11/30) 検索しなかった場合。
203                if( check( command, COMMAND_SET ) ) {
204                        final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE );
205                        if( executeCount > 0 && displayMsg != null && displayMsg.length() > 0 ) {
206                                buf.append( executeCount )
207                                        .append( getResource().getLabel( displayMsg ) )
208                                        .append( BR );
209                        }
210
211                        // 6.9.9.0 (2018/08/20) 「ERR0041:検索処理中に割り込みの検索要求がありました」エラーを、標準のErrorMessageに追加するようにします。
212                        if( table != null && ! commitTableObject( tableId, table ) ) {
213                                if( errMessage == null ) { errMessage = new ErrorMessage( "TableUpdateTag Query Error!" ); }
214                                // ERR0041:検索処理中に割り込みの検索要求がありました。処理されません。
215                                errMessage.addMessage( 0,ErrorMessage.NG,"ERR0041" );   
216                                errCode = ErrorMessage.NG;
217                        }
218
219//                      final String err = TaglibUtil.makeHTMLErrorTable( errMessage,getResource() );
220                        final String err = TaglibUtil.makeHTMLErrorTable( errMessage,getResource(),useSLabel );         // 7.0.7.0 (2019/12/13)
221                        if( err != null && err.length() > 0 ) {
222                                buf.append( err );
223                                // 6.4.1.2 (2016/01/22) QueryTag.errMsgId  → QueryTag.ERR_MSG_ID  refactoring
224                                setSessionAttribute( ERR_MSG_ID,errMessage );
225                        }
226                        else {
227                                // 6.4.1.2 (2016/01/22) QueryTag.errMsgId  → QueryTag.ERR_MSG_ID  refactoring
228                                removeSessionAttribute( ERR_MSG_ID );
229                        }
230                        label = buf.toString();
231
232//                      // 6.9.9.0 (2018/08/20) 「ERR0041:検索処理中に割り込みの検索要求がありました」エラーを、標準のErrorMessageに追加するようにします。
233//                      if( table != null && ! commitTableObject( tableId, table )  ) {
234//                              // 3.6.0.8 (2004/11/19) トランザクションチェックを行います。
235//                              jspPrint( "TableUpdateTag Query処理が割り込まれました。DBTableModel は登録しません。" );
236//                              return SKIP_PAGE ;
237//                      }
238                }
239
240                jspPrint( label );
241
242                // セキュリティチェック(データアクセス件数登録)
243                final long dyTime = System.currentTimeMillis()-dyStart;
244                final GUIInfo guiInfo = (GUIInfo)getSessionAttribute( HybsSystem.GUIINFO_KEY );
245                if( guiInfo != null ) { guiInfo.addWriteCount( executeCount,dyTime,sql ); }
246
247                if( useTimeView ) {             // 6.3.6.0 (2015/08/16)
248                        jspPrint( "<div id=\"queryTime\" value=\"" + (dyTime) + "\"></div>" );  // 3.5.6.3 (2004/07/12)
249                }
250                return errCode >= ErrorMessage.NG ? SKIP_PAGE : EVAL_PAGE ;
251        }
252
253        /**
254         * タグリブオブジェクトをリリースします。
255         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
256         *
257         * @og.rev 4.0.2.0 (2007/12/25) commitTableModel追加
258         * @og.rev 4.1.2.0 (2008/03/12) sqlType追加
259         * @og.rev 5.1.7.0 (2010/06/01) quotCheckを指定できるようにする。※但し、初期値はfalse固定。
260         */
261        @Override
262        protected void release2() {
263                super.release2();
264                sqlType                 = null;         // INSERT,COPY,UPDATE,MODIFY,DELETE
265                resourceType    = null;
266                resTypeColNo    = -1;
267                conditionKey    = null;         // 条件判定するカラムIDを指定(初期値は columnId )
268                conditionList   = null;         // 条件判定する値のリストを、"|"で区切って登録(初期値は、無条件) 7.0.1.8 (2019/01/28) 正規表現に変更
269                selectedAll             = false;
270                commitTableModel= true;         // 4.0.2.0 (2007/12/25)
271                followCdkh              = false;        // 4.3.2.0 (2008/09/09)
272                quotCheck               = false;        // 5.1.7.0 (2010/06/01)
273        }
274
275        /**
276         * Query を実行します。
277         *
278         * @og.rev 4.0.2.0 (2007/12/25) commitTableModel追加
279         * @og.rev 6.3.6.1 (2015/08/28) close(),realClose() 廃止。Queryはキャッシュしません。
280         *
281         * @param   query オブジェクト
282         */
283        @Override
284        protected void execute( final Query query ) {
285
286                        final int[] rowNo = getParameterRows();         // 4.0.0 (2005/01/31)
287                        if( rowNo.length > 0 ) {
288                                query.execute( rowNo,table );
289
290                                errCode = query.getErrorCode();
291                                errMessage = query.getErrorMessage();
292
293                                // リソースクリア処理
294                                if( resourceType != null ) {
295                                        resTypeColNo = table.getColumnNo( "CLM" );              // キーは、CLM
296                                }
297
298                                // 逆順にDELETEしないと、行番号がずれてしまう。
299                                int row;
300                                for( int j=rowNo.length-1; j>=0; j-- ) {
301                                        row = rowNo[j];
302                                        if( resTypeColNo >= 0 ) {
303                                                clearResourceData( table.getValue( row,resTypeColNo ) );                // リソースのクリア
304                                        }
305
306                                        if( commitTableModel ) {        // 4.0.2.0 (2007/12/25)
307                                                if( DBTableModel.DELETE_TYPE.equals( table.getModifyType( row ) ) ) {
308                                                        table.removeValue( row );
309                                                }
310                                                else {
311                                                        table.resetModify( row );
312                                                }
313                                        }
314                                }
315                        }
316        }
317
318        /**
319         * 表示データの HybsSystem.ROW_SEL_KEY を元に、選ばれた 行番号の
320         * 配列を返します。
321         * ここでは、conditionKey に値が設定されている場合は、そのカラムの値が
322         * conditionList にマッチする場合のみ対象選択行として返します。
323         * 値がセットされていない場合は、通常のCommonTagSupport#getParameterRows()
324         * が呼ばれます。
325         * なにも選ばれていない場合は、サイズ0の配列を返します。
326         *
327         * @og.rev 4.3.2.0 (2008/09/09) followCdkh属性対応
328         * @og.rev 7.0.1.8 (2019/01/28) conditionListの判定を、正規表現に変更
329         *
330         * @return       (選ばれていない場合は、サイズ0の配列を返す)
331         * @og.rtnNotNull
332         */
333        @Override
334        protected int[] getParameterRows() {
335                int[] rowNo ;
336                if( selectedAll ) {
337                        final int rowCnt = table.getRowCount();         // 3.5.5.7 (2004/05/10)
338                        rowNo = new int[ rowCnt ];
339                        for( int i=0; i<rowCnt; i++ ) {
340                                rowNo[i] = i;
341                        }
342                } else {
343                        rowNo = super.getParameterRows();               // 4.0.0 (2005/01/31)
344                }
345
346                // 7.0.1.8 (2019/01/28) conditionListの判定を、正規表現に変更
347//              if( conditionKey != null ) {
348                if( conditionKey != null && conditionList != null ) {                   // 7.0.1.8 (2019/01/28)
349                        final int col = table.getColumnNo( conditionKey );
350                        final List<Integer> list = new ArrayList<>();
351                        final Pattern ptn = Pattern.compile( conditionList );           // 7.0.1.8 (2019/01/28)
352                        for( int i=0; i<rowNo.length; i++ ) {
353//                              final String val = "|" + table.getValue( rowNo[i],col ) + "|";
354//                              if( conditionList.indexOf( val ) >= 0 ) {
355//                                      list.add( Integer.valueOf( rowNo[i] ) );
356//                              }
357                                final String val = nval( table.getValue( rowNo[i],col ) , "" );         // 7.0.1.8 (2019/01/28)
358                                if( ptn.matcher( val ).matches() ) {
359                                        list.add( Integer.valueOf( rowNo[i] ) );
360                                }
361                        }
362
363                        final int size = list.size();
364                        rowNo = new int[size];
365                        for( int i=0; i<size; i++ ) {
366                                rowNo[i] = list.get(i).intValue();
367                        }
368                }
369
370                // 4.3.2.0 (2008/09/09)
371                if( sqlType != null && sqlType.length() > 0 && followCdkh ) {
372                        final List<Integer> flist = new ArrayList<>();
373                        for( int i=0; i<rowNo.length; i++ ) {
374                                final String cdkh = table.getModifyType( rowNo[i] );
375//                              if( ( ( "INSERT".equals( sqlType ) || "COPY".equals( sqlType ) )
376//                                                      && DBTableModel.INSERT_TYPE.equals( cdkh ) )
377//                                      ||
378//                                      ( ( "UPDATE".equals( sqlType ) || "CHANGE".equals( sqlType ) )
379//                                                      && DBTableModel.UPDATE_TYPE.equals( cdkh ) )
380//                                      ||
381//                                      (   "DELETE".equals( sqlType )
382//                                                      && DBTableModel.DELETE_TYPE.equals( cdkh ) ) ) {
383//                                      flist.add(  Integer.valueOf( rowNo[i] ) );
384//                              }
385                                // 6.9.7.0 (2018/05/14) PMD Useless parentheses.
386                                if(     ( "INSERT".equals( sqlType ) || "COPY".equals(   sqlType ) )    && DBTableModel.INSERT_TYPE.equals( cdkh )
387                                        ||      ( "UPDATE".equals( sqlType ) || "CHANGE".equals( sqlType ) )    && DBTableModel.UPDATE_TYPE.equals( cdkh )
388                                        ||        "DELETE".equals( sqlType )                                                                    && DBTableModel.DELETE_TYPE.equals( cdkh ) ) {
389                                                flist.add( Integer.valueOf( rowNo[i] ) );
390                                }
391                        }
392
393                        final int size = flist.size();
394                        rowNo = new int[size];
395                        for( int i=0; i<size; i++ ) {
396                                rowNo[i] = flist.get(i).intValue();
397                        }
398                }
399
400                return rowNo;
401        }
402
403        /**
404         * 【TAG】Query を発行する為のクラスIDを指定します({@og.doc03Link queryType 初期値:JDBCTableUpdate})。
405         *
406         * @og.tag
407         * 引数指定のINSERT/UPDATE文を実行する場合の、queryType 属性を使用します。
408         * このタグでは、execute( int[] ,DBTableModel )を実行します。
409         * 代表的なクラスとして、"JDBCTableUpdate" が標準で用意されています。
410         *
411         * タグにより使用できる/出来ないがありますが、これは、org.opengion.hayabusa.db
412         * 以下の Query_**** クラスの **** を与えます。
413         * これらは、Query インターフェースを継承したサブクラスです。
414         * {@og.doc03Link queryType Query_**** クラス}
415         *
416         * @param       id Queryタイプ
417         * @see         org.opengion.hayabusa.db.Query  Queryのサブクラス
418         * @see         org.opengion.hayabusa.db.Query#execute( int[] ,DBTableModel )
419         */
420        @Override
421        public void setQueryType( final String id ) {
422                super.setQueryType( nval( id,"JDBCTableUpdate" ) );
423        }
424
425        /**
426         * resourceType が設定されたときのみ使用される、キャッシュの初期化メソッドです。
427         *
428         * @param       key     初期化を行うキー
429         */
430        private void clearResourceData( final String key ) {
431                getResource().clear( key );
432        }
433
434        /**
435         * 【特殊】クリアするリソースの種類[GEA03/GEA04/GEA08]を指定します。
436         *
437         * @og.tag
438         * 注意:この属性は、リソース関連DBのメンテナンス時にのみ、内部リソースキャッシュを
439         * クリアする目的で使用します。一般の属性としては、使用することはないため、
440         * ご注意ください。
441         * リソース関連のテーブルを更新した場合、リソースキャッシュをクリアして
442         * 置かないと、データベースの値が反映されません。
443         * 昔は、リソースの更新ごとに、全件クリアしていましたが、部分クリアが
444         * できるようになったため、部分クリアを行います。
445         * こでは、(GEA03,GEA04,GEA08) のどれかを指定してください。
446         *
447         * @param       type    クリアリソースタイプ [GEA03/GEA04/GEA08]
448         */
449        public void setResourceType( final String type ) {
450                resourceType = nval( getRequestParameter(type),resourceType );
451
452                if( resourceType != null &&
453                        "|GEA03|GEA04|GEA08|".indexOf( "|" + resourceType + "|" ) < 0 ) {
454                                final String errMsg = "resourceTypeは GEA03,GEA04,GEA08 のどれかです。"
455                                                        + "resourceType=" + type ;
456                                throw new HybsSystemException( errMsg );
457                }
458        }
459
460        /**
461         * 【TAG】条件判定するカラムIDを指定します(初期値:null)。
462         *
463         * @og.tag
464         * 指定のカラムIDの値と、conditionList の値を比較して、
465         * 存在する場合は、Query 処理を実行します。
466         * 例えば、conditionKey="CDKH" として、conditionList="A" とすれば、
467         * 改廃コードが"A"のデータで、かつ選択されたデータのみを処理します。
468         * 設定しない場合は、通常の処理と同様に、選択行のみ処理されます。
469         *
470         * @param       key 条件判定カラム
471         * @see         #setConditionList( String )
472         */
473        public void setConditionKey( final String key ) {
474                conditionKey = nval( getRequestParameter( key ),null ) ;
475        }
476
477        /**
478         * 【TAG】条件判定する値のリストを、"|"で区切って登録します(初期値:無条件)。
479         *
480         * @og.tag
481         * conditionKey とペアで指定します。ここには、カラムの設定値のリストを
482         * 指定することで、複数条件(OR結合)での比較を行い、リストにカラム値が
483         * 存在する場合のみ、Query 処理を実行します。
484         * 値が設定されている場合は、その値とマッチする必要があります。なにもセット
485         * されない場合、または、null の場合は、null データとマッチする場合のみ処理
486         * されますので、ご注意ください。
487         *
488         * @og.rev 7.0.1.8 (2019/01/28) conditionListの判定を、正規表現に変更
489         *
490         * @param       list    条件判定値 ("|"区切のリスト)
491         * @see         #setConditionKey( String )
492         */
493        public void setConditionList( final String list ) {
494//              conditionList = "|" + nval( getRequestParameter( list ),"" ) + "|" ;
495                conditionList = nval( getRequestParameter( list ),"" ) ;
496        }
497
498        /**
499         * 【TAG】データを全件選択済みとして処理するかどうか[true/false]を指定します(初期値:false)。
500         *
501         * @og.tag
502         * 全てのデータを選択済みデータとして扱って処理します。
503         * 全件処理する場合に、(true/false)を指定します。
504         * 初期値は false です。
505         *
506         * @param  all データを全件選択済み [true:全件選択済み/false:通常]
507         */
508        public void setSelectedAll( final String all ) {
509                selectedAll = nval( getRequestParameter( all ),selectedAll );
510        }
511
512        /**
513         * 【特殊】SQL実行後に結果をDBTableModelに反映させるかどうか[true/false]を指定します(初期値:true)。
514         *
515         * @og.tag
516         * 注意:この属性は、リソース関連DBのメンテナンス時に、複数DBへの登録を行うための、
517         * 暫定対応として定義しています。
518         * falseにした場合は、実データとDBTableModelの整合性が取れなくなるため、使用には十分注して下さい。
519         * 初期値は true です。
520         *
521         * @og.rev 4.0.2.0 (2007/12/25) 新規作成
522         *
523         * @param  commitTblMdl 反映有無 [true:反映する/false:反映しない]
524         */
525        public void setCommitTableModel( final String commitTblMdl ) {
526                commitTableModel = nval( getRequestParameter( commitTblMdl ),commitTableModel );
527        }
528
529        /**
530         * 引数の名称配列。
531         *
532         * @return      名称配列
533         */
534        protected String[] getNames() {
535                return table.getNames() ;
536        }
537
538        /**
539         * 【TAG】BODY部に書かれている Param の SQLタイプを指定します。
540         *
541         * @og.tag
542         * TableUpdateParamTag は、上位の TableUpdateTag の sqlType 属性 と同じ
543         * sqlType 属性の場合のみ、SQL文を合成・出力します。
544         * つまり、TableUpdateTag側のsqlType 属性をパラメータに、TableUpdateParamTag
545         * の sqlType 属性を固定値にすることで、どのパラメータを使用するかを
546         * 選択できる機能を実現する事が可能です。
547         *
548         * @og.rev 4.1.2.0 (2008/03/12) 新規追加
549         *
550         * @param       type SQLタイプ
551         */
552        public void setSqlType( final String type ) {
553                sqlType = nval( getRequestParameter( type ),sqlType );
554        }
555
556        /**
557         * 【TAG】DBTableModelの改廃Cに従って処理を行うかを指定します。
558         *
559         * @og.tag
560         * この属性は、sqlTypeが指定されている場合のみ有効です。
561         * sqlTypeが指定されている場合、そのsqlTypeに対応した、改廃Cが設定されている
562         * 行のみを処理します。
563         * 対応関係は、以下の通りです。
564         *  sqlType = "INSERT" or "COPY" ⇒ 改廃C='A'のみ処理
565         *  sqlType = "UPDATE" or "CHANGE" ⇒ 改廃C='C'のみ処理
566         *  sqlType = "DELETE" ⇒ 改廃C='D'のみ処理
567         *
568         * @og.rev 4.3.2.0 (2008/09/09) 新規追加
569         *
570         * @param       flag 改廃C処理 [true:行う/false:行わない]
571         */
572        public void setFollowCdkh( final String flag ) {
573                followCdkh = nval( getRequestParameter( flag ),followCdkh );
574        }
575
576        /**
577         * 【TAG】リクエスト情報の シングルクォート(') 存在チェックを実施するかどうか[true/false]を設定します(初期値:false)。
578         *
579         * @og.tag
580         * SQLインジェクション対策の一つとして、暫定的ではありますが、SQLのパラメータに
581         * 渡す文字列にシングルクォート(') を許さない設定にすれば、ある程度は防止できます。
582         * 数字タイプの引数には、 or 5=5 などのシングルクォートを使用しないコードを埋めても、
583         * 数字チェックで検出可能です。文字タイプの場合は、必ず (')をはずして、
584         * ' or 'A' like 'A のような形式になる為、(')チェックだけでも有効です。
585         * (') が含まれていたエラーにする(true)/かノーチェックか(false)を指定します。
586         * ※(他のタグは、システムリソースのUSE_SQL_INJECTION_CHECK[={@og.value SystemData#USE_SQL_INJECTION_CHECK}])
587         * ですが、JSPの互換性を考慮し、初期値を固定でfalseにしています)
588         *
589         * @og.rev 5.1.7.0 (2010/06/01) 新規追加
590         *
591         * @param   flag クォートチェック [true:する/それ以外:しない]
592         */
593        @Override
594        public void setQuotCheck( final String flag ) {
595                quotCheck = nval( getRequestParameter( flag ),quotCheck );
596        }
597
598        /**
599         * SQLタイプを返します。
600         *
601         * @og.rev 4.1.2.0 (2008/03/12) 新規追加
602         *
603         * @return      SQLタイプ
604         */
605        protected String getSqlType() {
606                return sqlType ;
607        }
608
609        /**
610         * このオブジェクトの文字列表現を返します。
611         * 基本的にデバッグ目的に使用します。
612         *
613         * @og.rev 4.0.2.0 (2007/12/25) resourceColumn、commitTableModel追加
614         *
615         * @return このクラスの文字列表現
616         * @og.rtnNotNull
617         */
618        @Override
619        public String toString() {
620                return ToString.title( this.getClass().getName() )
621                                .println( "VERSION"                     ,VERSION                )
622                                .println( "resourceType"        ,resourceType   )
623                                .println( "resTypeColNo"        ,resTypeColNo   )
624                                .println( "conditionKey"        ,conditionKey   )
625                                .println( "conditionList"       ,conditionList  )
626                                .println( "followCdkh"          ,followCdkh             )
627                                .println( "CMD_ENTRY"           ,CMD_ENTRY              )
628                                .println( "commitTabelModel",commitTableModel )         // 4.0.2.0 (2007/12/25)
629                                .println( "sql"                         ,sql                    )               // 4.1.2.0 (2008/03/12)
630                                .println( "Other..."    ,getAttributes().getAttribute() )
631                                .fixForm().toString()
632                        + CR
633                        + super.toString() ;
634        }
635}