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.common.HybsSystemException; 020 import org.opengion.hayabusa.db.DBTableModel; 021 import org.opengion.hayabusa.report.DBTableReport; 022 import org.opengion.fukurou.util.FileUtil; 023 import org.opengion.fukurou.util.Shell; 024 025 import org.opengion.fukurou.util.StringUtil ; 026 import static org.opengion.fukurou.util.StringUtil.nval ; 027 028 import java.io.File; 029 import java.io.IOException; 030 import java.io.ObjectOutputStream; 031 import java.io.ObjectInputStream; 032 033 /** 034 * 検索結果の DBTableModelオブジェクトをレポ?ト形式に変換するタグです? 035 * 036 * ??タ(DBTableModel)と、コントローラ(DBTableReport クラス)を与えて? 037 * 外部からコントロールすることで、各種形式で ??タ(DBTableModel)を表示させること? 038 * 可能です? 039 * 040 * @og.formSample 041 * ●形式?lt;og:report fileURL="[???]" listId="[???]" ??? /> 042 * ●body?な? 043 * 044 * ●Tag定義?? 045 * <og:report 046 * listId ○?TAG】帳票IDを指定します?(??) 047 * fileURL 【TAG】雛型?HTMLファイルの保存してある ?レクトリを指定しま? 048 * programFile 【TAG】HTMLファイルをEXCEL変換する場合に使用するBATファイルを指定しま? 049 * outFileURL 【TAG】?力HTMLファイルの保存してある?レクトリを指定しま? 050 * outFilename ○?TAG】ファイルを作?するとき?出力ファイル名をセ?します?(??) 051 * headerKeys 【TAG】固定部の{@KEY} の KEY 部?CSV形式で??しま? 052 * headerVals 【TAG】固定部のKEY に対応する?をCSV形式で??しま? 053 * footerKeys 【TAG】繰り返し部の終?に表示する key 部?CSV形式で??しま? 054 * footerVals 【TAG】固定部のKEY に対応する?をCSV形式で??しま? 055 * pageEndCut 【TAG】??ー部(繰り返し部)がなくなったときに、それ以降を表示するかど?[true/false]を指定しま?初期値:true) 056 * reportClass 【TAG】実際に書き?すクラス名?略称(DBTableReport_**** の ****)をセ?しま?初期値:HTML) 057 * language 【TAG】タグ?で使用する?コード[ja/en/zh/…]を指定しま? 058 * scope 【TAG】キャ?ュする場合?スコープ[request/page/session/applicaton]を指定しま?初期値:session) 059 * tableId 【TAG?通常使?せん)sessionから?す?DBTableModelオブジェクト? ID 060 * debug 【TAG】デバッグ??を?力するかど?[true/false]を指定しま?初期値:false) 061 * /> 062 * 063 * ●使用? 064 * 065 * @og.group そ?他?? 066 * 067 * @version 4.0 068 * @author Kazuhiko Hasegawa 069 * @since JDK5.0, 070 */ 071 public class ReportTableTag extends CommonTagSupport { 072 //* こ?プログラ??VERSION??を設定します? {@value} */ 073 private static final String VERSION = "4.0.0.0 (2005/08/31)" ; 074 075 private static final long serialVersionUID = 4000 ; // 4.0.0 (2005/01/31) 076 077 // 印刷時に使用する?ポラリフォル? 078 private final String REPORT_URL = 079 nval( HybsSystem.sys( "REPORT_FILE_URL" ) , 080 HybsSystem.sys( "FILE_URL" ) + "REPORT/" ) ; 081 082 // 3.8.0.4 (2005/08/08) 印刷時に使用するシス?ID 083 private static final String SYSTEM_ID =HybsSystem.sys( "SYSTEM_ID" ); 084 085 // 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更 086 private final int TIMEOUT = HybsSystem.sysInt( "REPORT_DAEMON_TIMEOUT" ); 087 088 private final String BASE_URL = HybsSystem.sys( "FILE_URL" ); 089 090 private String[] headerKeys = null; // 固定部の{@KEY} の KEY 部??する?カンマで??できる? 091 private String[] headerVals = null; // 固定部のKEY に対応する?を指定する? {@KEY} に置き換わる? 092 private String[] footerKeys = null; // 繰り返し部の終?に表示する key 部??する?カンマで??できる? 093 private String[] footerVals = null; // 繰り返し部の終?に表示する key に対する値を指定する? 094 private boolean pageEndCut = true; // ボディー部(繰り返し部)がなくなったときに、それ以降?ペ?ジを?力するか?する? 095 private String fileURL = BASE_URL; // 雛型のHTMLファイルの保存してある ?レクトリを指定します? 096 private String outFileURL = BASE_URL; // 出力HTMLファイルの保存してある ?レクトリを指定します? 097 private String outFilename = null; // 出力HTMLファイル名を?します? ?レクトリ名を含んでも構いません? 098 private String reportClass = "HTML"; 099 100 private transient DBTableModel table = null; 101 private String tableId = HybsSystem.TBL_MDL_KEY ; 102 // 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更 103 private String listId = null ; // 雛型のHTMLファイル名を?します? 104 private String programFile = null; // HTMLファイルのEXCEL化を行うバッチファイルを指定します? 105 // private boolean direct = false; 106 // private static final String disposition = "inline"; // 固? 107 108 /** 109 * Taglibの終?グが見つかったときに処??doEndTag() ?オーバ?ライドします? 110 * 111 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ? 112 * @og.rev 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更 113 * @og.rev 4.0.0.0 (2007/10/18) メ?ージリソース統? getResource().getMessage > getResource().getLabel ) 114 * @og.rev 4.0.0.0 (2007/11/28) メソ?の戻り?をチェ?します? 115 * 116 * @return 後続???? 117 */ 118 @Override 119 public int doEndTag() { 120 debugPrint(); 121 122 // int rtnCode = EVAL_PAGE; 123 final int rtnCode; 124 125 table = (DBTableModel)getObject( tableId ); 126 if( table == null || table.getRowCount() == 0 ) { 127 rtnCode = SKIP_PAGE ; // ペ?ジの残りの処?行わな?? 128 } 129 else { 130 131 // try { 132 133 synchronized( ReportTableTag.class ) { 134 String reportDir = HybsSystem.url2dir( REPORT_URL ) + SYSTEM_ID + HybsSystem.FS + listId ; 135 // String ykno = HybsSystem.getDate( "yyyyMMddHHmmss" ); 136 String ykno = String.valueOf( Math.round( Math.random() * 1000000 ) ) ; 137 138 create( reportDir,ykno ) ; 139 140 // 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が?? 141 if( programFile != null && "HTML".equalsIgnoreCase( reportClass ) ) { 142 String htmlFile = reportDir + HybsSystem.FS + ykno ; 143 String cmd = makeShellCommand( htmlFile,listId ); 144 programRun( cmd ); 145 } 146 147 if( outFilename != null ) { 148 File xlsFile = new File( reportDir,ykno + ".xls" ); 149 File outDir = new File( HybsSystem.url2dir( outFileURL ) ); 150 // if( !outDir.exists() ) { outDir.mkdirs(); } 151 if( !outDir.exists() && !outDir.mkdirs() ) { 152 String errMsg = "??フォル?作?できませんでした?" + outDir + "]" ; 153 throw new RuntimeException( errMsg ); 154 } 155 File outFile = new File( outDir,outFilename ); 156 // File outFile = new File( outFileURL,outFilename ); 157 FileUtil.copy( xlsFile , outFile ); 158 159 // String msg = getResource().getMessage( "MSG0003" ) // MSG0003=ファイルの登録が完?ました? 160 String msg = getResource().getLabel( "MSG0003" ) // MSG0003=ファイルの登録が完?ました? 161 + HybsSystem.BR 162 // + getResource().getMessage( "MSG0022" ) // MSG0022=ファイル? 163 + getResource().getLabel( "MSG0022" ) // MSG0022=ファイル? 164 + ":" + outFile.getAbsolutePath() ; 165 jspPrint( msg ); 166 167 // if( direct ) { 168 // directLoad( outFile.getAbsolutePath(),outFilename ); 169 // directLoad( xlsFile.getAbsolutePath(),outFilename ); 170 // } 171 } 172 // else { 173 // String redirectUrl = StringUtil.urlAppend( sys( "CONTEXT_URL" ), 174 // REPORT_URL + SYSTEM_ID + "/" + 175 // listId + "/" + ykno + ".xls" ) ; 176 // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse(); 177 // response.sendRedirect( response.encodeRedirectURL( redirectUrl ) ); 178 // } 179 } 180 // } 181 // catch(IOException ex) { 182 // String errMsg = "Error in ReportTableTag: " + toString(); 183 // throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数の並び?更 184 // } 185 rtnCode = EVAL_PAGE ; 186 } 187 188 return( rtnCode ); 189 } 190 191 /** 192 * タグリブオブジェクトをリリースします? 193 * キャ?ュされて再利用される?で、フィールド?初期設定を行います? 194 * 195 * @og.rev 2.0.0.4 (2002/09/27) カスタ?グの release() メソ?を?追? 196 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応?release2() ?doEndTag()で呼ぶ? 197 * @og.rev 3.1.3.0 (2003/04/10) REPORT_ENCODE(帳票エンコー?ング)を利用するように修正? 198 * @og.rev 3.8.0.4 (2005/08/08) filename 削除、listId ,programFile 追?, 199 * 200 */ 201 @Override 202 protected void release2() { 203 super.release2(); 204 headerKeys = null; 205 headerVals = null; 206 footerKeys = null; 207 footerVals = null; 208 pageEndCut = true; 209 fileURL = BASE_URL; 210 outFileURL = BASE_URL; 211 outFilename = null; // 出力ファイル? 212 reportClass = "HTML"; 213 table = null; 214 tableId = HybsSystem.TBL_MDL_KEY ; 215 listId = null ; // 3.8.0.4 (2005/08/08) 216 programFile = null ; // 3.8.0.4 (2005/08/08) 217 // direct = false; 218 } 219 220 /** 221 * TableWriter の実オブジェクトを生?して?PrintWriter に書き込みます? 222 * 223 * @og.rev 3.1.3.0 (2003/04/10) REPORT_ENCODE(帳票エンコー?ング)を利用するように修正? 224 * @og.rev 3.5.4.3 (2004/01/05) HTMLDBTableReport のクラス名変更? 225 * @og.rev 3.6.0.0 (2004/09/17) メソ?名?変更。setInputFile ?setTemplateFile 226 * @og.rev 3.8.0.0 (2005/06/07) setTemplateFile メソ?の引数?String ?File に変更 227 * @og.rev 3.8.0.4 (2005/08/08) 帳票出力に準拠した方式に変更 228 * @og.rev 4.0.0.0 (2005/01/31) lang ?ResourceManager へ変更 229 * 230 * @param reportDir 出力ディレクトリ? 231 * @param ykno 要求番号 232 */ 233 private void create( final String reportDir,final String ykno ) { 234 235 String className = "org.opengion.hayabusa.report.DBTableReport_" + reportClass ; 236 DBTableReport report = (DBTableReport)HybsSystem.newInstance( className ); // 3.5.5.3 (2004/04/09) 237 238 String MODELDIR = HybsSystem.url2dir( fileURL ) ; 239 240 File templateFile = null; 241 File firstTemplateFile = null; 242 243 // 本来は、各クラス中で処?べき?そ?ためのオブジェクト指向なの?ら? 244 if( "HTML".equalsIgnoreCase( reportClass ) ) { 245 templateFile = FileUtil.checkFile( MODELDIR, listId + ".html" , 1 ); 246 firstTemplateFile = FileUtil.checkFile( MODELDIR, listId + "_FIRST.html" ,1 ); 247 } 248 else if( "Excel".equalsIgnoreCase( reportClass ) ) { 249 templateFile = FileUtil.checkFile( MODELDIR, listId + ".xls" , 1 ); 250 } 251 else { 252 String errMsg = "リポ?トクラスがサポ?ト外です?[" + reportClass + "]" 253 + "クラスは、HTML、Excel のみサポ?トされて?す?" ; 254 throw new RuntimeException( errMsg ); 255 } 256 257 FileUtil.copy( templateFile,new File( reportDir ) ); 258 259 report.setDBTableModel( table ); 260 report.setTemplateFile( templateFile ); // 3.6.0.0 (2004/09/17) 261 report.setFirstTemplateFile( firstTemplateFile ); // 3.6.0.0 (2004/09/17) 262 report.setOutputDir( reportDir ); 263 report.setOutputFileKey( ykno ); 264 report.setHeaderKeys( headerKeys ); 265 report.setHeaderVals( headerVals ); 266 report.setFooterKeys( footerKeys ); 267 report.setFooterVals( footerVals ); 268 report.setPageEndCut( pageEndCut ); 269 report.setResourceManager( getResource() ); // 4.0.0 (2005/01/31) 270 report.setListId( listId ); // 3.6.1.0 (2005/01/05) 271 report.writeReport(); 272 } 273 274 /** 275 * 【TAG?通常使?せん)sessionから?す?DBTableModelオブジェクト? ID? 276 * 277 * @og.tag 278 * 表示処?に???ポインタを書き換えた)DBTableModelオブジェクトを 279 * 同じキーで、sessionに登録します? 280 * 初期値は、HybsSystem.TBL_MDL_KEY です? 281 * 282 * @param tableId sessionに登録する時? ID 283 */ 284 public void setTableId( final String tableId ) { 285 this.tableId = nval( getRequestParameter( tableId ), this.tableId ); 286 } 287 288 /** 289 * 【TAG】帳票IDを指定します? 290 * 291 * @og.tag 292 * 雛形ファイルは、帳票ID.html となります?また?ファースト?ージ対応?場合?? 293 * 帳票ID_FIRST.html になります? 294 * なお?filename 属?が指定された場合?、そちらが優先されます? 295 * 296 * @og.rev 3.8.0.4 (2005/08/08) 新規追? 297 * 298 * @param listId 帳票ID 299 */ 300 public void setListId( final String listId ) { 301 this.listId = nval( getRequestParameter( listId ), this.listId ); 302 } 303 304 /** 305 * 【TAG】固定部の{@KEY} の KEY 部?CSV形式で??します? 306 * 307 * @og.tag 308 * カンマで??できます? 309 * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します? 310 * こうしな???タ自身にカンマを持って?場合に?をミスる為です? 311 * 312 * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取? 313 * 314 * @param hKeys 固定部の key 315 */ 316 public void setHeaderKeys( final String hKeys ) { 317 headerKeys = getCSVParameter( hKeys ); 318 } 319 320 /** 321 * 【TAG】固定部のKEY に対応する?をCSV形式で??します? 322 * 323 * @og.tag 324 * カンマで??で、リクエスト情報でも設定できます? 325 * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します? 326 * こうしな???タ自身にカンマを持って?場合に?をミスる為です? 327 * 328 * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取? 329 * 330 * @param hVals 固定部の値 331 */ 332 public void setHeaderVals( final String hVals ) { 333 headerVals = getCSVParameter( hVals ); 334 } 335 336 /** 337 * 【TAG】繰り返し部の終?に表示する key 部?CSV形式で??します? 338 * 339 * @og.tag 340 * カンマで??できます? 341 * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します? 342 * こうしな???タ自身にカンマを持って?場合に?をミスる為です? 343 * 344 * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取? 345 * 346 * @param ftKeys 繰り返し部の終?に表示する key 347 */ 348 public void setFooterKeys( final String ftKeys ) { 349 footerKeys = getCSVParameter( ftKeys ); 350 } 351 352 /** 353 * 【TAG】固定部のKEY に対応する?をCSV形式で??します? 354 * 355 * @og.tag 356 * カンマで??で、リクエスト情報でも設定できます? 357 * ?方法?、CSV変数を?に?してから、getRequestParameter で値を取得します? 358 * こうしな???タ自身にカンマを持って?場合に?をミスる為です? 359 * 360 * @og.rev 3.5.6.2 (2004/07/05) 先に配?に?してからリクエスト変数の値を取? 361 * @og.rev 3.8.1.2 (2005/12/19) footer 関連の値とpageEndCut の関係を解除します? 362 * 363 * @param ftVals 繰り返し部の終?に表示する値 364 */ 365 public void setFooterVals( final String ftVals ) { 366 footerVals = getCSVParameter( ftVals ); 367 } 368 369 /** 370 * 【TAG】??ー部(繰り返し部)がなくなったときに、それ以降を表示するかど?[true/false]を指定しま?初期値:true)? 371 * 372 * @og.tag 373 * true では、それ以降を出力しません? 374 * 初期値は "true" (なくなった時点で、?力しな??)です? 375 * 376 * @og.rev 3.8.1.2 (2005/12/19) footer 関連の値とpageEndCut の関係を解除します? 377 * 378 * @param peCut 繰り返し部の終?に継続??るかど? (true:処?な?false:処?? 379 */ 380 public void setPageEndCut( final String peCut ) { 381 pageEndCut = nval( getRequestParameter( peCut ),pageEndCut ); 382 } 383 384 /** 385 * 【TAG】雛型?HTMLファイルの保存してある ?レクトリを指定します? 386 * 387 * @og.tag 388 * こ?属?で?される?レクトリのファイルを読み取ります? 389 * ?方法???常の fileURL 属?と同様に、?頭が?'/' (UNIX) また??文字目が? 390 * ":" (Windows)の場合?、指定?URLそ?ままの?レクトリに、そ?な??合?? 391 * シス?パラメータ の FILE_URL 属?で??フォル??下に、作?されます? 392 * fileURL = "{@USER.ID}" と?すると、FILE_URL 属?で??フォル??下に? 393 * さらに、各個人ID別のフォル?作?して、そこを操作します? 394 * 395 * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソ?の利用 396 * @og.rev 4.0.0.0 (2007/11/20) ?された?レクトリ名??が"\"or"/"で終わって???合に?/"を付加する? 397 * 398 * @param url 雛型のHTMLファイルの?レクトリ 399 */ 400 public void setFileURL( final String url ) { 401 String furl = nval( getRequestParameter( url ),null ); 402 if( furl != null ) { 403 char ch = furl.charAt( furl.length()-1 ); 404 if( ch != '/' && ch != '\\' ) { furl = furl + "/"; } 405 fileURL = StringUtil.urlAppend( fileURL,furl ); 406 } 407 } 408 409 /** 410 * 【TAG】HTMLファイルをEXCEL変換する場合に使用するBATファイルを指定します? 411 * 412 * @og.tag 413 * ファイルは、フルパスで?してください? 414 * ?がな??合?、変換処??行いません? 415 * 通常は、dbdef2/def/Script/runExcelPrint.bat を呼び出してください? 416 * 初期値は、null(変換処?な?です? 417 * 418 * @og.rev 3.8.0.4 (2005/08/08) 新規追? 419 * 420 * @param programFile プログラ?ァイル? 421 */ 422 public void setProgramFile( final String programFile ) { 423 this.programFile = nval( getRequestParameter( programFile ),this.programFile ); 424 } 425 426 /** 427 * 【TAG】?力HTMLファイルの保存してある?レクトリを指定します? 428 * 429 * @og.tag 430 * こ?属?で?される?レクトリにファイルを?力します? 431 * ?方法???常の fileURL 属?と同様に、?頭が?'/' (UNIX) また??文字目が? 432 * ":" (Windows)の場合?、指定?URLそ?ままの?レクトリに、そ?な??合?? 433 * シス?パラメータ の FILE_URL 属?で??フォル??下に、作?されます? 434 * fileURL = "{@USER.ID}" と?すると、FILE_URL 属?で??フォル??下に? 435 * さらに、各個人ID別のフォル?作?して、そこに出力します? 436 * 437 * @og.rev 4.0.0.0 (2007/11/20) ?された?レクトリ名??が"\"or"/"で終わって???合に?/"を付加する? 438 * 439 * @param url 出力HTMLファイルの?レクトリ 440 */ 441 public void setOutFileURL( final String url ) { 442 String furl = nval( getRequestParameter( url ),null ); 443 if( furl != null ) { 444 char ch = furl.charAt( furl.length()-1 ); 445 if( ch != '/' && ch != '\\' ) { furl = furl + "/"; } 446 outFileURL = StringUtil.urlAppend( outFileURL,furl ); 447 } 448 } 449 450 /** 451 * 【TAG】ファイルを作?するとき?出力ファイル名をセ?します? 452 * 453 * @og.tag ファイルを作?するとき?出力ファイル名をセ?します? 454 * 455 * @param filename 出力ファイル? 456 */ 457 public void setOutFilename( final String filename ) { 458 this.outFilename = nval( getRequestParameter( filename ),this.outFilename ); 459 } 460 461 /** 462 * 【TAG】実際に書き?すクラス名?略称(DBTableReport_**** の ****)をセ?しま?初期値:HTML)? 463 * 464 * @og.tag 465 * これは、org.opengion.hayabusa.report 以下? DBTableReport_**** クラスの **** ? 466 * 与えます?これら?、DBTableReport インターフェースを継承したサブクラスです? 467 * 初期値は?HTML" です? 468 * 属?クラス定義の {@link org.opengion.hayabusa.report.DBTableReport DBTableReport} を参照願います? 469 * 470 * @param reportClass クラス?の略称) 471 * @see org.opengion.hayabusa.report.DBTableReport DBTableReportのサブクラス 472 */ 473 public void setReportClass( final String reportClass ) { 474 this.reportClass = nval( getRequestParameter( reportClass ),this.reportClass ); 475 } 476 477 /** 478 * 【TAG】結果をダイレクトにEXCEL起動するかど?[true/false]を指定しま?初期値:false[ファイル])? 479 * 480 * @og.tag 結果をダイレクトに EXCEL ファイルとして出力するかど?をセ?します? 481 * 482 * @param flag ?レク?true)??ファイル(そ?? 483 */ 484 // public void setDirect( final String flag ) { 485 // direct = nval( getRequestParameter( flag ),direct ); 486 // } 487 488 /** 489 * シェルコマンド???を作?します? 490 * 491 * 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が?? 492 * 493 * @og.rev 3.8.0.4 (2005/08/08) 新規追? 494 * @og.rev 3.8.0.8 (2005/10/03) ??モングループ??ォルト?設? 495 * 496 * @param htmlFile パ?サ済みのHTMLファイル(拡張子な? 497 * @param listId 雛形ファイル(帳票ID) 498 * 499 * @return シェルコマンド??? 500 */ 501 private String makeShellCommand( final String htmlFile,final String listId ) { 502 StringBuilder buf = new StringBuilder( HybsSystem.BUFFER_SMALL ); 503 504 buf.append( programFile ).append( " " ); // 実行するコマン? 505 buf.append( "\"" ); 506 buf.append( htmlFile ).append( "_*.html\" " ); // 入力HTMLファイル 507 buf.append( "\"xls\" " ); // プリンタ? 508 // ?ーファイルを指定する?がある? 509 buf.append( "\"" ); 510 buf.append( htmlFile ).append( ".xls\" " ); // ?ー出力ファイル 511 buf.append( listId ); // モ?ファイル? 512 buf.append( " NULL" ); // ?ー??モングルー? 513 514 return buf.toString(); 515 } 516 517 /** 518 * 実際のレポ?ト?力??行います? 519 * 520 * 処?ラス(reportClass)?HTML の場合?、Shell を起動して、VBS で EXCEL化が?? 521 * 522 * @og.rev 3.8.0.4 (2005/08/08) 新規追? 523 * 524 * @param shellCmd シェルを実行するコマンド文字? 525 */ 526 private void programRun( final String shellCmd ) { 527 Shell shell = new Shell(); 528 shell.setCommand( shellCmd,true ); // BATCHプロセスで実行す? 529 shell.setWait( true ); // プロセスの終?? 530 shell.setTimeout( TIMEOUT ); // 3.6.1.0 (2005/01/05) Shell の タイ?ウトを設? 531 532 int rtnCode = shell.exec(); // 0 は正常終?示? 533 534 if( rtnCode != 0 ) { 535 String errMsg = "Shell Command exequte Error." + HybsSystem.CR 536 + "==============================" 537 + shellCmd + HybsSystem.CR 538 + shell.getStdoutData() + HybsSystem.CR 539 + shell.getStderrData() + HybsSystem.CR ; 540 throw new HybsSystemException( errMsg ); // 3.5.5.4 (2004/04/15) 引数の並び?更 541 } 542 } 543 544 /** 545 * Excel ファイルをダイレクトで返す forward 処?行います? 546 * 547 * @og.rev 4.0.0.0 (2007/06/11) 新規追? 548 * 549 * @param fwdUrl 実際に転送するファイルアドレス 550 * @param fname 転送で返すファイル? 551 */ 552 // private void directLoad( final String fwdUrl,final String fname ) { 553 // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse(); 554 // 555 // try { 556 // String url = response.encodeRedirectURL( fwdUrl ); // 3.5.4.9 (2004/02/25) 557 // String filename = StringUtil.urlEncode( fname ); 558 // 559 // (response).setHeader( "Content-Disposition",disposition + "; filename=\"" + filename + "\"" ); 560 // response.sendRedirect( url ); 561 // // pageContext.forward( url ); 562 // } catch(IOException ex) { 563 // String errMsg = "フォワードでIOエラーが発生しました? + toString(); 564 // throw new HybsSystemException( errMsg,ex ); 565 //// } catch( ServletException ex) { 566 //// String errMsg = "フォワードでServletエラーが発生しました? + toString(); 567 //// throw new HybsSystemException( errMsg,ex ); 568 // } 569 // } 570 571 /** 572 * タグの名称を?返します? 573 * 自??身のクラス名より?自動的に取り出せな?め?こ?メソ?をオーバ?ライドします? 574 * 575 * @og.rev 4.0.0.0 (2005/01/31) 新規追? 576 * 577 * @return タグの名称 578 */ 579 @Override 580 protected String getTagName() { 581 return "report" ; 582 } 583 584 /** 585 * シリアライズ用のカスタ?リアライズ書き込みメソ? 586 * 587 * @og.rev 4.0.0.0 (2006/09/31) 新規追? 588 * @serialData 589 * 590 * @param strm ObjectOutputStreamオブジェク? 591 */ 592 private void writeObject( final ObjectOutputStream strm ) throws IOException { 593 strm.defaultWriteObject(); 594 } 595 596 /** 597 * シリアライズ用のカスタ?リアライズ読み込みメソ? 598 * 599 * ここでは、transient 宣?れた?変数の??初期化が?なフィールド?み設定します? 600 * 601 * @og.rev 4.0.0.0 (2006/09/31) 新規追? 602 * @serialData 603 * 604 * @param strm ObjectInputStreamオブジェク? 605 * @see #release2() 606 */ 607 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException { 608 strm.defaultReadObject(); 609 } 610 611 /** 612 * こ?オブジェクト???表現を返します? 613 * 基本???目?使用します? 614 * 615 * @return こ?クラスの??表現 616 */ 617 @Override 618 public String toString() { 619 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 620 .println( "VERSION" ,VERSION ) 621 .println( "headerKeys" ,headerKeys ) 622 .println( "headerVals" ,headerVals ) 623 .println( "footerKeys" ,footerKeys ) 624 .println( "footerVals" ,footerVals ) 625 .println( "pageEndCut" ,pageEndCut ) 626 .println( "fileURL" ,fileURL ) 627 .println( "outFileURL" ,outFileURL ) 628 .println( "outFilename" ,outFilename ) 629 .println( "reportClass" ,reportClass ) 630 .println( "tableId" ,tableId ) 631 .println( "listId" ,listId ) 632 .println( "programFile" ,programFile ) 633 .println( "REPORT_FILE_URL" ,REPORT_URL ) 634 .println( "SYSTEM_ID" ,SYSTEM_ID ) 635 .println( "TIMEOUT" ,TIMEOUT ) 636 .println( "BASE_URL" ,BASE_URL ) 637 .println( "Other..." ,getAttributes().getAttribute() ) 638 .fixForm().toString() ; 639 } 640 }