<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: is it possible to find IRoles by using "contains" or "like" as SQL statement?</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement</link><description>&lt;p&gt;In currently, we can find exactly an IRole by using "ivy.wf.getSecurityContext().findRole()"&lt;/p&gt;
&lt;p&gt;But, how can we get a list of IRoles that having same prefix name, or using a keyword to get all IRoles into a list?&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 22 Jan 2014 10:19:08 -0500</lastBuildDate><item><title>Answer by Raphael Bürgin</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement/488</link><description>&lt;p&gt;I think we never find such e completed class in java.&lt;/p&gt;
&lt;p&gt;But its easy to handle in a short methode like this. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public List&amp;lt;IRole&amp;gt; roleWithPrefix(String prefix){
    List&amp;lt;IRole&amp;gt; rolesToReturn = new ArrayList&amp;lt;IRole&amp;gt;();
    List&amp;lt;IRole&amp;gt; roles = Ivy.wf().getSecurityContext().getRoles();

    for(IRole role : roles){
        if(role.getName().startsWith(prefix)){
            rolesToReturn.add(role);
        }
    }
    return rolesToReturn;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I think with a singeltonpattern you can add this method very efficient on your application&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raphael Bürgin</dc:creator><pubDate>Wed, 22 Jan 2014 10:19:08 -0500</pubDate><guid>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement/488</guid></item><item><title>Answer by anphunl</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement/486</link><description>&lt;p&gt;I think you can get all roles and handle them by Java code&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ivy.wf.getSecurityContext().getRoles()&lt;/p&gt;
&lt;/blockquote&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">anphunl</dc:creator><pubDate>Wed, 22 Jan 2014 09:00:44 -0500</pubDate><guid>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement/486</guid></item></channel></rss>