Ejemplo n.º 1
0
 // ### ==========  write main DB File and all tables ============  ###########
 public static void writeTablesToFile() throws Exception {
   // write sepparate files for the future testing
   Util.writeFile(Const.WORKING_DIR + Const.PATH_SEP + "header.dat", headerTable.data);
   Util.writeFile(
       Const.WORKING_DIR + Const.PATH_SEP + "operators_names.dat", operatorsNamesTable.data);
   Util.writeFile(
       Const.WORKING_DIR + Const.PATH_SEP + "app_settings.dat", applicationsSettingsTable.data);
   Util.writeFile(
       Const.WORKING_DIR + Const.PATH_SEP + "carrier_index.dat", carrierIndexTable.data);
   // write main DB file
   Util.writeDBFile();
 }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    Const.HEAD_DB_VERSION = 1;

    for (int i = 0; i < args.length; i++) {
      if ("-mms".equals(args[i]) && args.length > i + 1) {
        pathMMSFile = args[++i];
        if (!(pathMMSFile.endsWith(".txt") || pathMMSFile.endsWith(".csv"))) {
          System.out.println(
              "Wrong input file type with MMS setting. Supported types: .txt or .csv");
          System.exit(1);
        }
      } else if ("-browser".equals(args[i]) && args.length > i + 1) {
        pathBrowserFile = args[++i];
        if (!(pathBrowserFile.endsWith(".txt") || pathBrowserFile.endsWith(".csv"))) {
          System.out.println(
              "Wrong input file type with Browser setting. Supported types: .txt or .csv");
          System.exit(1);
        }
      } else if ("-java".equals(args[i]) && args.length > i + 1) {
        pathJavaAppFile = args[++i];
        if (!(pathJavaAppFile.endsWith(".txt") || pathJavaAppFile.endsWith(".csv"))) {
          System.out.println(
              "Wrong input file type with Java setting. Supported types: .txt or .csv");
          System.exit(1);
        }
      } else if ("-im".equals(args[i]) && args.length > i + 1) {
        pathIMFile = args[++i];
        if (!(pathIMFile.endsWith(".txt") || pathIMFile.endsWith(".csv"))) {
          System.out.println(
              "Wrong input file type with IM setting. Supported types: .txt or .csv");
          System.exit(1);
        }
      } else if ("-nozip".equals(args[i])) {
        USE_ZIP = false;
      } else if ("-debug".equals(args[i])) {
        REMOVE_WORKING_DIR = false;
      } else if ("-dump".equals(args[i]) && args.length == 2) {
        DBDumper dbdumper = new DBDumper();
        System.out.println("============== Dumping DB File ============== ");
        dbdumper.dump(args[i + 1]);
        System.out.println("============== End dumping DB File ============== \n");
        System.exit(0);
      } else {
        System.out.println(" Wrong parameters...");
        usage();
        System.exit(1);
      }
    }

    // validate input files and set file type (IS_INPUT_TXT_FILE)
    String err = Util.validateAndSetInputParms();
    if (err != null) {
      System.out.println(err);
      usage();
      System.exit(1);
    }

    Generator g = new Generator();
    try {
      g.proceed();
      System.out.println(
          "\n========================================================\n"
              + "DB generation finished successfully.\n"
              + "File '"
              + Const.DB_FILE_NAME
              + "' has been created.\n"
              + "========================================================\n");
    } catch (Exception e) {
      Util.deleteFile(Const.DB_FILE_NAME);

      System.out.println("\n===================== Error ===============================");
      System.out.println(
          " DB generation failed.\n"
              + " Please check file '"
              + Const.ERROR_FILE_NAME
              + "' for more details\n");
      // System.out.println(e.getMessage());
      System.out.println("===========================================================\n");
      // e.printStackTrace();
      try {
        Util.writeFile(Const.ERROR_FILE_NAME, e.getMessage());
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }