Changeset 1118


Ignore:
Timestamp:
Jun 10, 2009, 1:21:51 PM (12 years ago)
Author:
Nicklas Nordborg
Message:

References #229: Implement API for additional GenePattern? web services

The test servlet now use the wrapper classes when possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/servlet/Test.java

    r1107 r1118  
    2929import javax.servlet.http.HttpServletResponse;
    3030
    31 import org.genepattern.client.GPClient;
    32 import org.genepattern.webservice.JobResult;
    3331import org.genepattern.webservice.Parameter;
    34 import org.genepattern.webservice.WebServiceException;
     32import org.genepattern.webservice.TaskInfoAttributes;
    3533
    3634import net.sf.basedb.clients.web.Base;
    37 import net.sf.basedb.core.Application;
    3835import net.sf.basedb.core.DbControl;
    3936import net.sf.basedb.core.File;
     
    4239import net.sf.basedb.genepattern.file.BaseFileProxy;
    4340import net.sf.basedb.genepattern.file.FileTransferGateway;
    44 import net.sf.basedb.util.FileUtil;
    45 import net.sf.basedb.util.StaticCache;
     41import net.sf.basedb.genepattern.wrapper.GPClient;
     42import net.sf.basedb.genepattern.wrapper.JobResult;
     43import net.sf.basedb.genepattern.wrapper.ParameterInfo;
     44import net.sf.basedb.genepattern.wrapper.TaskInfo;
    4645
    4746import java.io.IOException;
    48 import java.io.InputStream;
    4947import java.io.PrintWriter;
    50 import java.io.Writer;
    5148import java.net.URL;
    5249
     
    9390
    9491      GPClient gp = new GPClient(GP_HOME, GP_LOGIN, GP_PWD);
    95       JobResult result = gp.runAnalysis(
     92      //AdminProxy ap = new AdminProxy(GP_HOME, GP_LOGIN, GP_PWD);
     93     
     94      TaskInfo[] tasks = gp.getModules(null);
     95      PrintWriter out = response.getWriter();
     96      out.println("<b>Tasks</b><br>");
     97      for (TaskInfo ti : tasks)
     98      {
     99        org.genepattern.webservice.TaskInfo gpTi = ti.getGPTaskInfo();
     100        TaskInfoAttributes tia = gpTi.getTaskInfoAttributes();
     101        out.println("name="+ti.getName()+"<br>");
     102        out.println("access_id="+gpTi.getAccessId()+"<br>");
     103        out.println("descr="+ti.getDescription()+"<br>");
     104        out.println("ID="+gpTi.getID()+"<br>");
     105        out.println("lsid="+ti.getLsid()+"<br>");
     106        out.println("shortname="+gpTi.getShortName()+"<br>");
     107        out.println("userid="+gpTi.getUserId()+"<br>");
     108        out.println("containsinputfileparam="+gpTi.containsInputFileParam()+"<br>");
     109        out.println("pipeline="+ti.isPipeline()+"<br>");
     110        out.println("attr="+gpTi.getAttributes()+"<br>");
     111        out.println("tiattr="+tia+"<br>");
     112        out.println("toString=" + ti.toString());
     113        out.println("<hr>");
     114      }
     115      out.flush();
     116
     117     
     118      ParameterInfo[] info = gp.getParameters("urn:lsid:broad.mit.edu:cancer.software.genepattern.module.analysis:00044:5", null);
     119      //PrintWriter out = response.getWriter();
     120      out.println("<b>Parameters</b><br>");
     121      for (ParameterInfo pi : info)
     122      {
     123        org.genepattern.webservice.ParameterInfo gpPi = pi.getGPParameterInfo();
     124        out.println("name="+pi.getName()+"<br>");
     125        out.println("label="+pi.getLabel()+"<br>");
     126        out.println("descr="+pi.getDescription()+"<br>");
     127        out.println("default="+pi.getDefaultValue()+"<br>");
     128        out.println("choices="+pi.getChoices()+"<br>");
     129        out.println("attr="+gpPi.getAttributes()+"<br>");
     130        out.println("optional="+pi.isOptional()+"<br>");
     131        out.println("inputfile="+pi.isInputFile()+"<br>");
     132        out.println("outputfile="+gpPi.isOutputFile()+"<br>");
     133        out.println("password="+gpPi.isPassword()+"<br>");
     134        out.println("toString=" + pi.toString());
     135        out.println("<hr>");
     136      }
     137      out.flush();
     138     
     139      int jobId = gp.runAnalysisNoWait(
    96140        "urn:lsid:broad.mit.edu:cancer.software.genepattern.module.analysis:00044:5",
    97141        new Parameter[]{
     
    110154          new Parameter("output.filename", "<input.file_basename>.comp.marker.odf")
    111155        });
    112      
    113      
     156      JobResult result = gp.waitFor(jobId, 5000);
     157      org.genepattern.webservice.JobResult gpJr = result.getGPJobResult();
    114158      String[] files = result.getOutputFileNames();
    115       PrintWriter out = response.getWriter();
     159      out.println("<p><b>Result files:</b><br>");
    116160      for (String f : files)
    117161      {
    118         URL url = result.getURL(f);
    119         out.print("<a href=\"" + url + "\" target=\"_new\">" + f + ": " + url + "</a><br>");
     162        URL url = gpJr.getURL(f);
     163        out.println("<a href=\"" + url + "\" target=\"_new\">" + f + ": " + url + "</a><br>");
    120164      }
    121165
    122166    }
    123     catch (WebServiceException ex)
     167    catch (Exception ex)
    124168    {
    125169      throw new ServletException(ex);
Note: See TracChangeset for help on using the changeset viewer.