001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.hayabusa.taglib;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.db.DBColumn;
020    import org.opengion.hayabusa.db.DBTableModel;
021    import org.opengion.fukurou.util.Attributes;
022    import org.opengion.fukurou.util.ErrorMessage;
023    import org.opengion.fukurou.model.ArrayDataModel;
024    import org.opengion.fukurou.model.Formatter;
025    
026    import static org.opengion.fukurou.util.StringUtil.nval ;
027    
028    import java.util.List;
029    import java.util.ArrayList;
030    import java.util.Enumeration;
031    import java.util.Locale ;
032    
033    import java.io.ObjectOutputStream;
034    import java.io.ObjectInputStream;
035    import java.io.IOException;
036    
037    /**
038     * 検索結果の DBTableModelオブジェクトに値を設定するタグですã?
039     *
040     * columnSet と共に使用する場合ã?、entryタグ の command属æ?と、columnSetタグ の command属æ?ã�?
041     * ä¸??した場合ã?み、å?ç�?�•れますã?
042     * entryタグは、そのコマンドにより、DBTableModelオブジェクトã?値を設定しますã?
043     * たとえã?、command="INSERT" ならã?ã€?¼‘行å?のãƒ??タを選択された行番号の次に挿入しますã?
044     * またã?追åŠ??変更、削除されたã?DBTableModelオブジェクãƒ?でもã?å†?ƒ¨にはå…??ãƒ??タã‚?
045     * 持ってã�?‚‹ため、command="RESET" でå…??状態に戻すことが可能ですã?
046     *
047     * @og.formSample
048     * ●形式ï¼?
049     *       ・<og:entry command="…">
050     *             <og:columnSet command="…" />
051     *         </og:entry>
052     *       ・<og:entry command="…" />
053     *             ?¥?¥?¥columnSetを使わなã�??合でもresult.jspから次画面(insert,modify,copy.jspç­?に
054     *                にDBTableModelをもってã�?��場合には、å¿?�š?’を書ã�?�¦くださいã€?
055     *                (取消ã?ときã?エンジンå†?�§DBTableModelを操作するã?に使用する為)
056     * ●body?šあã‚?EVAL_BODY_BUFFERED:BODYを評価しã?{@XXXX} を解析しまã�?
057     *
058     * ●Tag定義??
059     *   <og:entry
060     *       command          ○ã?TAG】コマンãƒ?INSERT/COPY/MODIFY/DELETE/ENTRY/CHANGE/RESET/ALLRESET/ALLACTION/RESETDATA/INSERTONE/REALDELETE/REQENTRY)を設定しまã�?å¿??)
061     *       scope              【TAG】キャãƒ?‚·ュする場合ã?スコープ[request/page/session/applicaton]を指定しまã�?初期値:session)
062     *       repeatCount        【TAG】指定ã?回数åˆ?� けã?繰り返し処ç�?‚’行う回数を指定しまã�?初期値:1)
063     *       tableId            【TAGã€?通常使ã�?�¾せん)sessionからæ‰?¾—すã‚?DBTableModelオブジェクトã? ID
064     *       useConsistency     【TAG】Consistency キー による整合æ?チェãƒ?‚¯を行うかどã�?�‹を指定しまã�?初期値:true)
065     *       selectedAll        【TAG】データをå?件選択済みとして処ç�?�™るかどã�?�‹[true/false]を指定しまã�?初期値:false)
066     *       strictCheck        【TAG】カラãƒ?¼©?¤の存在チェãƒ?‚¯を行うかどã�?�‹[true/false]を指定しまã�?初期値:true)
067     *       noTransition       【TAGã€?通常は使ã�?�¾せん)画面遷移を行わなã�?½¢式ã?登録方法を使用するかをæŒ?®šしまã�?
068     *       debug              【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
069     *   >   ... Body ...
070     *   </og:entry>
071     *
072     * ●使用ä¾?
073     *    <og:entry command="{@command}"  >
074     *        <og:columnSet command="{@command}" columnId="ECNO"   action="CLEAR" />
075     *        <og:columnSet command="{@command}" columnId="JYOKYO" action="SET" value="1" />
076     *    </og:entry>
077     *
078     *    <og:entry command="MODIFY" rows="1" >
079     *        <og:columnSet  command="MODIFY" columnId="key" action="TBLSET" value="[key][lang]"/>
080     *    </og:entry>
081     *
082     *    action="ADD" は、DBTypeに依存した方法で、既存ã?値をã??‹ï¼?しますã?
083     *    <og:entry command="{@command}" repeatCount="5" >
084     *        <og:columnSet  command="{@command}" columnId="YKNO" action="ADD" />
085     *    </og:entry>
086     *
087     *    action="ADD" は、DBTypeに依存した方法で、既存ã?値に、value の値を加算しますã?
088     *    <og:entry command="{@command}" repeatCount="5" >
089     *        <og:columnSet  command="{@command}" columnId="YKNO" action="ADD" value="5" />
090     *    </og:entry>
091     *
092     *    command属æ? は、columnSetタグのcommand属æ?と同ä¸??場合ã?み、å?ç�?�—ますã?
093     *    [command属æ?]
094     *      INSERT     新è¦?
095     *      COPY       �?
096     *      MODIFY     変更
097     *      DELETE     削除
098     *      ENTRY      エントリー
099     *      CHANGE     チェンジ
100     *      RESET      リセãƒ?ƒˆ
101     *      ALLRESET   全件リセãƒ?ƒˆ
102     *      ALLACTION  オールアクション
103     *      RESETDATA  リセãƒ?ƒˆãƒ??タ
104     *      INSERTONE  新è¦?1行ã?み)
105     *      REALDELETE 物ç�?‰Š除
106     *      REQENTRY   リクエスト変数設å®?
107     *
108     *    command属æ? は、columnSetタグでæŒ?®šしますã?
109     *    [action属æ?]
110     *      DEFAULT カラãƒ?ƒªソースで定義した初期値をセãƒ?ƒˆしますã?
111     *      CLEAR   値をクリア(ゼロストリング "" )しますã?
112     *      ADD     現在の値ã‚??‹ï¼?しますã?  0 â‡?1 , A â‡?B , 9 â‡?10。value属æ?と併用すれば、指定ã?値を加算できますã?
113     *      SET     value で設定したå?ã‚?新しい値として登録しますã?
114     *      NULLSET å…??値ã�?NULL の場合だけã?value で設定した新しい値を登録しますã?
115     *      LOWER   小文字に変換しますã?
116     *      UPPER   大æ–?­—に変換しますã?
117     *      COPY    value にコピã?å…??カラãƒ?Dをセãƒ?ƒˆすれば、その値を代入しますã?
118     *      TBLSET  DBTableModel のå†?®¹を取り込んでæŒ?®šã? columnId カラãƒ?�«設定しますã?[カラãƒ?��] でæŒ?®šできますã?
119     *              またã?これはæ–?­—å?を解析してã€?value を作æ?しますã?で,æ–?­—å?連結等に使用できますã?
120     *      WRTCTRL writableControl を使用したカラãƒ?ƒ‡ータの先é?アンãƒ??バã?を削除しますã?
121     *      DBMENU  DBMENUでパラメータ設å®?コロン連結文å­?を使用したカラãƒ?ƒ‡ータの先é?ãƒ??タのみにしますã?
122     *      REQSET  valueでæŒ?®šしたカラãƒ??値をキーに、リクエスト変数から値を取出しã?セãƒ?ƒˆしますã?
123     *      SEQSET  valueの初期値を利用してã€?¼‘レコードごとにã€?¼‹1したå?をセãƒ?ƒˆしますã?
124     *      PREFIX  valueの値を後ろから検索しã?æŒ?®šã?カラãƒ??の前半部åˆ?‚’取得しまã�?記号は含みません)ã€?
125     *      SUFIX   valueの値を後ろから検索しã?æŒ?®šã?カラãƒ??の後半部åˆ?‚’取得しまã�?記号は含みません)ã€?
126     *      そã?ä»? カラãƒ??DBType の valueAction メソãƒ?ƒ‰を呼び出しますã?自由に設定可能ですã?
127     *
128     *    [strictCheck属æ?]は、カラãƒ?¼©?¤の存在チェãƒ?‚¯を行うかどã�?�‹を指定しまã�?初期値:true)
129     *      true    カラãƒ?¼©?¤がDBTableModel に存在しなã�??合ã?、エラーになるã?
130     *      false   カラãƒ?¼©?¤がDBTableModel に存在しなã�??合ã?、無視するã?
131     *
132     * @og.group 画面登録
133     *
134     * @version  4.0
135     * @author       Kazuhiko Hasegawa
136     * @since    JDK5.0,
137     */
138    public class EntryTag extends CommonTagSupport {
139            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
140            private static final String VERSION = "5.7.8.0 (2014/07/04)" ;
141    
142            private static final long serialVersionUID = 578020140704L ;
143    
144            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 新è¦?{@value} */
145            public static final String CMD_INSERT   = "INSERT" ;
146            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? è¤?? {@value} */
147            public static final String CMD_COPY             = "COPY" ;
148            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 変更 {@value} */
149            public static final String CMD_MODIFY   = "MODIFY" ;
150            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 削除 {@value} */
151            public static final String CMD_DELETE   = "DELETE" ;
152            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? エントリー {@value} */
153            public static final String CMD_ENTRY    = "ENTRY" ;
154            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? チェンジ {@value} */
155            public static final String CMD_CHANGE   = "CHANGE" ;
156            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? リセãƒ?ƒˆ {@value} */
157            public static final String CMD_RESET    = "RESET" ;
158            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 全件リセãƒ?ƒˆ {@value} */
159            public static final String CMD_ALLRESET         = "ALLRESET" ;  // 3.5.6.3 (2004/07/12)
160            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? オールアクション{@value} */
161            public static final String CMD_ALLACTION        = "ALLACTION" ;
162            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? リセãƒ?ƒˆ(ãƒ??タのみ){@value} */
163            public static final String CMD_RESETDATA        = "RESETDATA" ;         // 4.3.3.0 (2008/10/01)
164            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 追åŠ?1行ã?み){@value} */
165            public static final String CMD_INSERTONE        = "INSERTONE" ;         // 5.1.5.0 (2010/04/01)
166            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? 物ç�?‰Š除 {@value} */
167            public static final String CMD_REALDELETE       = "REALDELETE" ;                // 5.1.6.0 (2010/05/01)
168            /** command 引数に渡す事ã?出来ã‚?コマンãƒ? リクエスト変数設å®?{@value} */
169            public static final String CMD_REQENTRY         = "REQENTRY" ;                  // 5.6.1.2 (2013/02/22)
170    
171            // 3.5.6.3 (2004/07/12) CMD_ALLRESET    追åŠ?
172            // 4.3.3.0 (2008/10/01) CMD_RESETDATA   追åŠ?
173            // 5.1.5.0 (2010/04/01) CMD_INESRTONE   追åŠ?
174            // 5.1.6.0 (2010/05/01) CMD_REALDELETE  追åŠ?
175            private static final String[] COMMAND_LIST = new String[] {
176                    CMD_INSERT,CMD_COPY,CMD_MODIFY,CMD_DELETE,CMD_ENTRY,CMD_CHANGE,CMD_ALLACTION,CMD_RESET,CMD_ALLRESET,CMD_RESETDATA,CMD_INSERTONE,CMD_REALDELETE,CMD_REQENTRY };
177    
178            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? 初期値:{@value} */
179            public static final String ACT_DEFAULT  = "DEFAULT" ;
180            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? クリア {@value} */
181            public static final String ACT_CLEAR    = "CLEAR" ;
182            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? ?‹ï¼?{@value} */
183            public static final String ACT_ADD      = "ADD" ;
184            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? 小文字化{@value} */
185            public static final String ACT_LOWER    = "LOWER" ;
186            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? 大æ–?­—化{@value} */
187            public static final String ACT_UPPER    = "UPPER" ;
188            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? コピã? {@value} */
189            public static final String ACT_COPY     = "COPY" ;
190            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? セãƒ?ƒˆ {@value} */
191            public static final String ACT_SET      = "SET" ;
192            // 3.4.0.3 (2003/09/10) NULLSET Action を追åŠ?�—ますã?
193            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? NULLセãƒ?ƒˆ {@value} */
194            public static final String ACT_NULLSET  = "NULLSET" ;
195            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? ãƒ??ブルセãƒ?ƒˆ {@value} */
196            public static final String ACT_TBLSET   = "TBLSET" ;
197            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? ライトコントロール {@value} */
198            public static final String ACT_WRTCTRL  = "WRTCTRL" ;           // 3.8.1.5 (2006/03/30)
199            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? DBメニュー {@value} */
200            public static final String ACT_DBMENU  = "DBMENU" ;             // 3.8.5.3 (2006/08/07)
201            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? リクエストå?セãƒ?ƒˆ {@value} */
202            public static final String ACT_REQSET  = "REQSET" ;             // 5.4.2.1 (2011/12/09)
203            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? 連番値セãƒ?ƒˆ {@value} */
204            public static final String ACT_SEQSET  = "SEQSET" ;             // 5.6.5.2 (2013/06/21)
205            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? PREFIX値セãƒ?ƒˆ {@value} */
206            public static final String ACT_PREFIX  = "PREFIX" ;             // 5.6.6.1 (2013/07/12)
207            /** action 引数に渡す事ã?出来ã‚?アクションコマンãƒ? SUFIX値セãƒ?ƒˆ {@value} */
208            public static final String ACT_SUFIX   = "SUFIX" ;              // 5.6.6.1 (2013/07/12)
209    
210            // 3.5.6.0 (2004/06/18) すべてã‚?protected から private に変更しますã?
211            private String                          tableId         = HybsSystem.TBL_MDL_KEY;
212            private transient DBTableModel  table   = null;
213            private String                          command         = null;
214            private int[]                           rowNo           = null;
215            private List<Attributes>  values          = null;
216    
217            // 3.5.4.2 (2003/12/15) æŒ?®šã?回数繰り返す機è?を追åŠ?�—ますã?
218            private int                             repeatCount     = 1;
219    
220            // 3.5.5.7 (2004/05/10) Consistency キー による整合æ?チェãƒ?‚¯を行うかどã�?�‹を指定しますã?
221            private boolean                 useConsistency  = HybsSystem.sysBool( "USE_CONSISTENCY" );
222    
223            // 3.8.1.1 (2005/11/21) 全件選択されたこととして、å?ç�?�—ますã?
224            private boolean selectedAll = false;
225    
226            // 3.5.6.4 (2004/07/16) RESET コマンドã?ãƒ?ƒ•ォルトå?ç�?に、ALLRESET ã‚?
227            // 使用するかどã�?�‹を指定しまã�?初期値:false(使用しなã�?)ã€?
228            private final boolean RESET_ACTION_ALL_USE = HybsSystem.sysBool( "RESET_ACTION_ALL_USE" );
229    
230            // 4.0.0 (2006/09/31) カラãƒ?¼©?¤の存在チェãƒ?‚¯を行うかどã�?�‹を指定しますã?
231            private boolean strictCheck = true;
232    
233            private boolean noTransition= false;    // 4.3.3.0 (2008/10/01) 追åŠ?
234    
235            // 5.6.5.2 (2013/06/21) SEQSET アクションのカウンター
236            private int seqsetCnt = 0;
237    
238            /**
239             * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
240             *
241             * @og.rev 5.1.9.0 (2010/08/01) 戻りå?をã?EVAL_BODY_INCLUDE â†?EVAL_BODY_BUFFERED に変更
242             *
243             * @return      後続å?ç�??æŒ?¤º
244             */
245            @Override
246            public int doStartTag() {
247                    int rtn = EVAL_BODY_BUFFERED;           // 5.1.9.0 (2010/08/01) 変更
248    
249                    if( ! check( command, COMMAND_LIST ) ) {
250                            rtn = SKIP_BODY;
251                    }
252    
253                    return rtn;
254            }
255    
256            /**
257             * Taglibの終äº?‚¿グが見つかったときに処ç�?�™ã‚?doEndTag() ã‚?オーバã?ライドしますã?
258             *
259             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
260             * @og.rev 3.5.5.5 (2004/04/23) 登録時ã? 整合æ?パラメータチェãƒ?‚¯を行いますã?
261             * @og.rev 3.5.5.6 (2004/04/27) JSP画面の作æ?不å?合ã?ENTRY系で、command を投げた場合ã?、無視しますã?
262             * @og.rev 3.5.5.7 (2004/05/10) Consistency キー による整合æ?チェãƒ?‚¯を行うかどã�?�‹を指定しますã?
263             * @og.rev 3.5.5.8 (2004/05/20) Consistency キー による整合æ?チェãƒ?‚¯ã‚?checkConsistency() にé›?´?�—ますã?
264             * @og.rev 3.6.0.8 (2004/11/19) DBTableModel をセーブする時に、トランザクションチェãƒ?‚¯を行いますã?
265             * @og.rev 4.3.3.0 (2008/10/01) noTransition 属æ?を追åŠ?�—ますã?
266             * @og.rev 4.3.8.0 (2009/08/01) noTransition値取得ã?メソãƒ?ƒ‰名変更
267             * @og.rev 5.1.3.0 (2010/02/01) noTransitionのコントロールは、requestで行うã€?
268             *
269             * @return      後続å?ç�??æŒ?¤º
270             */
271            @Override
272            public int doEndTag() {
273                    debugPrint();           // 4.0.0 (2005/02/28)
274                    // noTransition = isNoTransitionRequest() || noTransition; // 4.3.3.0 (2008/10/01) 追åŠ?
275                    noTransition = isNoTransitionRequest(); // 5.1.3.0 (2010/02/01)
276                    startQueryTransaction( tableId );               // 3.6.0.8 (2004/11/19)
277                    table = (DBTableModel)getObject( tableId );
278    
279                    if( table != null && check( command, COMMAND_LIST ) ) {
280                            if( ! checkConsistency() ) { return SKIP_PAGE ; }
281                            if( rowNo == null ) { rowNo = getParameterRows(); }             // 4.0.0 (2005/01/31)
282    
283                            commandExec( command );
284    
285                            // 3.6.0.8 (2004/11/19) トランザクションチェãƒ?‚¯を行いますã?
286                            if( ! commitTableObject( tableId, table ) ) {
287                                    jspPrint( "EntryTag Query処ç�?�Œ割り込まれましたã€?BTableModel は登録しませんã€? );
288                                    return SKIP_PAGE;
289                            }
290                    }
291    
292                    return EVAL_PAGE ;
293            }
294    
295            /**
296             * タグリブオブジェクトをリリースしますã?
297             *
298             * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
299             *
300             * @og.rev 2.0.0.4 (2002/09/27) カスタãƒ?‚¿グの release() メソãƒ?ƒ‰をã?追åŠ?
301             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()で呼ぶã€?
302             * @og.rev 3.5.4.2 (2003/12/15) æŒ?®šã?回数繰り返す機è?を追åŠ?�—ますã?
303             * @og.rev 3.5.5.7 (2004/05/10) Consistency キー による整合æ?チェãƒ?‚¯を行うかどã�?�‹を指定しますã?
304             * @og.rev 3.8.1.1 (2005/11/21) selectedAll 追åŠ??全件選択されたこととして、å?ç�?�—ますã?
305             * @og.rev 4.0.0.0 (2006/09/31) strictCheck 追åŠ??
306             * @og.rev 4.3.3.0 (2008/10/01) noTransition 属æ?を追åŠ?�—ますã?
307             * @og.rev 5.6.5.2 (2013/06/21) seqsetCnt 属æ?を追åŠ?�—ますã?
308             *
309             */
310            @Override
311            protected void release2() {
312                    super.release2();
313                    tableId         = HybsSystem.TBL_MDL_KEY;
314                    table           = null;
315                    command         = null;
316                    rowNo           = null;
317                    values          = null;
318                    repeatCount     = 1;                    // 3.5.4.2 (2003/12/15)
319                    useConsistency  = HybsSystem.sysBool( "USE_CONSISTENCY" );              // 3.5.5.7 (2004/05/10)
320                    selectedAll = false;            // 3.8.1.1 (2005/11/21)
321                    strictCheck = true;                     // 4.0.0 (2006/09/31)
322                    noTransition= false;            // 4.3.3.0 (2008/10/01) 追åŠ?
323                    seqsetCnt       = 0;                    // 5.6.5.2 (2013/06/21) SEQSET アクションのカウンター
324            }
325    
326            /**
327             * å†?ƒ¨タグの ColumnSetTag より、å?ã€??カラãƒ??値を書き換える為の属æ?を指定しますã?
328             *
329             * è¤?•°の値を受け取って、後ほど、すべてのカラãƒ?�«対して処ç�?‚’行いますã?
330             *
331             * @og.rev 3.1.0.0 (2003/03/20) Vector を使用してã�?‚‹ç®?‰€でã€?�ž同期でも構わなã�?®?‰€をã?ArrayList に置換えã€?
332             * @og.rev 3.1.2.0 (2003/04/07) taglib パッケージå†?ƒ¨で使用してã�?‚‹ç®?‰€ã‚?protected 化するã?
333             *
334             * @param   attri       属æ?リスãƒ?
335             */
336            protected void setAttributes( final Attributes attri ) {
337                    if( values == null ) { values = new ArrayList<Attributes>(); }
338                    if( command.equalsIgnoreCase( attri.get( "command" ) ) ) {
339                            values.add( attri );
340                    }
341            }
342    
343            /**
344             * 【TAGã€?通常は使ã�?�¾せん)結果のDBTableModelをã?sessionに登録するときã?キーを指定しまã�?
345             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])ã€?
346             *
347             * @og.tag
348             * 検索結果より、DBTableModelオブジェクトを作æ?しますã?これをã?下流ã?viewタグ等に
349             * 渡すå?合にã€??常は、session を利用しますã?そã?場合ã?登録キーですã?
350             * query タグを同時に実行して、結果を求めるå?合ã?同ä¸?ƒ¡モリに配置される為ã€?
351             * こã? tableId 属æ?を利用して、メモリ空間をåˆ?�‘ますã?
352             *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value org.opengion.hayabusa.common.HybsSystem#TBL_MDL_KEY}])ã€?
353             *
354             * @param       id sessionに登録する時ã? ID
355             */
356            public void setTableId( final String id ) {
357                    tableId   = nval( getRequestParameter( id ),tableId );  // 3.8.0.9 (2005/10/17)
358            }
359    
360            /**
361             * 【TAG】コマンãƒ?INSERT,COPY,MODIFY,DELETE,ENTRY,CHANGE,ALLACTION,RESET)をセãƒ?ƒˆしますã?
362             *
363             * @og.tag
364             * コマンドã?,HTMLから(get/post)æŒ?®šされますã?で,CMD_xxx で設定される
365             * フィールド定数値のã�?�¥れかをã?æŒ?®šできますã?
366             *
367             * @param       cmd コマンãƒ?public static final 宣è¨?�•れてã�?‚‹æ–?­—å?)
368             * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.EntryTag.CMD_INSERT">コマンド定数</a>
369             */
370            public void setCommand( final String cmd ) {
371                    String cmd2 = getRequestParameter( cmd );
372                    if( cmd2 != null && cmd2.length() > 0 ) { command = cmd2.toUpperCase(Locale.JAPAN); }
373            }
374    
375            /**
376             * コマンドを実行しますã?
377             *
378             * コマンドã?,HTMLから(get/post)æŒ?®šされますã?で,setCommand()メソãƒ?ƒ‰で
379             * 登録しますã?
380             * コマンドを登録すると同時に,実行も行なã�?�¾すã?
381             *
382             * @og.rev 3.5.6.3 (2004/07/12) ALLRESET コマンドを追åŠ?�™るã?
383             * @og.rev 4.3.3.0 (2008/10/01) RESETDATA コマンドを追åŠ?�™るã?
384             * @og.rev 5.1.5.0 (2010/04/01) INSERTONE コマンドを追åŠ?�™るã?
385             * @og.rev 5.1.6.0 (2010/05/01) REALDELETE コマンドを追åŠ?�™るã?
386             * @og.rev 5.6.1.2 (2013/02/22) REQENTRY コマンドを追åŠ?�™るã?
387             *
388             * @param   command コマンãƒ?public static final 宣è¨?�•れてã�?‚‹æ–?­—å?)
389             */
390            private void commandExec( final String command ) {
391    
392                    table.setDefaultRowWritable( false );
393                    table.setDefaultRowChecked(  false );
394    
395                    if( CMD_INSERT.equals(      command ) ) { insert() ; }
396                    else if( CMD_COPY.equals(   command ) ) { copy()   ; }
397                    else if( CMD_MODIFY.equals( command ) ) { modify() ; }
398                    else if( CMD_CHANGE.equals( command ) ) { change() ; }
399                    else if( CMD_DELETE.equals( command ) ) { delete() ; }
400                    else if( CMD_ENTRY.equals(  command ) ) { entry()  ; }
401                    else if( CMD_RESET.equals(  command ) ) {
402                                    if( RESET_ACTION_ALL_USE )              { allReset() ; }        // 3.5.6.4 (2004/07/16)
403                                    else                                                    { reset()    ; }
404                    }
405                    else if( CMD_ALLRESET.equals(    command ) ) { allReset()  ; }  // 3.5.6.3 (2004/07/12)
406                    else if( CMD_ALLACTION.equals(   command ) ) { allAction() ; }
407                    else if( CMD_RESETDATA.equals(   command ) ) { resetData() ; }  // 4.3.3.0 (2008/10/01)
408                    else if( CMD_INSERTONE.equals(   command ) ) { insertOne() ; }  // 5.1.5.0 (2010/04/01)
409                    else if( CMD_REALDELETE.equals(  command ) ) { realDelete() ; } // 5.1.6.0 (2010/05/01)
410                    else if( CMD_REQENTRY.equals(    command ) ) { reqEntry()  ; }  // 5.6.1.2 (2013/02/22)
411            }
412    
413            /**
414             * DBTableModelに行を追åŠ?�—ますã?
415             *
416             * 注意:writableカラãƒ??暫定対応が入ってã�?�¾すã?単純な空白ãƒ??タã‚?
417             * インサートすると、カラãƒ?ƒ‡ータã�?null になる為?¤ 制御がおかしã�?
418             * なりますã?
419             *
420             * @og.rev 3.5.4.2 (2003/12/15) repeatCount による繰り返し処ç�?‚’追åŠ?
421             * @og.rev 4.3.3.0 (2008/10/01) noTransition 属æ?対å¿?
422             *
423             */
424            private void insert() {
425                    if( rowNo.length == 0 ) { rowNo = new int[] { -1 }; }
426    
427                    boolean rowWritableFlag = "WRITABLE".equalsIgnoreCase( table.getColumnName( 0 ) );      // writable 対ç­?
428                    // src の作æ?は、各チェãƒ?‚¯毎に行うå¿?¦�ã?なã�??æœ??のä¸?º¦ã�?�‘でよいã€?
429                    String[] src = new String[ table.getColumnCount() ];
430                    for( int j=0; j<src.length; j++ ) {
431                            DBColumn dbColumn = table.getDBColumn( j );
432                            src[j] = dbColumn.getDefault();
433                    }
434                    if( rowWritableFlag ) { src[0] = "true"; }      // writable 対ç­?
435    
436                    int rowCount = table.getRowCount();
437    
438                    // é€??にINSERTしなã�?�¨、行番号がずれてしまã�??
439                    for( int i=rowNo.length-1; i>=0; i-- ) {
440                            int row = rowNo[i];
441                            for( int cnt=0; cnt<repeatCount; cnt++ ) {
442                                    if( cnt >= 1 ) {             // ?’回目以é™?
443                                            src = table.getValues( row );
444                                    }
445    
446                                    String[] dst = new String[ table.getColumnCount() ];
447                                    System.arraycopy( src,0,dst,0,dst.length );
448                                    dst = setColumnValues( dst );
449    
450                                    // 4.3.3.0 (2008/10/01) noTransition属æ?対å¿?
451                                    if( noTransition ) { row = rowCount; }
452                                    else { row ++; }                                        // æŒ?®š行ã?下に追åŠ?�™るã?
453                                    table.addValues( dst,row );
454                                    table.setRowWritable( row,true );
455                                    table.setRowChecked(  row,true );
456                            }
457                    }
458            }
459    
460            /**
461             * DBTableModelに行を追åŠ?�—、チェãƒ?‚¯された行ã?値をセãƒ?ƒˆしますã?
462             *
463             * @og.rev 3.5.4.2 (2003/12/15) repeatCount による繰り返し処ç�?‚’追åŠ?
464             * @og.rev 4.3.3.0 (2008/10/01) noTransition 属æ?対å¿?
465             *
466             */
467            private void copy() {
468                    if( rowNo.length == 0 ) { insert() ; return ;}
469    
470                    int rowCount = table.getRowCount();
471    
472                    // é€??にCOPYしなã�?�¨、行番号がずれてしまã�??
473                    for( int i=rowNo.length-1; i>=0; i-- ) {
474                            for( int cnt=0; cnt<repeatCount; cnt++ ) {
475                                    String[] src = table.getValues( rowNo[i]+cnt );
476                                    String[] dst = new String[ table.getColumnCount() ];
477                                    System.arraycopy( src,0,dst,0,dst.length );
478                                    dst = setColumnValues( dst );
479    
480                                    // 4.3.3.0 (2008/10/01) noTransition属æ?対å¿?
481                                    int row = -1;
482                                    if( noTransition ) { row = rowCount; }
483                                    else { row = rowNo[i] + cnt + 1; }                      // æŒ?®š行ã?下に追åŠ?�™るã?
484    
485                                    table.addValues( dst,row );
486                                    table.setRowWritable( row,true );
487                                    table.setRowChecked(  row,true );
488                            }
489                    }
490            }
491    
492            /**
493             * DBTableModelの行を書込み可とますã?
494             *
495             * @og.rev 4.3.4.6 (2009/01/15) 画面遷移なし登録で既に改廃Cがセãƒ?ƒˆされてã�?‚‹場合ã?、columnSetタグの処ç�?‚’行わなã�??
496             *
497             */
498            private void modify() {
499                    for( int i=0; i<rowNo.length; i++ ) {
500                            String[] src = table.getValues( rowNo[i] );
501                            String[] dst = new String[ table.getColumnCount() ];
502                            System.arraycopy( src,0,dst,0,dst.length );
503    
504                            // 4.3.4.6 (2009/01/15)
505                            // 画面遷移なし登録の場合ã?既に改廃Cが付いてã�?‚‹(編é›?�•れてã�?‚‹)場合ã?ã€?
506                            // columnSetによる値のセãƒ?ƒˆを行わなã�??
507                            // (同じコマンドでè¤?•°のボタンを割り当ててã�?‚‹場合ã?è¤?•°回ã?変更・削除によって、å?に登録されã�?
508                            // 値が削除されてしまã�?�Ÿめã?
509                            if( !( noTransition && table.getModifyType( rowNo[i] ) != null && table.getModifyType( rowNo[i] ).length() > 0 ) ){
510                                    dst = setColumnValues( dst );
511                            }
512    
513                            table.setValues( dst,rowNo[i] );
514                            table.setRowWritable( rowNo[i],true );
515                            table.setRowChecked(  rowNo[i],true );
516                    }
517            }
518    
519            /**
520             * DBTableModelの行を変更しますã?
521    
522             * @og.rev 4.3.4.6 (2009/01/15) 画面遷移なし登録で既に改廃Cがセãƒ?ƒˆされてã�?‚‹場合ã?、columnSetタグの処ç�?‚’行わなã�??
523             *
524             */
525            private void change() {
526                    for( int i=0; i<rowNo.length; i++ ) {
527                            String[] src = table.getValues( rowNo[i] );
528                            String[] dst = new String[ table.getColumnCount() ];
529                            System.arraycopy( src,0,dst,0,dst.length );
530    
531                            // 4.3.4.6 (2009/01/15)
532                            if( !( noTransition && table.getModifyType( rowNo[i] ) != null && table.getModifyType( rowNo[i] ).length() > 0 ) ){
533                                    dst = setColumnValues( dst );
534                            }
535    
536                            table.setValues( dst,rowNo[i] );
537                    }
538            }
539    
540            /**
541             * DBTableModelの行を削除しますã?
542             *
543             * @og.rev 3.5.4.2 (2003/12/15) DELETE時にもå?の書き換えができるようにしますã?
544             * @og.rev 4.3.4.6 (2009/01/15) 画面遷移なし登録で既に改廃Cがセãƒ?ƒˆされてã�?‚‹場合ã?、columnSetタグの処ç�?‚’行わなã�??
545             *
546             */
547            private void delete() {
548                    for( int i=0; i<rowNo.length; i++ ) {
549                            // 3.5.4.2 (2003/12/15) 書き換えå?ç�?‚’追åŠ?
550                            String[] src = table.getValues( rowNo[i] );
551                            String[] dst = new String[ table.getColumnCount() ];
552                            System.arraycopy( src,0,dst,0,dst.length );
553    
554                            // 4.3.4.6 (2009/01/15)
555                            if( !( noTransition && table.getModifyType( rowNo[i] ) != null && table.getModifyType( rowNo[i] ).length() > 0 ) ){
556                                    dst = setColumnValues( dst );
557                            }
558    
559                            table.rowDelete( dst,rowNo[i] );
560                            table.setRowWritable( rowNo[i],true );
561                            table.setRowChecked( rowNo[i],true );
562                    }
563            }
564    
565            /**
566             * リクエスト情報から、セãƒ?ƒˆされたカラãƒ?��と値を取りå?しã?設定しますã?
567             *
568             * 設定å?は、å?ã€??キー??__" ??行番号 ですã?
569             * よって、å?は,ä¸?�¤ã�?�‘設定されてã�?�¾すã?
570             *
571             * @og.rev 3.5.3.1 (2003/10/31) チェãƒ?‚¯ボックスカラãƒ?‚’æŒ?®šしますã?
572             * @og.rev 3.6.0.6 (2004/10/22) chboxNames 属æ?はå»?­¢しますã?
573             * @og.rev 5.6.1.2 (2013/02/22) setRequestValuesメソãƒ?ƒ‰の互換性の対応ã?
574             */
575            private void entry() {
576                    if( rowNo.length > 0 ) {
577                            setRequestValues( false );              // 5.6.1.2 (2013/02/22) 互換性
578                            for( int i=0; i<rowNo.length; i++ ) {
579                                    String[] src = table.getValues( rowNo[i] );
580                                    String[] dst = new String[ table.getColumnCount() ];
581                                    System.arraycopy( src,0,dst,0,dst.length );
582                                    dst = setColumnValues( dst );
583    
584                                    table.setValues( dst,rowNo[i] );
585                                    table.setRowWritable( rowNo[i],true );
586                                    table.setRowChecked(  rowNo[i],true );
587                            }
588                    }
589            }
590    
591            /**
592             * リクエスト情報のãƒ??ブルモãƒ?ƒ«ãƒ??タをã?リセãƒ?ƒˆしますã?
593             *
594             * @og.rev 5.6.5.2 (2013/06/21) 行ループを 0?ž最終行ã? 降é?で廻しますã?
595             */
596            private void reset() {
597                    for( int i=rowNo.length-1; i>=0; i-- ) {
598                            table.resetRow( rowNo[i] );
599                    }
600            }
601    
602            /**
603             * ãƒ??ブルモãƒ?ƒ«ãƒ??タをã?全件リセãƒ?ƒˆしますã?
604             *
605             * @og.rev 3.5.6.3 (2004/07/12) 新規作æ?
606             * @og.rev 5.6.5.2 (2013/06/21) 行ループを 0?ž最終行ã? 降é?で廻しますã?
607             */
608            private void allReset() {
609                    int rowCount = table.getRowCount();
610                    for( int row=0; row<rowCount; row++ ) {
611                            table.resetRow( row );
612                    }
613            }
614    
615            /**
616             * DBTableModelの全ての行に対して,値をセãƒ?ƒˆしますã?
617             *
618             * @og.rev 5.6.5.2 (2013/06/21) 行ループを 0?ž最終行ã? 降é?で廻しますã?
619             */
620            private void allAction() {
621                    int rowCount = table.getRowCount();
622                    for( int row=0; row<rowCount; row++ ) {
623                            String[] src = table.getValues( row );
624                            String[] dst = new String[ table.getColumnCount() ];
625                            System.arraycopy( src,0,dst,0,dst.length );
626                            dst = setColumnValues( dst );
627    
628                            table.setValues( dst,row );
629                            table.setRowWritable( row,true );
630                            table.setRowChecked(  row,true );
631                    }
632            }
633    
634            /**
635             * リクエスト情報のãƒ??ブルモãƒ?ƒ«ãƒ??タをã?リセãƒ?ƒˆしますã?
636             * (ä½?�—、リセãƒ?ƒˆされた行ã?、チェãƒ?‚¯された状態ã?ままになりまã�?
637             *
638             * @og.rev 4.3.3.0 (2008/10/01) 新規作æ?
639             * @og.rev 5.6.5.2 (2013/06/21) 行ループを 0?ž最終行ã? 降é?で廻しますã?
640             */
641            private void resetData() {
642                    for( int i=0; i<rowNo.length; i++ ) {
643                            String cdkh = table.getModifyType( rowNo[i] );
644                            table.resetRow( rowNo[i] );
645                            // 更新又ã?、削除の時ã?み書き込み可能になるã?
646                            if( DBTableModel.UPDATE_TYPE.equals( cdkh ) || DBTableModel.DELETE_TYPE.equals( cdkh ) ) {
647                                    table.setRowWritable( rowNo[i],true );
648                                    table.setRowChecked(  rowNo[i],true );
649                            }
650                    }
651            }
652    
653            /**
654             * DBTableModelに行を追åŠ?�—ますã?(1行ã?み)
655             *
656             * 行が選択されてã�?‚‹かどã�?�‹に関わらずã?1行ã?みを追åŠ?�—ますã?
657             * (動きとしては、行が選択されてã�?�ªã�?ж態でINSERTコマンドを発行したå?合と同じでã�?
658             *
659             * @og.rev 5.1.5.0 (2010/04/01) 新規作æ?
660             *
661             */
662            private void insertOne() {
663                    rowNo = new int[0];
664                    insert();
665            }
666    
667            /**
668             * DBTableModelの行を物ç�?‰Š除しますã?
669             *
670             * 通常のãƒ??タベã?ス等で削除する場合ã?、DELETE行も残しておかなã�?�¨、どの行を削除するã�?
671             * 判らなくなりますã?またã?アプリケーションによっては、削除ではなくã?フラグã�?�‘を立てã‚?
672             * ケースもあるためã?現在の commend="DELETE" では、論理削除?‹å?の書き換えも可能になってã�?�¾すã?
673             * ここでの物ç�?‰Š除は、WriteTable など、ファイル出力時には、その行そのもã?をなくしておくほã�?�Œ
674             * 良ã�?‚±ースがあるためですã?
675             *
676             * @og.rev 5.1.6.0 (2010/05/01) REALDELETE コマンドを追åŠ?�™るã?
677             */
678            private void realDelete() {
679                    // é€??にしなã�?�¨、行番号がずれてしまã�??
680                    for( int i=rowNo.length-1; i>=0; i-- ) {
681                            table.removeValue( rowNo[i] );
682                    }
683            }
684    
685            /**
686             * リクエスト情報から、セãƒ?ƒˆされたカラãƒ?��と値を取りå?しã?設定しますã?
687             *
688             * 設定å?は、å?ã€??キー??__" ??行番号 ですã?
689             * ENTRYコマンドとの違いは、h_rowSel と無関係に、リクエストされた変数すべてã‚?
690             * 処ç�?�—ますã?
691             *
692             * @og.rev 5.6.1.2 (2013/02/22) 新規追åŠ?
693             */
694            private void reqEntry() {
695                    setRequestValues( true );       // リクエストされた変数すべてをå?ç�?
696                    int rowCount = table.getRowCount();
697                    for( int row=0; row<rowCount; row++ ) {
698                            String[] src = table.getValues( row );
699                            String[] dst = new String[ table.getColumnCount() ];
700                            System.arraycopy( src,0,dst,0,dst.length );
701                            dst = setColumnValues( dst );
702    
703                            table.setValues( dst,row );
704                            table.setRowWritable( row,true );
705                            table.setRowChecked(  row,true );
706                    }
707            }
708    
709            /**
710             * リクエスト情報から、セãƒ?ƒˆされたカラãƒ?��と値を取りå?しã?設定しますã?
711             *
712             * 設定å?は、å?ã€??キー??__" ??行番号 ですã?
713             * よって、å?は,ä¸?�¤ã�?�‘設定されてã�?�¾すã?
714             *
715             * @og.rev 3.1.0.0 (2003/03/20) 名前と行番号の区åˆ?‚Š記号ã‚?"^" から "__" に変更ã€?
716             * @og.rev 3.5.5.0 (2004/03/12) 名前と行番号の区åˆ?‚Š記号("__")をã?HybsSystem.JOINT_STRING  に変更ã€?
717             * @og.rev 3.6.0.6 (2004/10/22) chboxNames 属æ?はå»?­¢しますã?
718             * @og.rev 3.8.0.1 (2005/06/17) チェãƒ?‚¯ボックス対応で、エラーチェãƒ?‚¯をPL/SQLで行う場合ã?処ç�?©Ÿè?の追åŠ?
719             * @og.rev 3.8.0.2 (2005/07/11) チェãƒ?‚¯ボックス対応で、判定を DBColumnのgetEditor()を使用しまã�?
720             * @og.rev 4.0.0.0 (2006/09/31) strictCheck 追åŠ??
721             * @og.rev 4.3.7.3 (2009/06/22) HSQLDB対応でリクエストが空æ–?­—ã?場合ã?nullæ–?­—に変換する
722             * @og.rev 5.0.0.2 (2009/09/15) XSS対å¿?ALLはチェãƒ?‚¯しなã�?
723             * @og.rev 5.6.1.2 (2013/02/22) isAllRow 引数追åŠ?
724             *
725             * @param isAllRows 選択行番号に関係なくã?処ç�?�™るかどã�?�‹
726             */
727            private void setRequestValues( final boolean isAllRows ) {
728                    Enumeration<?> enume = getParameterNames();               // 4.3.3.6 (2008/11/15) Generics警告対å¿?
729    
730                    while( enume.hasMoreElements() ) {
731                            String key  = (String)(enume.nextElement());
732                            int    idx  = key.lastIndexOf(HybsSystem.JOINT_STRING);
733    
734                            if( idx > 0 ) {
735                                    String  column  = key.substring(0,idx);
736                                    int             clmNo   = table.getColumnNo( column,strictCheck );
737                                    if( clmNo < 0 ) { continue; }        // strictCheck 対å¿?
738                                    DBColumn dbColumn = table.getDBColumn( clmNo );
739                                    int      row      = Integer.parseInt( key.substring(idx + 2) );
740                                    // 5.0.0.2 (2009/09/15) æ–?­—種別ALLはXSSチェãƒ?‚¯しなã�?
741                                    // String   val      = dbColumn.valueSet( getRequestValue( key ) );
742                                    String   val = null;
743                                    if( "ALL".equals( dbColumn.getDbType() ) ){
744                                            val = dbColumn.valueSet( getRequestValue( key, false ) );
745                                    }
746                                    else{
747                                            val = dbColumn.valueSet( getRequestValue( key ) );
748                                    }
749    
750                                    // 3.6.0.6 (2004/10/22) チェãƒ?‚¯ボックスはマルチでãƒ??タが来ますã?
751                                    // 3.8.0.2 (2005/07/11) 判定を DBColumnのgetEditor()を使用
752                                    if( "0".equals(val) && "CHBOX".equals( dbColumn.getEditor() ) ) {
753                                            String[] vals = getRequestValues( key );
754                                            if( vals != null ) {
755                                                    for( int i=0; i<vals.length; i++ ) {
756                                                            if( "1".equals( vals[i] ) ) { val = "1"; break; }
757                                                    }
758                                            }
759                                    }
760    
761                                    // 5.6.1.2 (2013/02/22) リクエスト変数すべてのãƒ??タを設å®?
762                                    if( isAllRows ) {
763                                            // 4.3.7.3 (2009/06/22) HSQLDB対å¿?
764                                            if( val != null && val.length() == 0 ){
765                                                    val = null;
766                                            }
767                                            table.setValue(row, column, val );
768                                    }
769                                    // 従来のロジãƒ?‚¯(チェãƒ?‚¯を外してSUBMITするケースを想定してã�?‚‹ã€?
770                                    else {
771                                            // rowNo は、getParameterRows メソãƒ?ƒ‰でソートされてã�?‚‹のでã€?
772                                            // java.util.Arrays#binarySearch(int[] a, int key) が使えるはずã?
773                                            // 十å?にãƒ?‚¹トしてã�?�ªã�?�Ÿめã?今ã?変更しなã�??
774                                            for( int i=0; i<rowNo.length; i++ ) {
775                                                    if( rowNo[i] == row ) {
776                                                            // 4.3.7.3 (2009/06/22) HSQLDB対å¿?
777                                                            if( val != null && val.length() == 0 ){
778                                                                    val = null;
779                                                            }
780                                                            table.setValue(row, column, val );
781                                                    }
782                                            }
783                                    }
784                            }
785                    }
786            }
787    
788            /**
789             * ColumnSetTag でæŒ?®šされた条件をå?に、その行ã?値を書き換えますã?
790             *
791             * @og.rev 3.6.0.6 (2004/10/22) conditionKey とã€?conditionList 属æ?を追åŠ?
792             * @og.rev 3.8.1.5 (2006/03/30) writableControl を使用したカラãƒ?ƒ‡ータの先é?アンãƒ??バã?を削除しますã?
793             * @og.rev 4.0.0.0 (2006/09/31) strictCheck 追åŠ??
794             * @og.rev 4.3.7.3 (2009/06/22) HSQLDB対応で空æ–?­—â?NULL
795             * @og.rev 5.6.5.2 (2013/06/21) valueの初期値を利用してã€?¼‘レコードごとにã€?¼‹1したå?をセãƒ?ƒˆしますã?
796             * @og.rev 5.7.8.0 (2014/07/04) actionExec の引数ã‚?columnId ではなくã?DBColumnオブジェクãƒ?に変更しますã?
797             *
798             * @param       val æŒ?®š行データ配å?
799             *
800             * @return      変更後ã?æŒ?®š行データ配å?
801             */
802            private String[] setColumnValues( final String[] val ) {
803                    if( values != null ) {
804                            int size = values.size();
805                            for( int i=0; i<size; i++ ) {
806                                    Attributes attri = values.get( i );
807                                    String columnId = attri.get( "columnId" );
808                                    int clmNo = table.getColumnNo( columnId,strictCheck );
809                                    if( clmNo < 0 ) { continue; }        // strictCheck 対å¿?
810                                    String action = attri.get( "action" );
811                                    String newVal = attri.get( "value"  );
812                                    String oldVal = val[clmNo];
813    
814                                    // 3.6.0.6 (2004/10/22) 条件による処ç�??実行可否判å®?
815                                    String conditionList = attri.get( "conditionList" );
816                                    if( conditionList != null ) {   // null の場合ã?、無条件実è¡?
817                                            String conditionKey = attri.get( "conditionKey" );
818                                            int condClmNo = table.getColumnNo( conditionKey );
819                                            String condValue = "|" + val[condClmNo] + "|";
820                                            if( conditionList.indexOf( condValue ) < 0 ) {
821                                                    continue;
822                                            }
823                                    }
824    
825                                    if( ACT_COPY.equals( action ) ) {
826                                            int copyClmNo = table.getColumnNo( newVal );    // newVal はコピã?å…?‚«ラãƒ?��
827                                            val[clmNo] = val[copyClmNo];
828                                    }
829                                    else if( ACT_TBLSET.equals( action ) ) {
830                                            ArrayDataModel model = new ArrayDataModel( table.getNames() );
831                                            model.setValues( val,0 );
832                                            Formatter format = new Formatter( model );
833                                            format.setFormat( newVal );             // newValue はフォーマットされたæ–?­—å?
834                                            val[clmNo] = format.getFormatString( 0 );
835                                    }
836                                    // 3.8.1.5 (2006/03/30) writableControl を使用したカラãƒ?ƒ‡ータの先é?アンãƒ??バã?を削除しますã?
837                                    else if( ACT_WRTCTRL.equals( action ) ) {
838                                            if( oldVal != null && oldVal.length() > 0 && oldVal.charAt(0) == '_' ) {
839                                                    val[clmNo] = oldVal.substring( 1 );
840                                            }
841                                    }
842                                    // 3.8.5.3 (2006/08/07) DBMENUでパラメータ設å®?コロン連結文å­?を使用したカラãƒ?ƒ‡ータの先é?ãƒ??タのみにしますã?
843                                    else if( ACT_DBMENU.equals( action ) ) {
844                                            if( oldVal != null && oldVal.length() > 0 ) {
845                                                    int adrs = oldVal.indexOf( ':' );
846                                                    if( adrs >= 0 ) {
847                                                            val[clmNo] = oldVal.substring( 0,adrs );
848                                                    }
849                                            }
850                                    }
851                                    // 5.4.2.1 (2011/12/09) valueでæŒ?®šしたカラãƒ??値をキーに、リクエスト変数から値を取出しã?セãƒ?ƒˆしますã?
852                                    else if( ACT_REQSET.equals( action ) ) {
853                                            if( newVal != null && newVal.length() > 0 ) {
854                                                    int reqClmNo = table.getColumnNo( newVal );     // newVal はリクエスト取得å?カラãƒ?��
855                                                    String reqClm = val[reqClmNo];                          // こã?時点では、コロン引数が付いてã�?‚‹可能性があるã?
856    
857                                                    int adrs = reqClm.indexOf( ':' );                       // 先é?がカラãƒ?��
858                                                    if( adrs >= 0 ) {
859                                                            reqClm = reqClm.substring( 0,adrs );    // コロンより前方のåˆ?� け取りå?すã?
860                                                    }
861                                                    val[clmNo] = getRequestValue( reqClm );
862                                            }
863                                    }
864                                    // 5.6.5.2 (2013/06/21) valueの初期値を利用してã€?¼‘レコードごとにã€?¼‹1したå?をセãƒ?ƒˆしますã?
865                                    else if( ACT_SEQSET.equals( action ) ) {
866                                            int intVal = seqsetCnt ;
867                                            if( newVal != null && newVal.length() > 0 ) {
868                                                    intVal += Integer.parseInt( newVal );           // value の設定å?
869                                            }
870                                            val[clmNo] = String.valueOf( intVal );
871                                    }
872                                    else {
873                                            // 5.7.8.0 (2014/07/04) actionExec の引数ã‚?columnId ではなくã?DBColumnオブジェクãƒ?に変更しますã?
874    //                                      val[clmNo] = actionExec( action,columnId,oldVal,newVal );
875                                            DBColumn dbClm = table.getDBColumn( clmNo );
876                                            val[clmNo] = actionExec( action,dbClm,oldVal,newVal );
877                                    }
878    
879                                    // 4.3.7.3 (2009/06/22) HSQLDB対å¿?
880                                    if( val[clmNo] != null && val[clmNo].length() == 0){
881                                            val[clmNo] = null;
882                                    }
883                            }
884                    }
885                    seqsetCnt ++ ;          // // 5.6.5.2 (2013/06/21) SEQSET のカウンターã€?
886    
887                    return val;
888            }
889    
890            /**
891             * アクションを実行しますã?
892             *
893             * アクションは,æŒ?®šã?アクションコマンドに対応するå?ç�?‚’入力データに対して行いますã?
894             *
895             * @og.rev 3.4.0.3 (2003/09/10) NULLSET Action を追åŠ?�—ますã?
896             * @og.rev 5.6.0.3 (2012/01/24) ADD Action に、value引数の値を加算する機è?を追åŠ?�—ますã?
897             * @og.rev 5.6.6.1 (2013/07/12) action に、PREFIX,SUFIX を追åŠ?�—ますã?
898             * @og.rev 5.7.8.0 (2014/07/04) columnId ではなくã?DBColumnオブジェクãƒ?に変更しますã?
899             *
900             * @param   action アクションコマンãƒ?
901             * @param   dbColumn DBColumnオブジェクãƒ?
902             * @param   oldValue 入力データ(旧ãƒ??タ)
903             * @param   newValue 入力データ(新ãƒ??タ)
904             *
905             * @return      実行後ã?ãƒ??タ
906             * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.EntryTag.ACT_DEFAULT">アクション定数</a>
907             */
908    //      private String actionExec( final String action,final String clmId,final String oldValue,final String newValue ) {
909            private String actionExec( final String action,final DBColumn dbColumn,final String oldValue,final String newValue ) {
910                    String rtnVal = oldValue;
911    
912    //              DBColumn dbColumn = getDBColumn( clmId );       // 5.7.8.0 (2014/07/04)
913                    if( ACT_DEFAULT.equals(    action ) ) { rtnVal = dbColumn.getDefault(); }
914                    else if( ACT_CLEAR.equals( action ) ) { rtnVal = ""; }
915                    else if( ACT_SET.equals(   action ) ) { rtnVal = dbColumn.valueSet( newValue ); }
916                    else if( ACT_ADD.equals(   action ) ) { rtnVal = dbColumn.valueAdd( oldValue,newValue ); }      // 5.6.0.3 (2012/01/24)
917                    else if( ACT_LOWER.equals( action ) ) {
918                            if( oldValue == null ) { rtnVal = dbColumn.getDefault();  }
919                            else                   { rtnVal = oldValue.toLowerCase(Locale.JAPAN); }
920                    }
921                    else if( ACT_UPPER.equals( action ) ) {
922                            if( oldValue == null ) { rtnVal = dbColumn.getDefault();  }
923                            else                   { rtnVal = oldValue.toUpperCase(Locale.JAPAN); }
924                    }
925                    // 3.4.0.3 (2003/09/10) NULLSET Action を追åŠ?�—ますã?
926                    else if( ACT_NULLSET.equals( action ) ) {
927                            if( oldValue == null || oldValue.length() == 0 ) {
928                                    rtnVal = dbColumn.valueSet( newValue );
929                            }
930                    }
931                    // 5.6.6.1 (2013/07/12) PREFIX Action を追åŠ?�—ますã?
932                    else if( ACT_PREFIX.equals( action ) ) {
933                            if( oldValue != null && oldValue.length() > 0 && newValue != null && newValue.length() > 0 ) {
934                                    int indx = oldValue.lastIndexOf( newValue );
935                                    if( indx >= 0 ) {
936                                            rtnVal = oldValue.substring( 0,indx );
937                                    }
938                            }
939                    }
940                    // 5.6.6.1 (2013/07/12) SUFIX Action を追åŠ?�—ますã?
941                    else if( ACT_SUFIX.equals( action ) ) {
942                            if( oldValue != null && oldValue.length() > 0 && newValue != null && newValue.length() > 0 ) {
943                                    int indx = oldValue.lastIndexOf( newValue );
944                                    if( indx >= 0 ) {
945                                            rtnVal = oldValue.substring( indx+1 );          // åˆ?‰²記号は含まなã�??で?‹1するã?
946                                    }
947                            }
948                    }
949                    else {
950                            rtnVal = dbColumn.valueAction( action,oldValue,newValue );
951                    }
952    
953                    if( rtnVal == null ) { rtnVal = dbColumn.getDefault(); }
954    
955                    return rtnVal;
956            }
957    
958            /**
959             * 【TAG】指定ã?回数åˆ?� けã?繰り返し処ç�?‚’行う回数を指定しまã�?初期値:1)ã€?
960             *
961             * @og.tag
962             * 追åŠ?‚„è¤??時に、指定ã?回数åˆ?� けã?処ç�?‚’繰り返して、新規に行を
963             * 作æ?しますã?
964             * 繰り返しは、指定ã?行に対して行われã?繰り返し毎に、直前に作æ?されã�?
965             * 行をå…?�«処ç�?�—ますã?これは、例えば、columnSet で、action="ADD"の場合にã€?
966             * 繰り返す毎に、ADD処ç�?�Œ実行されることを意味しますã?
967             * 行がæŒ?®šされてã�?�ªã�??合ã?、å?頭空行に追åŠ?�—ますã?
968             * 初期値はã€?¼‘回ですã?
969             *
970             * @og.rev 3.5.4.2 (2003/12/15) 新規追åŠ?
971             *
972             * @param       rc      繰り返し処ç�?‚’行う回数を指å®?初期値:1)
973             */
974            public void setRepeatCount( final String rc ) {
975                    repeatCount = nval( getRequestParameter( rc ),repeatCount );
976            }
977    
978            /**
979             * 【TAG】Consistency キー による整合æ?チェãƒ?‚¯を行うかどã�?�‹を指定しまã�?初期値:true)ã€?
980             *
981             * @og.tag
982             * 検索結果ã‚?DBTableModel にセãƒ?ƒˆする時に、整合æ?キーの Consistency キーã‚?
983             * 作æ?しますã?これをã?Viewタグでhidden出力しておき、Entryタグでãƒ??タ書き換え時に
984             * 整合æ?チェãƒ?‚¯を行いますã?これは、IEの戻るã?タンで戻ったå?合に、画面の
985             * キーと検索結果の DBTableModel のå†?®¹がä¸??しなã�??合ã?エラーチェãƒ?‚¯に
986             * なりますã?
987             * こã?属æ?は、何らかã?ケースで、このエラーチェãƒ?‚¯を行いたくなã�??合にã€?
988             * false に設定することで、整合æ?チェãƒ?‚¯を行いませんã€?
989             * 初期値は、true(整合æ?チェãƒ?‚¯を行う)ですã?
990             *
991             * @og.rev 3.5.5.7 (2004/05/10) 新規登録
992             *
993             * @param       ck      Consistency Key の使用するかどã�?�‹(初期値:true)
994             */
995            public void setUseConsistency( final String ck ) {
996                    useConsistency = nval( getRequestParameter( ck ),useConsistency );
997            }
998    
999            /**
1000             * DBTableModel の 整合æ?パラメータとリクエスト情報を比è¼?ƒ�ェãƒ?‚¯しますã?
1001             * リクエスト情報は、その DBTableModel がå?力された view で hidden 属æ?で
1002             * 設定されますã?
1003             * 設定されるキーは、tableId が変更されてã�?�ªければ、HybsSystem.CONSISTENCY_KEY ですã?
1004             * 変更されてã�?‚Œば、HybsSystem.CONSISTENCY_KEY + tableId ですã?
1005             *
1006             * @og.rev 3.5.5.8 (2004/05/20) Consistency キー による整合æ?チェãƒ?‚¯ã‚?checkConsistency() にé›?´?�—ますã?
1007             *
1008             * @return チェãƒ?‚¯結果  true:正常/false:異常
1009             * @see org.opengion.hayabusa.common.HybsSystem#CONSISTENCY_KEY
1010             */
1011            private boolean checkConsistency() {
1012                    boolean rtn = true;
1013                    String key = HybsSystem.CONSISTENCY_KEY ;
1014    
1015                    String consisKey = getRequestValue( key );
1016                    if( consisKey != null && consisKey.length() > 0 ) {
1017                            if( useConsistency && ! consisKey.equals( table.getConsistencyKey() ) ) {
1018    
1019                                    ErrorMessage errMsgObj = new ErrorMessage( "Consistency Key Check Error!" );
1020                                    errMsgObj.addMessage( 0,ErrorMessage.NG,"ERR0033.1" );
1021                                    errMsgObj.addMessage( 0,ErrorMessage.NG,"ERR0033.2" );
1022                                    errMsgObj.addMessage( 0,ErrorMessage.NG,"ERR0033.3" );
1023                                    jspPrint( TaglibUtil.makeHTMLErrorTable( errMsgObj,getResource() ) );
1024                                    rtn = false;
1025                            }
1026                    }
1027                    else {
1028                            System.out.println( "EntryTag:Consistency Key is null" );
1029                    }
1030                    return rtn ;
1031            }
1032    
1033            /**
1034             * 表示ãƒ??タの HybsSystem.ROW_SEL_KEY をå?にã€?�¸ばれた 行を処ç�??対象としますã?
1035             *
1036             * @og.rev 3.8.1.1 (2005/11/21) selectedAll 追åŠ??全件選択されたこととして、å?ç�?�—ますã?
1037             * @og.rev 4.0.0.0 (2005/01/31) getParameterRows() を使用するように変更
1038             *
1039             * @return      選択行ã?配å?
1040             */
1041            @Override
1042            protected int[] getParameterRows() {
1043                    final int[] rowNo ;
1044                    if( selectedAll ) {
1045                            int rowCnt = table.getRowCount();               // 3.5.5.7 (2004/05/10)
1046                            rowNo = new int[ rowCnt ];
1047                            for( int i=0; i<rowCnt; i++ ) {
1048                                    rowNo[i] = i;
1049                            }
1050                    } else {
1051                            rowNo = super.getParameterRows();               // 4.0.0 (2005/01/31)
1052                    }
1053                    return rowNo ;
1054            }
1055    
1056            /**
1057             * 【TAG】データをå?件選択済みとして処ç�?�™るかどã�?�‹[true/false]を指定しまã�?初期値:false)ã€?
1058             *
1059             * @og.tag
1060             * 全てのãƒ??タを選択済みãƒ??タとして扱って処ç�?�—ますã?
1061             * 全件処ç�?�™るå?合にã€?true/false)を指定しますã?
1062             * 初期値は false ですã?
1063             *
1064             * @param  all ãƒ??タをå?件選択済み [true:全件選択済み/false:通常]
1065             */
1066            public void setSelectedAll( final String all ) {
1067                    selectedAll = nval( getRequestParameter( all ),selectedAll );
1068            }
1069    
1070            /**
1071             * 【TAG】カラãƒ?¼©?¤の存在チェãƒ?‚¯を行うかどã�?�‹[true/false]を指定しまã�?初期値:true)ã€?
1072             *
1073             * @og.tag
1074             * true の場合ã?カラãƒ?¼©?¤がDBTableModel に存在しなã�??合ã?、エラーになりますã?
1075             * false の場合ã?カラãƒ?¼©?¤がDBTableModel に存在しなã�??合ã?、無視しますã?
1076             * これは、検索条件によって、設定されるカラãƒ?�Œ異なるå?合でもã?entryタグã‚?
1077             * 正常に動作させたã�??合に、使用しますã?
1078             * 初期値は true (チェãƒ?‚¯を行う) ですã?
1079             *
1080             * @param  check 存在チェãƒ?‚¯を行うかどã�?�‹ [true:行う/false:行わない]
1081             */
1082            public void setStrictCheck( final String check ) {
1083                    strictCheck = nval( getRequestParameter( check ),strictCheck );
1084            }
1085    
1086            /**
1087             * 【TAGã€?通常は使ã�?�¾せん)画面遷移を行わなã�?½¢式ã?登録方法を使用するかをæŒ?®šしますã?
1088             *
1089             * @og.tag
1090             * 画面遷移なしã?登録を行うかどã�?�‹を指定しますã?
1091             * trueが指定された場合ã?entryタグでは、行ã?追åŠ??è¤??時にDBTableModel上ã?æœ?µ‚行にãƒ??タã‚?
1092             * 追åŠ?�—ますã?
1093             * 画面遷移なしモードã?場合ã?途中行に挿入されたå?合ã?既にクライアントに出力されてã�?‚‹
1094             * チェãƒ?‚¯ボックスの行番号ã‚?�„入力フィールドã?変数名との整合æ?を合わせるためにはã€?
1095             * 編é›?¡Œ以降ã?å�?¤‰数値をå?て再計算するå¿?¦�がありますã?
1096             * こã?処ç�??、レスポンス悪化に繋がるためã?DBTableModel上ã?、中間に行ã?挿入を行いませんã€?
1097             * ä½?�—画面表示上ã?ã€??常通り選択行ã?直下に行が挿入されるためã?DBTableModelのé ?•ªと標準é?ã�?
1098             * 異なりますã?(エンジン側では、各チェãƒ?‚¯ボックスの値で行を識別してã�?‚‹ため、問題ã?発生しません)
1099             *
1100             * こã?値は、og:headタグで設定å?、またã?前画面からの値を継承するためã€??常、この属æ?ではセãƒ?ƒˆしませんã€?
1101             *
1102             * @og.rev 4.3.3.0 (2008/10/01) 新規追åŠ?
1103             * @og.rev 5.1.3.0 (2010/02/01) noTransition、ajaxSubmitのコントロールは、requestで行うã€?
1104             *
1105             * @param   noTrnstn 画面遷移を行わなã�?½¢式ã?登録方法を使用するã�?
1106             */
1107            public void setNoTransition( final String noTrnstn ) {
1108                    setNoTransitionRequest( nval( getRequestParameter( noTrnstn ), isNoTransitionRequest() ) );
1109            }
1110    
1111            /**
1112             * シリアライズ用のカスタãƒ?‚·リアライズ書き込みメソãƒ?ƒ‰
1113             *
1114             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
1115             * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
1116             *
1117             * @param       strm    ObjectOutputStreamオブジェクãƒ?
1118             * @throws IOException  シリアライズに関する入出力エラーが発生したå?å�?
1119             */
1120            private void writeObject( final ObjectOutputStream strm ) throws IOException {
1121                    strm.defaultWriteObject();
1122            }
1123    
1124            /**
1125             * シリアライズ用のカスタãƒ?‚·リアライズ読み込みメソãƒ?ƒ‰
1126             *
1127             * ここでは、transient 宣è¨?�•れたå†?ƒ¨変数のå†??初期化がå¿?¦�なフィールドã?み設定しますã?
1128             *
1129             * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
1130             * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
1131             *
1132             * @param       strm    ObjectInputStreamオブジェクãƒ?
1133             * @see #release2()
1134             * @throws IOException  シリアライズに関する入出力エラーが発生したå?å�?
1135             * @throws ClassNotFoundException       クラスを見つけることができなかったå?å�?
1136             */
1137            private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
1138                    strm.defaultReadObject();
1139            }
1140    
1141            /**
1142             * こã?オブジェクトã?æ–?­—å?表現を返しますã?
1143             * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
1144             *
1145             * @return こã?クラスのæ–?­—å?表現
1146             */
1147            @Override
1148            public String toString() {
1149                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
1150                                    .println( "VERSION"                                     ,VERSION                                )
1151                                    .println( "tableId"                                     ,tableId                                )
1152                                    .println( "command"                                     ,command                                )
1153                                    .println( "rowNo"                               ,rowNo                          )
1154                                    .println( "repeatCount"                         ,repeatCount                    )
1155                                    .println( "useConsistency"                      ,useConsistency                 )
1156                                    .println( "selectedAll"                         ,selectedAll                    )
1157                                    .println( "strictCheck"                         ,strictCheck                    )
1158                                    .println( "noTransition"                        ,noTransition                   )
1159                                    .println( "RESET_ACTION_ALL_USE"        ,RESET_ACTION_ALL_USE   )
1160                                    .println( "Other..."                            ,getAttributes().getAttribute() )
1161                                    .fixForm().toString() ;
1162            }
1163    }