de.iai.ilcd.model.dao
Class DataSetDao<T extends DataSet,L extends de.fzk.iai.ilcd.service.model.IDataSetListVO>

java.lang.Object
  extended by de.iai.ilcd.model.dao.DataSetDao<T,L>
Type Parameters:
T - Element type that is accessed by this DAO
L - ListVO interface type for the access
Direct Known Subclasses:
ContactDao, FlowDao, FlowPropertyDao, LCIAMethodDao, ProcessDao, SourceDao, UnitGroupDao

public abstract class DataSetDao<T extends DataSet,L extends de.fzk.iai.ilcd.service.model.IDataSetListVO>
extends java.lang.Object

Common implementation for data set DAO objects


Constructor Summary
DataSetDao(java.lang.String jpaName, java.lang.Class<T> accessedClass, java.lang.Class<L> listVOClass)
          Create a data set DAO
 
Method Summary
protected  java.lang.String buildClassificationJoin(java.lang.String entityPrefix)
           Build up join string for classification containing query (with default values for classification field name and alias prefix), example: LEFT JOIN p.classification.classes c1 LEFT JOIN p.classification.classes c2 default classification field name = classification default alias prefix = c
protected  java.lang.String buildClassificationJoin(java.lang.String entityPrefix, java.lang.String classificFieldName, java.lang.String aliasPrefix)
           Build up join string for classification containing query, example: LEFT JOIN p.classification.classes c1 LEFT JOIN p.classification.classes c2
protected  java.lang.String buildClassificationWhere(java.lang.String entityPrefix)
           Build up string for classification where clause (with default values for classification field name and alias prefix), example: ( p.classification IS NULL OR (c1.level=0 AND c2.level=0) OR (c1.level=0 AND c2.level=1) ) default classification field name = classification default alias prefix = c
protected  java.lang.String buildClassificationWhere(java.lang.String entityPrefix, java.lang.String classificFieldName, java.lang.String aliasPrefix)
           Build up string for classification where clause, example: ( p.classification IS NULL OR (c1.level=0 AND c2.level=0) OR (c1.level=0 AND c2.level=1) )
 boolean checkAndPersist(T dataSet, PersistType pType, java.io.PrintWriter out)
          Generic persist method for data set objects.
protected abstract  javax.persistence.Query createQueryObject(org.apache.velocity.tools.generic.ValueParser params, java.lang.String sortCriterium, boolean ascending, boolean returnCount)
          This method must be implemented by each dao class extending this class.
protected  java.lang.Class<T> getAccessedClass()
          Get the class accessed by this DAO
 java.util.List<T> getAll()
          Get all data sets in the persistence unit of the represented type T
 java.lang.Long getAllCount()
          Get the count of elements in the database for type T
 java.util.List<T> getByClass(java.lang.String mainClass)
          Get data sets of type T by main class
 java.util.List<T> getByClass(java.lang.String mainClass, java.lang.String subClass)
          Get data sets of type T by main and sub class
 T getByDataSetId(long id)
          Get the data set of type T by JPA id
 T getByDataSetId(java.lang.String id)
          Get the data set of type T by JPA id
 T getByUuid(java.lang.String uuid)
          Get a the data set of type T by UUID string
 T getByUuidAndVersion(java.lang.String uuid, DataSetVersion version)
          Get LCIAMethod by UUID string and version
 java.util.List<T> getDataSets(int startIndex, int pageSize)
          Get pageSize data sets starting on startIndex
protected  java.lang.String getJpaName()
          Get the name in JPA of class
 long getNumberByClass(java.lang.String mainClass)
          Get number of data sets of type T by main class
 long getNumberByClass(java.lang.String mainClass, java.lang.String subClass)
          Get data sets of type T by main and sub class
 java.util.List<java.lang.String> getSubClasses(java.lang.String className, java.lang.String level)
          Get the sub classes for provided class name and level
 java.util.List<java.lang.String> getTopClasses()
          Get the top classes for the data set type T
 java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params)
          This method (local serach) works as search method for datasets only on local database entities, i.e.
 java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params, int startPosition, int pageSize, java.lang.String sortCriterium)
          This method (local lsearch) works as lsearch method for datasets only on local database entities, i.e.
 java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params, int startPosition, int pageSize, java.lang.String sortCriterium, boolean ascending)
          This method (local lsearch) works as lsearch method for datasets only on local database entities, i.e.
 void merge(DataSet dataSet)
           
protected abstract  void preCheckAndPersist(T dataSet)
          Invoked at beginning of checkAndPersist(DataSet, PersistType, PrintWriter) to manipulate data prior to persisting
 void remove(DataSet dataSet)
          Remove a given data set from the database
<E extends de.fzk.iai.ilcd.service.model.IDataSetListVO>
java.util.List<E>
search(java.lang.Class<E> dataSetClassType, org.apache.velocity.tools.generic.ValueParser params)
          This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI For a version without the dataSetClassType parameter look in the subclasses
<E extends de.fzk.iai.ilcd.service.model.IDataSetListVO>
java.util.List<E>
search(java.lang.Class<E> dataSetClassType, org.apache.velocity.tools.generic.ValueParser params, int startPosition, int pageSize, java.lang.String sortCriterium)
          This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI
<E extends de.fzk.iai.ilcd.service.model.IDataSetListVO>
java.util.List<E>
search(java.lang.Class<E> dataSetClassType, org.apache.velocity.tools.generic.ValueParser params, int startPosition, int pageSize, java.lang.String sortCriterium, boolean ascending)
          This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI
 java.util.List<L> search(org.apache.velocity.tools.generic.ValueParser params)
          Search for data sets of type T
 java.util.List<L> search(org.apache.velocity.tools.generic.ValueParser params, int startIndex, int pageSize)
          Search for data sets of type T
 long searchResultCount(org.apache.velocity.tools.generic.ValueParser params)
          Get result count for lsearch call
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSetDao

public DataSetDao(java.lang.String jpaName,
                  java.lang.Class<T> accessedClass,
                  java.lang.Class<L> listVOClass)
Create a data set DAO

Parameters:
jpaName - the name in JPA of class
accessedClass - the class accessed by this DAO
listVOClass - the interface based on ILCIAMethodListVO for the accessed class
Method Detail

getJpaName

protected java.lang.String getJpaName()
Get the name in JPA of class

Returns:
name in JPA of class

getAccessedClass

protected java.lang.Class<T> getAccessedClass()
Get the class accessed by this DAO

Returns:
class accessed by this DAO

getAll

public java.util.List<T> getAll()
Get all data sets in the persistence unit of the represented type T

Returns:
all data sets in the persistence unit of the represented type T

getAllCount

public java.lang.Long getAllCount()
Get the count of elements in the database for type T

Returns:
count of elements in the database for type T

getDataSets

public java.util.List<T> getDataSets(int startIndex,
                                     int pageSize)
Get pageSize data sets starting on startIndex

Parameters:
startIndex -
pageSize -
Returns:
list of matching elements

getByUuidAndVersion

public T getByUuidAndVersion(java.lang.String uuid,
                             DataSetVersion version)
Get LCIAMethod by UUID string and version

Parameters:
uuid - the UUID string
version - the version of the method
Returns:
LCIAMethod for the specified UUID string/version, or null if none found

getByUuid

public T getByUuid(java.lang.String uuid)
Get a the data set of type T by UUID string

Parameters:
uuid - the UUID string
Returns:
data set of type T for the specified UUID string, or null if none found

getByDataSetId

public T getByDataSetId(long id)
Get the data set of type T by JPA id

Parameters:
id - id of the data set
Returns:
data set of type T by JPA id

getByDataSetId

public T getByDataSetId(java.lang.String id)
Get the data set of type T by JPA id

Parameters:
id - id of the data set as string
Returns:
data set of type T by JPA id

getTopClasses

public java.util.List<java.lang.String> getTopClasses()
Get the top classes for the data set type T

Returns:
top classes for the data set type T

getSubClasses

public java.util.List<java.lang.String> getSubClasses(java.lang.String className,
                                                      java.lang.String level)
Get the sub classes for provided class name and level

Parameters:
className - class name
level - level
Returns:
sub classes for provided class name and level

getByClass

public java.util.List<T> getByClass(java.lang.String mainClass)
Get data sets of type T by main class

Parameters:
mainClass - the main class to get data sets by
Returns:
data sets of type T by main class

getNumberByClass

public long getNumberByClass(java.lang.String mainClass)
Get number of data sets of type T by main class

Parameters:
mainClass - the main class to get data sets by
Returns:
number of data sets of type T by main class

getByClass

public java.util.List<T> getByClass(java.lang.String mainClass,
                                    java.lang.String subClass)
Get data sets of type T by main and sub class

Parameters:
mainClass - the main class to get data sets by
subClass - the sub class to get data sets by
Returns:
data sets of type T by main and sub class

getNumberByClass

public long getNumberByClass(java.lang.String mainClass,
                             java.lang.String subClass)
Get data sets of type T by main and sub class

Parameters:
mainClass - the main class to get data sets by
subClass - the sub class to get data sets by
Returns:
data sets of type T by main and sub class

search

public java.util.List<L> search(org.apache.velocity.tools.generic.ValueParser params)
Search for data sets of type T

Parameters:
params - parameter
Returns:
found data sets of type T

search

public java.util.List<L> search(org.apache.velocity.tools.generic.ValueParser params,
                                int startIndex,
                                int pageSize)
Search for data sets of type T

Parameters:
params - parameter
Returns:
found data sets of type T

preCheckAndPersist

protected abstract void preCheckAndPersist(T dataSet)
Invoked at beginning of checkAndPersist(DataSet, PersistType, PrintWriter) to manipulate data prior to persisting

Parameters:
dataSet - data set to manipulate
See Also:
checkAndPersist(DataSet, PersistType, PrintWriter)

checkAndPersist

public boolean checkAndPersist(T dataSet,
                               PersistType pType,
                               java.io.PrintWriter out)
Generic persist method for data set objects.

Parameters:
dataSet - data set to persist
pType - which type of persistence operation, new, update (i.e. overwrite existing data set), ...
out - PrintWriter to log error messages which can be presented to the end user
Returns:
true if persist is successful, false otherwise
See Also:
preCheckAndPersist(DataSet)

lsearch

public java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params)
This method (local serach) works as search method for datasets only on local database entities, i.e. Process, Flow, ... To use a search method which also works distributed use the corresponding search method instead

Type Parameters:
T - Class name of "type" of objects to return, i.e. Process, Flow, ...
Parameters:
params - search parameters as key-value pairs
Returns:
list of datasets of type T

lsearch

public java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params,
                                 int startPosition,
                                 int pageSize,
                                 java.lang.String sortCriterium)
This method (local lsearch) works as lsearch method for datasets only on local database entities, i.e. Process, Flow, ... To use a lsearch method which also works distributed use the corresponding lsearch method

Type Parameters:
T - Class name of "type" of objects to return, i.e. Process, Flow, ...
Parameters:
params - lsearch parameters as key-value pairs
startPosition - start index within the whole list of lsearch results
pageSize - pages size, i.e. maximum count of results to return
sortCriterium - name of the objects field which should be used for sorting
Returns:
list of datasets of type T matching the lsearch criteria

lsearch

public java.util.List<T> lsearch(org.apache.velocity.tools.generic.ValueParser params,
                                 int startPosition,
                                 int pageSize,
                                 java.lang.String sortCriterium,
                                 boolean ascending)
This method (local lsearch) works as lsearch method for datasets only on local database entities, i.e. Process, Flow, ... To use a lsearch method which also works distributed use the corresponding lsearch method

Type Parameters:
T - Class name of "type" of objects to return, i.e. Process, Flow, ...
Parameters:
params - lsearch parameters as key-value pairs
startPosition - start index within the whole list of lsearch results
pageSize - pages size, i.e. maximum count of results to return
sortCriterium - name of the objects field which should be used for sorting
ascending - define ordering of result
Returns:
list of datasets of type T matching the lsearch criteria

search

public <E extends de.fzk.iai.ilcd.service.model.IDataSetListVO> java.util.List<E> search(java.lang.Class<E> dataSetClassType,
                                                                                         org.apache.velocity.tools.generic.ValueParser params)
This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI For a version without the dataSetClassType parameter look in the subclasses

Type Parameters:
E - interface name of "type" of objects to return, i.e. IProcessListVO, IFlowListVo, ...
Parameters:
dataSetClassType - Class object of T, i.e. IProcessListVO.class
params - search parameter
Returns:
List of objects of the give interface type E

search

public <E extends de.fzk.iai.ilcd.service.model.IDataSetListVO> java.util.List<E> search(java.lang.Class<E> dataSetClassType,
                                                                                         org.apache.velocity.tools.generic.ValueParser params,
                                                                                         int startPosition,
                                                                                         int pageSize,
                                                                                         java.lang.String sortCriterium)
This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI

Type Parameters:
E - interface name of "type" of objects to return, i.e. IProcessListVO, IFlowListVo, ...
Parameters:
dataSetClassType - Class object of T, i.e. IProcessListVO.class
params - search parameter as ParameterTool object
startPosition - start index for first search result
pageSize - size of one page of search results
sortCriterium - field name of object which is used for ordering
Returns:
list of objects of the given interface E

search

public <E extends de.fzk.iai.ilcd.service.model.IDataSetListVO> java.util.List<E> search(java.lang.Class<E> dataSetClassType,
                                                                                         org.apache.velocity.tools.generic.ValueParser params,
                                                                                         int startPosition,
                                                                                         int pageSize,
                                                                                         java.lang.String sortCriterium,
                                                                                         boolean ascending)
This search method can also be used for distributed search because it uses the common interface types of the ServiceAPI

Type Parameters:
E - interface name of "type" of objects to return, i.e. IProcessListVO, IFlowListVo, ...
Parameters:
dataSetClassType - Class object of T, i.e. IProcessListVO.class
params - search parameter as ParameterTool object
startPosition - start index for first search result
pageSize - size of one page of search results
sortCriterium - field name of object which is used for ordering
ascending - define the ordering of the result
Returns:
list of objects of the given interface E

searchResultCount

public long searchResultCount(org.apache.velocity.tools.generic.ValueParser params)
Get result count for lsearch call

Parameters:
params - lsearch parameters
Returns:
returns the count of results when a lsearch is issued with this lsearch parameters

createQueryObject

protected abstract javax.persistence.Query createQueryObject(org.apache.velocity.tools.generic.ValueParser params,
                                                             java.lang.String sortCriterium,
                                                             boolean ascending,
                                                             boolean returnCount)
This method must be implemented by each dao class extending this class. It will return the specific Query object to use for the given subclass of objects, i.e. Process, Flow, ... This method will then be used by the other generic lsearch functions to issue the special query.

Parameters:
params - lsearch parameter
sortCriterium - field of result object which will be used for ordering of lsearch results
returnCount - if true return count of lsearch result instead of lsearch results
Returns:
JPA Query objects for doing the lsearch

remove

public void remove(DataSet dataSet)
            throws DeleteDataSetException
Remove a given data set from the database

Parameters:
dataSet - data set to be removed
Throws:
DeleteDataSetException

merge

public void merge(DataSet dataSet)
           throws MergeException
Throws:
MergeException

buildClassificationWhere

protected java.lang.String buildClassificationWhere(java.lang.String entityPrefix)

Build up string for classification where clause (with default values for classification field name and alias prefix), example:

( p.classification IS NULL OR (c1.level=0 AND c2.level=0) OR (c1.level=0 AND c2.level=1) )

Parameters:
entityPrefix - prefix of the entity, in example it is p
Returns:
created where clause part with space at the end
See Also:
buildClassificationWhere(String, String, String)

buildClassificationWhere

protected java.lang.String buildClassificationWhere(java.lang.String entityPrefix,
                                                    java.lang.String classificFieldName,
                                                    java.lang.String aliasPrefix)

Build up string for classification where clause, example:

( p.classification IS NULL OR (c1.level=0 AND c2.level=0) OR (c1.level=0 AND c2.level=1) )

Parameters:
entityPrefix - prefix of the entity, in example it is p
classificFieldName - name of the classification field in the entity, in example it is classification
aliasPrefix - alias prefix for the left joined references, in example it is c
Returns:
created where clause part with space at the end

buildClassificationJoin

protected java.lang.String buildClassificationJoin(java.lang.String entityPrefix)

Build up join string for classification containing query (with default values for classification field name and alias prefix), example:

LEFT JOIN p.classification.classes c1 LEFT JOIN p.classification.classes c2

Parameters:
entityPrefix - prefix of the entity, in example it is p
Returns:
created join select clause part with space at the end
See Also:
buildClassificationJoin(String, String, String)

buildClassificationJoin

protected java.lang.String buildClassificationJoin(java.lang.String entityPrefix,
                                                   java.lang.String classificFieldName,
                                                   java.lang.String aliasPrefix)

Build up join string for classification containing query, example:

LEFT JOIN p.classification.classes c1 LEFT JOIN p.classification.classes c2

Parameters:
entityPrefix - prefix of the entity, in example it is p
classificFieldName - name of the classification field in the entity, in example it is classification
aliasPrefix - alias prefix for the left joined references, in example it is c
Returns:
created join select clause part with space at the end