コード例 #1
0
  /**
   * Method fired when "add" button is clicked.
   *
   * @param v add button's <tt>View</tt>
   */
  public void onAddClicked(View v) {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Account selectedAcc = (Account) accountsSpiner.getSelectedItem();
    if (selectedAcc == null) {
      logger.error("No account selected");
      return;
    }

    ProtocolProviderService pps = selectedAcc.getProtocolProvider();
    if (pps == null) {
      logger.error("No provider registered for account " + selectedAcc.getAccountName());
      return;
    }

    View content = findViewById(android.R.id.content);
    String contactAddress = ViewUtil.getTextViewValue(content, R.id.editContactName);

    String displayName = ViewUtil.getTextViewValue(content, R.id.editDisplayName);
    if (displayName != null && displayName.length() > 0) {
      addRenameListener(pps, null, contactAddress, displayName);
    }

    Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);
    ContactListUtils.addContact(
        pps, (MetaContactGroup) groupSpinner.getSelectedItem(), contactAddress);
    finish();
  }
コード例 #2
0
  private BigDecimal transferAmount(Account account1, Account account2, BigDecimal amount1) {
    if (account1.getCurrency().equals(account2.getCurrency())) return amount1;

    BigDecimal rate1 = currencyRates.get(account1.getCurrencyCode());
    BigDecimal rate2 = currencyRates.get(account2.getCurrencyCode());
    return amount1.multiply(rate1).divide(rate2, 0, RoundingMode.HALF_UP);
  }
コード例 #3
0
  public void onTransactionResult(TransactionResult tr) {
    log(Level.INFO, "Transaction {0} is validated", tr.hash);
    Map<AccountID, STObject> affected = tr.modifiedRoots();

    if (affected != null) {
      Hash256 transactionHash = tr.hash;
      UInt32 transactionLedgerIndex = tr.ledgerIndex;

      for (Map.Entry<AccountID, STObject> entry : affected.entrySet()) {
        Account account = accounts.get(entry.getKey());
        if (account != null) {
          STObject rootUpdates = entry.getValue();
          account
              .getAccountRoot()
              .updateFromTransaction(transactionHash, transactionLedgerIndex, rootUpdates);
        }
      }
    }

    Account initator = accounts.get(tr.initiatingAccount());
    if (initator != null) {
      log(Level.INFO, "Found initiator {0}, notifying transactionManager", initator);
      initator.transactionManager().notifyTransactionResult(tr);
    } else {
      log(Level.INFO, "Can't find initiating account!");
    }
    emit(OnValidatedTransaction.class, tr);
  }
コード例 #4
0
  /** Creates a new instance of AccountPicker */
  public AccountSelect(Display display, boolean enableQuit) {
    super();
    // this.display=display;

    setTitleItem(new Title(SR.MS_ACCOUNTS));

    accountList = new Vector();
    Account a;

    int index = 0;
    activeAccount = Config.getInstance().accountIndex;
    do {
      a = Account.createFromStorage(index);
      if (a != null) {
        accountList.addElement(a);
        a.active = (activeAccount == index);
        index++;
      }
    } while (a != null);
    if (accountList.isEmpty()) {
      a = Account.createFromJad();
      if (a != null) {
        // a.updateJidCache();
        accountList.addElement(a);
        rmsUpdate();
      }
    }
    attachDisplay(display);
    addCommand(cmdAdd);

    if (enableQuit) addCommand(cmdQuit);

    commandState();
    setCommandListener(this);
  }
コード例 #5
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
  /**
   * Deliveres notification to the user that an email has been dropped. Typically due to size
   * restriction
   *
   * @param account
   * @param messageNumber
   * @param message
   * @throws Exception
   */
  public void saveMessageDroppedNotification(
      Account account, int messageNumber, Message message, int reportedSize) throws Exception {
    MessageParser parser = new MessageParser();

    Email email = new Email();
    email.setSubject(
        "Your email"); // ReceiverUtilsTools.subSubject(parser.parseMsgSubject(message),
                       // subjectSize));
    email.setFrom(parser.parseMsgAddress(message, "FROM", false));
    email.setTo(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "TO", true)));
    email.setCc(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "CC", true)));
    email.setBcc(ReceiverUtilsTools.subAddress(parser.parseMsgAddress(message, "BCC", true)));
    email.setMaildate(ReceiverUtilsTools.dateToStr(message.getSentDate()));
    email.setStatus("0");
    email.setUserId(account.getUser_id());
    email.setMessage_type("EMAIL");

    Body body = new Body();

    String droppedMessage =
        getEmailDroppedMessage(account, getMessageDate(message), reportedSize, email.getFrom());

    body.setData(droppedMessage.getBytes());
    email.setBodySize(droppedMessage.length());

    int saveStatus = DALDominator.newSaveMail(account, email, body);

    if (log.isDebugEnabled())
      log.debug(
          String.format(
              "[%s] msgNum=%d, saving completed for dropped message with status %s",
              account.getName(), messageNumber, saveStatus));
  }
コード例 #6
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
  public boolean isAccountBeingUsed(Account account) {
    if (log.isDebugEnabled())
      log.debug(
          String.format(
              "Checking account %s, user_id %s for last registration with location service",
              account.getId(), account.getUser_id()));

    IPeekLocationService locationService = new PeekLocationService();
    Date lastUpdated = null;
    try {
      lastUpdated = locationService.getLastUpdatedTimestamp(account.getUser_id());
    } catch (DALException e) {
      log.error(UtilsTools.getExceptionStackTrace(e));
    }
    if (lastUpdated == null) {
      log.debug("Last updated value not found, so we should still check this account");
      return true;
    }
    Date now = new Date();
    Long interval = dayMultiplier * mailcheckDisableIntervalInHours;
    Long sinceLastConnection = now.getTime() - lastUpdated.getTime();
    if (sinceLastConnection > interval) {
      if (log.isDebugEnabled())
        log.debug(
            String.format(
                "Last mail check was %s hours ago, > %s hour interval , we will not check this account",
                sinceLastConnection / dayMultiplier, interval / dayMultiplier));
      return false;
    }

    return true;
  }
コード例 #7
0
  private void transfer(final Date date, final Account account1, final Account account2) {
    persistence.runInTransaction(
        em -> {
          BigDecimal amount1 = randomExpenseAmount(account1, date, 0.5);
          if (BigDecimal.ZERO.compareTo(amount1) >= 0) return;

          BigDecimal amount2 = transferAmount(account1, account2, amount1);

          Operation operation = metadata.create(Operation.class);
          operation.setOpType(OperationType.TRANSFER);
          operation.setOpDate(date);
          operation.setAcc1(account1);
          operation.setAmount1(amount1);
          operation.setAcc2(account2);
          operation.setAmount2(amount2);
          em.persist(operation);

          log.info(
              "Transfer: "
                  + date
                  + ", "
                  + account1.getName()
                  + ", "
                  + amount1
                  + ", "
                  + account2.getName()
                  + ", "
                  + amount2);
        });
  }
コード例 #8
0
ファイル: Atm.java プロジェクト: TracyMRohlin/Java-GUI
  public void printAllAccounts(String customerID) {
    // Sorts the customer based on ID, then prints the accounts information

    // change the withdrawal funcitons and deposit functions too
    ajf.dispose();
    ajf = new AdminRunningFrame(this);

    Collections.sort(cust, Customer.CompareIDs);
    String searchString = ajf.getCustomerID();

    StringBuilder stringResults = new StringBuilder();
    String header = header();
    stringResults.append(header);
    for (Customer customer : cust) {
      String id = customer.returnID();
      String name = customer.getName().toUpperCase();
      String pin = customer.returnPin();
      if (searchString.equals(id)) {
        ArrayList<Account> accounts = customer.getAccounts();
        if (!accounts.isEmpty()) {
          for (Account account : accounts) {
            if (account.checkActive()) {
              String accountNumber = account.returnNumber();
              double balance = account.returnBalance();
              String balanceAsString = formatter.format(balance);
              String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString);
              stringResults.append(customerInfo);
            }
          }
        }
      }
    }
    String resultsAsString = stringResults.toString();
    ajf.printInfo(resultsAsString);
  }
コード例 #9
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
 public boolean isTimeToReconcile(Account account) {
   return account.getLast_reconciliation() == null
       || (System.currentTimeMillis() - account.getLast_reconciliation().getTime())
           > 1000l
               * 60
               * Long.valueOf(
                   SysConfigManager.instance().getValue("reconciliationIntervalInMinutes", "60"));
 }
コード例 #10
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
 protected boolean isMessageAlreadyProcessed(
     String messageId, Account account, String storeBucket, Set<String> storeMessageIds)
     throws MessageStoreException {
   return messageId != null
       && (storeMessageIds.contains(messageId)
           || messageIdStore.hasMessage(
               account.getId(), storeBucket, messageId, account.getCountry()));
 }
コード例 #11
0
ファイル: AccountApp.java プロジェクト: ViTVetal/second_task
  public void show() throws SQLException {
    Dao<Account, String> accountDao = connect();
    List<Account> list = accountDao.queryForAll();

    for (Account ball : list) System.out.println(ball.getText() + " " + ball.getPrioritet());

    connectionSource.close();
  }
コード例 #12
0
 @Test
 public void findRepostByAccounts_Entity_複数_00() {
   Account acnt1 = Account.findByLoginName("goro_san").first();
   Account acnt2 = Account.findByLoginName("jiro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByAccounts(acnt1, acnt2).fetch();
   assertThat(lst.size(), is(24));
   // DBからの取得リストの並び保証なし
 }
コード例 #13
0
 private BigDecimal getDefaultLot() {
   Account account = this.get_Account();
   TradePolicyDetail tradePolicyDetail =
       this._settingsManager.getTradePolicyDetail(
           account.get_TradePolicyId(), this._instrument.get_Id());
   return this._isForDelivery
       ? tradePolicyDetail.get_PhysicalMinDeliveryQuantity()
       : AppToolkit.getDefaultLot(this._instrument, true, tradePolicyDetail, this);
 }
コード例 #14
0
 @Test
 public void findRepostByAccounts_Entity_複数_降順_00() {
   Account acnt1 = Account.findByLoginName("goro_san").first();
   Account acnt2 = Account.findByLoginName("jiro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByAccounts(acnt1, acnt2)
           .orderBy(RepostBase.OrderBy.DATE_OF_REPOST_DESC)
           .fetch();
   assertThat(lst.size(), is(24));
   assertThat(lst.get(0).contributor.loginUser.screenName, is("goro_san"));
 }
コード例 #15
0
 @Override
 public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException {
   UserDetails userDetails = null;
   Account account = accountRepository.findByLogin(login);
   if (null == account) {
     log.warn("User " + login + " not found");
     throw new UsernameNotFoundException("User " + login + " not found.");
   }
   List<GrantedAuthority> authorities = buildUserAuthority(account.getAuthorities());
   userDetails = buildUserForAuthentication(account, authorities);
   return userDetails;
 }
コード例 #16
0
 @Override
 public AccountDTO registerUser(RegistrationForm registrationForm) {
   if (null == registrationForm) {
     log.error("registrationForm was invalid, registration failed");
   } else {
     registrationForm.setPassword(EncodingUtils.encrypt(registrationForm.getPassword()));
     Account account = getMapper().map(registrationForm, Account.class);
     account.setAuthorities(new HashSet<>(Arrays.asList(Authority.AUTHOR)));
     return getMapper().map(accountRepository.save(account), AccountDTO.class);
   }
   return null;
 }
コード例 #17
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
  public void notifyAccountLock(Account account, String context) {
    PartnerCode partnerCode = account.getPartnerCode();
    String lockedOutMessageBody =
        SysConfigManager.instance()
            .getValue("lockedOutMessageBody", LOCKED_OUT_MESSAGE_BODY, partnerCode);
    String lockedOutMessageSubject =
        SysConfigManager.instance()
            .getValue("lockedOutMessageSubject", LOCKED_OUT_MESSAGE_SUBJECT, partnerCode);
    String lockedOutMessageFrom =
        SysConfigManager.instance()
            .getValue("lockedOutMessageFrom", LOCKED_OUT_MESSAGE_FROM, partnerCode);
    String lockedOutMessageAlias =
        SysConfigManager.instance()
            .getValue("lockedOutMessageAlias", LOCKED_OUT_MESSAGE_ALIAS, partnerCode);

    try {
      Email email = new Email();
      email.setSubject(lockedOutMessageSubject);

      email.setStatus("0");
      email.setUserId(account.getUser_id());
      email.setMessage_type("EMAIL");

      email.setFrom(lockedOutMessageFrom);
      email.setFrom_alias(lockedOutMessageAlias);
      email.setTo(account.getLoginName());
      email.setBodySize(lockedOutMessageBody.length());

      DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      email.setMaildate(dateFormat.format(new Date(System.currentTimeMillis()))); // ugh!

      email.setOriginal_account(account.getLoginName());

      // create the pojgo
      EmailPojo emailPojo = new EmailPojo();
      emailPojo.setEmail(email);

      Body body = new Body();
      body.setData(lockedOutMessageBody.getBytes());

      // note, the email will be encoded to prevent sql-injection. since this email is destined
      // directly for the
      // device, we need to reverse the encoding after the call to newSaveEmail
      new EmailRecievedService().newSaveEmail(account, email, body);

      // Added by Dan so we stop checking accounts that have incorrect passwords
      account.setStatus("0");

    } catch (Throwable t) {
      log.warn(String.format("failed to save locked out message for %s", context), t);
    }
  }
コード例 #18
0
ファイル: Main.java プロジェクト: BackupTheBerlios/symphonie
  public static void main(String[] args) {
    System.setProperty("fr.umlv.jbucks.factory", BuckFactoryImpl.class.getName());

    BuckFactory factory = BuckFactory.getFactory();
    Book book = factory.createBook("test");
    System.out.println(book.getName());

    book.setUserData("hello-UID", "12345");
    System.out.println("hello-UID " + book.getUserDataValue("hello-UID"));

    EventManager manager = factory.getEventManager();

    manager.addListener(
        Book.class,
        "accounts",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println(event);
          }
        });

    Account account = factory.createAccount(book, "remi");
    factory.createAccount(book, "gilles");

    List list = book.getAccounts();

    System.out.println(list);

    SortedSet transactions = account.getTransactions();

    manager.addListener(
        Account.class,
        "transactions",
        PropertyEvent.TYPE_PROPERTY_ADDED | PropertyEvent.TYPE_PROPERTY_REMOVED,
        new PropertyListener() {
          public void propertyChanged(PropertyEvent event) {
            System.out.println("transaction " + event);
          }
        });

    Transaction transaction =
        factory.createTransaction(new Date().getTime(), Collections.EMPTY_LIST);
    transactions.add(transaction);

    SortedSet tailSet = transactions.tailSet(transaction);

    System.out.println(tailSet);

    tailSet.add(factory.createTransaction(transaction.getDate() + 1, Collections.EMPTY_LIST));
  }
コード例 #19
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
  public void updateAccount(
      Account account,
      String newFolderHash,
      int newMessages,
      int folderDepth,
      Date lastMessageReceivedDate)
      throws DALException {
    account.setFolder_hash(newFolderHash);
    // reset login failures - since update account happens on successful mail fetch
    account.setLogin_failures(0);
    account.setLast_login_failure(null);

    account.setMessage_count(account.getMessage_count() + newMessages);

    account.setLast_mailcheck(new Date(System.currentTimeMillis()));

    account.setFolder_depth(folderDepth);

    if (lastMessageReceivedDate == null) {
      DALDominator.updateAccountReceiveInfo(account);
    } else {
      account.setLast_received_date(lastMessageReceivedDate);
      DALDominator.updateAccountReceiveInfoAndReceivedDate(account);
    }
  }
コード例 #20
0
  @RequestMapping(value = "/admin/index.html", method = RequestMethod.GET)
  public ModelAndView index() {

    ModelAndView modelAndView = new ModelAndView(index);
    ModelMap modelMap = modelAndView.getModelMap();

    List<User> users = userService.findAllUsers();
    Account account = accountService.findLatestRecord();
    int totalIncome = incomeService.getTotal();

    List<Food> dishes = foodService.findAllFoods();

    Payment todayPayment = paymentService.getPaymentOfToday();

    List<FoodType> catagorys = foodTypeService.findAllFoodTypes();
    Map<String, List<Food>> map = new HashMap<String, List<Food>>();

    for (FoodType type : catagorys) {
      List<Food> foods = foodService.findFoodByType(type.getGuid());
      if (foods.size() > 0) {
        map.put(type.getName(), foods);
      }
    }

    modelMap.put(USERS, users);

    if (account != null) {
      modelMap.put(REMAINDER, account.getRemainder());
    }

    modelMap.put(INCOMETOTAL, totalIncome);

    modelMap.put(DISHES, dishes);
    modelMap.put(CATAGORYS, map);

    if (todayPayment != null) {
      modelMap.put(TODAYCONSUME, todayPayment.getAmount());
    }

    List<String> contentPages = new ArrayList<String>();
    contentPages.add(dashboard + JSPSUFFIX);
    contentPages.add(userManage + JSPSUFFIX);
    contentPages.add(dishManage + JSPSUFFIX);
    modelMap.put(CONTENTPAGE, contentPages);

    List<StepBean> emptyStepBean = Collections.emptyList();
    modelMap.put(STEPS, emptyStepBean);

    return modelAndView;
  }
コード例 #21
0
  public void establishAccount(ServiceAcctInfo acct) {
    String[] args = {Integer.toString(acct.ID)};
    Cursor cur = db.query("acct", AC_COLS, "service_id=?", args, null, null, null);
    try {
      if (cur.moveToNext()) return;
    } finally {
      cur.close();
    }

    Account newAcct = new Account();
    newAcct.serviceId = acct.ID;
    newAcct.name = acct.desc;
    addAccount(newAcct);
  }
コード例 #22
0
ファイル: AccountApp.java プロジェクト: ViTVetal/second_task
  public void write() throws SQLException {
    Scanner sc = new Scanner(System.in);
    System.out.println("Text");
    String text = sc.nextLine();

    System.out.println("Prioritet");
    int prioritet = sc.nextInt();
    Account account = new Account();
    account.setText(text);
    account.setPrioritet(prioritet);
    Dao<Account, String> accountDao = connect();
    accountDao.create(account);
    System.out.println("Enter some string to continue");
    sc.next();
    connectionSource.close();
  }
コード例 #23
0
ファイル: AccountString.java プロジェクト: agustinf/OpenGTS
  /* 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();
  }
コード例 #24
0
ファイル: NewProviderSupport.java プロジェクト: phcd/TAB
 public boolean isMessageTooOld(Account account, Message message, String context)
     throws MessagingException {
   if (message.getSentDate() == null) {
     log.warn(
         String.format("we have a message with no sent date for %s, allowing message", context));
     return false;
   } else if (account.getRegister_time() == null) {
     log.warn(
         String.format(
             "we are process an account with no register time. this behavior is not understood yet %s, we will accept this message",
             context));
     return false;
   } else {
     boolean messageTooOld =
         (System.currentTimeMillis() - message.getSentDate().getTime())
             > 1000l * 60 * 60 * 24 * emailDaysCutoff;
     if (messageTooOld) {
       log.warn(
           String.format(
               "msgNum=%d, message is too old, sentDate=%s, discarding, for %s",
               message.getMessageNumber(), message.getSentDate(), context));
     }
     return messageTooOld;
   }
 }
コード例 #25
0
 @Test
 public void findRepostByTags_String_単数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByTags("tag-goro-red").contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
コード例 #26
0
 private BigDecimal randomExpenseAmount(Account account, Date date, Double part) {
   BigDecimal balance = balanceWorker.getBalance(account.getId(), date);
   if (BigDecimal.ZERO.compareTo(balance) >= 0) return BigDecimal.ZERO;
   else {
     return new BigDecimal((int) (Math.random() * balance.doubleValue() * part));
   }
 }
コード例 #27
0
 public Account getAccountFromCursor(Cursor cur) {
   Account acct = new Account();
   acct.ID = cur.getInt(0);
   acct.serviceId = cur.getInt(1);
   acct.name = cur.getString(2);
   String iAge = cur.getString(3);
   acct.lastUpdate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   acct.curBalAmt = cur.getDouble(4);
   iAge = cur.getString(5);
   acct.curBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   acct.availBalAmt = cur.getDouble(6);
   iAge = cur.getString(7);
   acct.availBalDate = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   iAge = cur.getString(8);
   acct.lastTrans = (iAge != null) ? new Date(Long.parseLong(iAge)) : null;
   return acct;
 }
コード例 #28
0
 @Test
 public void findRepostByCategories_String_複数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByCategories("cat-biz", "cat-enta").contributor(acnt).fetch();
   assertThat(lst.size(), is(3));
   // DBからの取得リストの並び保証なし
 }
コード例 #29
0
 // -------------------------------------+
 @Test
 public void findRepostByCategories_Entity_単数_投稿者_00() {
   Category cat1 = Category.findBySerialCode("cat-biz").first();
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst = RepostBase.findRepostByCategories(cat1).contributor(acnt).fetch();
   assertThat(lst.size(), is(2));
   // DBからの取得リストの並び保証なし
 }
コード例 #30
0
 @Test
 public void findRepostByTweets_String_複数_投稿者_00() {
   Account acnt = Account.findByLoginName("goro_san").first();
   List<RepostBase> lst =
       RepostBase.findRepostByTweets("twt-goro2", "twt-jiro1").contributor(acnt).fetch();
   assertThat(lst.size(), is(5));
   // DBからの取得リストの並び保証なし
 }