wildcard in search

User f52820d97e

11-02-2008 14:44:36

Hi,


I use the JSP interface with Tomcat/MySQL servers, and I have extra text columns, for example the reference.


In the query panel, I have the choice of =, <, <=, >, >=, but I would like to use wildcards, i.e. XX* if a reference is XX-01, XX-02, etc...


Is it possible?


Cheers,


Nicolas

ChemAxon e274e1bada

11-02-2008 15:27:08

Hi Nicolas,





The JSP example is not supporting wildcards in conditions at the moment, but it is a right request. We try to implement this in our next major release.





BTW the source code of our JSP example is open, feel free to change it according to your ideas.





Cheers,


Edvard

User f52820d97e

11-02-2008 15:38:28

Thanks for the answer! It will be great to see that, I am not sure I am capable to implement it in the JSP code, maybe I'll try...


Cheers,


Nicolas

ChemAxon 9c0afc9aaf

13-02-2008 03:50:18

For your information in case you try this yourself (or with your colleagues) in the meantime:








In searching.jsp there is a method createFilterQuery(). This basically assembles an SQL query returning applicable cd_id values for JChemSearch.setFilterQuery():





http://www.chemaxon.com/jchem/doc/api/chemaxon/jchem/db/JChemSearch.html#setFilterQuery(java.lang.String)





This should be modified according to your needs.





You can use the LIKE SQL operator in the WHERE clause, for example "LIKE XX%" matches all string starting with "XX".





Szilard

User f52820d97e

13-02-2008 10:50:50

Great Szilard, thanks!


I will try ASAP and post my thinking...


Cheers


Nicolas

User f52820d97e

18-02-2008 10:00:33

I got the workaround, here are the changes I made,


in query.jsp, extra line 1284


Code:
<option value=" LIKE ">Begins with</option>



(spaces are mandatory due to SQL syntax)


in searching.jsp, line 47


Code:
            if(isText) {


                value = "'" + value + "'";


            }



changed to


Code:
            if(isText) {


                if(relation.equals(" LIKE ")){


                value = "'" + value + "%'";


                } else {


                value = "'" + value + "'";}


            }



Thanks for the tip!


Nicolas

ChemAxon 9c0afc9aaf

18-02-2008 10:26:01

Hi Nicolas,





I'm glad you could manage to solve the problem.


We really appreciate that you are sharing the required changes with the community.


However to be really usable for others please also state the JChem version and/or attached the modified files


(otherwise "extra line 1284" is a bit foggy advice :) ).





Best regards,





Szilard

User f52820d97e

18-02-2008 11:22:40

Sorry... JChem v.5.0.0


Attached are the files modified in examples/db_search


Cheers,


Nicolas

ChemAxon 9c0afc9aaf

18-02-2008 16:07:06

Thank you for your contribution !





Cheers,





Szilard

User f52820d97e

18-02-2008 16:54:41

A small thing, but maybe useful... ;-) that's the least I can do!


Here is my 100th post...