<?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, 12 Feb 2014 18:31:36 -0500</lastBuildDate><item><title>Comment by Nikel Weis on anphunl's answer</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#519</link><description>&lt;p&gt;&lt;a href="/users/54/nghianguyen/"&gt;&lt;a href="/users/54/nghianguyen/"&gt;@nghianguyen&lt;/a&gt;&lt;/a&gt;: This is a Q&amp;amp;A-Platform where users assist other users and also the ivyTeam mixes in - not an official support-system. Use soreconnect if you have (urgent) cases.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Wed, 12 Feb 2014 18:31:36 -0500</pubDate><guid>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#519</guid></item><item><title>Comment by nghianguyen on Raphael Bürgin's answer</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#496</link><description>&lt;p&gt;Thank you, Raphael. I see that Ivy has not provide any APIs for searching IRoles, your comment is best way for now.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nghianguyen</dc:creator><pubDate>Fri, 24 Jan 2014 10:07:38 -0500</pubDate><guid>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#496</guid></item><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>Comment by nghianguyen on anphunl's answer</title><link>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#487</link><description>&lt;p&gt;I think it would be great if Ivy could handle this case. Anyway, thanks for your answer&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nghianguyen</dc:creator><pubDate>Wed, 22 Jan 2014 09:30:03 -0500</pubDate><guid>https://answers.axonivy.com/questions/485/is-it-possible-to-find-iroles-by-using-contains-or-like-as-sql-statement#487</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>