jchem results enhancements

User f5e6ccf034

15-12-2005 14:39:28

I have often wished it were possible to modify the schema of the results table (like we can modify the structure table schema) to add extra columns, in my case a serial number for the query and the user id. You can stop different users from clobbering each other's results by assigning each a different table but this will not scale at large sites: some dbas will object to so many tables. Furthermore as far as I can tell you are still out of luck with the issue of a query overwriting the earlier one.





Regards,





-- O.L.

ChemAxon 9c0afc9aaf

15-12-2005 16:57:02

Hi,





The result table creation is just a convenience method for the simplest case.





For more complicated cases it is recommended to write your own code for creating and filling the result table you desire.


It is really simple, only a few lines of code is needed (if your application does not have to support a wide range of RDBMS types).


This way would also have control over the type of result table, that you have mentioned in an other topic:





http://www.chemaxon.com/forum/ftopic1097.html





Would it be a feasible solution for you ?





(If you need help with this I can write a simple code sample for you.)





Best regards,





Szilard

User f5e6ccf034

15-12-2005 19:45:04

Ok I can do that, too. I like the convenience of being able to write an SQL query referencing the cd_id's in the result table because I am very vague about the SQL query string length limitation(s) and the "where cd_id in (blah blah)" clause that you must use if the cd_id's are not already in the db looks like it could get dangerously long.





-- O.L.

ChemAxon 9c0afc9aaf

16-12-2005 09:10:59

Hi,
Quote:
the "where cd_id in (blah blah)" clause that you must use if the cd_id's are not already in the db looks like it could get dangerously long.
We usually divide such operations into smaller batches, so the sql statement won't get too long.





Regards,





Szilard

User f5e6ccf034

17-12-2005 16:51:12

And what would you say is a good slice size in practice (for all engines and drivers) ?

ChemAxon 9c0afc9aaf

19-12-2005 16:24:16

We include 500 cd_id values in an IN clause in similar situations, this is fine for all RDBMS supported by us.





Regards,





Szilard

User cfaffaaf29

10-01-2006 20:47:24

I have been running the jsp1_x example under TomCat successfully and would like to experiment with modifying the output to the results page, specifically I would like to embed the ID number in a hyperlink. Sadly, I am woefully java ignorant but it looks like the code of interest is in


JCHEMHOME\examples\jsp1_x\searchresults.jsp





Which then gets "compiled" to


Tomcat 5.0\work\Catalina\localhost\jchem\org\apache\jsp\examples\jsp1_005fx\searchresults_jsp.java and searchresults_jsp.class





Code:



String getCellParam(int index, String structure, Object[][] args,


          String layout, float dissim) {


    String value = "";


    if(layout.startsWith("default")) {


   value = "|"+structure;


   boolean showDisSim = true;


   for(int i=0;i<args[0].length;i++) {


       String pre = "";


       if(args[1][i].toString().toLowerCase().equals("cd_id")) {


      pre = "ID: ";


       } else if(


      args[1][i].toString().toLowerCase().equals("cd_molweight")) {


      pre = "MW: ";





I was hoping to do something along the lines of changing


Code:



  if(args[1][i].toString().toLowerCase().equals("cd_id")) {


    pre = "ID: ";


to


    pre = "ID: <a href=\"http://localhost/mysite?args[0][i].toString()\" target=\"_blank\">args[0][i].toString()</a>";





While this certainly changed the output it sure was not what I wanted, besides having my structure cell squashed to invisibility, the html tags weren't recognized and I got no hyperlink. How should I modify searchresults.jsp to properly insert a link?





Thanks much,

ChemAxon 9c0afc9aaf

11-01-2006 09:25:23

Hi,





Your code does not work due to multiple reasons:





1. The expression inside the quotes will not be evaluated, your URL is a constant.





2. This string is displayed in the MarvinView applet (not in the html source) as a label.


Marvin will treat it as any other text and display it as is.


Since it's a long text and doesn't fit in the cell, the molecule gets smaller of course.





I recommend you the following:


- Try to ask someone with some Java / JSP experience to do these modifications.


- Use a button in MarvinView, which can have an action string. This action string can be a URL.





A working example is available at:





http://www.chemaxon.com/marvin/doc/dev/example-view2.2.html





You should be familiar with setting the layout for molecule tables:





http://www.chemaxon.com/marvin/doc/dev/viewman.html#advanced





Best regards,





Szilard

User cfaffaaf29

11-01-2006 14:05:21

OK. The examples (example-view2.2.html) specify numerous modifications to the mview_param parameters, but in which file are these modifications being made? Or is MarvinView modified through some interface?

ChemAxon 9c0afc9aaf

12-01-2006 08:24:05

Quote:
OK. The examples (example-view2.2.html) specify numerous modifications to the mview_param parameters, but in which file are these modifications being made?
Since searchresults.jsp generates the HTML source that contains the MarvinView table for result display, it's this file that should be modified.





Best regards,





Szilard

User cfaffaaf29

12-01-2006 19:30:10

Thanks very much for the help on adding a link, I was able to modify searchresults.jsp so as to add a button that fires an appropriate URL, for each structure. The last modification I would like to make to the jsp1_x example is to change the way that sessions start up for users. Rather than forcing them to make a table selection from seltable.jsp and then load all structures from the DB upon opening initsearch.jsp I would like to begin the session with query.jsp. But obviously a UID has to be issued before that page can be opened. Given that an initial session with setup.jsp has been completed so the connection parameters have already been stored, what is the minimal code I would have to add to query.jsp to make it usable as a startup page?





Thanks again, BPH

ChemAxon 9c0afc9aaf

16-01-2006 12:56:41

Hi,





Sorry for answering a bit late.





You can easily set the UID if not present by copying some code from index.jsp. Look for occurrences of "generateUserID" to quickly locate the relevant parts.





Some other session variables should also be present:





"ch" : contains the ConnectionHandler


or at least


"loginDetails" : needed in case the connection is closed or not existent


"strTableName" : the name of the structure table





If these are properly filled in case the user lands directly on query.jsp, it should work fine from that point.





Best regards,





Szilard

User 2f67f74af0

22-08-2008 17:35:18

Hi hallingb,


I was looking for a way to enhance the searchresult.jsp and starting session with query.jsp, and came across this post. Would you please show how you achieved that, if I'm not asking too much.


I'm not a java expert too, and no one knows java work with me.





Best regards.





Saif

ChemAxon 9c0afc9aaf

25-08-2008 22:41:54

Relevant parts of the code for session handling:








init.jsp :


Code:



String userID = (String)request.getParameter("uid");


String sessionVarPrefix=sessionPrefix + userID + ".";






In all subsequent pages this session prefix is used for all session variables.


This is only needed for preventing session problems in case of tabbed browsing for example - otherwise sessions are handled automatically.





If a required session variable is null, the session must have timed out, user is redirected to the starting page.





index.jsp generates the user ID if not exists yet:





Code:
String queryString=request.getQueryString();





    if (queryString==null) {


        queryString="";


    }


    if (queryString.indexOf("uid=")==-1) {


        if (queryString.length()!=0) {


            queryString+="&";


        }


        queryString+="uid="+generateUserID();


    }








private String generateUserID() {


    return ""+((long)(Math.random()*Long.MAX_VALUE));


}






All pages should take care to pass on the parameters (the part after the ? in the URL), to preserve the user ID.





Also from index.jsp:





Code:
<script language="javascript">


   <!--   


        //passing parameters (swing/awt) to the next page:


   document.loginForm.action="seltable.jsp"+"?<%=queryString%>";


        //-->


</script>






Szilard

User 2f67f74af0

02-09-2008 20:50:02

Hi Szilard,





Thank you for help. Before posting my question, I tried the code.





Here:
Quote:
<script language="javascript">


<!--


//passing parameters (swing/awt) to the next page:


document.loginForm.action="seltable.jsp"+"?<%=queryString%>";


//-->


</script>
I replaced seltable.jsp with query.jsp, expecting it to work. It keep going to (Your session has expired) page.


I'm not very good in this area of session and user id in jsp. There is no java person with me.


If you don't mind, would please give more info.





Thank you.

ChemAxon 9c0afc9aaf

04-09-2008 02:50:42

Hi,





The problem is that seltable.jsp does a lot if initialization, which is necessary for query.jsp to work (creates the connection, sets the structure table and the view format, etc)





You may want to preserve all these but instead of asking the question of what table to choose, just jump to query.jsp without even displaying anything for this page.





You can achieve this with the jsp:forward directive:


Code:



<jsp:forward page="query.jsp" />






The rewriting definitely needs understanding of the code from a technical person, it is more complex than it could be explained here.


Having someone there with some JSP skills would definitely help.





If you do not have anyone in-house, ChemAxon can also do this job for you (and more), as we are also providing ground support and services in the US now.


Please write to our support e-mail if you are interested in this.


(The e-mail can be found at the top of forum pages or here: http://www.chemaxon.com/contactus.html )





Best regards,





Szilard