org.utgenome.gwt.utgb.server
Class WebTrackBase

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.utgenome.gwt.utgb.server.RequestHandlerBase
              extended by org.utgenome.gwt.utgb.server.WebTrackBase
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, RequestHandler
Direct Known Subclasses:
ACGT, BEDViewer, BSSReadView, ChromosomeMap, CSEGViewer, DASDsn, DASViewer, DotPlot, EchoBackView, FontMetric, FontPanel, GeneViewer, KeywordSearch, LoadView, MethylViewer, ReadView, SAMViewer, ScaleBar, Sequence, SnappyVersion, Transparent, UsingTemplate

public abstract class WebTrackBase
extends RequestHandlerBase

Author:
leo
See Also:
Serialized Form

Constructor Summary
WebTrackBase()
           
 
Method Summary
 String createSQL(String sqlTemplate, Object... args)
          Create an SQL from a given template and variable assignments.
 String createSQLFromFile(String sqlFileName, Object... args)
          Create an SQL from a given file (relative to the caller class) and variable assignments.
static String createSQLStatement(String sqlTemplate, Object... args)
           
 String getActionPrefix(javax.servlet.http.HttpServletRequest request)
          Return the action prefix of the request
 String getActionSuffix(javax.servlet.http.HttpServletRequest request)
          Return the action suffix attached to the request
 org.xerial.db.sql.DatabaseAccess getDatabaseAccess(String databaseID)
          Retrieves the database access
static String getHTTPRequestQueryString(javax.servlet.http.HttpServletRequest request)
           
static String getProjectRootPath()
          Returns the path to the project root folder
 String getTrackConfigProperty(String key, String defaultValue)
          Get the property written in the track-config.xml file
<T> List<T>
loadJSON(Reader jsonStream, Class<T> resultClass)
          load the json data, and converts them into a list of result class instances
<T> void
loadJSON(Reader jsonStream, Class<T> resultClass, org.xerial.util.ObjectHandler<T> resultHandler)
          Load JSON data from the stream and convert the JSON data into Object of the given resultClass.
 BufferedReader openAction(javax.servlet.http.HttpServletRequest request, String path)
          Opens a BufferedReader that reads data from another action
 BufferedReader openAction(javax.servlet.http.HttpServletRequest request, String path, boolean bypassRequestParameter)
           
<T> void
toJSON(String databaseID, String sql, Class<T> resultClass, javax.servlet.http.HttpServletResponse response)
           
 
Methods inherited from class org.utgenome.gwt.utgb.server.RequestHandlerBase
doGet, doPost, handle, validate
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebTrackBase

public WebTrackBase()
Method Detail

createSQLStatement

public static String createSQLStatement(String sqlTemplate,
                                        Object... args)
                                 throws UTGBException
Throws:
UTGBException

getDatabaseAccess

public org.xerial.db.sql.DatabaseAccess getDatabaseAccess(String databaseID)
                                                   throws UTGBException
Retrieves the database access

Parameters:
name -
Returns:
Throws:
UTGBException

getTrackConfigProperty

public String getTrackConfigProperty(String key,
                                     String defaultValue)
Get the property written in the track-config.xml file

Parameters:
key -
Returns:

toJSON

public <T> void toJSON(String databaseID,
                       String sql,
                       Class<T> resultClass,
                       javax.servlet.http.HttpServletResponse response)
            throws UTGBException,
                   IOException
Type Parameters:
T -
Parameters:
databaseID -
sql -
classType -
Throws:
UTGBException
IOException

loadJSON

public <T> void loadJSON(Reader jsonStream,
                         Class<T> resultClass,
                         org.xerial.util.ObjectHandler<T> resultHandler)
              throws UTGBException,
                     IOException
Load JSON data from the stream and convert the JSON data into Object of the given resultClass. Each object is passed to the result handler.

Type Parameters:
T -
Parameters:
jsonStream -
resultClass -
resultHandler -
Throws:
UTGBException
IOException

loadJSON

public <T> List<T> loadJSON(Reader jsonStream,
                            Class<T> resultClass)
                 throws UTGBException,
                        IOException
load the json data, and converts them into a list of result class instances

Type Parameters:
T -
Parameters:
jsonStream -
resultClass -
Returns:
Throws:
UTGBException
IOException

openAction

public BufferedReader openAction(javax.servlet.http.HttpServletRequest request,
                                 String path)
                          throws javax.servlet.ServletException,
                                 IOException
Opens a BufferedReader that reads data from another action

Parameters:
request -
path - path to the another action. e.g. "hello"
Returns:
Throws:
javax.servlet.ServletException
IOException

openAction

public BufferedReader openAction(javax.servlet.http.HttpServletRequest request,
                                 String path,
                                 boolean bypassRequestParameter)
                          throws javax.servlet.ServletException,
                                 IOException
Parameters:
request -
path -
bypassRequestParameter -
Returns:
Throws:
javax.servlet.ServletException
IOException

getHTTPRequestQueryString

public static String getHTTPRequestQueryString(javax.servlet.http.HttpServletRequest request)

createSQLFromFile

public String createSQLFromFile(String sqlFileName,
                                Object... args)
                         throws IOException,
                                UTGBException
Create an SQL from a given file (relative to the caller class) and variable assignments.

Parameters:
sqlFileName - an SQL (text) file name, which contains a single sql expression. This SQL file can contain variables $1, $2, ..., where each of them corresponds to the args of this method
args - values each of them are assigned to the corresponding variable in the SQL
Returns:
the generated SQL
Throws:
IOException - when failed to read the file
UTGBException - UTGBErrorCode.InvalidSQLSyntax

createSQL

public String createSQL(String sqlTemplate,
                        Object... args)
                 throws UTGBException
Create an SQL from a given template and variable assignments.

Parameters:
sqlTemplate - an SQL template, which can contain variables $1, $2, ..., each of them corresponds to the args of this method
args - variable assignments
Returns:
the generated SQL
Throws:
UTGBException - UTGBErrorCode.InvalidSQLSyntax

getProjectRootPath

public static String getProjectRootPath()
Returns the path to the project root folder

Returns:

getActionSuffix

public String getActionSuffix(javax.servlet.http.HttpServletRequest request)
Return the action suffix attached to the request

Parameters:
request -
Returns:
the action suffix. if no suffix is specified in the action, return "".

getActionPrefix

public String getActionPrefix(javax.servlet.http.HttpServletRequest request)
Return the action prefix of the request

Parameters:
request -
Returns:


Copyright © 2007-2012 utgenome.org. All Rights Reserved.