19 package org.sleuthkit.autopsy.centralrepository.datamodel;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Objects;
25 import java.util.regex.Pattern;
26 import org.openide.util.NbBundle.Messages;
54 @Messages({
"CorrelationType.FILES.displayName=Files",
55 "CorrelationType.DOMAIN.displayName=Domains",
56 "CorrelationType.EMAIL.displayName=Email Addresses",
57 "CorrelationType.PHONE.displayName=Phone Numbers",
58 "CorrelationType.USBID.displayName=USB Devices"})
61 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttribute.
Type(FILES_TYPE_ID, Bundle.CorrelationType_FILES_displayName(),
"file",
true,
true));
62 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttribute.
Type(DOMAIN_TYPE_ID, Bundle.CorrelationType_DOMAIN_displayName(),
"domain",
true,
true));
63 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttribute.
Type(EMAIL_TYPE_ID, Bundle.CorrelationType_EMAIL_displayName(),
"email_address",
true,
true));
64 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttribute.
Type(PHONE_TYPE_ID, Bundle.CorrelationType_PHONE_displayName(),
"phone_number",
true,
true));
65 DEFAULT_CORRELATION_TYPES.add(
new CorrelationAttribute.
Type(USBID_TYPE_ID, Bundle.CorrelationType_USBID_displayName(),
"usb_devices",
true,
true));
66 return DEFAULT_CORRELATION_TYPES;
70 if(correlationValue == null) {
76 this.correlationValue = correlationValue.toLowerCase();
77 this.artifactInstances =
new ArrayList<>();
91 String result = this.
getID()
94 result = this.
getInstances().stream().map((inst) -> inst.toString()).reduce(result, String::concat);
124 this.correlationValue = correlationValue.toLowerCase();
154 public void setInstances(List<CorrelationAttributeInstance> artifactInstances) {
155 this.artifactInstances.clear();
156 if (null != artifactInstances) {
157 this.artifactInstances.addAll(artifactInstances);
167 this.artifactInstances.add(artifactInstance);
170 public static class Type implements Serializable {
189 public Type(
int id, String displayName, String dbTableName, Boolean supported, Boolean enabled)
throws EamDbException {
190 if(dbTableName == null) {
198 if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
199 throw new EamDbException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.");
215 public Type(String displayName, String dbTableName, Boolean supported, Boolean enabled)
throws EamDbException {
246 return this.
id == that.getId()
247 && Objects.equals(this.supported, that.isSupported())
248 && Objects.equals(
this.enabled, that.isEnabled());
254 hash = 67 * hash + Objects.hashCode(this.
id);
255 hash = 67 * hash + Objects.hashCode(this.supported);
256 hash = 67 * hash + Objects.hashCode(this.enabled);
262 StringBuilder str =
new StringBuilder();
263 str.append(
"(id=").append(
getId());
269 return str.toString();
374 if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) {
375 throw new EamDbException(
"Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.");
String getCorrelationValue()
CorrelationAttribute(Type correlationType, String correlationValue)
static final int PHONE_TYPE_ID
Type getCorrelationType()
static final int FILES_TYPE_ID
Type(int id, String displayName, String dbTableName, Boolean supported, Boolean enabled)
Boolean equals(CorrelationAttribute otherArtifact)
void setEnabled(Boolean enabled)
void setInstances(List< CorrelationAttributeInstance > artifactInstances)
static final int EMAIL_TYPE_ID
void addInstance(CorrelationAttributeInstance artifactInstance)
void setCorrelationValue(String correlationValue)
Type(String displayName, String dbTableName, Boolean supported, Boolean enabled)
boolean sameType(CorrelationAttribute.Type that)
static final long serialVersionUID
void setDbTableName(String dbTableName)
void setCorrelationType(Type correlationType)
boolean equals(Object that)
List< CorrelationAttributeInstance > getInstances()
final String DB_NAMES_REGEX
static final int DOMAIN_TYPE_ID
static List< CorrelationAttribute.Type > getDefaultCorrelationTypes()
void setSupported(Boolean supported)
void setDisplayName(String displayName)
static final int USBID_TYPE_ID
final List< CorrelationAttributeInstance > artifactInstances