table showing right

This commit is contained in:
Greg DiCristofaro 2023-07-05 19:52:13 -04:00
parent a4a3e0f42e
commit c8b7bb2a31
3 changed files with 110 additions and 35 deletions

View File

@ -71,8 +71,6 @@ import org.sleuthkit.datamodel.BlackboardArtifact.Category;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.DataArtifact;
import org.sleuthkit.datamodel.Score;
import org.sleuthkit.datamodel.Score.Priority;
import org.sleuthkit.datamodel.Score.Significance;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
@ -215,13 +213,13 @@ public class ScoreDAO extends AbstractDAO {
String filterSql = Stream.of(filterSqlPair.getRight(), dsClause)
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining("\nAND "));
if (StringUtils.isNotBlank(filterSql)) {
filterSql = "\n WHERE " + filterSql;
}
return "(SELECT COUNT(aggr_score.obj_id) "
+ BASE_AGGR_SCORE_QUERY
return "(SELECT COUNT(aggr_score.obj_id) "
+ BASE_AGGR_SCORE_QUERY
+ filterSql
+ ") AS "
+ filterSqlPair.getLeft();
@ -365,23 +363,28 @@ public class ScoreDAO extends AbstractDAO {
List<AbstractFile> files = getCase().findAllFilesWhere("obj_id IN (" + joinedFileIds + ")");
for (AbstractFile file : files) {
dataRows.add(new FileRowDTO(
file,
file.getId(),
List<Object> cellValues = Arrays.asList(
file.getName(),
file.getNameExtension(),
MediaTypeUtils.getExtensionMediaType(file.getNameExtension()),
file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.ALLOC),
file.getType(),
// the modified column types: source name, type, path, created time
Arrays.asList(
Bundle.ScoreDAO_types_filelbl(),
file.getUniquePath(),
file.getCtime() <= 0
? null
: TimeZoneUtils.getFormattedTime(file.getCtime())
);
dataRows.add(new ScoreResultRowDTO(
new FileRowDTO(
file,
file.getId(),
file.getName(),
Bundle.ScoreDAO_types_filelbl(),
file.getUniquePath(),
file.getCtime() <= 0
? null
: TimeZoneUtils.getFormattedTime(file.getCtime())
)));
file.getNameExtension(),
MediaTypeUtils.getExtensionMediaType(file.getNameExtension()),
file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.ALLOC),
file.getType(),
cellValues),
// the modified column types: source name, type, path, created time
cellValues,
file.getId()));
}
}
@ -396,23 +399,30 @@ public class ScoreDAO extends AbstractDAO {
// all rows should be data artifact rows, and can be appended accordingly
for (RowDTO rowDTO : artTableData.rows) {
if (rowDTO instanceof DataArtifactRowDTO dataArtRow) {
dataRows.add(new DataArtifactRowDTO(
dataArtRow.getArtifact(),
dataArtRow.getSrcContent(),
dataArtRow.getLinkedFile(),
dataArtRow.isTimelineSupported(),
Arrays.asList(
dataArtRow.getSrcContent().getName(),
dataArtRow.getArtifact().getType().getDisplayName(),
dataArtRow.getArtifact().getUniquePath(),
getTimeStamp(dataArtRow.getArtifact())
),
BlackboardArtifact.Type artifactType = dataArtRow.getArtifact().getType();
List<Object> cellValues = Arrays.asList(
dataArtRow.getSrcContent().getName(),
artifactType.getDisplayName(),
dataArtRow.getArtifact().getUniquePath(),
getTimeStamp(dataArtRow.getArtifact())
);
dataRows.add(new ScoreResultRowDTO(
new DataArtifactRowDTO(
dataArtRow.getArtifact(),
dataArtRow.getSrcContent(),
dataArtRow.getLinkedFile(),
dataArtRow.isTimelineSupported(),
cellValues,
dataArtRow.getId()),
artifactType,
cellValues,
dataArtRow.getId()));
}
}
}
//
return new BaseSearchResultsDTO(
SCORE_TYPE_ID,
Bundle.ScoreDAO_mainNode_displayName(),

View File

@ -0,0 +1,65 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2023 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.mainui.datamodel;
import java.util.List;
import org.sleuthkit.datamodel.BlackboardArtifact;
/**
* Score results dto.
*/
public class ScoreResultRowDTO extends BaseRowDTO {
private static final String TYPE_ID = "SCORE_RESULT_ROW";
public static String getTypeIdForClass() {
return TYPE_ID;
}
private final FileRowDTO fileDTO;
private final DataArtifactRowDTO artifactDTO;
private final BlackboardArtifact.Type artifactType;
public ScoreResultRowDTO(FileRowDTO fileDTO, List<Object> cellValues, long id) {
super(cellValues, TYPE_ID, id);
this.fileDTO = fileDTO;
this.artifactDTO = null;
this.artifactType = null;
}
public ScoreResultRowDTO(DataArtifactRowDTO artifactDTO, BlackboardArtifact.Type artifactType, List<Object> cellValues, long id) {
super(cellValues, TYPE_ID, id);
this.fileDTO = null;
this.artifactDTO = artifactDTO;
this.artifactType = artifactType;
}
public FileRowDTO getFileDTO() {
return fileDTO;
}
public DataArtifactRowDTO getArtifactDTO() {
return artifactDTO;
}
public BlackboardArtifact.Type getArtifactType() {
return artifactType;
}
}

View File

@ -92,8 +92,8 @@ public class SearchResultChildFactory extends ChildFactory<ChildKey> {
String typeId = key.getRow().getTypeId();
try {
if (ScoreResultRowDTO.getTypeIdForClass().equals(typeId) && key.getRow() instanceof ScoreResultRowDTO scoreRow) {
if (scoreRow.getArtifactDTO() != null) {
String iconPath = IconsUtil.getIconFilePath(scoreRow.getArtifactTypeId());
if (scoreRow.getArtifactDTO() != null && scoreRow.getArtifactType() != null) {
String iconPath = IconsUtil.getIconFilePath(scoreRow.getArtifactType().getTypeID());
return new DataArtifactNode(key.getSearchResults(), scoreRow.getArtifactDTO(), iconPath, nodeThreadPool);
} else if (scoreRow.getFileDTO() != null) {
return new FileNode(key.getSearchResults(), scoreRow.getFileDTO(), true, nodeThreadPool);