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 static org.opengion.fukurou.util.StringUtil.nval; 019 020 import java.io.IOException; 021 import java.io.ObjectInputStream; 022 import java.io.ObjectOutputStream; 023 import java.util.ArrayList; 024 import java.util.HashMap; 025 import java.util.List; 026 import java.util.Locale; 027 import java.util.Map; 028 029 import javax.script.ScriptEngine; 030 import javax.script.ScriptEngineManager; 031 import javax.script.ScriptException; 032 import javax.servlet.ServletException; 033 034 import org.opengion.fukurou.db.DBUtil; 035 import org.opengion.fukurou.db.Transaction; 036 import org.opengion.fukurou.db.TransactionReal; 037 import org.opengion.fukurou.model.Formatter; 038 import org.opengion.fukurou.util.ErrorMessage; 039 import org.opengion.fukurou.util.StringUtil; 040 import org.opengion.hayabusa.common.HybsSystem; 041 import org.opengion.hayabusa.common.HybsSystemException; 042 import org.opengion.hayabusa.db.DBTableModel; 043 import org.opengion.hayabusa.resource.ResourceManager; 044 045 /** 046 * 画面で入力された??タのチェ?を行うためのタグです? 047 * 048 * commandがNEWの場合?検索条件等?リクエストパラメータに対してチェ?を行います? 049 * commandがENTRYの場合?、登録時?DB??ブルモ?に対するチェ?を行います? 050 * (値の取得?、?に選択された行?みにつ?、実行されます?) 051 * 052 * チェ?を行うための定義は、SQL?又? JavaScriptの式が記述可能です? 053 * これら?式?タグのボディー部?記述します? 054 * 055 * SQL?よりチェ?を行う場合?、?件数が返されるように記述して下さ?select count(*) ??? ? 056 * こ?SQL?取得された件数とexistの属?値とを?合しチェ?を行います? 057 * ?れ?場合も、?立時は、正常とみなします? 058 * (?true:存在する? には、データが存在した場合に??で、なければエラーです?) 059 * 060 * JavaScript式を記述する場合?、?true or falseを返す式を?して下さ?? 061 * こ?式を評価した結果falseが返される場合?、エラーとみなします? 062 * 式に不等号等を使用する場合?、CDATAセクションで囲??して下さ?? 063 * 064 * また??れ?チェ?方法?場合でも?引数部に[カラ?]を用?Hybs拡張SQL? 065 * ?することが可能です? 066 * メ?ージIDの{0},{1}にはそれぞれ[カラ?]?されたカラ?及???タがカンマ区?で 067 * 自動的に設定されます? 068 * 069 * ※ こ?タグは、Transaction タグの対象です? 070 * 071 * @og.formSample 072 * <pre> 073 * ●形式? 074 * ・<og:dataCheck 075 * command = "{@command}" 076 * exist = "[auto|true|false|one|notuse]" 077 * errRemove = "[true|false]" 078 * msg = "{@msg}" 079 * msgParamKeys = "ZY03" : メ?ージリソースのキーをカンマ区?で??{2} 以降にセ? 080 * sqlType = "{@sqlType}" 081 * execType = "INSERT|COPY|UPDATE|MODIFY|DELETE" : sqlType を含??合?実? 082 * conditionKey = "FGJ" : 条件判定するカラ??を指?初期値は columnId ) 083 * conditionList = "0|1|8|9" : 条件判定する?のリストを?|"で区?て登録(初期値は、無条件) 084 * uniqCheckKeys = "CLM,LANG" : DBTableModel?のユニ?クキーチェ?を行うためのカラ? 085 * > 086 * 087 * ●body?あ?EVAL_BODY_BUFFERED:BODYを評価し?{@XXXX} を解析しま? 088 * (SQL?又? JavaScript? 089 * 090 * ●Tag定義?? 091 * <og:dataCheck 092 * command 【TAG】コマン?NEW or ENTRY)をセ?しま? 093 * exist 【TAG】データベ?スのチェ?方法[auto/true/false/one/notuse]を指定しま?初期値:auto[自動]) 094 * tableId 【TAG?通常は使?せん)結果をDBTableModelに書き込んで、sessionに登録するとき?キーを指定しま? 095 * dbid 【TAG?通常は使?せん)Queryオブジェクトを作?する時?DB接続IDを指定しま? 096 * lbl 【TAG】ラベルリソースIDを指定しま? 097 * lblParamKeys 【TAG】ラベルリソースの引数をカンマ区?で?しま? 098 * errRemove 【TAG】エラー時?選択行を取り除?継続??行うかど?[true/false]を指定しま?初期値:false) 099 * sqlType 【TAG】このチェ?を行う、SQLタイ?を指定しま? 100 * execType 【TAG】このチェ?を行う、実行タイ?を指定しま? 101 * conditionKey 【TAG】条件判定するカラ??を指定しま? 102 * conditionList 【TAG】条件判定する?のリストを?|"で区?て登録しま?初期値:無条件) 103 * uniqCheckClms 【TAG】指定されたキーに従って、メモリ上???ブルに対してユニ?クキーチェ?を行いま? 104 * beforeErrorJsp 【TAG】エラーが発生した際に、エラーメ?ージの表示前にincludeするJSPを指定しま? 105 * afterErrorJsp 【TAG】エラーが発生した際に、エラーメ?ージの表示後にincludeするJSPを指定しま? 106 * selectedAll 【TAG】データを?件選択済みとして処?るかど?[true/false]を指定しま?初期値:false) 107 * msg 【?】メ?ージIDを指定しま?lbl 属?を使用してください) 108 * msgParamKeys 【?】メ?ージリソースの引数をカンマ区?で?しま?lblParamKeys 属?を使用してください) 109 * debug 【TAG】デバッグ??を?力するかど?[true/false]を指定しま?初期値:false) 110 * > ... Body ... 111 * </og:dataCheck> 112 * 113 * ●使用? 114 * ・<og:dataCheck 115 * command = "ENTRY" 116 * exist = "true" 117 * msg = "MSG0001" 118 * > 119 * select count(*) from GEA03 where clm = [CLM] 120 * </og:dataCheck> 121 * 122 * ・exist 属?の値に応じて、チェ?方法が異なります? 123 * [ auto , true , false , one , notuse が指定できます?] 124 * 125 * ・<og:dataCheck 126 * command = "ENTRY" 127 * msg = "MSG0001" 128 * > 129 * <![CDATA[ 130 * [DYSTART] < [DY] && [DY] < [DYEND] 131 * ]]> 132 * </og:dataCheck> 133 * 134 * ・<og:dataCheck 135 * command = "ENTRY" 136 * msg = "MSG0001" 137 * > 138 * <![CDATA[ 139 * [GOKEI] < [TANKA] * [RITU] 140 * ]]> 141 * </og:dataCheck> 142 * </pre> 143 * 144 * @og.rev 4.1.1.1 (2008/02/22) 新規作? 145 * @og.group ??登録 146 * 147 * @version 4.0 148 * @author Hiroki Nakamura 149 * @since JDK5.0, 150 */ 151 public class DataCheckTag extends CommonTagSupport { 152 //* こ?プログラ??VERSION??を設定します? {@value} */ 153 private static final String VERSION = "5.6.1.1 (2013/02/08)"; 154 155 private static final long serialVersionUID = 561120130208L; 156 157 /** command 引数に渡す事?出来?コマン?{@value} */ 158 public static final String CMD_NEW = "NEW"; 159 160 /** command 引数に渡す事?出来?コマン?{@value} */ 161 public static final String CMD_ENTRY = "ENTRY"; 162 163 /** command 引数に渡す事?出来?コマン?リス? */ 164 private static final String[] COMMAND_LIST = { CMD_ENTRY, CMD_NEW }; 165 166 /** ?変数 */ 167 private transient DBTableModel table = null; 168 // private transient ErrorMessage errMessage = null; 169 private transient boolean isSql = false; 170 private transient boolean isUniqCheck = false; // 4.3.4.0 (2008/12/01) 追? 171 private transient ScriptEngine jsEngine = null; 172 private transient String bodyStr = null; // 4.3.4.0 (2008/12/01) 追? 173 174 /** タグで設定する属? */ 175 private String command = CMD_ENTRY; 176 private String exist = "auto"; 177 private String tableId = HybsSystem.TBL_MDL_KEY; 178 private String dbid = null; 179 private String msg = null; 180 private String[] msgParamKeys = null; // 4.2.0.1 (2008/03/27) 181 private boolean errRemove = false; 182 private String sqlType = null; // INSERT,COPY,UPDATE,MODIFY,DELETE 183 private String execType = null; // INSERT,COPY,UPDATE,MODIFY,DELETE 184 private boolean isExec = true; // 4.1.2.0 (2008/03/12) 185 186 private String conditionKey = null; // 4.2.0.1 (2008/03/27) 187 private String conditionList = null; // 4.2.0.1 (2008/03/27) 188 private String from = null; // 4.2.0.1 (2008/03/27) 189 private String[] uniqCheckClms = null; // 4.3.4.0 (2008/12/01) 190 191 private String beforeErrorJsp = null; // 5.1.9.0 (2010/08/01) 192 private String afterErrorJsp = null; // 5.1.9.0 (2010/08/01) 193 private boolean selectedAll = false; // 5.1.9.0 (2010/08/01) 194 195 /** 196 * Taglibの開始タグが見つかったときに処??doStartTag() ?オーバ?ライドします? 197 * 198 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 199 * @og.rev 4.1.2.0 (2008/03/12) sqlType,execType 判? 200 * 201 * @return 後続???? 202 */ 203 @Override 204 public int doStartTag() { 205 isExec = (sqlType == null || execType == null || execType.indexOf( sqlType ) >= 0 ); 206 207 if( isExec ) { 208 return( EVAL_BODY_BUFFERED ); // Body を評価する 209 } 210 else { 211 return(SKIP_BODY); // Body を評価しな? 212 } 213 } 214 215 /** 216 * Taglibのタグ本体を処??doAfterBody() ?オーバ?ライドします? 217 * 218 * @og.rev 4.3.4.0 (2008/12/01) 新規追? 219 * 220 * @return 後続????(SKIP_BODY) 221 */ 222 @Override 223 public int doAfterBody() { 224 bodyStr = getBodyString().trim(); 225 return(SKIP_BODY); 226 } 227 228 /** 229 * Taglibの終?グが見つかったときに処??doEndTag() ?オーバ?ライドします? 230 * 231 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 232 * @og.rev 4.1.2.0 (2008/03/12) sqlType,execType 判? 233 * @og.rev 4.2.0.1 (2008/03/27) from を取? 234 * @og.rev 4.2.1.0 (2008/04/11) ErrMessageManager対? 235 * @og.rev 4.3.4.0 (2008/12/01) ユニ?クキーチェ?対応?bodyContentの取得を#doAfterBody()で行う? 236 * @og.rev 5.1.9.0 (2010/08/01) エラーメ?ージの表示前後にincludeするJSPを指定できるようにする? 237 * @og.rev 5.1.9.0 (2010/08/01) Transaction 対応します? 238 * @og.rev 5.3.7.0 (2011/07/01) TransactionReal の引数変更 、Transaction対応で、close処?入れる? 239 * 240 * @return 後続???? 241 */ 242 @Override 243 public int doEndTag() { 244 debugPrint(); 245 int rtnCode = EVAL_PAGE; 246 247 // 4.1.2.0 (2008/03/12) 実行条件 isExec を評価 248 if( isExec && check( command, COMMAND_LIST ) ) { 249 // exist="notuse"の場合?チェ?しな? 250 if( exist.equalsIgnoreCase( "notuse" ) ) { return rtnCode; } 251 252 // パラメーターから処??タイプを判別 253 checkParam(); 254 255 // エラーメ?ージを管?るクラスを作?します? 256 ErrMessageManager manager = new ErrMessageManager(); 257 manager.setTitle( "Data Check Error!" ); 258 manager.setParamKeys( msgParamKeys ); 259 manager.setResourceManager( getResource() ); 260 manager.setFrom( from ); 261 262 // 5.1.9.0 (2010/08/01) TransactionTag 対? 263 Transaction tran = null ; 264 // 5.3.7.0 (2011/07/01) Transaction対応で、close処?入れる? 265 try { 266 if( isSql ) { 267 TransactionTag tranTag = (TransactionTag)findAncestorWithClass( this,TransactionTag.class ); 268 if( tranTag == null ) { 269 // tran = new TransactionReal( dbid,getApplicationInfo() ); 270 tran = new TransactionReal( getApplicationInfo() ); // 5.3.7.0 (2011/07/01) 引数変更 271 } 272 else { 273 tran = tranTag.getTransaction(); 274 } 275 } 276 277 // command="NEW"の場? 278 if( CMD_NEW.equals( command ) ) { 279 if( isSql ) { 280 // checkSql( str, null, null, DBTableModel.UPDATE_TYPE, 0 ); 281 // checkSql( bodyStr, manager, null, 0, DBTableModel.UPDATE_TYPE ); 282 checkSql( bodyStr, manager, null, 0, DBTableModel.UPDATE_TYPE, tran ); // 5.1.9.0 (2010/08/01) 283 } 284 else { 285 // checkJs( str, null, null, 0, jsEngine ); 286 checkJs( bodyStr, manager, null, 0, jsEngine ); 287 } 288 } 289 // command="ENTRY"の場???ブルモ?が存在しな??合?処?な? 290 else if( CMD_ENTRY.equals( command ) ) { 291 table = (DBTableModel) getObject( tableId ); 292 if( table != null && table.getRowCount() > 0 ) { 293 manager.setDBTableModel( table ); 294 if( isUniqCheck ) { 295 checkUnique( manager ); 296 } 297 else { 298 // checkRows( bodyStr, manager ); 299 checkRows( bodyStr, manager, tran ); // 5.1.9.0 (2010/08/01) 300 } 301 } 302 else { 303 System.out.println( "DBTableModel doesn't exist!! need this when command=\"ENTRY\"" ); 304 } 305 } 306 } 307 finally { 308 if( tran != null ) { tran.close(); } 309 } 310 311 // エラーが発生した?合?、エラーメ?ージを表示して以降?処?行わな?? 312 ErrorMessage errMessage = manager.getErrMessage() ; 313 if( errMessage != null && !errMessage.isOK() && !errRemove ) { 314 rtnCode = SKIP_PAGE; 315 316 // 5.1.9.0 (2010/08/01) エラーメ?ージの表示前にincludeするJSPを指? 317 if( beforeErrorJsp != null && beforeErrorJsp.length() > 0 ) { 318 includeJsp( beforeErrorJsp ); 319 } 320 321 jspPrint( TaglibUtil.makeHTMLErrorTable( errMessage, getResource() ) ); 322 323 // 5.1.9.0 (2010/08/01) エラーメ?ージの表示後にincludeするJSPを指? 324 if( afterErrorJsp != null && afterErrorJsp.length() > 0 ) { 325 includeJsp( afterErrorJsp ); 326 } 327 } 328 } 329 330 return( rtnCode ); 331 } 332 333 /** 334 * タグリブオブジェクトをリリースします? 335 * キャ?ュされて再利用される?で、フィールド?初期設定を行います? 336 * 337 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 338 * @og.rev 4.1.2.0 (2008/03/12) sqlType , execType , isExec 追? 339 * @og.rev 4.2.0.1 (2008/03/27) conditionKey , conditionList , msgParamKeys 追? 340 * @og.rev 5.1.9.0 (2010/08/01) beforeErrorJsp , afterErrorJsp, selectedAll 追? 341 */ 342 @Override 343 protected void release2() { 344 super.release2(); 345 tableId = HybsSystem.TBL_MDL_KEY; 346 dbid = null; 347 command = CMD_ENTRY; 348 table = null; 349 // errMessage = null; 350 exist = "auto"; 351 errRemove = false; 352 msg = null; 353 msgParamKeys = null; // 4.2.0.1 (2008/03/27) 354 isSql = false; 355 isUniqCheck = false; // 4.3.4.0 (2008/12/01) 356 jsEngine = null; 357 sqlType = null; // INSERT,COPY,UPDATE,MODIFY,DELETE 358 execType = null; // INSERT,COPY,UPDATE,MODIFY,DELETE 359 isExec = true; // 4.1.2.0 (2008/03/12) 360 conditionKey = null; // 4.2.0.1 (2008/03/27) 361 conditionList = null; // 4.2.0.1 (2008/03/27) 362 from = null; // 4.2.0.1 (2008/03/27) 363 bodyStr = null; // 4.3.4.0 (2008/12/01)) 364 uniqCheckClms = null; // 4.3.4.0 (2008/12/01) 365 beforeErrorJsp = null; // 5.1.9.0 (2010/08/01) 366 afterErrorJsp = null; // 5.1.9.0 (2010/08/01) 367 selectedAll = false; // 5.1.9.0 (2010/08/01) 368 } 369 370 /** 371 * 引数及?ボディー部??チェ?を行い、???タイプを判別します? 372 * @og.rev 5.5.8.0 (2012/11/01) タイプ判別変更 373 * @og.rev 5.6.1.1 (2013/02/08) FROM 部の?出し位置修正 374 * 375 */ 376 private void checkParam() { 377 isUniqCheck = ( uniqCheckClms != null && uniqCheckClms.length > 0 ) ? true : false; 378 if( isUniqCheck ) { 379 if( !CMD_ENTRY.equals( command ) ) { 380 String errMsg = "ユニ?クキーチェ?は、command=\"ENTRY\"の場合?み使用可能です?" 381 + " command=" + command ; // 5.1.8.0 (2010/07/01) errMsg 修正 382 throw new HybsSystemException( errMsg ); 383 } 384 } 385 else { 386 if( bodyStr == null || bodyStr.length() == 0 ) { 387 String errMsg = "Body部?チェ?定義を記述して下さ??"; 388 throw new HybsSystemException( errMsg ); 389 } 390 else { 391 // SQLチェ?かJavaScriptによるチェ?か?判? 392 String query = bodyStr.toUpperCase( Locale.JAPAN ); // 4.2.0.1 (2008/03/27) 393 // if( query.indexOf( "SELECT" ) >= 0 ) { 394 if( query.indexOf( "SELECT" ) == 0 ) { // 5.5.8.0 (2012/11/01) 先?に限定する?(trim済?ため) 395 isSql = true; 396 int st = query.indexOf( "FROM" ) ; 397 int ed = query.indexOf( "WHERE" ) ; 398 if( st > 0 && st < ed ) { 399 // from = query.substring( st,ed ).trim(); 400 from = query.substring( st+"FROM".length(),ed ).trim(); // 5.6.1.1 (2013/02/08) 401 } 402 } 403 else { 404 jsEngine = new ScriptEngineManager().getEngineByName( "JavaScript" ); 405 } 406 } 407 } 408 } 409 410 /** 411 * SQLによる??タチェ?を行います? 412 * チェ?方法?、exist属?の?に依存します? 413 * autoの場合?、テーブルモ?の改廃Cから自動でチェ?方法が決定されます? 414 * 415 * @param str 実行するSQL? 416 * @param manager ErrMessageManager オブジェク? 417 * @param values SQL??パラメータ 418 * @param row 行番号 419 * @param modifyType 改廃C 420 * @param tran トランザクションオブジェク? 421 * 422 * @return 処??成否 423 * 424 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 425 * @og.rev 4.2.1.0 (2008/04/11) ErrMessageManager対? 426 * @og.rev 5.1.9.0 (2010/08/01) Transaction 対応します? 427 */ 428 // private boolean checkSql( final String str, final String names, final String[] values 429 // , final String modifyType, final int row ) { 430 // private boolean checkSql( final String str, final ErrMessageManager manager, final String[] values 431 // , final int row, final String modifyType ) { 432 private boolean checkSql( final String str, final ErrMessageManager manager, final String[] values 433 , final int row, final String modifyType, final Transaction tran ) { 434 435 // int cnt = DBUtil.dbExist( str, values, getApplicationInfo(), dbid ); 436 int cnt = DBUtil.dbExist( str, values, tran, dbid ); // 5.1.9.0 (2010/08/01) 437 438 boolean okFlag = true; 439 String id = null; 440 if( ( exist.equalsIgnoreCase( "true" ) || ( exist.equalsIgnoreCase( "auto" ) 441 && ( DBTableModel.UPDATE_TYPE.equals( modifyType ) || DBTableModel.DELETE_TYPE.equals( modifyType ) ) ) ) && cnt <= 0 ) { 442 // ERR0025=??タ未登録エラー。キー={0}、?={1} の??タは、存在して?せん? 443 id = ( msg == null ? "ERR0025" : msg ); 444 okFlag = false; 445 } 446 else if( ( exist.equalsIgnoreCase( "false" ) || ( exist.equalsIgnoreCase( "auto" ) 447 && DBTableModel.INSERT_TYPE.equals( modifyType ) ) ) && cnt > 0 ) { 448 // ERR0026=??タ登録済みエラー。キー={0}、?={1} の??タは、すでに存在して?す? 449 id = ( msg == null ? "ERR0026" : msg ); 450 okFlag = false; 451 } 452 else if( exist.equalsIgnoreCase( "one" ) && cnt > 1 ) { 453 // ERR0027=??タ?重登録エラー。キー={0}、?={1} の??タは??て存在して?す? 454 id = ( msg == null ? "ERR0027" : msg ); 455 okFlag = false; 456 } 457 458 if( !okFlag ) { 459 manager.addMessage( row, id, values ); 460 461 // String vals = StringUtil.array2csv( values ); 462 // ResourceManager resource = getResource(); 463 // String fromLbl = resource.getLabel( from ); 464 // if( msgParamKeys == null || msgParamKeys.length == 0 ) { 465 // errMessage.addMessage( row, ErrorMessage.NG, id, names, vals, fromLbl ); 466 // } 467 // else { 468 // int size = msgParamKeys.length; 469 // String[] args = new String[size] ; 470 // for( int i=0; i<size; i++ ) { 471 // String key = msgParamKeys[i] ; 472 // if( "@KEY".equals( key ) ) { args[i] = names; } 473 // else if( "@VAL".equals( key ) ) { args[i] = vals; } 474 // else if( "@TBL".equals( key ) ) { args[i] = fromLbl;} 475 // // 4.2.1.0 (2008/04/11) リクエスト変数対? 476 // else if( "[".startsWith( key ) && "]".endsWith( key ) ) { 477 // if( table != null ) { 478 // args[i] = table.getValue( row,key.substrng( 1,key.length()-1 ) ); 479 // } 480 // } 481 // // 4.2.1.0 (2008/04/11) リクエスト変数対? 482 // else if( "{#".startsWith( key ) && "}".endsWith( key ) ) { 483 // args[i] = resource.getLabel( key.substrng( 2,key.length()-1 )); 484 // } 485 // else { 486 // args[i] = key; 487 // } 488 // } 489 // errMessage.addMessage( row, ErrorMessage.NG, id, args ); 490 // } 491 } 492 return okFlag; 493 } 494 495 /** 496 * JavaScriptの式を実行します? 497 * 実行した結果がboolean型でな??合?エラーとなります? 498 * 499 * @param str 実行するSQL? 500 * @param manager オブジェク? 501 * @param values 値配? 502 * @param row 行番号 503 * @param engine JavaScriptエンジン 504 * 505 * @return 処??成否 506 * 507 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 508 * @og.rev 4.2.0.1 (2008/03/27) getClass().getName() から、instanceof に変更 509 * @og.rev 4.2.1.0 (2008/04/11) ErrMessageManager対? 510 */ 511 // private boolean checkJs( final String str, final String names, final String[] values 512 // , final int row, final ScriptEngine engine ) { 513 private boolean checkJs( final String str, final ErrMessageManager manager, final String[] values 514 , final int row, final ScriptEngine engine ) { 515 // JavaScriptエンジンによる評価 516 Object obj = null; 517 try { 518 obj = engine.eval( str ); 519 } 520 catch( ScriptException ex ) { 521 String errMsg = "JavaScript式?パ?スに失敗しました?" + str + "]"; 522 throw new HybsSystemException( errMsg , ex ); 523 } 524 525 // 返り値がBoolean型かチェ? 526 boolean okFlag = false; 527 // 4.2.0.1 (2008/03/27) instanceof に変更 528 // if( obj != null && "java.lang.Boolean".equals( obj.getClass().getName() ) ) { 529 // if( obj != null && obj instanceof Boolean ) { 530 if( obj instanceof Boolean ) { // 4.3.1.1 (2008/08/23) instanceof チェ?は、nullチェ?不? 531 okFlag = ((Boolean)obj).booleanValue(); 532 } 533 else { 534 String errMsg = "JavaScript式には true 若しくは false が返るように設定して下さ? 535 + " Object=" + obj ; // 5.1.8.0 (2010/07/01) errMsg 修正 536 throw new HybsSystemException( errMsg ); 537 } 538 539 if( !okFlag ) { 540 // ERR0030=入力したデータが不正です?key={0} value={1} 形?{2} 541 String id = ( msg == null ? "ERR0030" : msg ); 542 543 manager.addMessage( row, id, values ); 544 545 // String vals = StringUtil.array2csv( values ); 546 // // ERR0030=入力したデータが不正です?key={0} value={1} 形?{2} 547 // String id = ( msg == null ? "ERR0030" : msg ); 548 // // 4.2.1.0 (2008/04/11) リクエスト変数対? 549 // if( msgParamKeys == null || msgParamKeys.length == 0 ) { 550 // errMessage.addMessage( row, ErrorMessage.NG, id, names, vals, str ); 551 // } 552 // else { 553 // int size = msgParamKeys.length; 554 // String[] args = new String[size] ; 555 // for( int i=0; i<size; i++ ) { 556 // ResourceManager resource = getResource(); 557 // String key = msgParamKeys[i] ; 558 // // 4.2.1.0 (2008/04/11) リクエスト変数対? 559 // if( "{#".startsWith( key ) && "}".endsWith( key ) ) { 560 // args[i] = resource.getLabel( key.substrng( 2,key.length()-1 )); 561 // } 562 // else { 563 // args[i] = key; 564 // } 565 // } 566 // errMessage.addMessage( row, ErrorMessage.NG, id, args ); 567 // } 568 } 569 570 return okFlag; 571 } 572 573 /** 574 * DB??ブルモ?の?に対して??タチェ?を行います? 575 * 576 * @param str チェ?対象の?? 577 * @param manager ErrMessageManagerオブジェク? 578 * @param tran Transactionトランザクションオブジェク? 579 * 580 * @og.rev 4.1.1.0 (2008/02/22) 新規作? 581 * @og.rev 4.2.0.1 (2008/03/27) conditionKey,conditionList 対? 582 * @og.rev 4.2.1.0 (2008/04/11) ErrMessageManager対? 583 * @og.rev 5.1.9.0 (2010/08/01) Transaction 対応します? 584 */ 585 // private void checkRows( final String str ) { 586 // private void checkRows( final String str, final ErrMessageManager manager ) { 587 private void checkRows( final String str, final ErrMessageManager manager, final Transaction tran ) { 588 589 int[] rowNo = getParameterRows(); // 4.0.0 (2005/01/31) 590 if( rowNo.length == 0 ) { return; } 591 592 Formatter format = new Formatter( table ); 593 format.setFormat( str ); 594 int[] clmNo = format.getClmNos(); 595 // 4.2.0.1 (2008/03/27) カラ?のメ?ージリソース??を作?します? 596 // String names = getKeysLabel( clmNo ); 597 598 manager.setClmNos( clmNo ); 599 600 // SQL??場合?み[xxx]?に変換したSQL?取?JavaScriptの場合?ループ?で?毎に取? 601 String query = null; 602 if( isSql ) { 603 query = format.getQueryFormatString(); 604 } 605 606 // 4.2.0.1 (2008/03/27) conditionKey,conditionList 対? 607 int cndKeyNo = -1; 608 if( conditionKey != null && conditionList != null ) { 609 cndKeyNo = table.getColumnNo( conditionKey ); // 不正??エラー 610 } 611 612 List<Integer> list = new ArrayList<Integer>(); 613 boolean okFlag = false; 614 for( int i = 0; i < rowNo.length; i++ ) { 615 int row = rowNo[i] ; 616 String[] values = getTableModelData( row, clmNo ); 617 // 4.2.0.1 (2008/03/27) 条件?がされて?場合に? 618 // Listに含まれな??合?、実行されな?? 619 // 4.2.1.0 (2008/04/11) 厳?処?ます? 620 if( cndKeyNo >= 0 && conditionList.indexOf( table.getValue( row,cndKeyNo ) ) < 0 ) { 621 String conVal = "|" + table.getValue( row,cndKeyNo ) + "|" ; 622 if( conditionList.indexOf( conVal ) < 0 ) { continue; } 623 } 624 625 if( isSql ) { 626 // okFlag = checkSql( query, names, values, table.getModifyType( row ), row ); 627 // okFlag = checkSql( query, manager, values, row, table.getModifyType( row ) ); 628 okFlag = checkSql( query, manager, values, row, table.getModifyType( row ), tran ); 629 } 630 else { 631 String jsStr = format.getFormatString( row, "\"" ); 632 // okFlag = checkJs( jsStr, names, values, row, jsEngine ); 633 okFlag = checkJs( jsStr, manager, values, row, jsEngine ); 634 } 635 636 if( errRemove && okFlag ) { 637 list.add( row ); 638 } 639 } 640 641 if( errRemove ) { 642 Integer[] in = list.toArray( new Integer[list.size()] ); 643 int[] newRowNo = new int[in.length]; 644 for( int i = 0; i < in.length; i++ ) { 645 newRowNo[i] = in[i].intValue(); 646 } 647 setParameterRows( newRowNo ); 648 } 649 } 650 651 /** 652 * DB??ブルモ?の?にユニ?クキーのチェ?を行います? 653 * 654 * @og.rev 4.3.4.0 (2008/12/01) 新規作? 655 * 656 * @param manager ErrMessageManagerオブジェク? 657 */ 658 private void checkUnique( final ErrMessageManager manager ) { 659 int[] rowNo = getParameterRows(); 660 if( rowNo.length == 0 ) { return; } 661 662 int[] clmNo = new int[uniqCheckClms.length]; 663 for( int i=0; i<clmNo.length; i++ ) { 664 clmNo[i] = table.getColumnNo( uniqCheckClms[i] ); 665 } 666 667 manager.setClmNos( clmNo ); 668 669 List<Integer> list = new ArrayList<Integer>(); 670 Map<String,Integer> map = new HashMap<String,Integer>(); 671 for( int i = 0; i < rowNo.length; i++ ) { 672 int row = rowNo[i] ; 673 String[] values = getTableModelData( row, clmNo ); 674 String key = StringUtil.array2line( values, " + " ); 675 676 if( map.get( key ) == null ) { 677 map.put( key, 1 ); 678 if( errRemove ) { 679 list.add( row ); 680 } 681 } 682 else { 683 // ERR0027=??タ?重登録エラー。キー={0}、?={1} の??タは??て存在して?す? 684 id = ( msg == null ? "ERR0027" : msg ); 685 manager.addMessage( row, id, values ); 686 } 687 } 688 689 if( errRemove ) { 690 Integer[] in = list.toArray( new Integer[list.size()] ); 691 int[] newRowNo = new int[in.length]; 692 for( int i = 0; i < in.length; i++ ) { 693 newRowNo[i] = in[i].intValue(); 694 } 695 setParameterRows( newRowNo ); 696 } 697 } 698 699 /** 700 * msgParamKeys 属?に対して、実際の値を割り当てます? 701 * 702 * ここでは?#064;KEY ?#064;TBL 、{#XX} 、{@XX} に対して、実際の値と置き換えられます? 703 * @VAL と、[XX] は、DBTableModel の行番号が?なので、?別処?判断します? 704 * msgParamKeys が?未??null) の場合?、null を返します? 705 * 706 * @param names カラ? 707 * @param fromLbl ??ブル? 708 * 709 * @og.rev 4.2.0.1 (2008/03/27) 新規作? 710 */ 711 // private String[] makeMsgParamVals( final String names,final String fromLbl ) { 712 // if( msgParamKeys == null ) { return null; } 713 // 714 // int size = msgParamKeys.length; 715 // String[] args = new String[size] ; 716 // ResourceManager resource = getResource(); 717 // 718 // for( int i=0; i<size; i++ ) { 719 // String key = msgParamKeys[i] ; 720 // if( "@KEY".equals( key ) ) { args[i] = names; } 721 // else if( "@VAL".equals( key ) ) { args[i] = key; } // そ?まま返す 722 // else if( "@TBL".equals( key ) ) { args[i] = fromLbl;} 723 // // 4.2.1.0 (2008/04/11) リクエスト変数対? 724 // else if( "[".startsWith( key ) && "]".endsWith( key ) ) { 725 // args[i] = key; // そ?まま返す 726 // } 727 // else if( "{#".startsWith( key ) && "}".endsWith( key ) ) { 728 // args[i] = resource.getLabel( key.substrng( 2,key.length()-1 )); 729 // } 730 // else { 731 // args[i] = getRequestParameter( key ); 732 // } 733 // } 734 // 735 // return args ; 736 // } 737 738 /** 739 * 【TAG?通常は使?せん)結果をDBTableModelに書き込んで、sessionに登録するとき?キーを指定します? 740 * 741 * @og.tag 初期値は、HybsSystem.TBL_MDL_KEY です? 742 * 743 * @param id sessionに登録する時? ID 744 */ 745 public void setTableId( final String id ) { 746 tableId = nval( getRequestParameter( id ), tableId ); 747 } 748 749 /** 750 * 【TAG?通常は使?せん)Queryオブジェクトを作?する時?DB接続IDを指定します? 751 * 752 * @og.tag Queryオブジェクトを作?する時?DB接続IDを指定します? 753 * 754 * @param id ??タベ?ス接続ID 755 */ 756 public void setDbid( final String id ) { 757 dbid = nval( getRequestParameter( id ), dbid ); 758 } 759 760 /** 761 * 【TAG】コマン?NEW or ENTRY)をセ?します? 762 * 763 * @og.tag 764 * コマンド?,HTMLから(get/post)?されます?で,CMD_xxx で設定される 765 * フィールド定数値の?れかを??できます? 766 * 767 * @param cmd コマン?public static final 宣?れて???) 768 * @see <a href="{@docRoot}/constant-values.html#org.opengion.hayabusa.taglib.DataCheckTag.CMD_NEW">コマンド定数</a> 769 */ 770 public void setCommand( final String cmd ) { 771 String cmd2 = getRequestParameter( cmd ); 772 if( cmd2 != null && cmd2.length() > 0 ) { 773 command = cmd2.toUpperCase( Locale.JAPAN ); 774 } 775 } 776 777 /** 778 * 【TAG】データベ?スのチェ?方法[auto/true/false/one/notuse]を指定しま?初期値:auto[自動])? 779 * 780 * @og.tag 781 * exist 属?に?された ?true:存在する??false:存在しな??one:ひとつ以下」? 782 * の値は、いずれの場合も、?立時は、正常とみなします? 783 * ?auto:自動」は、DBTableModeleのmodifyType(A,C,D)に応じて、チェ?します? 784 * A,C,D は、entryタグにコマンドを渡して??タを作?したときに、?部で作?されます? 785 * (command="NEW"の場合?、trueと同じ動きになります?) 786 * notuse は、チェ?を行いません。これ?、このタグを?有使用する場合に、外部で 787 * チェ?を行うかど?を指定できるようにするために使用します? 788 * (?true:存在する? には、データが存在した場合に??で、なければエラーです?) 789 * 初期値は?auto:自動」です? 790 * 791 * @param ext チェ?方??auto:自動」?true:存在する??false:存在しな??one:ひとつ以下」?notuse:チェ?しな?) 792 */ 793 public void setExist( final String ext ) { 794 exist = nval( getRequestParameter( ext ), exist ); 795 if( !"auto".equalsIgnoreCase( exist ) 796 && !"true".equalsIgnoreCase( exist ) 797 && !"false".equalsIgnoreCase( exist ) 798 && !"one".equalsIgnoreCase( exist ) 799 && !"notuse".equalsIgnoreCase( exist ) ) { 800 String errMsg = "exist 属?は?auto,true,false,one,notuse)を指定してください?[" + exist + "]" + HybsSystem.CR; 801 throw new HybsSystemException( errMsg ); 802 } 803 } 804 805 /** 806 * 【TAG】エラー時?選択行を取り除?継続??行うかど?[true/false]を指定しま?初期値:false)? 807 * 808 * @og.tag 809 * exist 属?に?された ?true:存在する??false:存在しな??one:ひとつ以下」? 810 * に対して、エラーが発生した選択行番号を?取り除?以下?処?継続するかど?? 811 * ?します? 812 * true に設定した?合?、エラー??タを削除し?継続??行うことができます? 813 * flase の場合?、エラー??タを表示して、継続??停止します? 814 * 初期値は?false:エラー時停止?です? 815 * 816 * @param flag エラー時?継続??[true:エラー行番号を取り除き継続??false:エラー時停止] 817 */ 818 public void setErrRemove( final String flag ) { 819 errRemove = nval( getRequestParameter( flag ), errRemove ); 820 } 821 822 /** 823 * 【?】メ?ージIDを指定しま?lbl 属?を使用してください)? 824 * 825 * @og.tag メ?ージIDを指定します? 826 * ???応じた?期設定?メ?ージIDは、以下?通りです? 827 * exist="true" ERR0025=??タ未登録エラー。キー={0}、?={1} の??タは、存在して?せん? 828 * exist="false" ERR0026=??タ登録済みエラー。キー={0}、?={1} の??タは、すでに存在して?す? 829 * exist="one" ERR0027=??タ?重登録エラー。キー={0}、?={1} の??タは??て存在して?す? 830 * JavaScript ERR0030=入力したデータが不正です?key={0} value={1} 形?{2} 831 * 引数のパラメータには??常、チェ?に使用した実データが?DBTableModel から取得されます? 832 * 引数を変更する場合?、msgParamKeys を使用してください? 833 * 834 * @og.rev 5.2.2.0 (2010/11/01) ?します?lbl 属?を使用してください? 835 * 836 * @param id メ?ージID 837 * @see #setMsgParamKeys( String ) 838 * @deprecated lbl 属?を使用してください? 839 */ 840 @Deprecated public void setMsg( final String id ) { 841 msg = nval( getRequestParameter( id ), msg ); 842 } 843 844 /** 845 * 【TAG】ラベルリソースIDを指定します? 846 * 847 * @og.tag ラベルリソースIDを指定します? 848 * ???応じた?期設定?ラベルリソースIDは、以下?通りです? 849 * exist="true" ERR0025=??タ未登録エラー。キー={0}、?={1} の??タは、存在して?せん? 850 * exist="false" ERR0026=??タ登録済みエラー。キー={0}、?={1} の??タは、すでに存在して?す? 851 * exist="one" ERR0027=??タ?重登録エラー。キー={0}、?={1} の??タは??て存在して?す? 852 * JavaScript ERR0030=入力したデータが不正です?key={0} value={1} 形?{2} 853 * 引数のパラメータには??常、チェ?に使用した実データが?DBTableModel から取得されます? 854 * 引数を変更する場合?、msgParamKeys を使用してください? 855 * 856 * @param id メ?ージID 857 * @see #setLblParamKeys( String ) 858 */ 859 @Override 860 public void setLbl( final String id ) { 861 // 継承親のメソ?を使わな?? 862 msg = nval( getRequestParameter( id ), msg ); 863 } 864 865 /** 866 * 【?】メ?ージリソースの引数をカンマ区?で?しま?lblParamKeys 属?を使用してください)? 867 * 868 * @og.tag 869 * メ?ージリソースのキーをカンマ区?で?することで、設定します? 870 * メ?ージに引数( {0},{1} など ) がある?合?ここで?した?? 871 * ?に、{0},{1},{2}・・・ に当てはめて?ます? 872 * キーワード?、カンマ区?で?し、それを?後?ラベルリソースで 873 * リソース変換を行います?(つまり?記述された?そ?も?では在りません) 874 * PL/SQL では?{#PN}" などと?して???、同様に "PN" と?しです? 875 * ??、where 条件に?されたキーと値は、@KEY と @VAL に? 876 * from と where の間???は?#064;TBL に対応付けられます? 877 * {@XXXX} 変数も使用できます?実データの値を取出した??合?、[PN]と 878 * すれば、DBTableModel の PN の値を取出します? 879 * なにも指定しな??合?、キー={0} 、?={1}、from={2} です? 880 * 881 * @og.rev 4.2.0.1 (2008/03/27) 新規追? 882 * 883 * @param keys メ?ージリソースのキー(CSV) 884 * @see #setLbl( String ) 885 * @deprecated lblParamKeys 属?を使用してください? 886 */ 887 @Deprecated public void setMsgParamKeys( final String keys ) { 888 msgParamKeys = getCSVParameter( keys ); 889 } 890 891 /** 892 * 【TAG】ラベルリソースの引数をカンマ区?で?します? 893 * 894 * @og.tag 895 * ラベルリソースのキーをカンマ区?で?することで、設定します? 896 * ラベルに引数( {0},{1} など ) がある?合?ここで?した?? 897 * ?に、{0},{1},{2}・・・ に当てはめて?ます? 898 * キーワード?、カンマ区?で?し、それを?後?ラベルリソースで 899 * リソース変換を行います?(つまり?記述された?そ?も?では在りません) 900 * PL/SQL では?{#PN}" などと?して???、同様に "PN" と?しです? 901 * ??、where 条件に?されたキーと値は?#064;KEY と @VAL に? 902 * from と where の間???は?#064;TBL に対応付けられます? 903 * {@XXXX} 変数も使用できます?実データの値を取出した??合?、[PN]と 904 * すれば、DBTableModel の PN の値を取出します? 905 * なにも指定しな??合?、キー={0} 、?={1}、from={2} です? 906 * 907 * @og.rev 4.2.0.1 (2008/03/27) 新規追? 908 * 909 * @param keys メ?ージリソースのキー(CSV) 910 * @see #setMsg( String ) 911 */ 912 public void setLblParamKeys( final String keys ) { 913 msgParamKeys = getCSVParameter( keys ); 914 } 915 916 /** 917 * 【TAG】このチェ?を行う、SQLタイ?を指定します? 918 * 919 * @og.tag 920 * SQLタイプ?、INSERT,COPY,UPDATE,MODIFY,DELETE などの記号を指定します? 921 * ?には、result 画面から update 画面へ遷移するとき?、command と 922 * 同じにしておけばよいでしょ?? 923 * これは、execType とマッチした?合?み、このチェ?が??れます? 924 * 簡?equals タグの代役に使用できます? 925 * なにも指定しな??合?、チェ?は実行されます? 926 * 927 * @og.rev 4.1.2.0 (2008/03/12) 新規追? 928 * 929 * @param type こ?チェ?を行う、SQLタイ? 930 */ 931 public void setSqlType( final String type ) { 932 sqlType = nval( getRequestParameter( type ),sqlType ); 933 } 934 935 /** 936 * 【TAG】このチェ?を行う、実行タイ?を指定します? 937 * 938 * @og.tag 939 * 実行タイプ?、sqlType とマッチした?合?み、このチェ?が??れます? 940 * 簡?equals タグの代役に使用できます? 941 * execType は、??が可能です?単純な??マッチで、sqlType ? 942 * 含め?、実行されます? 943 * 例えば、sqlType={@sqlType} execType="INSERT|COPY" とすれば? 944 * sqlType に、INSERT また?、COPY が登録された?合にチェ?が掛かります? 945 * なにも指定しな??合?、チェ?は実行されます? 946 * 947 * @og.rev 4.1.2.0 (2008/03/12) 新規追? 948 * 949 * @param type こ?チェ?を行う、実行タイ? 950 */ 951 public void setExecType( final String type ) { 952 execType = nval( getRequestParameter( type ),execType ); 953 } 954 955 /** 956 * 【TAG】条件判定するカラ??を指定します? 957 * 958 * @og.tag 959 * ??カラ??の値と、conditionList の値を比?て? 960 * 存在する場合?、check処?実行します? 961 * こ?処?有効なのは、command="ENTRY" の場合?みです? 962 * 963 * @og.rev 4.2.0.1 (2008/03/27) 新規追? 964 * 965 * @param key カラ?? 966 * @see #setConditionList( String ) 967 */ 968 public void setConditionKey( final String key ) { 969 conditionKey = nval( getRequestParameter( key ),null ) ; 970 } 971 972 /** 973 * 【TAG】条件判定する?のリストを?|"で区?て登録しま?初期値:無条件)? 974 * 975 * @og.tag 976 * conditionKey とペアで?します?ここには、カラ??設定?のリストを 977 * ?することで、?条件(??結合)での比?行い、リストにカラ??? 978 * 存在する場合?み、check処?実行します? 979 * こ?処?有効なのは、command="ENTRY" の場合?みです? 980 * 設定しな??合?、無条件に実行します? 981 * 982 * @og.rev 4.2.0.1 (2008/03/27) 新規追? 983 * 984 * @param list 条件判定する?("|"で区? 985 * @see #setConditionKey( String ) 986 */ 987 public void setConditionList( final String list ) { 988 conditionList = nval( getRequestParameter( list ),null ) ; 989 if( conditionList != null ) { 990 conditionList = "|" + conditionList + "|" ; 991 } 992 } 993 994 /** 995 * 【TAG】指定されたキーに従って、メモリ上???ブルに対してユニ?クキーチェ?を行います? 996 * 997 * @og.tag 998 * ユニ?クキーチェ?を行うキーを指定します?ここで、指定されたキーに対して? 999 * DBTableModelの値をチェ?し?全てのキーに同じ値となって?行が存在すればエラーとなります? 1000 * こ?チェ?は、command="ENTRY"の場合?み有効です? 1001 * また?こ?チェ?は他?チェ?(DB存在チェ?など)と同時に処?ることはできません? 1002 * キーが指定され手?場合?、??部?記述されて?定義は無視されます? 1003 * errRemoveの属?がtrueに?されて?場合?重??、DBTableModelの並び?ら見て? 1004 * ??の行?み処?れ?2つめ以降?重??無視されます? 1005 * なお?キーはカンマ区?(CSV形?で??が可能です? 1006 * 1007 * @og.rev 4.3.4.0 (2008/12/01) 新規追? 1008 * 1009 * @param clm チェ?キー(CSV形? 1010 */ 1011 public void setUniqCheckClms( final String clm ) { 1012 String tmp = nval( getRequestParameter( clm ),null ); 1013 uniqCheckClms = StringUtil.csv2Array( tmp ); 1014 } 1015 1016 /** 1017 * 【TAG】エラーが発生した際に、エラーメ?ージの表示前にincludeするJSPを指定します? 1018 * 1019 * @og.tag 1020 * エラーが発生した際に、エラーメ?ージの表示前にincludeするJSPを指定します? 1021 * エラーが発生して???合?、ここで?されたJSPが??れることはありません? 1022 * 通常は、戻るリンクなどを指定します? 1023 * 1024 * ??方法?、相対パス、絶対パスの両方で?することができます? 1025 * ?、絶対パスで?した?合?そ?基点は、コン?スト?ルートディレクトリになります? 1026 * ? beforeErrorJsp = "/jsp/common/history_back.jsp" 1027 * 1028 * @og.rev 5.1.9.0 (2010/08/01) 新規追? 1029 * 1030 * @param jsp 表示前にincludeするJSPファイル? 1031 */ 1032 public void setBeforeErrorJsp( final String jsp ) { 1033 beforeErrorJsp = nval( getRequestParameter( jsp ),beforeErrorJsp ); 1034 } 1035 1036 /** 1037 * 【TAG】エラーが発生した際に、エラーメ?ージの表示後にincludeするJSPを指定します? 1038 * 1039 * @og.tag 1040 * エラーが発生した際に、エラーメ?ージの表示前にincludeするJSPを指定します? 1041 * エラーが発生して???合?、ここで?されたJSPが??れることはありません? 1042 * 1043 * ??方法?、相対パス、絶対パスの両方で?することができます? 1044 * ?、絶対パスで?した?合?そ?基点は、コン?スト?ルートディレクトリになります? 1045 * ? afterErrorJsp = "/jsp/common/history_back.jsp" 1046 * 1047 * @og.rev 5.1.9.0 (2010/08/01) 新規追? 1048 * 1049 * @param jsp 表示後にincludeするJSPファイル? 1050 */ 1051 public void setAfterErrorJsp( final String jsp ) { 1052 afterErrorJsp = nval( getRequestParameter( jsp ),afterErrorJsp ); 1053 } 1054 1055 /** 1056 * 【TAG】データを?件選択済みとして処?るかど?[true/false]を指定しま?初期値:false)? 1057 * 1058 * @og.tag 1059 * 全ての??タを選択済み??タとして扱って処?ます? 1060 * 全件処?る?合に?true/false)を指定します? 1061 * 初期値は false です? 1062 * 1063 * @og.rev 5.1.9.0 (2010/08/01) 新規追? 1064 * 1065 * @param all 選択済みとして処?るかど?[true:全件選択済み/false:通常] 1066 */ 1067 public void setSelectedAll( final String all ) { 1068 selectedAll = nval( getRequestParameter( all ),selectedAll ); 1069 } 1070 1071 /** 1072 * ??行番号の、カラ?o配?(int[])に対応した?の配?を返します? 1073 * 1074 * 表示??タの HybsSystem.ROW_SEL_KEY を?に?ばれた 行を 1075 * 処??対象とします? 1076 * 1077 * @og.rev 4.2.0.1 (2008/03/27) row と clm を?れ替えます?(他とあわせま? 1078 * 1079 * @param row 行番号 1080 * @param clmNo カラ?o配? 1081 * 1082 * @return 行番号とカラ?o配?に対応した?値の配? 1083 */ 1084 // private String[] getTableModelData( final int[] clmNo, final int row ) { 1085 private String[] getTableModelData( final int row, final int[] clmNo ) { 1086 String[] values = new String[clmNo.length]; 1087 for( int i = 0; i < values.length; i++ ) { 1088 values[i] = table.getValue( row, clmNo[i] ); 1089 } 1090 return values; 1091 } 1092 1093 /** 1094 * ??行番号の、カラ?o配?(int[])に対応したカラ?の配?を返します? 1095 * 1096 * @og.rev 4.3.1.1 (2008/08/23) ? 1097 * 1098 * @param clmNo カラ?o配? 1099 * 1100 * @return String[] カラ?o配?に対応した?カラ?の配? 1101 */ 1102 // private String[] getTableModelClm( final int[] clmNo ) { 1103 // String[] clm = new String[clmNo.length]; 1104 // for( int i = 0; i < clm.length; i++ ) { 1105 // clm[i] = table.getColumnName( clmNo[i] ); 1106 // } 1107 // return clm; 1108 // } 1109 1110 /** 1111 * カラ?o配?(int[])に対応したカラ?のメ?ージリソース??を返します? 1112 * 1113 * @og.rev 4.3.1.1 (2008/08/23) ErrMessageManager ?クラスへ移? 1114 * 1115 * @param clmNo カラ?o配? 1116 * 1117 * @return カラ?o配?に対応した?カラ?のメ?ージリソース 1118 */ 1119 // private String getKeysLabel( final int[] clmNo ) { 1120 // ResourceManager resource = getResource(); 1121 // 1122 // StringBuilder buf = new StringBuilder(); 1123 // if( clmNo.length > 0 ) { 1124 // String key = table.getColumnName( clmNo[0] ); 1125 // buf.append( resource.getLabel( key ) ); 1126 // for( int i=1; i<clmNo.length; i++ ) { 1127 // key = table.getColumnName( clmNo[i] ); 1128 // buf.append( "," ).append( resource.getLabel( key ) ); 1129 // } 1130 // } 1131 // 1132 // return buf.toString(); 1133 // } 1134 1135 /** 1136 * エラーメ?ージの前後に処?るJSPをインクルードします? 1137 * 1138 * @og.rev 5.1.9.0 (2010/08/01) 新規作? 1139 * 1140 * @param jsp JSP? 1141 */ 1142 private void includeJsp( final String jsp ) { 1143 try { 1144 pageContext.include( jsp, false ); 1145 } catch ( IOException ex ) { 1146 String errMsg = jsp + " の include に失敗しました?"; 1147 throw new HybsSystemException( errMsg,ex ); 1148 } catch ( ServletException ex ) { 1149 String errMsg = jsp + " の include に失敗しました?"; 1150 throw new HybsSystemException( errMsg,ex ); 1151 } 1152 } 1153 1154 /** 1155 * 表示??タの HybsSystem.ROW_SEL_KEY を?に?ばれた 行を処??対象とします? 1156 * 1157 * <del>rowNo[] ?null の場合?み、取込を行います?</del> 1158 * 1159 * @og.rev 5.1.9.0 (2010/08/01) 新規追? 1160 * 1161 * @return 選択行?配? 1162 */ 1163 @Override 1164 protected int[] getParameterRows() { 1165 final int[] rowNo ; 1166 if( selectedAll ) { 1167 int rowCnt = table.getRowCount(); 1168 rowNo = new int[ rowCnt ]; 1169 for( int i=0; i<rowCnt; i++ ) { 1170 rowNo[i] = i; 1171 } 1172 } else { 1173 rowNo = super.getParameterRows(); 1174 } 1175 return rowNo ; 1176 } 1177 1178 /** 1179 * ErrMessage を管?て? メソ????クラス 1180 * 1181 * 繰返し処?と、固定部が混在したエラーメ?ージで、固定部を?に処?? 1182 * 繰返し部は、?時に処?るよ?しました? 1183 * また?実際にエラーが発生して?になるまで、実行遅延させます? 1184 * 1185 * @og.rev 4.2.1.0 (2008/04/11) 新規追? 1186 * @og.rev 4.3.0.0 (2008/07/24) クラス宣?static? 1187 */ 1188 private static final class ErrMessageManager { 1189 // 引数として初期設定される変数 1190 private String title = null; 1191 private String from = null; 1192 private String[] msgKeys = null; 1193 private ResourceManager resource = null; 1194 private DBTableModel table = null; 1195 private int[] clmNo = null; 1196 1197 // ?引数として処?れたキャ?ュ値 1198 private ErrorMessage errMessage = null; 1199 private String names = null; 1200 private String fromLbl = null; 1201 private String[] msgVals = null; 1202 1203 private boolean isFirst = true; // 初期化されて??true 1204 1205 /** 1206 * ErrMessage のタイトルを設定します? 1207 * 1208 * @param title タイトル 1209 */ 1210 public void setTitle( final String title ) { this.title = title; } 1211 1212 /** 1213 * 処?象の??ブル名を設定します? 1214 * 1215 * @param from ??ブル? 1216 */ 1217 public void setFrom( final String from ) { this.from = from; } 1218 1219 /** 1220 * 処?象の??ブルオブジェクトを設定します? 1221 * 1222 * @param table DBTableModelオブジェク? 1223 */ 1224 public void setDBTableModel( final DBTableModel table ) { this.table = table; } 1225 1226 /** 1227 * ResourceManagerオブジェクトを設定します? 1228 * 1229 * @param resource ResourceManagerオブジェク? 1230 */ 1231 public void setResourceManager( final ResourceManager resource ) { this.resource = resource; } 1232 1233 /** 1234 * msgParamKeys 属?の配?を設定します? 1235 * 1236 * @param msgKeys 属?の配? 1237 */ 1238 public void setParamKeys( final String[] msgKeys ) { this.msgKeys = msgKeys; } 1239 1240 /** 1241 * カラ?列を設定します? 1242 * 1243 * @param clmNo カラ? 1244 */ 1245 public void setClmNos( final int[] clmNo ) { this.clmNo = clmNo ; } 1246 1247 /** 1248 * 初期処?行います? 1249 * エラー処??、エラー時?み実行する為、??な??合?、??不要です? 1250 * ??のエラー出力までは、?部オブジェクト?構築??行いません? 1251 * ?回目以降?、?部変数にキャ?ュされた変換値を利用して??化します? 1252 * 1253 * @og.rev 4.2.3.2 (2008/06/20) from が?null なら?なにもしな?? 1254 */ 1255 private void firstExecute() { 1256 errMessage = new ErrorMessage( title ); 1257 1258 // ??ブル(from) をキーにラベルリソースから値を取得します? 1259 // 4.2.3.2 (2008/06/20) from が?null なら?なにもしな?? 1260 if( from != null ) { 1261 fromLbl = resource.getLabel( from ); 1262 } 1263 1264 // カラ?号配?から、カラ?のラベルリソース??のCSV??を作?します? 1265 names = getKeysLabel( clmNo ); 1266 1267 if( msgKeys != null && msgKeys.length > 0 ) { 1268 int size = msgKeys.length; 1269 msgVals = new String[size] ; 1270 1271 for( int i=0; i<size; i++ ) { 1272 String key = msgKeys[i] ; 1273 if( key != null ) { 1274 if( "@KEY".equals( key ) ) { msgVals[i] = names; } 1275 else if( "@TBL".equals( key ) ) { msgVals[i] = fromLbl;} 1276 else if( key.startsWith( "{#" ) && key.endsWith( "}" ) ) { 1277 msgVals[i] = resource.getLabel( key.substring( 2,key.length()-1 )); 1278 } 1279 else { 1280 msgVals[i] = key; 1281 } 1282 } 1283 } 1284 } 1285 } 1286 1287 /** 1288 * カラ?o配?(int[])に対応したカラ?のメ?ージリソース??を返します? 1289 * 1290 * @param clmNo カラ?o配? 1291 * @return カラ?o配?に対応した?カラ?のメ?ージリソース 1292 */ 1293 private String getKeysLabel( final int[] clmNo ) { 1294 StringBuilder buf = new StringBuilder(); 1295 if( table != null && clmNo.length > 0 ) { 1296 String key = table.getColumnName( clmNo[0] ); 1297 buf.append( resource.getLabel( key ) ); 1298 for( int i=1; i<clmNo.length; i++ ) { 1299 key = table.getColumnName( clmNo[i] ); 1300 buf.append( "," ).append( resource.getLabel( key ) ); 1301 } 1302 } 1303 1304 return buf.toString(); 1305 } 1306 1307 /** 1308 * カラ?列を設定します? 1309 * 1310 * @og.rev 4.3.5.7 (2008/03/22) エラーメ?ージの行番号を実際の行番号と??させる? 1311 * 1312 * @param row カラ? 1313 * @param id カラ? 1314 * @param values ??行に対する値 1315 */ 1316 public void addMessage( final int row, final String id, final String[] values ) { 1317 if( isFirst ) { firstExecute(); isFirst = false; } 1318 1319 String vals = StringUtil.array2csv( values ); 1320 if( msgVals == null ) { 1321 // errMessage.addMessage( row, ErrorMessage.NG, id, names, vals, fromLbl ); 1322 errMessage.addMessage( row + 1, ErrorMessage.NG, id, names, vals, fromLbl ); 1323 } 1324 else { 1325 int size = msgKeys.length; 1326 String[] args = new String[size] ; 1327 1328 for( int i=0; i<size; i++ ) { 1329 String key = msgVals[i] ; 1330 if( key != null ) { 1331 if( "@VAL".equals( key ) ) { args[i] = vals; } 1332 else if( key.startsWith( "[" ) && key.endsWith( "]" ) ) { 1333 if( table != null ) { 1334 args[i] = table.getValue( row,key.substring( 1,key.length()-1 ) ); 1335 } 1336 } 1337 else { 1338 args[i] = key; 1339 } 1340 } 1341 } 1342 // errMessage.addMessage( row, ErrorMessage.NG, id, args ); 1343 errMessage.addMessage( row + 1, ErrorMessage.NG, id, args ); 1344 } 1345 } 1346 1347 /** 1348 * ErrorMessageオブジェクトを返します? 1349 * 1350 * @return ErrorMessage オブジェク? 1351 */ 1352 public ErrorMessage getErrMessage() { return errMessage; } 1353 } 1354 1355 /** 1356 * シリアライズ用のカスタ?リアライズ書き込みメソ? 1357 * 1358 * @og.rev 4.0.0.0 (2006/09/31) 新規追? 1359 * @serialData 1360 * 1361 * @param strm ObjectOutputStreamオブジェク? 1362 */ 1363 private void writeObject( final ObjectOutputStream strm ) throws IOException { 1364 strm.defaultWriteObject(); 1365 } 1366 1367 /** 1368 * シリアライズ用のカスタ?リアライズ読み込みメソ? 1369 * 1370 * ここでは、transient 宣?れた?変数の??初期化が?なフィールド?み設定します? 1371 * 1372 * @og.rev 4.0.0.0 (2006/09/31) 新規追? 1373 * @serialData 1374 * 1375 * @param strm ObjectInputStreamオブジェク? 1376 * @see #release2() 1377 */ 1378 private void readObject( final ObjectInputStream strm ) throws IOException, ClassNotFoundException { 1379 strm.defaultReadObject(); 1380 } 1381 1382 /** 1383 * こ?オブジェクト???表現を返します? 1384 * 基本???目?使用します? 1385 * 1386 * @return こ?クラスの??表現 1387 */ 1388 @Override 1389 public String toString() { 1390 return org.opengion.fukurou.util.ToString.title(this.getClass().getName() ) 1391 .println( "VERSION", VERSION ) 1392 .println( "tableId", tableId ) 1393 .println( "dbid", dbid ) 1394 .println( "command", command ) 1395 .println( "exist", exist ) 1396 .println( "msg", msg ) 1397 .println( "Other...", getAttributes().getAttribute() ).fixForm().toString(); 1398 } 1399 }