922: Put DataSource name in AccountDeviceInstanceKey

- address review comments
This commit is contained in:
Raman 2017-12-15 13:52:23 -05:00
parent dc829e6a17
commit 94b156bbfd

View File

@ -56,10 +56,10 @@ class AccountsRootChildren extends ChildFactory<AccountDeviceInstanceKey> {
protected boolean createKeys(List<AccountDeviceInstanceKey> list) { protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = new ArrayList<>(); List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = new ArrayList<>();
try { try {
for (AccountDeviceInstance adi : commsManager.getAccountDeviceInstancesWithRelationships(commsFilter)) { for (AccountDeviceInstance accountDeviceInstance : commsManager.getAccountDeviceInstancesWithRelationships(commsFilter)) {
long communicationsCount = commsManager.getRelationshipSourcesCount(adi, commsFilter); long communicationsCount = commsManager.getRelationshipSourcesCount(accountDeviceInstance, commsFilter);
String dataSourceName = getDataSourceName(adi); String dataSourceName = getDataSourceName(accountDeviceInstance);
accountDeviceInstanceKeys.add(new AccountDeviceInstanceKey(adi, commsFilter, communicationsCount, dataSourceName)); accountDeviceInstanceKeys.add(new AccountDeviceInstanceKey(accountDeviceInstance, commsFilter, communicationsCount, dataSourceName));
}; };
} catch (TskCoreException tskCoreException) { } catch (TskCoreException tskCoreException) {
logger.log(Level.SEVERE, "Error getting filtered account device instances", tskCoreException); logger.log(Level.SEVERE, "Error getting filtered account device instances", tskCoreException);
@ -74,18 +74,18 @@ class AccountsRootChildren extends ChildFactory<AccountDeviceInstanceKey> {
return new AccountDeviceInstanceNode(key, commsManager); return new AccountDeviceInstanceNode(key, commsManager);
} }
private String getDataSourceName(AccountDeviceInstance adi) { private String getDataSourceName(AccountDeviceInstance accountDeviceInstance) {
try { try {
final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase(); final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
for (DataSource dataSource : sleuthkitCase.getDataSources()) { for (DataSource dataSource : sleuthkitCase.getDataSources()) {
if (dataSource.getDeviceId().equals(adi.getDeviceId())) { if (dataSource.getDeviceId().equals(accountDeviceInstance.getDeviceId())) {
return sleuthkitCase.getContentById(dataSource.getId()).getName(); return sleuthkitCase.getContentById(dataSource.getId()).getName();
} }
} }
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error getting datasource name, falling back on device ID.", ex); logger.log(Level.SEVERE, "Error getting datasource name, falling back on device ID.", ex);
} }
return adi.getDeviceId(); return accountDeviceInstance.getDeviceId();
} }
/** /**