示例#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();
  }
示例#2
0
 /* create string */
 public static AccountString createNewAccountString(Account account, String strID)
     throws DBException {
   if ((account != null) && (strID != null) && !strID.equals("")) {
     AccountString str =
         AccountString.getAccountString(account, strID, true); // does not return null
     str.save();
     return str;
   } else {
     throw new DBException("Invalid Account/StringID specified");
   }
 }