Ejemplo n.º 1
0
 static void addNewLanguage() {
   if (dbIsOpen()) {
     System.out.println("New language name: ");
     String newLanguage = scanner.next();
     try {
       DatabaseConnection.updateListOfLanguages(flags.getConnection(), newLanguage);
     } catch (SQLException ex) {
       printSQLException(ex);
     }
   }
 }
Ejemplo n.º 2
0
 static void showLanguages() {
   if (dbIsOpen()) {
     try {
       ArrayList<String> listOfLanguages =
           DatabaseConnection.getListOfLanguages(flags.getConnection());
       for (String language : listOfLanguages) {
         System.out.println(language);
       }
     } catch (SQLException ex) {
       printSQLException(ex);
     }
   }
 }
Ejemplo n.º 3
0
  static void programRun() {
    System.out.println("Give a command: ");
    String command = scanner.next().toLowerCase();
    if (command.equals("")) {

    } else if (command.equals("exit")) {
      insideExitCommand = true;
      while (insideExitCommand) {
        System.out.println("Are you sure you want to quit? Y/N");
        command = scanner.next().toLowerCase();
        if (command.startsWith("y")) {
          System.out.println("Goodbye.");
          programIsOn = false;
          insideExitCommand = false;
        } else if (command.startsWith("n")) {
          insideExitCommand = false;
        } else {
          printCommandUnknown();
        }
      }
    } else if (command.equals("help")) {
      helpCommand();
    } else if (command.equals("opendb")) {
      openDB();
      // to be continued
    } else if (command.equals("start") || command.equals("analyze")) {
      insideStart = true;
      while (insideStart) {
        Operation operation = new Operation(scanner, flags, command);
        operation.main();
        insideStart = false;
      }
    } else if (command.equals("truncate")) {
      if (dbIsOpen()) {
        try {
          DatabaseConnection.truncateTables(flags.getConnection());
        } catch (SQLException ex) {
          printSQLException(ex);
        }
      }
    } else if (command.equals("addlang")) {
      addNewLanguage();
    } else if (command.equals("showlangs")) {
      showLanguages();
    } else if (command.equals("automatic")) {
      flags.setApproveFormsAutomatically(!flags.areFormsAutomaticallyApproved());
    } else {
      printCommandUnknown();
    }
  }