gov.nih.nci.system.applicationservice.impl
Class ApplicationServiceImpl

java.lang.Object
  extended by gov.nih.nci.system.applicationservice.impl.ApplicationServiceImpl
All Implemented Interfaces:
ApplicationService
Direct Known Subclasses:
LexEVSApplicationServiceImpl

public class ApplicationServiceImpl
extends java.lang.Object
implements ApplicationService

Implementation for the methods in the service layer

Version:
1.0
Author:
Satish Patel

Constructor Summary
ApplicationServiceImpl(ClassCache classCache)
          Default constructor.
 
Method Summary
protected
<E> java.util.List<E>
convertToListProxy(java.util.Collection originalList, java.lang.Object query, java.lang.String classname, java.lang.Integer start)
           
<E> java.util.List<E>
getAssociation(java.lang.Object source, java.lang.String associationName)
          Retrieves an associated object for the example object specified by the source parameter.
protected  ClassCache getClassCache()
           
protected  DAO getDAO(java.lang.String classname)
           
 java.lang.Integer getMaxRecordsCount()
          Returns the maximum number of records the ApplicationService has been configured to return at one time.
 java.lang.Integer getQueryRowCount(java.lang.Object criteria, java.lang.String targetClassName)
          Returns the number of records that meet the search criteria.
protected
<E> java.util.List<E>
privateQuery(java.lang.Object criteria, java.lang.String targetClassName)
          Prepares the #gov.nih.nci.system.dao.Request object and uses #query(Request) to retrieve results from the data source.
<E> java.util.List<E>
query(DetachedCriteria detachedCriteria)
          Retrieves the result from the data source using the CQL query.
<E> java.util.List<E>
query(DetachedCriteria detachedCriteria, java.lang.String targetClassName)
          Retrieves the result from the data source using the CQL query.
<E> java.util.List<E>
query(java.lang.Object criteria, java.lang.Integer firstRow, java.lang.String targetClassName)
          Used by the infrastructure to get next chunk of records in the result set.
<E> java.util.List<E>
search(java.lang.Class targetClass, java.util.List objList)
          Retrieves the result from the data source using the Query by Example.
<E> java.util.List<E>
search(java.lang.Class targetClass, java.lang.Object obj)
          Retrieves the result from the data source using the Query by Example.
<E> java.util.List<E>
search(java.lang.String path, java.util.List objList)
          Retrieves the result from the data source using a Nested Search Criteria.
<E> java.util.List<E>
search(java.lang.String path, java.lang.Object obj)
          Retrieves the result from the data source using the Nested Search Criteria.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationServiceImpl

public ApplicationServiceImpl(ClassCache classCache)
Default constructor. Cache is required and is expected to have a collection of DAO System properties is also a required parameter used to determine system specific parameters

Method Detail

query

public <E> java.util.List<E> query(DetachedCriteria detachedCriteria,
                                   java.lang.String targetClassName)
                        throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using the CQL query. The CQL query structure is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the CQL query structure is converted in the Hibernate Query Language (HQL). Hibernate converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount(). Note: The targetClassName parameter will not be interpreted by the system. This parameter will be determined from the CQLQuery.

Specified by:
query in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
gov.nih.nci.system.applicationservice.ApplicationService#query(org.hibernate.criterion.DetachedCriteria, java.lang.String)

query

public <E> java.util.List<E> query(DetachedCriteria detachedCriteria)
                        throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using the CQL query. The CQL query structure is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the CQL query structure is converted in the Hibernate Query Language (HQL). Hibernate converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount().

Specified by:
query in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
gov.nih.nci.system.applicationservice.ApplicationService#query(org.hibernate.criterion.DetachedCriteria)

search

public <E> java.util.List<E> search(java.lang.Class targetClass,
                                    java.lang.Object obj)
                         throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using the Query by Example. The targetClass specifies the object that the user intends to fetch after executing the query. The targetClass should be same as the example object or associated object for the example object. The example query is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the example query structure is converted in the Hibernate Query Language (HQL). Hibernate converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount().

Specified by:
search in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.search(java.lang.Class, java.lang.Object)

search

public <E> java.util.List<E> search(java.lang.Class targetClass,
                                    java.util.List objList)
                         throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using the Query by Example. The targetClass specifies the object that the user intends to fetch after executing the query. The targetClass should be same as the object specified in the objList or associated object for the example object. Also, all the objects in the objList has to be of the same type. The example query is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the example query structure is converted in the Hibernate Query Language (HQL). Hibernate converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount().

Specified by:
search in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.search(java.lang.Class, java.util.List)

search

public <E> java.util.List<E> search(java.lang.String path,
                                    java.lang.Object obj)
                         throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using the Nested Search Criteria. The path specifies the list of objects (separated by commas) which should be used to reach the target object from the example object passed as obj, or the associated object for the example object. Internally, the Nested Search Criteria is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the query structure is first converted into the Hibernate Query Language (HQL). Hibernate then converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount().

Specified by:
search in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.search(java.lang.String, java.lang.Object)

query

public <E> java.util.List<E> query(java.lang.Object criteria,
                                   java.lang.Integer firstRow,
                                   java.lang.String targetClassName)
                        throws ApplicationException
Description copied from interface: ApplicationService
Used by the infrastructure to get next chunk of records in the result set. Use this method in conjunction with the ApplicationService.getMaxRecordsCount() to determine what should be the start of next chunk.

Specified by:
query in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.query(java.lang.Object, java.lang.Integer, java.lang.String)

search

public <E> java.util.List<E> search(java.lang.String path,
                                    java.util.List objList)
                         throws ApplicationException
Description copied from interface: ApplicationService
Retrieves the result from the data source using a Nested Search Criteria. The path specifies the list of objects (separated by commas), which should be used to reach the target object from the example objects passed in the objList or associated object for the example object. The Nested Search Criteria is converted into the data source specific query language. For the Object Relational Mapping based persistence tier, the query structure is first converted into the Hibernate Query Language (HQL). Hibernate then converts the HQL into SQL and executes it against the relational database. The retrieved results are converted into a list which may not be completely loaded. If the retrieved results are more than the maximum number of supported records as indicated by ApplicationService.getMaxRecordsCount() then the result set will be partially loaded. The client framework will execute a subsequent query (transparent to the client application) against the ApplicationService to load the remaining results in the chunk no greater than value specified by ApplicationService.getMaxRecordsCount().

Specified by:
search in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.search(java.lang.String, java.util.List)

getQueryRowCount

public java.lang.Integer getQueryRowCount(java.lang.Object criteria,
                                          java.lang.String targetClassName)
                                   throws ApplicationException
Description copied from interface: ApplicationService
Returns the number of records that meet the search criteria. The method is used by the client framework to determine the number of chunk of results. Use this method in conjunction with the ApplicationService.getMaxRecordsCount()

Specified by:
getQueryRowCount in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.getQueryRowCount(java.lang.Object, java.lang.String)

getAssociation

public <E> java.util.List<E> getAssociation(java.lang.Object source,
                                            java.lang.String associationName)
                                 throws ApplicationException
Description copied from interface: ApplicationService
Retrieves an associated object for the example object specified by the source parameter.

Specified by:
getAssociation in interface ApplicationService
Returns:
Throws:
ApplicationException
See Also:
ApplicationService.getAssociation(java.lang.Object, java.lang.String)

getMaxRecordsCount

public java.lang.Integer getMaxRecordsCount()
Description copied from interface: ApplicationService
Returns the maximum number of records the ApplicationService has been configured to return at one time.

Specified by:
getMaxRecordsCount in interface ApplicationService
Returns:

privateQuery

protected <E> java.util.List<E> privateQuery(java.lang.Object criteria,
                                             java.lang.String targetClassName)
                                  throws ApplicationException
Prepares the #gov.nih.nci.system.dao.Request object and uses #query(Request) to retrieve results from the data source. The results are converted in the list which is only partially loaded upto the maximum number of record that the system can support at a time.

Parameters:
criteria -
targetClassName -
Returns:
Throws:
ApplicationException

convertToListProxy

protected <E> java.util.List<E> convertToListProxy(java.util.Collection originalList,
                                                   java.lang.Object query,
                                                   java.lang.String classname,
                                                   java.lang.Integer start)

getDAO

protected DAO getDAO(java.lang.String classname)
              throws ApplicationException
Throws:
ApplicationException

getClassCache

protected ClassCache getClassCache()