19 package org.sleuthkit.autopsy.discovery.search;
21 import java.time.DayOfWeek;
22 import java.time.Instant;
23 import java.time.ZonedDateTime;
24 import java.time.temporal.TemporalAdjusters;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.Objects;
28 import java.util.TimeZone;
29 import java.util.logging.Level;
30 import org.openide.util.NbBundle;
51 static class SearchKey
implements Comparable<SearchKey> {
53 private final String keyString;
57 private final List<AbstractFilter> filters;
58 private final SleuthkitCase sleuthkitCase;
72 SearchKey(String userName, List<AbstractFilter> filters,
77 this.groupAttributeType = groupAttributeType;
78 this.groupSortingType = groupSortingType;
79 this.sortingMethod = sortingMethod;
80 this.filters = filters;
82 StringBuilder searchStringBuilder =
new StringBuilder();
83 searchStringBuilder.append(userName);
85 searchStringBuilder.append(filter.toString());
87 searchStringBuilder.append(groupAttributeType).append(groupSortingType).append(sortingMethod);
88 keyString = searchStringBuilder.toString();
89 this.sleuthkitCase = sleuthkitCase;
90 this.centralRepository = centralRepository;
103 SearchKey(String userName, List<AbstractFilter> filters,
107 this(userName, filters, groupAttributeType, groupSortingType,
108 sortingMethod, null, null);
112 public int compareTo(SearchKey otherSearchKey) {
113 return getKeyString().compareTo(otherSearchKey.getKeyString());
117 public boolean equals(Object otherKey) {
118 if (otherKey ==
this) {
122 if (!(otherKey instanceof SearchKey)) {
126 SearchKey otherSearchKey = (SearchKey) otherKey;
127 if (this.sleuthkitCase != otherSearchKey.getSleuthkitCase()
128 || this.centralRepository != otherSearchKey.getCentralRepository()) {
132 return getKeyString().equals(otherSearchKey.getKeyString());
136 public int hashCode() {
138 hash = 79 * hash + Objects.hashCode(getKeyString());
147 String getKeyString() {
156 List<AbstractFilter> getFilters() {
157 return Collections.unmodifiableList(this.filters);
166 return groupSortingType;
175 return groupAttributeType;
184 return sortingMethod;
192 SleuthkitCase getSleuthkitCase() {
193 return this.sleuthkitCase;
202 return this.centralRepository;
209 public abstract static class GroupKey implements Comparable<GroupKey> {
217 abstract String getDisplayName();
227 abstract public boolean equals(Object otherKey);
246 int compareClassNames(
GroupKey otherGroupKey) {
247 return this.getClass().getName().compareTo(otherGroupKey.getClass().getName());
252 return getDisplayName();
259 static class FileSizeGroupKey
extends GroupKey {
268 FileSizeGroupKey(
Result file) {
278 String getDisplayName() {
279 return getFileSize().toString();
283 public int compareTo(GroupKey otherGroupKey) {
284 if (otherGroupKey instanceof FileSizeGroupKey) {
285 FileSizeGroupKey otherFileSizeGroupKey = (FileSizeGroupKey) otherGroupKey;
286 return Integer.compare(getFileSize().getRanking(), otherFileSizeGroupKey.getFileSize().getRanking());
288 return compareClassNames(otherGroupKey);
293 public boolean equals(Object otherKey) {
294 if (otherKey ==
this) {
298 if (!(otherKey instanceof FileSizeGroupKey)) {
302 FileSizeGroupKey otherFileSizeGroupKey = (FileSizeGroupKey) otherKey;
303 return getFileSize().equals(otherFileSizeGroupKey.getFileSize());
307 public int hashCode() {
308 return Objects.hash(getFileSize().getRanking());
316 SearchData.FileSize getFileSize() {
324 static class FileTypeGroupKey
extends GroupKey {
326 private final SearchData.Type fileType;
333 FileTypeGroupKey(Result file) {
334 fileType = ((ResultFile) file).getFileType();
338 String getDisplayName() {
339 return getFileType().toString();
343 public int compareTo(GroupKey otherGroupKey) {
344 if (otherGroupKey instanceof FileTypeGroupKey) {
345 FileTypeGroupKey otherFileTypeGroupKey = (FileTypeGroupKey) otherGroupKey;
346 return Integer.compare(getFileType().getRanking(), otherFileTypeGroupKey.getFileType().getRanking());
348 return compareClassNames(otherGroupKey);
353 public boolean equals(Object otherKey) {
354 if (otherKey ==
this) {
358 if (!(otherKey instanceof FileTypeGroupKey)) {
362 FileTypeGroupKey otherFileTypeGroupKey = (FileTypeGroupKey) otherKey;
363 return getFileType().equals(otherFileTypeGroupKey.getFileType());
367 public int hashCode() {
368 return Objects.hash(getFileType().getRanking());
376 SearchData.Type getFileType() {
384 static class KeywordListGroupKey
extends GroupKey {
386 private final List<String> keywordListNames;
387 private final String keywordListNamesString;
395 "DiscoveryKeyUtils.KeywordListGroupKey.noKeywords=None"})
396 KeywordListGroupKey(ResultFile file) {
397 keywordListNames = file.getKeywordListNames();
398 if (keywordListNames.isEmpty()) {
399 keywordListNamesString = Bundle.DiscoveryKeyUtils_KeywordListGroupKey_noKeywords();
401 keywordListNamesString = String.join(
",", keywordListNames);
406 String getDisplayName() {
407 return getKeywordListNamesString();
411 public int compareTo(GroupKey otherGroupKey) {
412 if (otherGroupKey instanceof KeywordListGroupKey) {
413 KeywordListGroupKey otherKeywordListNamesGroupKey = (KeywordListGroupKey) otherGroupKey;
416 if (getKeywordListNames().isEmpty()) {
417 if (otherKeywordListNamesGroupKey.getKeywordListNames().isEmpty()) {
422 }
else if (otherKeywordListNamesGroupKey.getKeywordListNames().isEmpty()) {
426 return getKeywordListNamesString().compareTo(otherKeywordListNamesGroupKey.getKeywordListNamesString());
428 return compareClassNames(otherGroupKey);
433 public boolean equals(Object otherKey) {
434 if (otherKey ==
this) {
438 if (!(otherKey instanceof KeywordListGroupKey)) {
442 KeywordListGroupKey otherKeywordListGroupKey = (KeywordListGroupKey) otherKey;
443 return getKeywordListNamesString().equals(otherKeywordListGroupKey.getKeywordListNamesString());
447 public int hashCode() {
448 return Objects.hash(getKeywordListNamesString());
456 List<String> getKeywordListNames() {
457 return Collections.unmodifiableList(keywordListNames);
467 String getKeywordListNamesString() {
468 return keywordListNamesString;
475 static class FileTagGroupKey
extends GroupKey {
477 private final List<String> tagNames;
478 private final String tagNamesString;
486 "DiscoveryKeyUtils.FileTagGroupKey.noSets=None"})
487 FileTagGroupKey(ResultFile file) {
488 tagNames = file.getTagNames();
490 if (tagNames.isEmpty()) {
491 tagNamesString = Bundle.DiscoveryKeyUtils_FileTagGroupKey_noSets();
493 tagNamesString = String.join(
",", tagNames);
498 String getDisplayName() {
499 return getTagNamesString();
503 public int compareTo(GroupKey otherGroupKey) {
504 if (otherGroupKey instanceof FileTagGroupKey) {
505 FileTagGroupKey otherFileTagGroupKey = (FileTagGroupKey) otherGroupKey;
508 if (getTagNames().isEmpty()) {
509 if (otherFileTagGroupKey.getTagNames().isEmpty()) {
514 }
else if (otherFileTagGroupKey.getTagNames().isEmpty()) {
518 return getTagNamesString().compareTo(otherFileTagGroupKey.getTagNamesString());
520 return compareClassNames(otherGroupKey);
525 public boolean equals(Object otherKey) {
526 if (otherKey ==
this) {
529 if (!(otherKey instanceof FileTagGroupKey)) {
532 FileTagGroupKey otherFileTagGroupKey = (FileTagGroupKey) otherKey;
533 return getTagNamesString().equals(otherFileTagGroupKey.getTagNamesString());
537 public int hashCode() {
538 return Objects.hash(getTagNamesString());
546 List<String> getTagNames() {
547 return Collections.unmodifiableList(tagNames);
557 String getTagNamesString() {
558 return tagNamesString;
565 static class ParentPathGroupKey
extends GroupKey {
567 private String parentPath;
568 private Long parentID;
575 ParentPathGroupKey(ResultFile file) {
578 parent = file.getFirstInstance().getParent();
579 }
catch (TskCoreException ignored) {
583 while (parent != null && parent instanceof AbstractFile && ((AbstractFile) parent).isFile()) {
585 parent = parent.getParent();
586 }
catch (TskCoreException ignored) {
590 setParentPathAndID(parent, file);
599 private void setParentPathAndID(Content parent, ResultFile file) {
600 if (parent != null) {
602 parentPath = parent.getUniquePath();
603 parentID = parent.getId();
604 }
catch (TskCoreException ignored) {
609 if (parentPath == null) {
610 if (file.getFirstInstance().getParentPath() != null) {
611 parentPath = file.getFirstInstance().getParentPath();
620 String getDisplayName() {
621 return getParentPath();
625 public int compareTo(GroupKey otherGroupKey) {
626 if (otherGroupKey instanceof ParentPathGroupKey) {
627 ParentPathGroupKey otherParentPathGroupKey = (ParentPathGroupKey) otherGroupKey;
628 int comparisonResult = getParentPath().compareTo(otherParentPathGroupKey.getParentPath());
629 if (comparisonResult == 0) {
630 comparisonResult = getParentID().compareTo(otherParentPathGroupKey.getParentID());
632 return comparisonResult;
634 return compareClassNames(otherGroupKey);
639 public boolean equals(Object otherKey) {
640 if (otherKey ==
this) {
644 if (!(otherKey instanceof ParentPathGroupKey)) {
648 ParentPathGroupKey otherParentPathGroupKey = (ParentPathGroupKey) otherKey;
649 return getParentPath().equals(otherParentPathGroupKey.getParentPath()) && getParentID().equals(otherParentPathGroupKey.getParentID());
653 public int hashCode() {
655 hashCode = 61 * hashCode + Objects.hash(getParentPath());
656 hashCode = 61 * hashCode + Objects.hash(getParentID());
665 String getParentPath() {
682 static class DataSourceGroupKey
extends GroupKey {
684 private final long dataSourceID;
685 private String displayName;
693 "# {0} - Data source name",
694 "# {1} - Data source ID",
695 "DiscoveryKeyUtils.DataSourceGroupKey.datasourceAndID={0}(ID: {1})",
696 "# {0} - Data source ID",
697 "DiscoveryKeyUtils.DataSourceGroupKey.idOnly=Data source (ID: {0})"})
698 DataSourceGroupKey(Result result) {
700 dataSourceID = result.getDataSourceObjectId();
703 Content ds = result.getDataSource();
704 displayName = Bundle.DiscoveryKeyUtils_DataSourceGroupKey_datasourceAndID(ds.getName(), ds.getId());
705 }
catch (TskCoreException ex) {
706 logger.log(Level.WARNING,
"Error looking up data source with ID " + dataSourceID, ex);
707 displayName = Bundle.DiscoveryKeyUtils_DataSourceGroupKey_idOnly(dataSourceID);
712 String getDisplayName() {
717 public int compareTo(GroupKey otherGroupKey) {
718 if (otherGroupKey instanceof DataSourceGroupKey) {
719 DataSourceGroupKey otherDataSourceGroupKey = (DataSourceGroupKey) otherGroupKey;
720 return Long.compare(getDataSourceID(), otherDataSourceGroupKey.getDataSourceID());
722 return compareClassNames(otherGroupKey);
727 public boolean equals(Object otherKey) {
728 if (otherKey ==
this) {
732 if (!(otherKey instanceof DataSourceGroupKey)) {
736 DataSourceGroupKey otherDataSourceGroupKey = (DataSourceGroupKey) otherKey;
737 return getDataSourceID() == otherDataSourceGroupKey.getDataSourceID();
741 public int hashCode() {
742 return Objects.hash(getDataSourceID());
750 long getDataSourceID() {
759 static class NoGroupingGroupKey
extends GroupKey {
764 NoGroupingGroupKey() {
769 "DiscoveryKeyUtils.NoGroupingGroupKey.allFiles=All Files"})
771 String getDisplayName() {
772 return Bundle.DiscoveryKeyUtils_NoGroupingGroupKey_allFiles();
776 public int compareTo(GroupKey otherGroupKey) {
778 if (otherGroupKey instanceof NoGroupingGroupKey) {
781 return compareClassNames(otherGroupKey);
786 public boolean equals(Object otherKey) {
787 if (otherKey ==
this) {
791 return otherKey instanceof NoGroupingGroupKey;
795 public int hashCode() {
803 static class DomainCategoryGroupKey
extends GroupKey {
805 private final String webCategory;
807 DomainCategoryGroupKey(Result result) {
808 if (result instanceof ResultDomain) {
809 ResultDomain domain = (ResultDomain) result;
810 this.webCategory = domain.getWebCategory();
812 throw new IllegalArgumentException(
"Input result should be of type ResultDomain");
817 String getDisplayName() {
818 return this.webCategory;
822 public boolean equals(Object otherKey) {
823 if (otherKey instanceof GroupKey) {
824 return compareTo((GroupKey) otherKey) == 0;
830 public int hashCode() {
831 return Objects.hash(getWebCategory());
835 public int compareTo(GroupKey otherGroupKey) {
836 if (otherGroupKey instanceof DomainCategoryGroupKey) {
837 DomainCategoryGroupKey webCategoryKey = (DomainCategoryGroupKey) otherGroupKey;
838 return this.webCategory.compareTo(webCategoryKey.getWebCategory());
840 return compareClassNames(otherGroupKey);
844 String getWebCategory() {
845 return this.webCategory;
852 static class PreviouslyNotableGroupKey
extends GroupKey {
854 private final SearchData.PreviouslyNotable notableStatus;
856 PreviouslyNotableGroupKey(Result result) {
857 this.notableStatus = result.getPreviouslyNotableInCR();
861 String getDisplayName() {
862 return this.notableStatus.toString();
866 public boolean equals(Object otherKey) {
867 if (otherKey instanceof GroupKey) {
868 return compareTo((GroupKey) otherKey) == 0;
874 public int hashCode() {
875 return Objects.hash(getStatus().getRanking());
879 public int compareTo(GroupKey otherGroupKey) {
880 if (otherGroupKey instanceof PreviouslyNotableGroupKey) {
881 PreviouslyNotableGroupKey otherFrequencyGroupKey = (PreviouslyNotableGroupKey) otherGroupKey;
882 return Integer.compare(getStatus().getRanking(), otherFrequencyGroupKey.getStatus().getRanking());
884 return compareClassNames(otherGroupKey);
888 SearchData.PreviouslyNotable getStatus() {
889 return notableStatus;
896 static class FrequencyGroupKey
extends GroupKey {
898 private final SearchData.Frequency frequency;
905 FrequencyGroupKey(Result result) {
906 frequency = result.getFrequency();
910 String getDisplayName() {
911 return getFrequency().toString();
915 public int compareTo(GroupKey otherGroupKey) {
916 if (otherGroupKey instanceof FrequencyGroupKey) {
917 FrequencyGroupKey otherFrequencyGroupKey = (FrequencyGroupKey) otherGroupKey;
918 return Integer.compare(getFrequency().getRanking(), otherFrequencyGroupKey.getFrequency().getRanking());
920 return compareClassNames(otherGroupKey);
925 public boolean equals(Object otherKey) {
926 if (otherKey ==
this) {
930 if (!(otherKey instanceof FrequencyGroupKey)) {
934 FrequencyGroupKey otherFrequencyGroupKey = (FrequencyGroupKey) otherKey;
935 return getFrequency().equals(otherFrequencyGroupKey.getFrequency());
939 public int hashCode() {
940 return Objects.hash(getFrequency().getRanking());
948 SearchData.Frequency getFrequency() {
956 static class HashHitsGroupKey
extends GroupKey {
958 private final List<String> hashSetNames;
959 private final String hashSetNamesString;
967 "DiscoveryKeyUtils.HashHitsGroupKey.noHashHits=None"})
968 HashHitsGroupKey(ResultFile file) {
969 hashSetNames = file.getHashSetNames();
971 if (hashSetNames.isEmpty()) {
972 hashSetNamesString = Bundle.DiscoveryKeyUtils_HashHitsGroupKey_noHashHits();
974 hashSetNamesString = String.join(
",", hashSetNames);
979 String getDisplayName() {
980 return getHashSetNamesString();
984 public int compareTo(GroupKey otherGroupKey) {
985 if (otherGroupKey instanceof HashHitsGroupKey) {
986 HashHitsGroupKey otherHashHitsGroupKey = (HashHitsGroupKey) otherGroupKey;
989 if (getHashSetNames().isEmpty()) {
990 if (otherHashHitsGroupKey.getHashSetNames().isEmpty()) {
995 }
else if (otherHashHitsGroupKey.getHashSetNames().isEmpty()) {
999 return getHashSetNamesString().compareTo(otherHashHitsGroupKey.getHashSetNamesString());
1001 return compareClassNames(otherGroupKey);
1006 public boolean equals(Object otherKey) {
1007 if (otherKey ==
this) {
1011 if (!(otherKey instanceof HashHitsGroupKey)) {
1015 HashHitsGroupKey otherHashHitsGroupKey = (HashHitsGroupKey) otherKey;
1016 return getHashSetNamesString().equals(otherHashHitsGroupKey.getHashSetNamesString());
1020 public int hashCode() {
1021 return Objects.hash(getHashSetNamesString());
1029 List<String> getHashSetNames() {
1030 return Collections.unmodifiableList(hashSetNames);
1038 String getHashSetNamesString() {
1039 return hashSetNamesString;
1046 static class InterestingItemGroupKey
extends GroupKey {
1048 private final List<String> interestingItemSetNames;
1049 private final String interestingItemSetNamesString;
1056 @NbBundle.Messages({
1057 "DiscoveryKeyUtils.InterestingItemGroupKey.noSets=None"})
1058 InterestingItemGroupKey(ResultFile file) {
1059 interestingItemSetNames = file.getInterestingSetNames();
1061 if (interestingItemSetNames.isEmpty()) {
1062 interestingItemSetNamesString = Bundle.DiscoveryKeyUtils_InterestingItemGroupKey_noSets();
1064 interestingItemSetNamesString = String.join(
",", interestingItemSetNames);
1069 String getDisplayName() {
1070 return getInterestingItemSetNamesString();
1074 public int compareTo(GroupKey otherGroupKey) {
1075 if (otherGroupKey instanceof InterestingItemGroupKey) {
1076 InterestingItemGroupKey otherInterestingItemGroupKey = (InterestingItemGroupKey) otherGroupKey;
1079 if (this.getInterestingItemSetNames().isEmpty()) {
1080 if (otherInterestingItemGroupKey.getInterestingItemSetNames().isEmpty()) {
1085 }
else if (otherInterestingItemGroupKey.getInterestingItemSetNames().isEmpty()) {
1089 return getInterestingItemSetNamesString().compareTo(otherInterestingItemGroupKey.getInterestingItemSetNamesString());
1091 return compareClassNames(otherGroupKey);
1096 public boolean equals(Object otherKey) {
1097 if (otherKey ==
this) {
1101 if (!(otherKey instanceof InterestingItemGroupKey)) {
1105 InterestingItemGroupKey otherInterestingItemGroupKey = (InterestingItemGroupKey) otherKey;
1106 return getInterestingItemSetNamesString().equals(otherInterestingItemGroupKey.getInterestingItemSetNamesString());
1110 public int hashCode() {
1111 return Objects.hash(getInterestingItemSetNamesString());
1119 List<String> getInterestingItemSetNames() {
1120 return Collections.unmodifiableList(interestingItemSetNames);
1130 String getInterestingItemSetNamesString() {
1131 return interestingItemSetNamesString;
1138 static class LastActivityDateGroupKey
extends GroupKey {
1140 private ZonedDateTime currentWeekCutOff;
1147 LastActivityDateGroupKey(Result result) {
1148 if (result instanceof ResultDomain) {
1149 ResultDomain domainResult = ((ResultDomain) result);
1152 throw new IllegalArgumentException(
"Expected a domain result only.");
1156 @NbBundle.Messages({
1157 "# {0} - month abbreviation",
1158 "# {1} - day of month",
1160 "DiscoveryAttributes.ActivityDateGroupKey.getDisplayNameTemplate=Week of {0} {1}, {2}"
1163 String getDisplayName() {
1164 MonthAbbreviation currentCutOffMonth = MonthAbbreviation.fromMonthValue(currentWeekCutOff.getMonthValue());
1165 return Bundle.DiscoveryAttributes_ActivityDateGroupKey_getDisplayNameTemplate(
1166 currentCutOffMonth.toString(), Integer.toString(currentWeekCutOff.getDayOfMonth()),
1167 Integer.toString(currentWeekCutOff.getYear()));
1171 public boolean equals(Object otherKey) {
1172 if (otherKey ==
this) {
1176 if (!(otherKey instanceof LastActivityDateGroupKey)) {
1180 LastActivityDateGroupKey dateGroupKey = (LastActivityDateGroupKey) otherKey;
1181 return getDisplayName().equals(dateGroupKey.getDisplayName());
1185 public int hashCode() {
1186 return Objects.hash(getDisplayName());
1190 public int compareTo(GroupKey otherGroupKey) {
1191 if (otherGroupKey instanceof LastActivityDateGroupKey) {
1192 LastActivityDateGroupKey otherDateGroupKey = (LastActivityDateGroupKey) otherGroupKey;
1193 return Long.compare(otherDateGroupKey.currentWeekCutOff.toEpochSecond(), currentWeekCutOff.toEpochSecond());
1195 return compareClassNames(otherGroupKey);
1206 Instant startActivityAsInsant = Instant.ofEpochSecond(epochSeconds);
1211 ZonedDateTime startActivityAsDateTime = ZonedDateTime.ofInstant(startActivityAsInsant, currentTimeZone.toZoneId());
1214 return startActivityAsDateTime.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
1220 static class FirstActivityDateGroupKey
extends GroupKey {
1222 private ZonedDateTime currentWeekCutOff;
1229 FirstActivityDateGroupKey(
Result result) {
1230 if (result instanceof ResultDomain) {
1231 ResultDomain domainResult = ((ResultDomain) result);
1234 throw new IllegalArgumentException(
"Expected a domain result only.");
1239 String getDisplayName() {
1240 MonthAbbreviation currentCutOffMonth = MonthAbbreviation.fromMonthValue(currentWeekCutOff.getMonthValue());
1241 return Bundle.DiscoveryAttributes_ActivityDateGroupKey_getDisplayNameTemplate(
1242 currentCutOffMonth.toString(), Integer.toString(currentWeekCutOff.getDayOfMonth()),
1243 Integer.toString(currentWeekCutOff.getYear()));
1247 public boolean equals(Object otherKey) {
1248 if (otherKey ==
this) {
1252 if (!(otherKey instanceof FirstActivityDateGroupKey)) {
1256 FirstActivityDateGroupKey dateGroupKey = (FirstActivityDateGroupKey) otherKey;
1257 return getDisplayName().equals(dateGroupKey.getDisplayName());
1261 public int hashCode() {
1262 return Objects.hash(getDisplayName());
1266 public int compareTo(GroupKey otherGroupKey) {
1267 if (otherGroupKey instanceof FirstActivityDateGroupKey) {
1268 FirstActivityDateGroupKey otherDateGroupKey = (FirstActivityDateGroupKey) otherGroupKey;
1269 return Long.compare(otherDateGroupKey.currentWeekCutOff.toEpochSecond(), currentWeekCutOff.toEpochSecond());
1271 return compareClassNames(otherGroupKey);
1281 static class PageViewsGroupKey
extends GroupKey {
1283 private final String displayName;
1284 private final PageViews pageViews;
1291 PageViewsGroupKey(Result result) {
1292 if (result instanceof ResultDomain) {
1293 Long totalPageViews = ((ResultDomain) result).getTotalPageViews();
1294 if (totalPageViews == null) {
1295 totalPageViews = 0L;
1297 pageViews = PageViews.fromPageViewCount(totalPageViews);
1298 displayName = pageViews.toString();
1300 throw new IllegalArgumentException(
"Expected a domain instance only.");
1305 String getDisplayName() {
1310 public int hashCode() {
1311 return Objects.hash(displayName);
1319 PageViews getPageViews() {
1324 public boolean equals(Object otherKey) {
1325 if (otherKey ==
this) {
1329 if (!(otherKey instanceof PageViewsGroupKey)) {
1333 PageViewsGroupKey pageViewsKey = (PageViewsGroupKey) otherKey;
1334 return pageViews.equals(pageViewsKey.getPageViews());
1338 public int compareTo(GroupKey otherGroupKey) {
1339 if (otherGroupKey instanceof PageViewsGroupKey) {
1340 PageViewsGroupKey pageViewsKey = (PageViewsGroupKey) otherGroupKey;
1341 return getPageViews().compareTo(pageViewsKey.getPageViews());
1343 return compareClassNames(otherGroupKey);
1351 static class ObjectDetectedGroupKey
extends GroupKey {
1353 private final List<String> objectDetectedNames;
1354 private final String objectDetectedNamesString;
1361 @NbBundle.Messages({
1362 "DiscoveryKeyUtils.ObjectDetectedGroupKey.noSets=None"})
1363 ObjectDetectedGroupKey(ResultFile file) {
1364 objectDetectedNames = file.getObjectDetectedNames();
1365 if (objectDetectedNames.isEmpty()) {
1366 objectDetectedNamesString = Bundle.DiscoveryKeyUtils_ObjectDetectedGroupKey_noSets();
1368 objectDetectedNamesString = String.join(
",", objectDetectedNames);
1373 String getDisplayName() {
1374 return getObjectDetectedNamesString();
1378 public int compareTo(GroupKey otherGroupKey) {
1379 if (otherGroupKey instanceof ObjectDetectedGroupKey) {
1380 ObjectDetectedGroupKey otherObjectDetectedGroupKey = (ObjectDetectedGroupKey) otherGroupKey;
1383 if (this.getObjectDetectedNames().isEmpty()) {
1384 if (otherObjectDetectedGroupKey.getObjectDetectedNames().isEmpty()) {
1389 }
else if (otherObjectDetectedGroupKey.getObjectDetectedNames().isEmpty()) {
1393 return getObjectDetectedNamesString().compareTo(otherObjectDetectedGroupKey.getObjectDetectedNamesString());
1395 return compareClassNames(otherGroupKey);
1400 public boolean equals(Object otherKey) {
1401 if (otherKey ==
this) {
1405 if (!(otherKey instanceof ObjectDetectedGroupKey)) {
1409 ObjectDetectedGroupKey otherObjectDetectedGroupKey = (ObjectDetectedGroupKey) otherKey;
1410 return getObjectDetectedNamesString().equals(otherObjectDetectedGroupKey.getObjectDetectedNamesString());
1414 public int hashCode() {
1415 return Objects.hash(getObjectDetectedNamesString());
1423 List<String> getObjectDetectedNames() {
1424 return Collections.unmodifiableList(objectDetectedNames);
1434 String getObjectDetectedNamesString() {
1435 return objectDetectedNamesString;
static final Logger logger
static FileSize fromVideoSize(long size)
static TimeZone getTimeZone(Content content)
abstract boolean equals(Object otherKey)
AbstractFile getFirstInstance()
FileSize(int ranking, long minB, long maxB, String displayName, String displaySize)
synchronized static Logger getLogger(String name)
static ZonedDateTime getCurrentWeekCutOff(long epochSeconds, ResultDomain domainResult)