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.resource.GUIInfo;
020 import org.opengion.hayabusa.resource.UserInfo;
021 import org.opengion.hayabusa.db.DBTableModel;
022 import org.opengion.hayabusa.db.DBColumn;
023 import org.opengion.hayabusa.db.DBTableModelUtil;
024
025 import static org.opengion.fukurou.util.StringUtil.nval ;
026
027 import java.io.ObjectOutputStream;
028 import java.io.ObjectInputStream;
029 import java.io.IOException;
030
031 /**
032 * 画面リソースのオブジェクトを検索しã?DBTableModel にセãƒ?ƒˆするタグですã?
033 *
034 * ファイルの検索結果は、GUIKEY,ADDRESS,REALADDRESS,SEQNO,GROUPS,CLASSIFY,LEVEL,
035 * NAME_JA,SNAME,LNAME,ROLES,RWMODE,TARGET,PARAM,KBLINK,DESCRIPTION,DYUPD のカラãƒ?‚’持つ
036 * DBTableModel にセãƒ?ƒˆ されますã?こã?カラãƒ??、固定ですã?
037 * 並び替えã?および、画面リソースの選別(where 条件)は、固定で、指定できませんã€?
038 *
039 * [カラãƒ?��] 検索するオブジェクトã?属æ?は、以下ã?カラãƒ?��で作æ?されますã?(固å®?
040 * GUIKEY 画面ID
041 * ADDRESS 実行アドレス
042 * REALADDRESS 実行実アドレス
043 * SEQNO 表示é ?
044 * GROUPS メニュグルーãƒ?
045 * CLASSIFY メニュåˆ?¡?
046 * LEVEL メニュ階層番号
047 * NAME_JA 画面名称
048 * SNAME 画面名称(short)
049 * LNAME 画面名称(long)
050 * ROLES ロールズ
051 * MODE アクセスモードå?(mr,mw,-r,-w のç¾??)
052 * TARGET ターゲãƒ?ƒˆ
053 * PARAM 設定å?(パラメータ)
054 * KBLINK リンク区åˆ?
055 * DESCRIPTION 概要説æ˜?
056 * DYUPD 更新日æ™?
057 *
058 * [roles 属æ?] 画面リソースの選別となるã?ROLES 属æ?
059 *
060 * @og.formSample
061 * ●形式ï¼?lt;og:guiQuery command="…" roles="…" />
062 * ●body?šなã�?
063 *
064 * ●Tag定義??
065 * <og:guiQuery
066 * roles 【TAG】画面リソースの条件となるロールズを指定しまã�?
067 * level 【TAG】画面リソースの条件となるレベルを指定しまã�?
068 * rwmode 【TAG】画面リソースの条件となるRWモードをæŒ?®šしまã�?
069 * command 【TAG】コマンãƒ?NEW,RENEW)をセãƒ?ƒˆしまã�?PlsqlUpdateTag,UpdateTag の場合ã?、ENTRY)
070 * scope 【TAG】キャãƒ?‚·ュする場合ã?スコープ[request/page/session/applicaton]を指定しまã�?初期値:session)
071 * displayMsg 【TAG】検索結果を画面上に表示するメãƒ?‚»ージリソースIDを指定しまã�?(初期値:VIEW_DISPLAY_MSG[=])
072 * notfoundMsg 【TAG】検索結果がゼロ件の場合に表示するメãƒ?‚»ージリソースIDを指定しまã�?初期値:MSG0077[対象ãƒ??タはありませんでした])
073 * tableId 【TAGã€?通常は使ã�?�¾せん)結果のDBTableModelをã?sessionに登録するときã?キーを指定しまã�?
074 * debug 【TAG】デバッグæƒ??をå?力するかどã�?�‹[true/false]を指定しまã�?初期値:false)
075 * > ... Body ...
076 * </og:guiQuery>
077 *
078 * ●使用ä¾?
079 * <og:guiQuery
080 * command = "NEW"
081 * roles = "AA|BB|CC"
082 * />
083 *
084 * @og.rev 5.2.2.0 (2010/11/01) 新規追åŠ?
085 * @og.group そã?他å?åŠ?
086 *
087 * @version 4.0
088 * @author Kazuhiko Hasegawa
089 * @since JDK5.0,
090 */
091 public class GuiQueryTag extends QueryTag {
092 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
093 private static final String VERSION = "5.3.3.0 (2011/03/01)" ;
094
095 private static final long serialVersionUID = 533020110301L ;
096
097 private static final String[] SELECT =
098 new String[] { "GUIKEY","ADDRESS","REALADDRESS","SEQNO","GROUPS","CLASSIFY","LEVEL",
099 // "NAME_JA","SNAME","LNAME","ROLES","RWMODE","TARGET","PARAM","KBLINK","DESCRIPTION" };
100 "NAME_JA","SNAME","LNAME","ROLES","RWMODE","TARGET","PARAM","KBLINK","DESCRIPTION","DYUPD" };
101
102 private static final int GUIKEY = 0;
103 private static final int ADDRESS = 1;
104 private static final int REALADDRESS = 2;
105 private static final int SEQNO = 3;
106 private static final int GROUPS = 4;
107 private static final int CLASSIFY = 5;
108 private static final int LEVEL = 6;
109 private static final int NAME_JA = 7;
110 private static final int SNAME = 8;
111 private static final int LNAME = 9;
112 private static final int ROLES = 10;
113 private static final int RWMODE = 11;
114 private static final int TARGET = 12;
115 private static final int PARAM = 13;
116 private static final int KBLINK = 14;
117 private static final int DESCRIPTION = 15;
118 private static final int DYUPD = 16; // 5.3.3.0 (2011/03/01) 更新日時追åŠ?
119
120 /** command 引数に渡す事ã?出来ã‚?コマンãƒ?リスãƒ? */
121 // private static final String[] COMMAND_LIST = new String[] { CMD_NEW , CMD_RENEW };
122
123 private String roles = null;
124 private String level = null;
125 private String rwmode = null;
126
127 /**
128 * Taglibの開始タグが見つかったときに処ç�?�™ã‚?doStartTag() ã‚?オーバã?ライドしますã?
129 *
130 * 通常の QueryTagでは、Body を評価する(EVAL_BODY_BUFFERED)を返しますがã€?
131 * GuiQueryでは BODYを評価しなã�?‚º、SKIP_BODY を返しますã?
132 *
133 * @return 後続å?ç�??æŒ?¤º(SKIP_BODY)
134 */
135 @Override
136 public int doStartTag() {
137 super.doStartTag();
138
139 // DBTableModel の初期åŒ?
140 table = initDBTable();
141
142 // 実è¡?
143 execute() ;
144
145 return(SKIP_BODY); // Body を評価しなã�?
146 }
147
148 /**
149 * タグリブオブジェクトをリリースしますã?
150 * キャãƒ?‚·ュされて再利用されるã?で、フィールドã?初期設定を行いますã?
151 *
152 */
153 @Override
154 protected void release2() {
155 super.release2();
156 roles = null;
157 level = null;
158 rwmode = null;
159 }
160
161 /**
162 * guiQuery を実行しますã?
163 *
164 */
165 protected void execute() {
166 UserInfo userInfo = new UserInfo( "XX","ja","DUMMY",roles,null,"GF","127.0.0.1",null );
167
168 getResource().makeGUIInfos( userInfo );
169
170 GUIInfo[] guiInfos = userInfo.getGUIInfos();
171
172 for( int i=0; i<guiInfos.length; i++ ) {
173 addGUIInfo( guiInfos[i] );
174 }
175 executeCount = table.getRowCount();
176 }
177
178 /**
179 * 初期化された DBTableModel を返しますã?
180 *
181 * @return ãƒ??ブルモãƒ?ƒ«
182 */
183 private DBTableModel initDBTable() {
184 DBTableModel tbl = DBTableModelUtil.newDBTable();
185
186 tbl.init( SELECT.length );
187 for( int i=0; i<SELECT.length; i++ ) {
188 DBColumn dbColumn = getDBColumn( SELECT[i] );
189 tbl.setDBColumn( i,dbColumn );
190 }
191
192 return tbl ;
193 }
194
195 /**
196 * DBTableModel に、ファイルæƒ??をセãƒ?ƒˆしますã?
197 * ファイルの検索結果は、GUIKEY,ADDRESS,REALADDRESS,SEQNO,GROUPS,CLASSIFY,LEVEL,
198 * NAME_JA,SNAME,LNAME,ROLES,RWMODE,TARGET,PARAM,KBLINK,DESCRIPTION,DYUPD のカラãƒ?‚’持つ
199 * DBTableModel にセãƒ?ƒˆ されますã?こã?カラãƒ??、固定ですã?
200 *
201 * @og.rev 5.3.3.0 (2011/03/01) 更新日時追åŠ??åˆ?¡žを名称でセãƒ?ƒˆ
202 *
203 * @param guiInfo セãƒ?ƒˆする画面リソース
204 */
205 private void addGUIInfo( final GUIInfo guiInfo ) {
206 String guiLevel = String.valueOf( guiInfo.getLevel() );
207 if( level != null && !level.equals( guiLevel ) ) { return; }
208
209 String guiMode = guiInfo.getMode();
210 if( rwmode != null && guiMode != null && !guiMode.startsWith( rwmode ) ) { return; }
211
212 String[] data = new String[ SELECT.length ];
213
214 data[GUIKEY ] = guiInfo.getKey();
215 data[ADDRESS ] = guiInfo.getAddress();
216 data[REALADDRESS] = guiInfo.getRealAddress();
217 data[SEQNO ] = String.valueOf( guiInfo.getSequence() );
218 data[GROUPS ] = guiInfo.getGroups();
219 // data[CLASSIFY ] = guiInfo.getClassify();
220 data[CLASSIFY ] = getResource().getLabel( guiInfo.getClassify() );
221 data[LEVEL ] = guiLevel;
222 data[NAME_JA ] = guiInfo.getLabel();
223 data[SNAME ] = guiInfo.getName();
224 data[LNAME ] = guiInfo.getLongName();
225 data[ROLES ] = guiInfo.getRoles();
226 data[RWMODE ] = guiMode;
227 data[TARGET ] = guiInfo.getTarget();
228 data[PARAM ] = guiInfo.getParam();
229 data[KBLINK ] = guiInfo.getKblink();
230 data[DESCRIPTION] = guiInfo.getDescription();
231 data[DYUPD ] = guiInfo.getDyupd();
232
233 table.addColumnValues( data );
234 }
235
236 /**
237 * 【TAG】画面リソースの条件となるロールズを指定しますã?
238 *
239 * @og.tag
240 * ロールズ判定ã?、ダミã?ユーザーを作æ?して通常の処ç�?�¨同様ã?判定方式で
241 * 有効な画面リソースをピãƒ?‚¯アãƒ??しますã?
242 *
243 * @param rols ロールズ
244 */
245 public void setRoles( final String rols ) {
246 roles = nval( getRequestParameter( rols ),roles );
247 }
248
249 /**
250 * 【TAG】画面リソースの条件となるレベルを指定しますã?
251 *
252 * @og.tag
253 * レベル判定ã?、文字å?レベルの判定を行いますã?
254 * 画面リソースの階層番号(レベル)はã€?
255 * ã€?:グループå?類メニュー(class="GUI_GRP"のtdタグで囲われまã�?
256 * ã€?:トップ階層(【å?類名称ã€?
257 * ã€?:選択階層(通常の折りたたみメニュー)
258 * ã€?:選択非表示(通常はã€?š してありまã�?
259 * ですã?
260 *
261 * ロール等ã?他ã?条件でピックアãƒ??されたリソースと AND 処ç�?�•れますã?
262 * 何もæŒ?®šしなければ、すべてを対象としますã?
263 *
264 * @param lvl ロールズ
265 */
266 public void setLevel( final String lvl ) {
267 level = nval( getRequestParameter( lvl ),level );
268 }
269
270 /**
271 * 【TAG】画面リソースの条件となるRWモードをæŒ?®šしますã?
272 *
273 * @og.tag
274 * RWモード判定ã?、文字å?レベルの判定を行いますã?(通常のRW判定と異なりまã�?
275 * RWモードã?代表çš?�ª記述は、mw,mr,-w,-r ですã?ここでは、特殊な検索は出来なã�?�Ÿめã?
276 * 上記文字å?そã?ままで、ä¸??するかã?m,- の前方ä¸??で判断するかã?どちらかですã?
277 *
278 * ロール等ã?他ã?条件でピックアãƒ??されたリソースと AND 処ç�?�•れますã?
279 * 何もæŒ?®šしなければ、すべてを対象としますã?
280 *
281 * @param mode RWモーãƒ?
282 */
283 public void setRwmode( final String mode ) {
284 rwmode = nval( getRequestParameter( mode ),rwmode );
285 }
286
287 /**
288 * シリアライズ用のカスタãƒ?‚·リアライズ書き込みメソãƒ?ƒ‰
289 *
290 * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
291 * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
292 *
293 * @param strm ObjectOutputStreamオブジェクãƒ?
294 * @throws IOException 入出力エラーが発生したå?å�?
295 */
296 private void writeObject( final ObjectOutputStream strm ) throws IOException {
297 strm.defaultWriteObject();
298 }
299
300 /**
301 * シリアライズ用のカスタãƒ?‚·リアライズ読み込みメソãƒ?ƒ‰
302 *
303 * ここでは、transient 宣è¨?�•れたå†?ƒ¨変数のå†??初期化がå¿?¦�なフィールドã?み設定しますã?
304 *
305 * @og.rev 4.0.0.0 (2006/09/31) 新規追åŠ?
306 * @serialData ä¸?ƒ¨のオブジェクトã?、シリアライズされませんã€?
307 *
308 * @param strm ObjectInputStreamオブジェクãƒ?
309 * @see #release2()
310 * @throws IOException シリアライズに関する入出力エラーが発生したå?å�?
311 * @throws ClassNotFoundException クラスを見つけることができなかったå?å�?
312 */
313 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
314 strm.defaultReadObject();
315 }
316
317 /**
318 * こã?オブジェクトã?æ–?—å?表現を返しますã?
319 * 基本çš?�«ãƒ?ƒ�ãƒ?‚°目çš?�«使用しますã?
320 *
321 * @return こã?クラスのæ–?—å?表現
322 */
323 @Override
324 public String toString() {
325 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
326 .println( "VERSION" ,VERSION )
327 .println( "roles" ,roles )
328 .fixForm().toString()
329 + HybsSystem.CR
330 + super.toString() ;
331 }
332 }