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="{@docRoot}/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="{@docRoot}/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 * <del>カラ?とカラ?oは同時には登録できません?/del>
223 * 全く同じ?容を設定する?合には、カラ?をC??形?カンマ区?)で
224 * ??することが可能です?
225 *
226 * @og.rev 3.6.0.6 (2004/10/22) columnNo に伴な?更
227 *
228 * @param clmid カラ??
229 */
230 public void setColumnId( final String clmid ) {
231 columnId = getRequestParameter( clmid );
232 }
233
234 /**
235 * 【TAG】条件判定するカラ??を指定しま?初期値は columnId )?
236 *
237 * @og.tag
238 * ??カラ??の値と、conditionList の値を比?て?
239 * 存在する場合?、action処?実行します?
240 * 例えば、?期?設?action="DEFAULT")で、??"0" の場合だけ適用するような
241 * ケースに使用できます?
242 * ?しな??合?、columnId と同じキーになります?
243 * 注意:columnId は???形式で?同時に?できます?そ?場合??
244 * conditionKey には、?設定する機?はありませんので、?カラ?
245 * 同?ラ?使用する場合?、conditionKey に値を設定できます?
246 * 値を設定しな??合?、?動的に、columnId と同?なります?
247 *
248 * @og.rev 3.6.0.6 (2004/10/22) 新規追?
249 *
250 * @param key カラ??
251 * @see #setConditionList( String )
252 */
253 public void setConditionKey( final String key ) {
254 conditionKey = nval( getRequestParameter( key ),null ) ;
255 }
256
257 /**
258 * 【TAG】条件判定する?のリストを?|"で区?て登録しま?初期値:無条件)?
259 *
260 * @og.tag
261 * conditionKey とペアで?します?ここには、カラ??設定?のリストを
262 * ?することで、?条件(??結合)での比?行い、リストにカラ???
263 * 存在する場合?み、action処?実行します?
264 * 設定しな??合?、無条件に実行します?
265 *
266 * @og.rev 3.6.0.6 (2004/10/22) 新規追?
267 *
268 * @param list 条件判定する?("|"区?
269 * @see #setConditionKey( String )
270 */
271 public void setConditionList( final String list ) {
272 set( "conditionList","|" + getRequestParameter( list ) + "|" );
273 }
274
275 /**
276 * 【TAG】カラ??が存在しな?きに無視するかど?を指定しま?初期値:true)?
277 *
278 * @og.tag
279 * カラ??する場合?、DBTableModel に存在するカラ?対してのみ?
280 * 処?適用するべきで??常存在しな?ラ?使用した場合?、Exception ?
281 * throw されます?(strictCheck="true" 初期値の動作です?)
282 * ところが?動的??ブル検索などでカラ?不特定な場合?DBTableModel に
283 * 存在しな??合に、無視したい場合があります?そ?場合?、strictCheck="false"
284 * に設定すると、カラ?存在しな??合?、エラーにせず、無視します?
285 * 初期値は、true:厳格に処??です?
286 *
287 * @og.rev 4.0.0.0 (2006/09/31) 新規追?
288 *
289 * @param strict 無視するかど?[true/false]
290 */
291 public void setStrictCheck( final String strict ) {
292 set( "strictCheck",getRequestParameter( strict ) );
293 }
294
295 /**
296 * こ?オブジェクト???表現を返します?
297 * 基本???目?使用します?
298 *
299 * @return こ?クラスの??表現
300 */
301 @Override
302 public String toString() {
303 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
304 .println( "VERSION" ,VERSION )
305 .println( "columnId" ,columnId )
306 .println( "conditionKey",conditionKey )
307 .println( "Other..." ,getAttributes().getAttribute() )
308 .fixForm().toString() ;
309 }
310 }