Example #1
0
 private SearchVO convertAccountEntityToTableData(AccountEntity accountEntity) {
   SearchVO tableData = new SearchVO();
   tableData.setKey(accountEntity.getKey());
   tableData.setAccounts(accountEntity.getKey());
   tableData.setAppId(accountEntity.getAppid());
   if (accountEntity.getDevices() != null) {
     tableData.setDevices(accountEntity.getDevices());
   }
   if (accountEntity.getPhones() != null) {
     tableData.setPhones(accountEntity.getPhones());
   }
   tableData.setUid("--");
   return tableData;
 }
Example #2
0
  public boolean updateData(String data) {
    String[] waitChange = data.split(";");
    for (int i = 0; i < waitChange.length; i++) {
      String[] keyValue = waitChange[i].split("&&");
      Map<String, String> records = convertKeyValue(keyValue);
      String accounts = records.get("accounts");
      String phones = records.get("phones");
      String devices = records.get("devices");
      String appId = records.get("appId");
      String key = records.get("key");
      String uid = records.get("uid");
      Date date = new Date();
      if (appId == null || appId.equals("")) {
        return false;
      }

      String policyIds = getCurrentPolicy(appId);

      // change account data
      if (key != null && key.equalsIgnoreCase(accounts)) {

        if (policyIds.indexOf("10") > -1) {
          AccountEntity oldAccountEntity = accountBL.getAccount4One(key, appId);
          if (oldAccountEntity != null) {
            oldAccountEntity.setPhones(phones);
            oldAccountEntity.setDevices(devices);
            oldAccountEntity.setTimestamp(date);
            accountBL.updateAccount4One(oldAccountEntity);
          }
        }

        if (policyIds.indexOf("20") > -1) {
          AccountEntity oldAccountEntity = accountBL.getAccount4Two(key, appId);
          if (oldAccountEntity != null) {
            oldAccountEntity.setPhones(phones);
            oldAccountEntity.setDevices(devices);
            oldAccountEntity.setTimestamp(date);
            accountBL.updateAccount4Two(oldAccountEntity);
          }
        }
      }

      // change phone data
      if (key != null && key.equalsIgnoreCase(phones)) {
        if (policyIds.indexOf("10") > -1) {
          PhoneEntity oldPhoneEntity = phoneBL.getPhone4One(key, appId);
          if (oldPhoneEntity != null) {
            oldPhoneEntity.setAccounts(accounts);
            oldPhoneEntity.setDevices(devices);
            oldPhoneEntity.setTimestamp(date);
            phoneBL.updatePhone4Two(oldPhoneEntity);
          }
        }

        if (policyIds.indexOf("20") > -1) {
          PhoneEntity oldPhoneEntity = phoneBL.getPhone4Two(key, appId);
          if (oldPhoneEntity != null) {
            oldPhoneEntity.setAccounts(accounts);
            oldPhoneEntity.setDevices(devices);
            oldPhoneEntity.setTimestamp(date);
            phoneBL.updatePhone4Two(oldPhoneEntity);
          }
        }
      }

      // change device data
      if (key != null && key.equalsIgnoreCase(devices)) {
        if (policyIds.indexOf("10") > -1) {
          DeviceEntity oldDeviceEntity = deviceBL.getDevice4One(key, appId);
          if (oldDeviceEntity != null) {
            oldDeviceEntity.setAccounts(accounts);
            oldDeviceEntity.setPhones(phones);
            oldDeviceEntity.setTimestamp(date);
            deviceBL.updateDevice4One(oldDeviceEntity);
          }
        }

        if (policyIds.indexOf("20") > -1) {
          DeviceEntity oldDeviceEntity = deviceBL.getDevice4Two(key, appId);
          if (oldDeviceEntity != null) {
            oldDeviceEntity.setAccounts(accounts);
            oldDeviceEntity.setPhones(phones);
            oldDeviceEntity.setTimestamp(date);
            deviceBL.updateDevice4Two(oldDeviceEntity);
          }
        }
      }
    }

    return true;
  }