public List<SearchVO> getData(FilterVO myFilter) { List<SearchVO> tableData = new ArrayList<SearchVO>(); String account = myFilter.getAccount(); String phone = myFilter.getPhone(); String device = myFilter.getDevice(); String appId = myFilter.getAppId(); if (appId == null || myFilter.getAppId().equalsIgnoreCase("")) { return tableData; } String policyIds = getCurrentPolicy(appId); if (account != null && !"".equals(account)) { if (policyIds.indexOf("10") > -1) { AccountEntity accountEntity = accountBL.getAccount4One(account, appId); if (accountEntity != null) { SearchVO accountData = convertAccountEntityToTableData(accountEntity); tableData.add(accountData); } } if (policyIds.indexOf("20") > -1) { AccountEntity accountEntity = accountBL.getAccount4Two(account, appId); if (accountEntity != null) { SearchVO accountData = convertAccountEntityToTableData(accountEntity); tableData.add(accountData); } } } if (phone != null && !"".equals(phone)) { if (policyIds.indexOf("10") > -1) { PhoneEntity phoneEntity = phoneBL.getPhone4One(phone, appId); if (phoneEntity != null) { SearchVO phoneData = convertPhoneEntityToTableData(phoneEntity); tableData.add(phoneData); } } if (policyIds.indexOf("20") > -1) { PhoneEntity phoneEntity = phoneBL.getPhone4Two(phone, appId); if (phoneEntity != null) { SearchVO phoneData = convertPhoneEntityToTableData(phoneEntity); tableData.add(phoneData); } } } if (device != null && !"".equals(device)) { if (policyIds.indexOf("10") > -1) { DeviceEntity deviceEntity = deviceBL.getDevice4One(device, appId); if (deviceEntity != null) { SearchVO deviceData = convertDeviceEntityToTableData(deviceEntity); tableData.add(deviceData); } } if (policyIds.indexOf("20") > -1) { DeviceEntity deviceEntity = deviceBL.getDevice4Two(device, appId); if (deviceEntity != null) { SearchVO deviceData = convertDeviceEntityToTableData(deviceEntity); tableData.add(deviceData); } } } if (policyIds.indexOf("30") > -1) { if (account != null && !"".equals(account)) { WBListEntity blacklistEntity = blackListBL.getBlackList(account); if (blacklistEntity != null) { tableData.add(convertBlackListEntityToTableData(blacklistEntity)); } } if (phone != null && !"".equals(phone)) { WBListEntity blacklistEntity = blackListBL.getBlackList(phone); if (blacklistEntity != null) { tableData.add(convertBlackListEntityToTableData(blacklistEntity)); } } if (device != null && !"".equals(device)) { WBListEntity blacklistEntity = blackListBL.getBlackList(device); if (blacklistEntity != null) { tableData.add(convertBlackListEntityToTableData(blacklistEntity)); } } } return tableData; }
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; }