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