org.LexGrid.LexBIG.caCore.web.util
Class LexEVSHTTPUtils

java.lang.Object
  extended by org.LexGrid.LexBIG.caCore.web.util.LexEVSHTTPUtils
All Implemented Interfaces:
Serializable

public class LexEVSHTTPUtils
extends Object
implements Serializable

HTTPUtils presents various methods to generate search criteria from xquery like syntax. This class also provides functionality to generate XML result.

Version:
1.1
Author:
Shaziya Muhsin, Dan Dumitru
See Also:
Serialized Form

Field Summary
private  LexEVSApplicationService applicationService
           
private  LexEVSClassCache classCache
           
private  String codingSchemeName
           
private  String codingSchemeVersion
           
private  String criteria
           
private static org.apache.log4j.Logger log
           
private  org.jdom.Namespace namespace
           
private  String pageNumber
           
private  String pageSize
           
private  String query
           
private  String resultCounter
           
private  List results
           
private  String roleName
           
private static long serialVersionUID
           
private  String servletName
           
private  String startIndex
           
private  String targetClassName
           
private  String targetPackageName
           
 
Constructor Summary
LexEVSHTTPUtils(javax.servlet.ServletContext context)
           
 
Method Summary
private  String buildCriteriaString(Map<String,Object> map)
          Returns an id field from an array of fields
private  Object buildSearchCriteria(String packageName, List criteriaList)
          Generates a search criteria from a criteria list
private  Map<String,Object> getAllNonNullPrimitiveFieldsNamesAndValues(Object obj)
           
 String getCodingSchemeName()
           
private  String getCodingSchemeNameAndVersionURLString()
           
 String getCodingSchemeVersion()
           
 String getCriteria()
          Returns the criteria value
private  org.jdom.Element getElement(Object result, String recordNum)
          Generates an Element for a given result object.
private  org.jdom.Element getElement2(Object result, String recordNum)
          Generates an Element for a given result object
private  Field getFieldByName(Field[] fields, String fieldName)
          Returns a field that matches the given String from an array of fields
private  Object getFieldValue(Field field, Object domain)
          Returns a field value
 boolean getMatch(gov.nih.nci.system.web.util.HTTPUtils prop)
          Returns true if a match is found
 String getPackageName(String className)
          Returns the package name of a given class
 String getPageNumber()
          Returns the pageNumber
 String getPageSize()
          Returns the page size
private  String getParamatarizedListType(Field field)
           
 String getQuery()
          Returns a query
 String getQueryType(String url)
          Returns a query type value based on a given string.
 String getResultCounter()
          Returns the resultCounter value
 List getResults()
          Returns a list of result objects
 Object[] getResultSet()
          Returns an array of result objects
private  String getSearchClassNames(String searchClasses)
          Returns fully qualified search class names
 List<String> getSearchCriteriaList(String criteria)
          Returns a search criteria list from a criteria
 String getServletName()
          Returns http servlet name
 String getStartIndex()
          Returns startIndex value
 String getTargetClassName()
          Returns target class name
 String getTargetPackageName()
          Returns the target package name
 org.jdom.Document getXMLDocument(Object[] resultSet, int pageNumber)
          Generates an org.jdom.Document based on a resultSet
static boolean isPropertyInitialized(Object proxy, String propertyName)
           
 boolean locateClass(String className)
          Returns true if the given class name is found
private  void printRecord(Object result, String servletName, javax.servlet.ServletOutputStream out, int recordNum)
          Displays a record on screen
 void printResults(javax.servlet.http.HttpServletResponse response)
          Prints results on screen
 void setPageSize(int size)
          Sets the page size value
 void setQueryArguments(String queryText)
          Sets argument values based on a given queryText
 void setResults(List resultList)
          Sets the results value
 void setServletName(String name)
          Sets the http Servlet name
 void setStartIndex(String index)
          Sets the startIndex value
private  boolean validateSyntax(String query)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

private static org.apache.log4j.Logger log

applicationService

private LexEVSApplicationService applicationService

classCache

private LexEVSClassCache classCache

query

private String query

startIndex

private String startIndex

resultCounter

private String resultCounter

pageNumber

private String pageNumber

pageSize

private String pageSize

criteria

private String criteria

targetClassName

private String targetClassName

servletName

private String servletName

targetPackageName

private String targetPackageName

roleName

private String roleName

codingSchemeName

private String codingSchemeName

codingSchemeVersion

private String codingSchemeVersion

results

private List results

namespace

private org.jdom.Namespace namespace
Constructor Detail

LexEVSHTTPUtils

public LexEVSHTTPUtils(javax.servlet.ServletContext context)
Method Detail

setServletName

public void setServletName(String name)
Sets the http Servlet name

Parameters:
name -

getServletName

public String getServletName()
Returns http servlet name

Returns:

getStartIndex

public String getStartIndex()
Returns startIndex value

Returns:

setStartIndex

public void setStartIndex(String index)
Sets the startIndex value

Parameters:
index -

getResults

public List getResults()
Returns a list of result objects

Returns:

setResults

public void setResults(List resultList)
Sets the results value

Parameters:
resultList -

setQueryArguments

public void setQueryArguments(String queryText)
                       throws Exception
Sets argument values based on a given queryText

Parameters:
queryText - - http query
Throws:
Exception

getQuery

public String getQuery()
Returns a query

Returns:

getTargetClassName

public String getTargetClassName()
Returns target class name

Returns:

getCriteria

public String getCriteria()
Returns the criteria value

Returns:

getPageNumber

public String getPageNumber()
Returns the pageNumber

Returns:

setPageSize

public void setPageSize(int size)
Sets the page size value

Parameters:
size -

getPageSize

public String getPageSize()
Returns the page size

Returns:

getResultCounter

public String getResultCounter()
Returns the resultCounter value

Returns:

getCodingSchemeName

public String getCodingSchemeName()

getCodingSchemeVersion

public String getCodingSchemeVersion()

getQueryType

public String getQueryType(String url)
Returns a query type value based on a given string.

Parameters:
url -
Returns:

getTargetPackageName

public String getTargetPackageName()
Returns the target package name

Returns:

buildSearchCriteria

private Object buildSearchCriteria(String packageName,
                                   List criteriaList)
                            throws Exception
Generates a search criteria from a criteria list

Parameters:
packageName - - specifies the package name
criteriaList - - specifies a list of criteria instances.
Returns:
Throws:
Exception

getSearchClassNames

private String getSearchClassNames(String searchClasses)
                            throws Exception
Returns fully qualified search class names

Parameters:
searchClasses - - specifies the search class names
packageName - - specifies the package name
Returns:
Throws:
Exception

getSearchCriteriaList

public List<String> getSearchCriteriaList(String criteria)
Returns a search criteria list from a criteria

Parameters:
criteria - - specifies the criteria string
Returns:

validateSyntax

private boolean validateSyntax(String query)

getXMLDocument

public org.jdom.Document getXMLDocument(Object[] resultSet,
                                        int pageNumber)
                                 throws Exception
Generates an org.jdom.Document based on a resultSet

Parameters:
resultSet - - specifies a list of populated domain objects
pageNumber - - specifies the page number
Returns:
Throws:
Exception

getCodingSchemeNameAndVersionURLString

private String getCodingSchemeNameAndVersionURLString()

getElement2

private org.jdom.Element getElement2(Object result,
                                     String recordNum)
                              throws Exception
Generates an Element for a given result object

Parameters:
result - - an instance of a class
recordNum - - specifies the record number in the result set
Returns:
Throws:
Exception

getPackageName

public String getPackageName(String className)
                      throws Exception
Returns the package name of a given class

Parameters:
className - - specifies the class name
Returns:
Throws:
Exception

locateClass

public boolean locateClass(String className)
Returns true if the given class name is found

Parameters:
className -
Returns:

buildCriteriaString

private String buildCriteriaString(Map<String,Object> map)
                            throws Exception
Returns an id field from an array of fields

Parameters:
fields -
Returns:
Throws:
Exception

getAllNonNullPrimitiveFieldsNamesAndValues

private Map<String,Object> getAllNonNullPrimitiveFieldsNamesAndValues(Object obj)
                                                               throws Exception
Throws:
Exception

getFieldByName

private Field getFieldByName(Field[] fields,
                             String fieldName)
                      throws Exception
Returns a field that matches the given String from an array of fields

Parameters:
fields - All fields
fieldName - Field name
Returns:
Throws:
Exception

getFieldValue

private Object getFieldValue(Field field,
                             Object domain)
                      throws Exception
Returns a field value

Parameters:
field - - specifies the field
domain - - specifies the object
Returns:
Throws:
Exception

getResultSet

public Object[] getResultSet()
                      throws Exception
Returns an array of result objects

Returns:
Throws:
Exception

getMatch

public boolean getMatch(gov.nih.nci.system.web.util.HTTPUtils prop)
Returns true if a match is found

Parameters:
prop - - an instance of an HTTPUtils class
Returns:

printResults

public void printResults(javax.servlet.http.HttpServletResponse response)
                  throws IOException,
                         javax.servlet.ServletException
Prints results on screen

Parameters:
resultList -
response -
Throws:
IOException
javax.servlet.ServletException

printRecord

private void printRecord(Object result,
                         String servletName,
                         javax.servlet.ServletOutputStream out,
                         int recordNum)
                  throws Exception
Displays a record on screen

Parameters:
result -
servletName -
out -
recordNum -
Throws:
Exception

getElement

private org.jdom.Element getElement(Object result,
                                    String recordNum)
                             throws Exception
Generates an Element for a given result object.

Parameters:
result - - specifies the populated EVS domain object
recordNum - - specifies the record number in the result set
Returns:
the element
Throws:
Exception - the exception

isPropertyInitialized

public static boolean isPropertyInitialized(Object proxy,
                                            String propertyName)

getParamatarizedListType

private String getParamatarizedListType(Field field)