| |
---|
| | |
---|
| | public class DbFuel extends Osmdb { |
---|
| | @SuppressWarnings("FieldNameHidesFieldInSuperclass") |
---|
| | public static final String TABLE_NAME = "FUEL"; |
---|
| | public static final String CLASS_NAME = "DbFuel"; |
---|
| | |
---|
| | /** メイン |
---|
| | * |
---|
| | * @param args |
---|
| |
---|
| | public static void main(String[] args) throws Exception |
---|
| | { |
---|
| | if (args.length < 1) { |
---|
| | commandHelp(); |
---|
| | throw new Exception("[ERROR] Illegal command call 'DbFuel'"); |
---|
| | throw new Exception( |
---|
| | String.format("[ERROR] Illegal command call '%s'", CLASS_NAME) |
---|
| | ); |
---|
| | } |
---|
| | |
---|
| | // HSQLディレクトリがなければエラー |
---|
| | File dbdir = new File("database"); |
---|
| | if (!dbdir.isDirectory()) { |
---|
| | throw new FileNotFoundException("Directory 'database' is not found."); |
---|
| | } |
---|
| | |
---|
| | Connection hsqldb = null; |
---|
| | try { |
---|
| | hsqldb = DatabaseTool.openDb("database"); |
---|
| | try (Connection hsqldb = DatabaseTool.openDb("database")) { |
---|
| | switch (args[0]) { |
---|
| | case "-INIT": |
---|
| | { |
---|
| | // DB.tableを作成(初期化) |
---|
| |
---|
| | { |
---|
| | // GMLからの読み込み |
---|
| | if (args.length < 2) { |
---|
| | throw new Exception( |
---|
| | "[ERROR] Illegal command call 'DbFuel -IMPORT <gml directory>'" |
---|
| | "[ERROR] Illegal command call '"+ CLASS_NAME +" -IMPORT <gml directory>'" |
---|
| | ); |
---|
| | } |
---|
| | DbFuel dbFuel = new DbFuel(hsqldb); |
---|
| | dbFuel.importGmlfiles(args[1]); |
---|
| |
---|
| | { |
---|
| | // REMOVEDファイルを読み込み |
---|
| | if (args.length < 2) { |
---|
| | throw new Exception( |
---|
| | "[ERROR] Illegal command call 'DbFuel -REMOVED <removed.json.txt>'" |
---|
| | "[ERROR] Illegal command call '"+ CLASS_NAME +" -REMOVED <removed.json.txt>'" |
---|
| | ); |
---|
| | } |
---|
| | DbFuel dbFuel = new DbFuel(hsqldb); |
---|
| | dbFuel.loadRemoved(new File(args[1])); |
---|
| |
---|
| | case "-EXPORT": |
---|
| | // 'table.FUEL'の内容をCSV形式にして標準出力に出力する |
---|
| | DbFuel.export(hsqldb); |
---|
| | break; |
---|
| | case "-OUTPUT": |
---|
| | { |
---|
| | // REMOVEDファイルを読み込み |
---|
| | if (args.length < 2) { |
---|
| | throw new Exception( |
---|
| | "[ERROR] Illegal command call '"+ CLASS_NAME +" -OUTPUT <removed.json.txt>'" |
---|
| | ); |
---|
| | } |
---|
| | DbFuel dbFuel = new DbFuel(hsqldb); |
---|
| | dbFuel.outputRemoved(new File(args[1])); |
---|
| | break; |
---|
| | } |
---|
| | default: |
---|
| | commandHelp(); |
---|
| | throw new Exception("[ERROR] Illegal command call 'DbFuel'"); |
---|
| | } |
---|
| | } |
---|
| | finally { |
---|
| | if (hsqldb != null) { |
---|
| | DatabaseTool.closeDb(hsqldb); |
---|
| | throw new Exception("[ERROR] Illegal command call '"+ CLASS_NAME +"'"); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | static void commandHelp() { |
---|
| | System.out.println("[Command Call]"); |
---|
| | System.out.println("> DbFuel -INIT"); |
---|
| | System.out.println("> "+ CLASS_NAME +" -INIT"); |
---|
| | System.out.println(" Initillaize detabase table 'FUEL'."); |
---|
| | System.out.println(); |
---|
| | System.out.println("> DbFuel -IMPORT <gml directory>"); |
---|
| | System.out.println("> "+ CLASS_NAME +" -IMPORT <gml directory>"); |
---|
| | System.out.println(" Import from GML files."); |
---|
| | System.out.println(); |
---|
| | System.out.println("> DbFuel -REMOVED <removed.json.txt>"); |
---|
| | System.out.println("> "+ CLASS_NAME +" -REMOVED <removed.json.txt>"); |
---|
| | System.out.println(" Import REMOVED json.text file."); |
---|
| | System.out.println(); |
---|
| | System.out.println("> DbFuel -EXPORT"); |
---|
| | System.out.println("> "+ CLASS_NAME +" -EXPORT"); |
---|
| | System.out.println(" 'table.*'の内容をCSV形式にして標準出力に出力する"); |
---|
| | System.out.println(); |
---|
| | System.out.println("> "+ CLASS_NAME +" -OUTPUT <removed.json.txt>"); |
---|
| | System.out.println(" removedデータをファイルに追記する"); |
---|
| | System.out.println(); |
---|
| | } |
---|
| | |
---|
| | public DbFuel(Connection hsqldb) { |
---|
| |
---|
| | |