1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
import com.bioxpr.sendmail.SendMail;
import com.bioxpr.streptopathways.bean.Redirectable;
import com.bioxpr.streptopathways.util.Utils;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.StringTokenizer;
import javax.mail.MessagingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author dbourgais
*/
public class AjaxGenes extends MyServlet implements Redirectable{
/**
* 0 => hids
* 1 => taxonomy id
* 2 => ontology id
* 3 => databank
*/
private String[]input = new String[4];
private String ontology;
private void setParameters(HttpServletRequest request) {
this.input[0] = request.getParameter("hids");
this.input[1] = request.getParameter("taxid");
this.input[2] = request.getParameter("oid");
this.input[3] = request.getParameter("db");
}
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, MessagingException {
PrintWriter out = response.getWriter();
setParameters(request);
out.println("<ul class=\"menud\"><li>");
try {
this.ontology = Utils.getOntology(this.input[3], this.input[2]);
String taxid = this.input[1];
StringTokenizer st = new StringTokenizer(this.input[0], ",");
out.println("<ul>");
while (st.hasMoreElements()) {
String hid = st.nextToken();
String[] res = new String[2];
if (Utils.isValidHID(Long.parseLong(hid))) {
res = Utils.getFirstUGeneNameForGeneList(hid, taxid);
} else {
res = Utils.getFirstUGeneNameForGeneList2(hid, taxid);
}
out.println("<li>");
out.print("<a href=\"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=report&list_uids=" + res[1] + "\" target=\"_blank\">");
out.println(res[0]);
out.print("</a>");
out.println("</li>");
}
out.println("</ul>");
} catch (SQLException ex) {
SendMail.sendText(to, null, from, ex.getClass().getName(),
ex.getMessage()+"\n"+ex.getSQLState());
} catch (ClassNotFoundException ex) {
SendMail.sendText(to, null, from, ex.getClass().getName(),
ex.getMessage());
}
finally{
out.println("</li></ul>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try{
processRequest(request, response);
}catch(MessagingException me){}
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try{
processRequest(request, response);
}catch(MessagingException me){}
}
/**
* Returns a short description of the servlet.
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
public void redirect(HttpServletRequest request, HttpServletResponse response, String keyAttribute, Object attribute, String page) throws ServletException, IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
public void redirect(HttpServletRequest request, HttpServletResponse response, String page) throws ServletException, IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
} |
Partager