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 }