OSDN Git Service

#34479 対応中
[jaxcel/jaxcel.git] / Jaxcel / src / org / hanei / jaxcel / util / MakeReportTool.java
1 /**
2  * Copyright 2014 Hanei Management Co.,Ltd. 
3  * 
4  * This file is part of Jaxcel
5  * 
6  *  Jaxcel is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU Lesser General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  Jaxcel is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 package org.hanei.jaxcel.util;
20
21 import java.io.File;
22 import java.io.FileInputStream;
23 import java.io.InputStreamReader;
24 import java.util.HashMap;
25 import net.arnx.jsonic.JSON;
26 import org.hanei.jaxcel.report.ReportMaker;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 /**
31  * Excel帳票出力コマンドラインツールクラス
32  * 
33  * @since 1.00.00
34  * @author Noboru Saito
35  */
36 public class MakeReportTool {
37
38         private static final Logger log = LoggerFactory.getLogger(MakeReportTool.class);
39
40         /**
41          * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。<br>
42          * 
43          * @param args<br>
44          * <ul>
45          * <li>arg1 [必須]: Excelテンプレートファイルパス</li>
46          * <li>arg2 [必須]: パラメータJSONファイルパス</li>
47          * <li>arg3 [必須]: Excel帳票出力ファイルパス</li>
48          * <li>arg4 [任意]: カスタムプロパティファイルパス</li>
49          * </ul>
50          * 
51          * @throws Exception 
52          */
53         public static void main(String[] args) throws Exception {
54                 
55                 ReportMaker maker;
56
57                 // check
58                 if(args.length < 3) {
59                         System.out.println("illegal arguments.");
60                         System.out.println("arg1 [required] : template excel file path");
61                         System.out.println("arg2 [required] : parameters json file path");
62                         System.out.println("arg3 [required] : output excel file path");
63                         System.out.println("arg4 [option]   : custom property file path");
64                         System.out.println("...relative path from the build root. or absolute path");
65                         System.exit(1);
66                 }
67                 
68                 // data load
69                 HashMap<String, Object> parameter = JSON.decode(new InputStreamReader(new FileInputStream(new File(args[1])), "UTF-8"));
70                 
71                 // creation ReportMaker 
72                 if(args.length >= 4) {
73                         maker = new ReportMaker(new File(args[3]));
74                 }
75                 else {
76                         maker = new ReportMaker();
77                 }
78                 
79                 // makeReport
80                 log.info("====== makeReport Start ======");
81                 maker.makeReport(new File(args[0]), parameter, new File(args[2]));
82                 System.out.println("output complate: " + args[2]);
83                 log.info("====== makeReport End ======");
84                 System.exit(0);
85         }
86
87 }