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.HybsSystemException;
019    import org.opengion.fukurou.util.Attributes;
020    import org.opengion.fukurou.util.StringUtil;
021    
022    import static org.opengion.fukurou.util.StringUtil.nval ;
023    
024    /**
025     * 検索結果の DBTableModelオブジェクト?カラ??を操?設定?変換、ADDなど)するタグです?
026     *
027     * entry タグの子タグとして使用します?entryタグと、このcolumnSetタグの command
028     * が同じ?合?み、実行されます?
029     * 処?法?、action で?します?
030     *
031     * @og.formSample
032     * ●形式?lt;og:entry command="…">
033     *             <og:setColumn
034     *                 command   ="…"          : entryタグのcommandと??する場合に実?
035     *                 columnId  ="…"          : 処?行うカラ??を指???,??可)
036     *                 action    ="…"          : 処?法を??
037     *                 value     ="…"          : 設定する?を指?action="TBLSET"のみ[カラ?]使用可能)
038     *                 conditionKey  ="…"      : 条件判定するカラ??を指?初期値は columnId )
039     *                 conditionList ="…"      : 条件判定する?のリストを?|"で区?て登録(初期値は、無条件)
040     *             />
041     *         </og:entry>
042     * ●body?な?
043     *
044     * ●Tag定義??
045     *   <og:columnSet
046     *       command            【TAG】コマン?INSERT/COPY/MODIFY/DELETE/ENTRY/CHANGE/RESET/ALLRESET/ALLACTION/RESETDATA/INSERTONE/REALDELETE/REQENTRY)を設定しま?
047     *       columnId         ○?TAG】カラ??をセ?しま???時は、カンマ区??で設定す?(??)?
048     *       value              【TAG】?をセ?しま?
049     *       action             【TAG】アクション(DEFAULT/CLEAR/ADD/SET/NULLSET/LOWER/UPPER/COPY/TBLSET//WRTCTRL/DBMENU/REQSET/SEQSET)をセ?しま?
050     *       conditionKey       【TAG】条件判定するカラ??を指定しま?初期値は columnId )
051     *       conditionList      【TAG】条件判定する?のリストを?|"で区?て登録しま?初期値:無条件)
052     *       caseKey            【TAG】このタグ自体を利用するかど?の条件キーを指定しま?初期値:null) 5.7.7.2 (2014/06/20)
053     *       caseVal            【TAG】このタグ自体を利用するかど?の条件値を指定しま?初期値:null) 5.7.7.2 (2014/06/20)
054     *       caseNN             【TAG】指定?値が?null/ゼロ?? でな???Not Null=NN)は、このタグは使用されま?初期値:true) 5.7.7.2 (2014/06/20)
055     *       caseNull           【TAG】指定?値が?null/ゼロ?? の場合?、このタグは使用されま?初期値:true) 5.7.7.2 (2014/06/20)
056     *       debug              【TAG】デバッグ??を?力するかど?[true/false]を指定しま?初期値:false)
057     *   />
058     *
059     * ●使用?
060     *    <og:entry command="{@command}"  >
061     *        <og:columnSet command="{@command}" columnId="ECNO"   action="CLEAR" />
062     *        <og:columnSet command="{@command}" columnId="JYOKYO" action="SET" value="1" />
063     *    </og:entry>
064     *
065     *    <og:entry command="MODIFY" rows="1" >
066     *        <og:columnSet command="MODIFY" columnId="key" action="TBLSET" value ="[key][lang]"/>
067     *    </og:entry>
068     *
069     *    command属? は、entryタグのcommand属?と同??場合?み、??ます?
070     *    [command属?]
071     *      INSERT     新?
072     *      COPY       ??
073     *      MODIFY     変更
074     *      DELETE     削除
075     *      ENTRY      エントリー
076     *      CHANGE     チェンジ
077     *      RESET      リセ?
078     *      ALLRESET   全件リセ?
079     *      ALLACTION  オールアクション
080     *      RESETDATA  リセ???タ
081     *      INSERTONE  新?1行?み)
082     *      REALDELETE 物?除
083     *      REQENTRY   リクエスト変数設?
084     *
085     *    [action属?]
086     *      DEFAULT カラ?ソースで定義した初期値をセ?します?
087     *      CLEAR   値をクリア(ゼロストリング "" )します?
088     *      ADD     現在の値???します?  0 ?1 , A ?B , 9 ?10。value属?と併用すれば、指定?値を加算できます?
089     *      SET     value で設定した??新しい値として登録します?
090     *      NULLSET ??値?NULL の場合だけ?value で設定した新しい値を登録します?
091     *      LOWER   小文字に変換します?
092     *      UPPER   大?に変換します?
093     *      COPY    value にコピ???カラ?Dをセ?すれば、その値を代入します?
094     *      TBLSET  DBTableModel の?を取り込んで?? columnId カラ?設定します?
095     *              [カラ?] で?できます?
096     *              また?これは??を解析して?value を作?します?で,??連結等に使用できます?
097     *      WRTCTRL writableControl を使用したカラ?ータの先?アン??バ?を削除します?
098     *      DBMENU  DBMENUでパラメータ設?コロン連結文?を使用したカラ?ータの先???タのみにします?
099     *      REQSET  valueで?したカラ??値をキーに、リクエスト変数から値を取出し?セ?します?
100     *      SEQSET  valueの初期値を利用して?レコードごとに?1した?をセ?します?
101     *      PREFIX  valueの値を後ろから検索し???カラ??の前半部?取得しま?記号は含みません)?
102     *      SUFIX   valueの値を後ろから検索し???カラ??の後半部?取得しま?記号は含みません)?
103     *      そ?? カラ??DBType の valueAction メソ?を呼び出します?自由に設定可能です?
104     *
105     * @og.group 画面登録
106     *
107     * @version  4.0
108     * @author       Kazuhiko Hasegawa
109     * @since    JDK5.0,
110     */
111    public class ColumnSetTag extends CommonTagSupport {
112            //* こ?プログラ??VERSION??を設定します?       {@value} */
113            private static final String VERSION = "5.7.7.2 (2014/06/20)" ;
114    
115            private static final long serialVersionUID = 577220140620L ;
116    
117            private String columnId         = null;
118            private String conditionKey = null;
119    
120            /**
121             * Taglibの開始タグが見つかったときに処??doStartTag() ?オーバ?ライドします?
122             *
123             * @og.rev 3.6.0.6 (2004/10/22) columnNo に伴な?除
124             * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属?を追?
125             *
126             * @return      後続????(SKIP_BODY)
127             */
128            @Override
129            public int doStartTag() {
130                    // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属?を追?
131                    if( useTag() ) {
132                            EntryTag entry = (EntryTag)findAncestorWithClass( this,EntryTag.class );
133                            if( entry == null ) {
134                                    String errMsg = "<b>" + getTagName() + "タグは、EntryTag のBODY部に記述される?があります?</b>";
135                                    throw new HybsSystemException( errMsg );
136                            }
137    
138                            Attributes standardAttri = getAttributes();
139                            String[] clms = StringUtil.csv2Array( columnId );
140                            for( int i=0; i<clms.length; i++ ) {
141                                    Attributes attri = new Attributes( standardAttri );
142                                    attri.set( "columnId", clms[i] );
143                                    // conditionKey ?null の場合?、columnId が設定される?
144                                    attri.set( "conditionKey", nval( conditionKey,clms[i] ) );
145                                    entry.setAttributes( attri );
146                            }
147                    }
148    
149                    return SKIP_BODY ;
150            }
151    
152            /**
153             * タグリブオブジェクトをリリースします?
154             * キャ?ュされて再利用される?で、フィールド?初期設定を行います?
155             *
156             * @og.rev 2.0.0.4 (2002/09/27) カスタ?グの release() メソ?を?追?
157             * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ?
158             * @og.rev 3.6.0.6 (2004/10/22) columnNo に伴な?更
159             *
160             */
161            @Override
162            protected void release2() {
163                    super.release2();
164                    columnId         = null;
165                    conditionKey = null;
166            }
167    
168            /**
169             * 【TAG】コマン?INSERT,COPY,MODIFY,DELETE,ENTRY,CHANGE,RESET,ALLACTION)を設定します?
170             *
171             * @og.tag
172             * 上位? EntryTag のコマンドと??した場合?み、??れます?
173             * ここでは、コマンド文字?の整合?チェ?は行って?せん?
174             *
175             * @param       command コマン?
176             * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.EntryTag.CMD_INSERT">コマンド定数</a>
177             */
178            public void setCommand( final String command ) {
179                    set( "command",getRequestParameter( command ) );
180            }
181    
182            /**
183             * 【TAG】?をセ?します?
184             *
185             * @og.tag
186             * 設定する?をセ?します?
187             *
188             * @param       value 値
189             */
190            public void setValue( final String value ) {
191                    set( "value",getRequestParameter( value ) );
192            }
193    
194            /**
195             * 【TAG】アクション(DEFAULT/CREAR/ADD/SET/NULLSET/LOWER/UPPER/COPY/TBLSET/WRTCTRL/DBMENU/REQSET/SEQSET/PREFIX/SUFIX)をセ?します?
196             *
197             * @og.tag
198             * ここでは、アクション??の整合?チェ?を行っておりません?
199             *
200             * DEFAULT カラ?ソースで定義した初期値をセ?します?
201             * CREAR   値をクリア(ゼロストリング &quot;&quot; )します?
202             * ADD     現在の値???します?  0 ?1 , A ?B , 9 ?10。value属?と併用すれば、指定?値を加算できます?
203             * SET     value で設定した??新しい値として登録します?
204             * NULLSET ??値?NULL の場合だけ?value で設定した新しい値を登録します?
205             * LOWER   小文字に変換します?
206             * UPPER   大?に変換します?
207             * COPY    value にコピ???カラ?Dをセ?すれば、その値を代入します?
208             * TBLSET  DBTableModel の?を取り込んで?? columnId カラ?設定します?[カラ?] で?できます?
209             * WRTCTRL writableControl を使用したカラ?ータの先?アン??バ?を削除します?
210             * DBMENU  DBMENUでパラメータ設?コロン連結文?を使用したカラ?ータの先???タのみにします?
211             * REQSET  valueで?したカラ??値をキーに、リクエスト変数から値を取出し?セ?します?
212             * SEQSET  valueの初期値を利用して?レコードごとに?1した?をセ?します?
213             * PREFIX  valueの値を後ろから検索し???カラ??の前半部?取得しま?記号は含みません)?
214             * SUFIX   valueの値を後ろから検索し???カラ??の後半部?取得しま?記号は含みません)?
215             * そ?? カラ??DBType の valueAction メソ?を呼び出します?自由に設定可能です?
216             *
217             * @param       action アクション??
218             * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.EntryTag.ACT_DEFAULT">アクション定数</a>
219             */
220            public void setAction( final String action ) {
221                    set( "action",getRequestParameter( action ) );
222            }
223    
224            /**
225             * 【TAG】カラ??をセ?しま???時は、カンマ区??で設定す??
226             *
227             * @og.tag
228             * 処?適用するカラ??を指定します?
229             * 全く同じ?容を設定する?合には、カラ?をC??形?カンマ区?)で
230             * ??することが可能です?
231             *
232             * @og.rev 3.6.0.6 (2004/10/22) columnNo に伴な?更
233             *
234             * @param       clmid カラ??
235             */
236            public void setColumnId( final String clmid ) {
237                    columnId = getRequestParameter( clmid );
238            }
239    
240            /**
241             * 【TAG】条件判定するカラ??を指定しま?初期値は columnId )?
242             *
243             * @og.tag
244             * ??カラ??の値と、conditionList の値を比?て?
245             * 存在する場合?、action処?実行します?
246             * 例えば、?期?設?action="DEFAULT")で、??"0" の場合だけ適用するような
247             * ケースに使用できます?
248             * ?しな??合?、columnId と同じキーになります?
249             * 注意:columnId は???形式で?同時に?できます?そ?場合??
250             * conditionKey には、?設定する機?はありませんので、?カラ?
251             * 同?ラ?使用する場合?、conditionKey に値を設定できます?
252             * 値を設定しな??合?、?動的に、columnId と同?なります?
253             *
254             * @og.rev 3.6.0.6 (2004/10/22) 新規追?
255             *
256             * @param       key カラ??
257             * @see         #setConditionList( String )
258             */
259            public void setConditionKey( final String key ) {
260                    conditionKey = nval( getRequestParameter( key ),null ) ;
261            }
262    
263            /**
264             * 【TAG】条件判定する?のリストを?|"で区?て登録しま?初期値:無条件)?
265             *
266             * @og.tag
267             * conditionKey とペアで?します?ここには、カラ??設定?のリストを
268             * ?することで、?条件(??結合)での比?行い、リストにカラ???
269             * 存在する場合?み、action処?実行します?
270             * 設定しな??合?、無条件に実行します?
271             *
272             * @og.rev 3.6.0.6 (2004/10/22) 新規追?
273             *
274             * @param       list 条件判定する?("|"区?
275             * @see         #setConditionKey( String )
276             */
277            public void setConditionList( final String list ) {
278                    set( "conditionList","|" + getRequestParameter( list ) + "|" );
279            }
280    
281            /**
282             * 【TAG】カラ??が存在しな?きに無視するかど?を指定しま?初期値:true)?
283             *
284             * @og.tag
285             * カラ??する場合?、DBTableModel に存在するカラ?対してのみ?
286             * 処?適用するべきで??常存在しな?ラ?使用した場合?、Exception ?
287             * throw されます?(strictCheck="true" 初期値の動作です?)
288             * ところが?動的??ブル検索などでカラ?不特定な場合?DBTableModel に
289             * 存在しな??合に、無視したい場合があります?そ?場合?、strictCheck="false"
290             * に設定すると、カラ?存在しな??合?、エラーにせず、無視します?
291             * 初期値は、true:厳格に処??です?
292             *
293             * @og.rev 4.0.0.0 (2006/09/31) 新規追?
294             *
295             * @param       strict 無視するかど?[true/false]
296             */
297            public void setStrictCheck( final String strict ) {
298                    set( "strictCheck",getRequestParameter( strict ) );
299            }
300    
301            /**
302             * こ?オブジェクト???表現を返します?
303             * 基本???目?使用します?
304             *
305             * @return こ?クラスの??表現
306             */
307            @Override
308            public String toString() {
309                    return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
310                                    .println( "VERSION"             ,VERSION                )
311                                    .println( "columnId"    ,columnId               )
312                                    .println( "conditionKey",conditionKey   )
313                                    .println( "Other..."    ,getAttributes().getAttribute() )
314                                    .fixForm().toString() ;
315            }
316    }