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 }