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 org.opengion.hayabusa.common.HybsSystem;
019import org.opengion.hayabusa.common.HybsSystemException;
020import org.opengion.hayabusa.db.DBTableModel;
021import org.opengion.hayabusa.db.TableFilter;
022import org.opengion.hayabusa.html.ViewMarker;                                   // 8.0.0.0 (2021/09/30)
023import org.opengion.fukurou.db.Transaction;
024import org.opengion.fukurou.util.ErrorMessage;
025import org.opengion.fukurou.util.StringUtil;
026import org.opengion.fukurou.util.ToString;                                              // 6.1.1.0 (2015/01/17)
027
028import static org.opengion.fukurou.util.StringUtil.nval ;
029
030import java.util.concurrent.ConcurrentMap;                                              // 6.4.3.3 (2016/03/04)
031import java.util.Map;                                                                                   // 7.4.0.1 (2021/04/16)
032
033/**
034 * TableFilter のサブクラスをCALLしてDBTableModelにアクセスするタグです。
035 *
036 * DBTableModel を TableFilter のサブクラス(classIdで指定)に渡して処理を実行します。
037 * クラスを作成する場合は、org.opengion.hayabusa.db.TableFilter インターフェースを継承した
038 * クラスにする必要があります。また、classId 属性には、システムリソース で
039 * 設定した TableFilter.XXXX の XXXX を指定します。
040 *
041 * BODY部分は、SQLを記述する為だけに使っていましたが、CSS定義形式の書式で、keys,vals を記述
042 * できるようにします。
043 * これは、下記のようなパラメータを、keys="KEY,KEY2,KEY3" vals='AAAA,"BB,CC,DD",EE' のような記述形式と
044 *   {
045 *        KEY1 : AAAA ;
046 *        KEY2 : BB,CC,DD ;
047 *        KEY3 : EE ;
048 *        ・・・・・・
049 *   }
050 * のような、CSS形式に類似の形式でも記述できるようにしました。
051 * keys,vals と CSS定義形式パラメータを同時に指定した場合は、両方とも有効です。
052 * ただし、キーが重複した場合は、不定と考えてください。
053 * 現時点では、CSS定義形式パラメータが優先されますが、これは、単に内部パラメータMapへの
054 * 登録順が、CSS定義形式パラメータが後の為、上書きされるためです。
055 *
056 * ※ このタグは、Transaction タグの対象です。
057 *
058 * @og.formSample
059 * ●形式:<og:tableFilter classId="…" />
060 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します)
061 *
062 * ●Tag定義:
063 *   <og:tableFilter
064 *       classId          ○【TAG】データベース処理を実行するクラスパスを指定します(必須)。
065 *       tableId            【TAG】(通常は使いません)DBTableModel sessionに登録されているキーを指定します
066 *       viewMarkerId       【TAG】(通常は使いません)requestから取得する ViewMarker に対応する Attributes オブジェクトの ID
067 *       modifyType         【TAG】データ処理の方法(A:追加 C:更新 D:削除)を指定します
068 *       keys               【TAG】リンク先に渡すキーを指定します
069 *       vals               【TAG】keys属性に対応する値をCSV形式で複数指定します
070 *       selectedAll        【TAG】データを全件選択済みとして処理するかどうか[true/false]を指定します(初期値:false)
071 *       stopZero           【TAG】検索結果が0件のとき処理を続行するかどうか[true/false]を指定します(初期値:false[続行する])
072 *       scope              【TAG】キャッシュする場合のスコープ[request/page/session/application]を指定します(初期値:session)
073 *       dbid               【TAG】(通常は使いません)Queryオブジェクトを作成する時のDB接続IDを指定します
074 *       useSLabel          【TAG】7.0.7.0 (2019/12/13) エラーメッセージにSLABELを利用するかどうか[true/false]を指定します(初期値:false)
075 *       caseKey            【TAG】このタグ自体を利用するかどうかの条件キーを指定します(初期値:null) 5.7.7.2 (2014/06/20)
076 *       caseVal            【TAG】このタグ自体を利用するかどうかの条件値を指定します(初期値:null) 5.7.7.2 (2014/06/20)
077 *       caseNN             【TAG】指定の値が、null/ゼロ文字列 でない場合(Not Null=NN)は、このタグは使用されます(初期値:判定しない) 5.7.7.2 (2014/06/20)
078 *       caseNull           【TAG】指定の値が、null/ゼロ文字列 の場合は、このタグは使用されます(初期値:判定しない) 5.7.7.2 (2014/06/20)
079 *       caseIf             【TAG】指定の値が、true/TRUE文字列の場合は、このタグは使用されます(初期値:判定しない)
080 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
081 *   >   ... Body ...
082 *   </og:tableFilter>
083 *
084 * ●使用例
085 *    ・引数/プロシジャーを直接書く場合
086 *    【entry.jsp】
087 *        <og:tableFilter
088 *            classId     = "WL_LOGICSET"         :TableFilter のサブクラス(実行クラス)
089 *            tableId     = "WL0000"              :登録元のDBTableModelのsession/request変数内の取得キー
090 *            keys        = "AA,BB,CC"            :実行クラスへの引数のキー
091 *            vals        = "{@AA},{@BB},{@CC}"   :実行クラスへの引数の値
092 *            selectedAll = "false/true"          :処理対象の行を全行選択するかどうか(初期値:false)
093 *            modifyType  = "A/C/D"               :処理の方法(A:追加 C:更新 D:削除)を指定します。初期値は自動です。
094 *        />
095 *
096 *    ・BODY部分に、CSS形式のパラメータ(keys,vals)を記述する例
097 *
098 *        <og:tableFilter
099 *            classId     = "WL_LOGICSET"         :TableFilter のサブクラス(実行クラス)
100 *            tableId     = "WL0000"              :登録元のDBTableModelのsession/request変数内の取得キー
101 *            selectedAll = "false/true"          :処理対象の行を全行選択するかどうか(初期値:false)
102 *            modifyType  = "A/C/D"               :処理の方法(A:追加 C:更新 D:削除)を指定します。初期値は自動です。
103 *        >
104 *               {
105 *                   AA    :  {@AA}
106 *                   BB    :  {@BB}
107 *                   CC    :  {@CC}
108 *               }
109 *        </og:tableFilter>
110 *
111 * @og.group その他
112 * @og.rev 3.8.5.0 (2006/03/20) 新規作成
113 *
114 * @version  0.9.0  2000/10/17
115 * @author   Kazuhiko Hasegawa
116 * @since    JDK1.1,
117 */
118public class TableFilterTag extends CommonTagSupport {
119        /** このプログラムのVERSION文字列を設定します。   {@value} */
120        private static final String VERSION = "8.0.0.0 (2021/10/01)" ;
121        private static final long serialVersionUID = 800020211001L ;
122
123        private static final String ERR_MSG_ID  = HybsSystem.ERR_MSG_KEY;               // 6.4.1.1 (2016/01/16) errMsgId  → ERR_MSG_ID  refactoring
124        private transient DBTableModel  table   ;
125
126        private String          tableId         = HybsSystem.TBL_MDL_KEY;
127        private String          viewMarkerId= HybsSystem.VIEW_MARK_KEY;                         // 8.0.0.0 (2021/09/30)
128        private String          classId         ;
129        private String          modifyType      ;
130        private String[]        keys            ;
131        private String[]        vals            ;
132
133        private   String        dbid            ;       // 4.2.4.0 (2008/06/23)
134        private   String        sql                     ;       // 5.6.5.2 (2013/06/21) bodyからSQL文のみを切り出す。
135        /** 6.4.3.1 (2016/02/12) PMD refactoring. 取り出し元を HashMap → ConcurrentHashMap に置き換え。  */
136        private   ConcurrentMap<String,String>  paramMap;       // 5.6.5.2 (2013/06/21) bodyからparamMapを取りだし。
137
138        private boolean         selectedAll     ;
139        private boolean         stopZero        ;       // 5.7.6.2 (2014/05/16) stopZero属性追加
140        private boolean         useSLabel       ;       // 7.0.7.0 (2019/12/13) エラーメッセージにSLABELを利用するかどうか[true/false]を指定します(初期値:false)
141
142        /**
143         * デフォルトコンストラクター
144         *
145         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
146         */
147        public TableFilterTag() { super(); }            // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
148
149        /**
150         * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
151         *
152         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
153         *
154         * @return      後続処理の指示( EVAL_BODY_BUFFERED )
155         */
156        @Override
157        public int doStartTag() {
158                // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
159                if( !useTag() ) { return SKIP_BODY ; }
160
161                table = (DBTableModel)getObject( tableId );
162
163                if( keys != null && vals != null && keys.length != vals.length ) {
164                        final String errMsg = "keys と vals の設定値の数が異なります。: " + CR
165                                                + "keys.length=[" + keys.length + "] , "
166                                                + "keys.length=[" + StringUtil.array2line( keys,"," ) + "]"
167                                                + CR
168                                                + "vals.length=[" + vals.length + "] , "
169                                                + "vals.length=[" + StringUtil.array2line( vals,"," ) + "]";
170                        throw new HybsSystemException( errMsg );
171                }
172
173                startQueryTransaction( tableId );
174                return EVAL_BODY_BUFFERED ;             // Body を評価する
175        }
176
177        /**
178         * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。
179         *
180         * @og.rev 5.6.5.2 (2013/06/21) bodyローカル化、sql、paramMap 追加
181         * @og.rev 5.6.5.2 (2013/06/21) bodyローカル化、sql、paramMap 追加
182         * @og.rev 8.0.0.0 (2021/10/01) ロジック間違い。DBSELECTのSQL文は、{}の中は処理しない
183         *
184         * @return      後続処理の指示(SKIP_BODY)
185         */
186        @Override
187        public int doAfterBody() {
188                final String body = nval( getBodyString(),null );
189
190                // paramMapの取り出し
191                paramMap = StringUtil.cssParse( body );
192
193                // SQL文の切り出し classId="DBSELECT" の場合のみの処理
194                if( "DBSELECT".equalsIgnoreCase( classId ) && body != null ) {
195                        final int ad1 = body.indexOf( '{' );
196                        final int ad2 = body.indexOf( '}' );
197
198                        // 8.0.0.0 (2021/10/01) DBSELECTの場合、{}の中を削除して、残りをSQL文として認識させる。{} は最大1組とする。
199                        if( ad1 >= 0 && ad2 >= 0 ) {
200                                sql = new StringBuilder( body ).delete( ad1,ad2 ).toString().trim();            // {} の間を削除する。
201        //                      sql = body.substring( 0,ad1 ).trim() + body.substring( ad2+1 ).trim();
202                        }
203                        else {
204                                sql = body.trim();
205                        }
206                }
207
208                return SKIP_BODY ;
209        }
210
211        /**
212         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
213         *
214         * @og.rev 3.8.7.0 (2006/12/15) アクセスログ取得の為,ApplicationInfoオブジェクトを設定
215         * @og.rev 4.2.3.0 (2008/06/23) DBIDとボディー部分の記述を下位クラスに渡す用に修正
216         * @og.rev 4.3.7.4 (2009/07/01) Resouceオブジェクトを下位クラスに渡す用に修正
217         * @og.rev 5.1.9.0 (2010/08/01) Transaction 対応
218         * @og.rev 5.2.1.0 (2010/10/01) debugPrint() メソッドの処理条件見直し
219         * @og.rev 5.3.7.0 (2011/07/01) TransactionReal の引数変更 、Transaction対応で、close処理を入れる。
220         * @og.rev 5.6.5.2 (2013/06/21) bodyローカル化、sql、paramMap 追加
221         * @og.rev 5.7.6.2 (2014/05/16) table件数が変わる場合、"DB.COUNT" キーでリクエストに再セットする。
222         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
223         * @og.rev 6.0.4.0 (2014/11/28) NullPointerException が発生するので、事前にチェックします。
224         * @og.rev 6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。
225         * @og.rev 6.4.3.3 (2016/03/04) HybsSystem.newInstance(String,String) への置き換え。
226         * @og.rev 7.0.7.0 (2019/12/13) useSLabel 属性を追加。
227         * @og.rev 8.0.0.0 (2021/09/30) viewMarker追加
228         *
229         * @return      後続処理の指示
230         */
231        @Override
232        public int doEndTag() {
233                // デバッグ時には、オブジェクト内部情報を表示する。
234                debugPrint();   // 5.2.1.0 (2010/10/01) debugPrint() メソッド自体に、isDebug() が組み込まれている。
235
236                // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
237                if( !useTag() ) { return EVAL_PAGE ; }
238
239                int rtnCode = EVAL_PAGE;        // try ~ finally の関係で、変数化しておく
240
241                final int[] rowNo = getParameterRows();
242
243                // 5.1.9.0 (2010/08/01) Transaction 対応
244                // 5.3.7.0 (2011/07/01) Transaction対応で、close処理を入れる。
245
246                // 6.3.6.1 (2015/08/28) Transaction でAutoCloseableを使用したtry-with-resources構築に対応。
247                try( Transaction tran = getTransaction() ) {
248
249                        final TableFilter filter = HybsSystem.newInstance( "TableFilter_" , classId );
250
251                        filter.setDBTableModel( table );
252                        filter.setParameterRows( rowNo );
253                        filter.setModifyType( modifyType );
254                        filter.setKeysVals( keys,vals );
255        //              filter.setApplicationInfo( getApplicationInfo() );      // 3.8.7.0 (2006/12/15)
256                        filter.setTransaction( tran );                                          // 5.1.9.0 (2010/08/01) Transaction 対応
257                        filter.setDebug( isDebug() );
258                        filter.setDbid( dbid );                                 // 4.2.4.0 (2008/06/23)
259                        filter.setSql( sql );                                   // 5.6.5.2 (2013/06/21) sql 追加
260                        filter.setParamMap( paramMap );                 // 5.6.5.2 (2013/06/21) paramMap 追加
261                        filter.setResource( getResource() );    // 4.3.7.4 (2009/07/01)
262
263                        final ViewMarker viewMarker = (ViewMarker)getRequestAttribute( viewMarkerId );
264                        if( viewMarker != null ) {
265                                viewMarker.setDBTableModel( table ) ;
266                                filter.setViewMarker( viewMarker );             // 8.0.0.0 (2021/09/30)
267                        }
268
269                        // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point.
270                        final int rowCnt1 = table == null ? -1 : table.getRowCount();   // filter 処理の前の行件数をチェック
271
272                        table = filter.execute();
273
274                        // 7.4.0.1 (2021/04/16) filterからの値の戻し
275                        for( final Map.Entry<String,String> entry : filter.getReturnMap().entrySet() ) {
276                                setRequestAttribute( entry.getKey() , entry.getValue() );
277                        }
278
279                        // 5.7.6.2 (2014/05/16) table件数が変わる場合、"DB.COUNT" キーでリクエストに再セットする。
280                        final int rowCnt2 = table == null ? -1 : table.getRowCount();
281                        if( rowCnt1 != rowCnt2 ) {
282                                setRequestAttribute( "DB.COUNT" , String.valueOf( rowCnt2 ) );
283                        }
284
285                        final int errCode = filter.getErrorCode();
286
287                        if( errCode >= ErrorMessage.NG )  {     // 異常
288                                rtnCode = SKIP_PAGE;
289                        }
290
291                        // 5.7.6.2 (2014/05/16) 件数0件(または、table==null)かつ stopZero = true
292                        if( rowCnt2 <= 0 && stopZero ) { return SKIP_PAGE; }
293
294                        // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid declaring a variable if it is unreferenced before a possible exit point.
295                        final ErrorMessage errMessage = filter.getErrorMessage();
296//                      final String err = TaglibUtil.makeHTMLErrorTable( errMessage,getResource() );
297                        final String err = TaglibUtil.makeHTMLErrorTable( errMessage,getResource(),useSLabel );         // 7.0.7.0 (2019/12/13)
298                        if( err != null && err.length() > 0 ) {
299                                jspPrint( err );
300                                setSessionAttribute( ERR_MSG_ID,errMessage );
301                        }
302                        else {
303                                removeSessionAttribute( ERR_MSG_ID );
304                        }
305                        tran.commit();                          // 6.3.6.1 (2015/08/28)
306                }
307
308                if( table != null && ! commitTableObject( tableId, table ) ) {
309                        rtnCode = SKIP_PAGE ;
310                }
311
312                return rtnCode ;
313        }
314
315        /**
316         * タグリブオブジェクトをリリースします。
317         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
318         *
319         * @og.rev 5.6.5.2 (2013/06/21) body廃止、sql、paramMap 追加
320         * @og.rev 5.7.6.2 (2014/05/16) stopZero属性追加
321         * @og.rev 7.0.7.0 (2019/12/13) useSLabel 属性を追加。
322         */
323        @Override
324        protected void release2() {
325                super.release2();
326                table           = null;
327                tableId         = HybsSystem.TBL_MDL_KEY;
328                classId         = null;
329                viewMarkerId= HybsSystem.VIEW_MARK_KEY;         // 8.0.0.0 (2021/09/30)
330                modifyType      = null;
331                keys            = null;
332                vals            = null;
333                selectedAll     = false;
334                stopZero        = false;        // 5.7.6.2 (2014/05/16) stopZero属性追加
335                dbid            = null;         // 4.2.4.0 (2008/06/23)
336                sql                     = null;         // 5.6.5.2 (2013/06/21) bodyからSQL文のみを切り出す。
337                paramMap        = null;         // 5.6.5.2 (2013/06/21) bodyからparamMapを取りだす。
338                useSLabel       = false;        // 7.0.7.0 (2019/12/13) エラーメッセージにSLABELを利用するかどうか[true/false]を指定します(初期値:false)
339        }
340
341        /**
342         * 表示データの HybsSystem.ROW_SEL_KEY を元に、選ばれた 行を処理の対象とします。
343         *
344         * @og.rev 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs)
345         *
346         * @return      選択行の配列
347         * @og.rtnNotNull
348         */
349        @Override
350        protected int[] getParameterRows() {
351                final int[] rowNo ;
352                // 6.3.9.0 (2015/11/06) コンストラクタで初期化されていないフィールドを null チェックなしで利用している(findbugs)
353                if( selectedAll && table != null ) {
354                        final int rowCnt = table.getRowCount();
355                        rowNo = new int[rowCnt];
356                        for( int i=0; i<rowCnt; i++ ) {
357                                rowNo[i] = i;
358                        }
359                } else {
360                        rowNo = super.getParameterRows();               // 4.0.0 (2005/01/31)
361                }
362                return rowNo;
363        }
364
365        /**
366         * 【TAG】データベース処理を実行するテーブルフィルターのクラスIDを指定します。
367         *
368         * @og.tag
369         * ここで指定するクラスIDは、システムリソース にて TableFilter の
370         * サブクラス(インターフェース継承)として指定する必要があります。
371         *
372         * クラス自身は、org.opengion.hayabusa.db.TableFilter インターフェースを継承している必要があります。
373         * {@og.doc03Link tableFilter TableFilter_**** クラス}
374         *
375         * @param       id 実行クラスID
376         * @see         org.opengion.hayabusa.db.TableFilter  TableFilter インターフェース
377         */
378        public void setClassId( final String id ) {
379                classId = nval( getRequestParameter( id ),classId );
380        }
381
382        /**
383         * 【TAG】(通常は使いません)結果のDBTableModelを、sessionに登録するときのキーを指定します
384         *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value HybsSystem#TBL_MDL_KEY}])。
385         *
386         * @og.tag
387         * 検索結果より、DBTableModelオブジェクトを作成します。これを、下流のviewタグ等に
388         * 渡す場合に、通常は、session を利用します。その場合の登録キーです。
389         * query タグを同時に実行して、結果を求める場合、同一メモリに配置される為、
390         * この tableId 属性を利用して、メモリ空間を分けます。
391         *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value HybsSystem#TBL_MDL_KEY}])。
392         *
393         * @param       id テーブルID (sessionに登録する時のID)
394         */
395        public void setTableId( final String id ) {
396                tableId = nval( getRequestParameter( id ),tableId );
397        }
398
399        /**
400         * 【TAG】(通常は使いません)requestから取得する ViewMarker に対応する Attributes オブジェクトの ID。
401         *
402         * @og.tag
403         * ViewForm オブジェクトに、ViewMarker オブジェクトをこのキーより取得することにより、
404         * カラムに対して、マーカー情報を付加して表示させる。
405         * 初期値は、HybsSystem.VIEW_MARK_KEY です。
406         *
407         * @og.rev 8.0.0.0 (2021/09/30) viewMarker追加
408         *
409         * @param       id ViewMarkerオブジェクトID
410         */
411        public void setViewMarkerId( final String id ) {
412                final String temp = getRequestParameter( id ) ;
413                if( temp != null && temp.length() > 0 ) {
414                        viewMarkerId = temp + TaglibUtil.MARK_ID;
415                }
416        }
417
418        /**
419         * 【TAG】データを全件選択済みとして処理するかどうか[true/false]を指定します(初期値:false)。
420         *
421         * @og.tag
422         * 全てのデータを選択済みデータとして扱って処理します。
423         * 全件処理する場合に、指定します。(true/false)
424         * デフォルト false です。
425         *
426         * @param  all 全件選択済み [true:全件選択済み/false:通常]
427         */
428        public void setSelectedAll( final String all ) {
429                selectedAll = nval( getRequestParameter( all ),selectedAll );
430        }
431
432        /**
433         * 【TAG】検索結果が0件のとき処理を停止するかどうか[true/false]を指定します(初期値:false[続行する])。
434         *
435         * @og.tag
436         * 初期値は、false(続行する)です。
437         *
438         * @og.rev 5.7.6.2 (2014/05/16) 新規追加
439         *
440         * @param  cmd 0件時停止可否 [true:処理を中止する/false:続行する]
441         */
442        public void setStopZero( final String cmd ) {
443                stopZero = nval( getRequestParameter( cmd ),stopZero );
444        }
445
446        /**
447         * 【TAG】データ処理の方法[A:追加/C:更新/D:削除]を指定します(初期値:自動判定)。
448         *
449         * @og.tag
450         * 通常は、DBTableModel に自動設定されている modifyType を元に、データ処理方法を
451         * 選別します。(A:追加 C:更新 D:削除)
452         * この場合、行単位で modifyType の値を取得して判別する必要がありますが、一般には
453         * 処理対象は、全件おなじ modifyType である可能性が高いです。
454         * また、selectedAll などで強制的に全件処理対象とする場合は、modifyType に値が
455         * 設定さていません。その様な場合に外部より modifyType を指定します。
456         * 初期値は、自動判定 です。
457         *
458         * @param  type 処理方法 [A:追加/C:更新/D:削除]
459         */
460        public void setModifyType( final String type ) {
461                modifyType = nval( getRequestParameter( type ),modifyType );
462
463                if( modifyType != null && !"A".equals( modifyType ) && !"C".equals( modifyType ) && !"D".equals( modifyType ) ) {
464                        final String errMsg = "modifyType は A:追加 C:更新 D:削除 のどれかを指定してください。: " + CR
465                                                + "modifyType=[" + modifyType + "]";
466                        throw new HybsSystemException( errMsg );
467                }
468        }
469
470        /**
471         * 【TAG】リンク先に渡すキーを指定します。
472         *
473         * @og.tag
474         * 戻る時に、検索時のキャッシュに指定した引数以外に指定したり、別の値に置き換えたり
475         * する場合のキーを設定できます。CSV形式で複数指定できます。
476         * vals 属性には、キーに対応する値を、設定してください。
477         * 分解方法は、CSV変数を先に分解してから、getRequestParameter で値を取得します。
478         * こうしないとデータ自身にカンマを持っている場合に分解をミスる為です。
479         *
480         * @param       key リンク先に渡すキー
481         */
482        public void setKeys( final String key ) {
483                keys = getCSVParameter( key );
484        }
485
486        /**
487         * 【TAG】names属性に対応する値をCSV形式で複数指定します。
488         *
489         * @og.tag
490         * キーに設定した値を、CSV形式で複数して出来ます。
491         * 指定順序は、キーと同じにしておいて下さい。
492         * 分解方法は、CSV変数を先に分解してから、getRequestParameter で値を取得します。
493         * こうしないとデータ自身にカンマを持っている場合に分解をミスる為です。
494         *
495         * @param       val names属性に対応する値 (CSV形式)
496         */
497        public void setVals( final String val ) {
498                vals = getCSVParameter( val );
499        }
500
501        /**
502         * 【TAG】(通常は使いません)Queryオブジェクトを作成する時のDB接続IDを指定します。
503         *
504         * @og.tag
505         * Queryオブジェクトを作成する時のDB接続IDを指定します。
506         * これは、システムリソースで、DEFAULT_DB_URL 等で指定している データベース接続先
507         * 情報に、XX_DB_URL を定義することで、 dbid="XX" とすると、この 接続先を使用して
508         * データベースにアクセスできます。
509         *
510         * @param       id データベース接続ID
511         */
512        public void setDbid( final String id ) {
513                dbid = nval( getRequestParameter( id ),dbid );
514        }
515
516        /**
517         * 【TAG】エラーメッセージにSLABELを利用するかどうか[true/false]を指定します(初期値:false)。
518         *
519         * @og.tag
520         * 通常のエラーメッセージは、ラベル(長)が使われますが、これをラベル(短)を使いたい場合に、true にセットします。
521         * ここでのラベル(短)は、タグ修飾なしの、ラベル(短)です。
522         * 標準はfalse:利用しない=ラベル(長)です。
523         * true/false以外を指定した場合はfalse扱いとします。
524         *
525         * ラベルリソースの概要説明があれば表示しますが、useSLabel="true" 時は、概要説明を表示しません。
526         *
527         * @og.rev 7.0.7.0 (2019/12/13) 新規追加
528         *
529         * @param prm SLABEL利用 [true:利用する/false:利用しない]
530         */
531        public void setUseSLabel( final String prm ) {
532                useSLabel = nval( getRequestParameter( prm ),useSLabel );
533        }
534
535        /**
536         * このオブジェクトの文字列表現を返します。
537         * 基本的にデバッグ目的に使用します。
538         *
539         * @return このクラスの文字列表現
540         * @og.rtnNotNull
541         */
542        @Override
543        public String toString() {
544                return ToString.title( this.getClass().getName() )
545                                .println( "VERSION"                     ,VERSION                )
546                                .println( "tableId"                     ,tableId                )
547                                .println( "classId"                     ,classId                )
548                                .println( "modifyType"          ,modifyType             )
549                                .println( "selectedAll"         ,selectedAll    )
550                                .println( "keys"                        ,keys                   )
551                                .println( "vals"                        ,vals                   )
552                                .println( "dbid"                        ,dbid                   ) // 4.2.4.0 (2008/06/23)
553                                .println( "sql"                         ,sql                    ) // 5.6.5.2 (2013/06/21)
554                                .fixForm().toString() ;
555        }
556}