19 package org.sleuthkit.autopsy.datamodel;
 
   21 import java.beans.PropertyChangeEvent;
 
   22 import java.beans.PropertyChangeListener;
 
   23 import java.lang.ref.WeakReference;
 
   24 import java.util.ArrayList;
 
   25 import java.util.List;
 
   26 import java.util.logging.Level;
 
   27 import org.apache.commons.lang3.tuple.Pair;
 
   28 import org.openide.util.NbBundle.Messages;
 
   50 class GetSCOTask 
implements Runnable {
 
   52     private final WeakReference<AbstractContentNode<?>> weakNodeRef;
 
   53     private static final Logger logger = Logger.getLogger(GetSCOTask.class.getName());
 
   54     private final PropertyChangeListener listener;
 
   56     GetSCOTask(WeakReference<AbstractContentNode<?>> weakContentRef, PropertyChangeListener listener) {
 
   57         this.weakNodeRef = weakContentRef;
 
   58         this.listener = listener;
 
   61     @Messages({
"GetSCOTask.occurrences.defaultDescription=No correlation properties found",
 
   62         "GetSCOTask.occurrences.multipleProperties=Multiple different correlation properties exist for this result"})
 
   65         AbstractContentNode<?> contentNode = weakNodeRef.get();
 
   67         if (contentNode == null || UserPreferences.getHideSCOColumns()) {
 
   71         Pair<Score, String> scoreAndDescription;
 
   72         Pair<Long, String> countAndDescription = null;
 
   73         scoreAndDescription = contentNode.getScorePropertyAndDescription();
 
   75         String description = Bundle.GetSCOTask_occurrences_defaultDescription();
 
   76         List<CorrelationAttributeInstance> listOfPossibleAttributes = 
new ArrayList<>();
 
   77         Content contentFromNode = contentNode.getContent();
 
   79         if (contentFromNode instanceof AbstractFile) {
 
   80             listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AbstractFile) contentFromNode));
 
   81         } 
else if (contentFromNode instanceof AnalysisResult) {
 
   82             listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AnalysisResult) contentFromNode));
 
   83         } 
else if (contentFromNode instanceof DataArtifact) {
 
   84             listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((DataArtifact) contentFromNode));
 
   85         } 
else if (contentFromNode instanceof OsAccount) {
 
   87                 List<OsAccountInstance> osAccountInstances = ((OsAccount) contentFromNode).getOsAccountInstances();
 
   94                 OsAccountInstance osAccountInstance = osAccountInstances.isEmpty() ? null : osAccountInstances.get(0);
 
  136                 listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch(osAccountInstance));
 
  137             } 
catch (TskCoreException ex) {
 
  138                 logger.log(Level.SEVERE, 
"Unable to get the DataSource or OsAccountInstances from an OsAccount with ID: " + contentFromNode.getId(), ex);
 
  141         DataResultViewerTable.HasCommentStatus commentStatus = contentNode.getCommentProperty(contentNode.getAllTagsFromDatabase(), listOfPossibleAttributes);
 
  142         CorrelationAttributeInstance corInstance = null;
 
  143         if (CentralRepository.isEnabled()) {
 
  144             if (listOfPossibleAttributes.size() > 1) {
 
  146                 description = Bundle.GetSCOTask_occurrences_multipleProperties();
 
  147             } 
else if (!listOfPossibleAttributes.isEmpty()) {
 
  149                 corInstance = listOfPossibleAttributes.get(0);
 
  151             countAndDescription = contentNode.getCountPropertyAndDescription(corInstance, description);
 
  153         if (Thread.currentThread().isInterrupted()) {
 
  157         if (listener != null) {
 
  158             listener.propertyChange(
new PropertyChangeEvent(
 
  159                     AutopsyEvent.SourceType.LOCAL.toString(),
 
  160                     AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),
 
  161                     null, 
new SCOData(scoreAndDescription, commentStatus, countAndDescription)));