Beispiel #1
0
  /* update title string */
  public static void updateAccountString(
      Account account, String stringID, String description, String singular, String plural)
      throws DBException {

    /* valid account? */
    if (account == null) {
      throw new DBException("Account not specified.");
    }

    /* delete? */
    // delete if both singular/plural values are empty/null
    if (((singular == null) || singular.equals("")) && ((plural == null) || plural.equals(""))) {
      String acctID = account.getAccountID();
      AccountString.Key key = new AccountString.Key(acctID, stringID);
      key.delete(true); // also delete dependencies (if any)
      return;
    }

    /* get/create AccountString */
    AccountString str = AccountString.getAccountString(account, stringID);
    if (str == null) {
      str = AccountString.getAccountString(account, stringID, true);
    }

    /* insert/update */
    str.setDescription(description);
    str.setSingularTitle(singular);
    str.setPluralTitle((plural != null) ? plural : singular);
    str.save();
  }