mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 01:37:43 +00:00
6185: Consolidate duplicated code and remove unused code from Central Repository code
This commit is contained in:
parent
7b5fe7d294
commit
4e28a8686f
@ -806,15 +806,6 @@ public interface CentralRepository {
|
|||||||
public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException;
|
public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns list of all correlation types.
|
|
||||||
*
|
|
||||||
* @return list of Correlation types
|
|
||||||
* @throws CentralRepoException
|
|
||||||
*/
|
|
||||||
List<CorrelationAttributeInstance.Type> getCorrelationTypes() throws CentralRepoException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get account type by type name.
|
* Get account type by type name.
|
||||||
*
|
*
|
||||||
|
@ -3134,27 +3134,12 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CorrelationAttributeInstance.Type> getDefinedCorrelationTypes() throws CentralRepoException {
|
public List<CorrelationAttributeInstance.Type> getDefinedCorrelationTypes() throws CentralRepoException {
|
||||||
Connection conn = connect();
|
|
||||||
|
|
||||||
List<CorrelationAttributeInstance.Type> aTypes = new ArrayList<>();
|
synchronized (typeCache) {
|
||||||
PreparedStatement preparedStatement = null;
|
if (isCRTypeCacheInitialized == false) {
|
||||||
ResultSet resultSet = null;
|
getCorrelationTypesFromCr();
|
||||||
String sql = "SELECT * FROM correlation_types";
|
|
||||||
|
|
||||||
try {
|
|
||||||
preparedStatement = conn.prepareStatement(sql);
|
|
||||||
resultSet = preparedStatement.executeQuery();
|
|
||||||
while (resultSet.next()) {
|
|
||||||
aTypes.add(getCorrelationTypeFromResultSet(resultSet));
|
|
||||||
}
|
}
|
||||||
return aTypes;
|
return new ArrayList<>(typeCache.asMap().values());
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
throw new CentralRepoException("Error getting all correlation types.", ex); // NON-NLS
|
|
||||||
} finally {
|
|
||||||
CentralRepoDbUtil.closeStatement(preparedStatement);
|
|
||||||
CentralRepoDbUtil.closeResultSet(resultSet);
|
|
||||||
CentralRepoDbUtil.closeConnection(conn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3285,45 +3270,6 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all correlation types. It uses the cache to build the
|
|
||||||
* list. If the cache is empty, it reads from the database and loads up the
|
|
||||||
* cache.
|
|
||||||
*
|
|
||||||
* @return List of correlation types.
|
|
||||||
* @throws CentralRepoException
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<CorrelationAttributeInstance.Type> getCorrelationTypes() throws CentralRepoException {
|
|
||||||
|
|
||||||
synchronized (typeCache) {
|
|
||||||
if (isCRTypeCacheInitialized == false) {
|
|
||||||
getCorrelationTypesFromCr();
|
|
||||||
}
|
|
||||||
return new ArrayList<>(typeCache.asMap().values());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a Correlation type with the specified name.
|
|
||||||
*
|
|
||||||
* @param correlationtypeName Correlation type name
|
|
||||||
* @return Correlation type matching the given name, null if none matches.
|
|
||||||
*
|
|
||||||
* @throws CentralRepoException
|
|
||||||
*/
|
|
||||||
public CorrelationAttributeInstance.Type getCorrelationTypeByName(String correlationtypeName) throws CentralRepoException {
|
|
||||||
List<CorrelationAttributeInstance.Type> correlationTypesList = getCorrelationTypes();
|
|
||||||
|
|
||||||
CorrelationAttributeInstance.Type correlationType
|
|
||||||
= correlationTypesList.stream()
|
|
||||||
.filter(x -> correlationtypeName.equalsIgnoreCase(x.getDisplayName()))
|
|
||||||
.findAny()
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the EamArtifact.Type that has the given Type.Id from the central repo
|
* Get the EamArtifact.Type that has the given Type.Id from the central repo
|
||||||
|
@ -123,7 +123,7 @@ final public class CommonAttributeCaseSearchResults {
|
|||||||
if (currentCaseDataSourceMap == null) { //there are no results
|
if (currentCaseDataSourceMap == null) { //there are no results
|
||||||
return filteredCaseNameToDataSourcesTree;
|
return filteredCaseNameToDataSourcesTree;
|
||||||
}
|
}
|
||||||
CorrelationAttributeInstance.Type attributeType = CentralRepository.getInstance().getCorrelationTypes()
|
CorrelationAttributeInstance.Type attributeType = CentralRepository.getInstance().getDefinedCorrelationTypes()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(filterType -> filterType.getId() == resultTypeId)
|
.filter(filterType -> filterType.getId() == resultTypeId)
|
||||||
.findFirst().get();
|
.findFirst().get();
|
||||||
|
@ -129,7 +129,7 @@ final public class CommonAttributeCountSearchResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CentralRepository eamDb = CentralRepository.getInstance();
|
CentralRepository eamDb = CentralRepository.getInstance();
|
||||||
CorrelationAttributeInstance.Type attributeType = eamDb.getCorrelationTypes()
|
CorrelationAttributeInstance.Type attributeType = eamDb.getDefinedCorrelationTypes()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(filterType -> filterType.getId() == this.resultTypeId)
|
.filter(filterType -> filterType.getId() == this.resultTypeId)
|
||||||
.findFirst().get();
|
.findFirst().get();
|
||||||
|
@ -255,7 +255,7 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
|
|||||||
filterByDocuments = interCasePanel.documentsCheckboxIsSelected();
|
filterByDocuments = interCasePanel.documentsCheckboxIsSelected();
|
||||||
}
|
}
|
||||||
if (corType == null) {
|
if (corType == null) {
|
||||||
corType = CentralRepository.getInstance().getCorrelationTypes().get(0);
|
corType = CentralRepository.getInstance().getDefinedCorrelationTypes().get(0);
|
||||||
}
|
}
|
||||||
if (caseId == InterCasePanel.NO_CASE_SELECTED) {
|
if (caseId == InterCasePanel.NO_CASE_SELECTED) {
|
||||||
builder = new AllInterCaseCommonAttributeSearcher(filterByMedia, filterByDocuments, corType, percentageThreshold);
|
builder = new AllInterCaseCommonAttributeSearcher(filterByMedia, filterByDocuments, corType, percentageThreshold);
|
||||||
@ -366,7 +366,7 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer
|
|||||||
filterByDocuments = interCasePanel.documentsCheckboxIsSelected();
|
filterByDocuments = interCasePanel.documentsCheckboxIsSelected();
|
||||||
}
|
}
|
||||||
if (corType == null) {
|
if (corType == null) {
|
||||||
corType = CentralRepository.getInstance().getCorrelationTypes().get(0);
|
corType = CentralRepository.getInstance().getDefinedCorrelationTypes().get(0);
|
||||||
}
|
}
|
||||||
if (caseId == InterCasePanel.NO_CASE_SELECTED) {
|
if (caseId == InterCasePanel.NO_CASE_SELECTED) {
|
||||||
builder = new AllInterCaseCommonAttributeSearcher(filterByMedia, filterByDocuments, corType, percentageThreshold);
|
builder = new AllInterCaseCommonAttributeSearcher(filterByMedia, filterByDocuments, corType, percentageThreshold);
|
||||||
|
@ -118,7 +118,7 @@ public final class InterCasePanel extends javax.swing.JPanel {
|
|||||||
void setupCorrelationTypeFilter() {
|
void setupCorrelationTypeFilter() {
|
||||||
this.correlationTypeFilters = new HashMap<>();
|
this.correlationTypeFilters = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getCorrelationTypes();
|
List<CorrelationAttributeInstance.Type> types = CentralRepository.getInstance().getDefinedCorrelationTypes();
|
||||||
for (CorrelationAttributeInstance.Type type : types) {
|
for (CorrelationAttributeInstance.Type type : types) {
|
||||||
correlationTypeFilters.put(type.getDisplayName(), type);
|
correlationTypeFilters.put(type.getDisplayName(), type);
|
||||||
this.correlationTypeComboBox.addItem(type.getDisplayName());
|
this.correlationTypeComboBox.addItem(type.getDisplayName());
|
||||||
|
@ -111,7 +111,7 @@ final class CorrelationCaseChildNodeFactory extends ChildFactory<CorrelationCase
|
|||||||
private CorrelationAttributeInstance.Type getCorrelationType(Account.Type accountType) throws CentralRepoException {
|
private CorrelationAttributeInstance.Type getCorrelationType(Account.Type accountType) throws CentralRepoException {
|
||||||
if (correlationTypeMap == null) {
|
if (correlationTypeMap == null) {
|
||||||
correlationTypeMap = new HashMap<>();
|
correlationTypeMap = new HashMap<>();
|
||||||
List<CorrelationAttributeInstance.Type> correcationTypeList = CentralRepository.getInstance().getCorrelationTypes();
|
List<CorrelationAttributeInstance.Type> correcationTypeList = CentralRepository.getInstance().getDefinedCorrelationTypes();
|
||||||
correcationTypeList.forEach((type) -> {
|
correcationTypeList.forEach((type) -> {
|
||||||
correlationTypeMap.put(type.getId(), type);
|
correlationTypeMap.put(type.getId(), type);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user