package it.unibz.inf.ontop.protege.gui.treemodels;

import it.unibz.inf.ontop.model.atom.TargetAtom;
import it.unibz.inf.ontop.model.term.ImmutableFunctionalTerm;
import it.unibz.inf.ontop.model.term.ImmutableTerm;
import it.unibz.inf.ontop.model.term.Variable;

public class TreeModelTools {

    /** A helper method to check a match */
    public static boolean match(String keyword, TargetAtom atom) {
        return atom.getSubstitutedTerms().stream()
                .anyMatch(t -> match(keyword, t));

    }

    public static boolean match(String keyword, ImmutableTerm term) {
        if (term instanceof ImmutableFunctionalTerm) {
            ImmutableFunctionalTerm functionTerm = (ImmutableFunctionalTerm) term;
            if (functionTerm.getFunctionSymbol().toString().contains(keyword)) { // match found!
                return true;
            }
            // Recursive
            return functionTerm.getTerms().stream()
                    .anyMatch(t -> match(keyword, t));
        }
        if (term instanceof Variable) {
            return ((Variable) term).getName().contains(keyword); // match found!
        }
        return false;
    }
}

@@ -204,24 +204,76 @@
 utableTerm;%0A
+import it.unibz.inf.ontop.model.term.ValueConstant;%0A
 import it.un
@@ -346,16 +346,23 @@
 %0A    /**
+%0A     *
  A helpe
@@ -386,16 +386,21 @@
  a match
+%0A    
  */%0A    
@@ -1052,16 +1052,18 @@
 d, t));%0A
+//
         
@@ -1063,24 +1063,21 @@
        %7D
-%0A       
+ else
  if (ter
@@ -1097,24 +1097,26 @@
 Variable) %7B%0A
+//
             
@@ -1186,33 +1186,182 @@
 found!%0A        %7D
-%0A
+ else if (term instanceof ValueConstant) %7B%0A            return ((ValueConstant) term).getValue().contains(keyword); // match found!%0A        %7D else%0A    
         return f

fix protege search