<!doctype html><htmllang=enclass="js csstransforms3d"><head><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><metaname=generatorcontent="Hugo 0.80.0"><metaname=descriptioncontent="Strolch is a parameterized framework for use on servers and IoT"><metaname=authorcontent="Robert von Burg"><linkrel=iconhref=/favicon.icotype=image/ico><title>Searches - Strolch</title><linkhref=/css/nucleus.css?1678977092rel=stylesheet><linkhref=/css/fontawesome-all.min.css?1678977092rel=stylesheet><linkhref=/css/hybrid.css?1678977092rel=stylesheet><linkhref=/css/featherlight.min.css?1678977092rel=stylesheet><linkhref=/css/perfect-scrollbar.min.css?1678977092rel=stylesheet><linkhref=/css/auto-complete.css?1678977092rel=stylesheet><linkhref=/css/atom-one-dark-reasonable.css?1678977092rel=stylesheet><linkhref=/css/theme.css?1678977092rel=stylesheet><linkhref=/css/hugo-theme.css?1678977092rel=stylesheet><linkhref=/css/theme-green.css?1678977092rel=stylesheet><scriptsrc=/js/jquery-3.3.1.min.js?1678977092></script><style>:root#header+#content>#left>#rlblock_left{display:none!important}</style></head><bodydata-url=/documentation/searches/><navid=sidebar><divid=header-wrapper><divid=header><aid=logohref=/><imgsrc=/logo.png></a></div><divclass=searchbox><labelfor=search-by><iclass="fas fa-search"></i></label><inputdata-search-inputid=search-bytype=searchplaceholder=Search...>
from the <ahref=https://camel.apache.org/target=_blank>Apache Camel</a> project.</p><p>There are four main search classes:</p><ul><li>RootElementSearch - search for any of Resource, Order or Activity elements</li><li>ResourceSearch - search for Resources</li><li>OrderSearch - search for Orders</li><li>ActivitySearch - search for Activities</li></ul><p>No search is useful without a <code>where</code> clause, which are called search
expressions. When writing a search, there are multiple ways to add such where
clauses. Either</p><ul><li>override the <code>define()</code>-method in your sub class and add the where clauses by
calling the <code>where()</code> method, or</li><li>define special methods on the class e.g. <code>byColor()</code> which also calls the
<code>where()</code>-method to add a search expression, or</li><li>directly call the <code>where()</code>-method after instantiating a search.</li></ul><p>When extending the class, then the search expressions are available as methods
on the super class, otherwise you can statically import them from
.</p><p>Examples of search expressions with search predicates follow:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>ResourceSearch search<spanstyle=color:#f92672>=</span><spanstyle=color:#66d9ef>new</span> ResourceSearch<spanstyle=color:#f92672>();</span>
<spanstyle=color:#75715e>// predicate either as parameter, or chained
</code></pre></div><p>Note how the predicates can be chained to the search expression, or passed as a
parameter to the expression.</p><p>In addition to using predefined search search expressions, one can also just
pass a lambda expression which performs a custom filter:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>personSearch<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>where</span><spanstyle=color:#f92672>(</span>person <spanstyle=color:#f92672>-></span> person<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>getName</span><spanstyle=color:#f92672>().</span><spanstyle=color:#a6e22e>length</span><spanstyle=color:#f92672>()</span><spanstyle=color:#f92672>==</span> 3<spanstyle=color:#f92672>);</span>
the <ahref=https://github.com/strolch-li/strolch/blob/develop/li.strolch.agent/src/test/java/li/strolch/search/StrolchSearchTest.javatarget=_blank>StrolchSearchTest</a>
for many ways in which you can implement tests.</p><divclass="notices tip"><p>Note that strolch searches requires privileges, thus when you
use a strolch search, add it to the role of the user in <code>PrivilegeRoles.xml</code>:</p></div><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-xmldata-lang=xml>
<spanstyle=color:#f92672></Allow></span><spanstyle=color:#75715e><!-- internal used for when the search is done in an internal service --></span>