Class AbstractFilteringVoEnabledDao<O extends Identifiable, VO extends IdentifiableValueObject<O>>
- Type Parameters:
O- the entity typeVO- the corresponding VO type
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, BaseDao<O>, BaseVoEnabledDao<O,VO>, FilteringDao<O>, FilteringVoEnabledDao<O, VO>
- Direct Known Subclasses:
AbstractCriteriaFilteringVoEnabledDao, AbstractQueryFilteringVoEnabledDao
FilteringVoEnabledDao.- Author:
- poirigui
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classConfigurer for filterable properties and their aliases.protected static final classMeta-information for a filterable property.Nested classes/interfaces inherited from interface FilteringDao
FilteringDao.ConjunctSpec -
Field Summary
Fields inherited from class AbstractVoEnabledDao
REPORT_SLOW_QUERY_AFTER_MSFields inherited from class AbstractDao
log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFilteringVoEnabledDao(String objectAlias, Class<? extends O> elementClass, SessionFactory sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidconfigureFilterableProperties(AbstractFilteringVoEnabledDao<O, VO>.FilterablePropertiesConfigurer configurer) Register filterable properties.final <T> FiltergetFilter(String property, Class<T> propertyType, Filter.Operator operator, Collection<T> values) Obtain aFilterwith an already parsed collection of values.final <T> FiltergetFilter(String property, Class<T> propertyType, Filter.Operator operator, T value) Obtain aFilterwith an already parsed value.final FiltergetFilter(String property, Filter.Operator operator, String value) Obtain anFilterfor the entity this DAO is providing.final FiltergetFilter(String property, Filter.Operator operator, String value, SubqueryMode subqueryMode) final FiltergetFilter(String property, Filter.Operator operator, Collection<String> values) Similar toFilteringDao.getFilter(String, Filter.Operator, String), but with a collection of values.final FiltergetFilter(String property, Filter.Operator operator, Collection<String> values, SubqueryMode subqueryMode) final FiltergetFilter(List<FilteringDao.ConjunctSpec> conjuncts, SubqueryMode subqueryMode) Build a filter requiring a SINGLE element of a to-many relation to satisfy EVERY given predicate.List all properties availble for filtering.getFilterablePropertyAllowedValues(String propertyName) Obtain a short list of allowed values for the given property, or null if unrestricted.getFilterablePropertyDescription(String propertyName) Obtain a short description for a given filterable property.protected final AbstractFilteringVoEnabledDao.FilterablePropertyMetagetFilterablePropertyMeta(String propertyName) Expose registered object-alias mappings to subclasses (e.g.Class<?> getFilterablePropertyType(String propertyName) Obtain the type of the given filterable property.protected final Stringfinal SortgetSort(String property, Sort.Direction direction, Sort.NullMode nullMode) booleanisFilterablePropertyDeprecated(String property) Indicate if the given property is deprecated.booleanisFilterablePropertyUsingSubquery(String property) Indicate if the given property is using a subquery for filtering.resolveFilterablePropertyMeta(String propertyName) resolveFilterablePropertyMeta(String objectAlias, Class<? extends Identifiable> clazz, String propertyName) Methods inherited from class AbstractVoEnabledDao
doLoadValueObject, doLoadValueObjects, loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIds, postProcessValueObjectsMethods inherited from class AbstractDao
countAll, create, create, find, findByProperty, findByPropertyIn, findIdByProperty, findOneByProperty, findOrCreate, getBatchSize, getElementClass, getEntityName, getIdentifierPropertyName, getSessionFactory, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, save, save, streamAll, streamAll, streamQuery, update, updateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseDao
countAll, create, create, find, findOrCreate, getElementClass, load, load, loadAll, loadReference, loadReference, reload, reload, remove, remove, save, save, streamAll, streamAll, update, updateMethods inherited from interface BaseVoEnabledDao
loadAllValueObjects, loadValueObject, loadValueObjectById, loadValueObjects, loadValueObjectsByIdsMethods inherited from interface FilteringDao
count, load, load, loadIdsMethods inherited from interface FilteringVoEnabledDao
loadValueObjects, loadValueObjects, loadValueObjectsByCursor
-
Constructor Details
-
AbstractFilteringVoEnabledDao
protected AbstractFilteringVoEnabledDao(@Nullable String objectAlias, Class<? extends O> elementClass, SessionFactory sessionFactory)
-
-
Method Details
-
getFilterablePropertyObjectAliases
Expose registered object-alias mappings to subclasses (e.g. the JPA Criteria DAO) so they can wire alias-prefixed filter/sort paths back to explicit joins on the root.Returns a map of
objectAlias→ dotted prefix (without the trailing"."). Aliases registered with anullobjectAlias are skipped. -
getObjectAlias
- Returns:
- the HQL object alias used to refer to the root entity in this DAO's queries
(e.g.
eeforExpressionExperiment), ornullwhen the DAO operates on the implicit root.
-
afterPropertiesSet
@OverridingMethodsMustInvokeSuper public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
getFilterableProperties
Description copied from interface:FilteringDaoList all properties availble for filtering.- Specified by:
getFilterablePropertiesin interfaceFilteringDao<O extends Identifiable>
-
configureFilterableProperties
@OverridingMethodsMustInvokeSuper protected void configureFilterableProperties(AbstractFilteringVoEnabledDao<O, VO>.FilterablePropertiesConfigurer configurer) Register filterable properties. -
getFilterablePropertyType
Description copied from interface:FilteringDaoObtain the type of the given filterable property.- Specified by:
getFilterablePropertyTypein interfaceFilteringDao<O extends Identifiable>- Throws:
IllegalArgumentException- if no such property exists, the cause will be aNoSuchFieldException
-
getFilterablePropertyDescription
@Nullable public String getFilterablePropertyDescription(String propertyName) throws IllegalArgumentException Description copied from interface:FilteringDaoObtain a short description for a given filterable property.- Specified by:
getFilterablePropertyDescriptionin interfaceFilteringDao<O extends Identifiable>- Throws:
IllegalArgumentException- if no such property exists
-
getFilterablePropertyAllowedValues
@Nullable public List<Object> getFilterablePropertyAllowedValues(String propertyName) throws IllegalArgumentException Description copied from interface:FilteringDaoObtain a short list of allowed values for the given property, or null if unrestricted.The returned values must be of the type outlined by
FilteringDao.getFilterablePropertyType(String), generally a list ofStringorIntegerto denote possible values for an enumerated type.- Specified by:
getFilterablePropertyAllowedValuesin interfaceFilteringDao<O extends Identifiable>- Throws:
IllegalArgumentException
-
isFilterablePropertyUsingSubquery
Description copied from interface:FilteringDaoIndicate if the given property is using a subquery for filtering.- Specified by:
isFilterablePropertyUsingSubqueryin interfaceFilteringDao<O extends Identifiable>- Throws:
IllegalArgumentException- if the property does not exist
-
isFilterablePropertyDeprecated
Description copied from interface:FilteringDaoIndicate if the given property is deprecated.- Specified by:
isFilterablePropertyDeprecatedin interfaceFilteringDao<O extends Identifiable>- Throws:
IllegalArgumentException- if the property does not exist
-
getFilter
Description copied from interface:FilteringDaoObtain anFilterfor the entity this DAO is providing.It is the responsibility of the DAO to infer the filter property type as well as the alias to use.
If the filter refers to a related entity (i.e. a
BioAssayof anExpressionExperiment), then the DAO should inject the corresponding DAO and delegate it the work of creating the filter.In the frontend, that correspond to a FilterArg, but since the definition is not available here, we unpack its attributes.
- Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>- Parameters:
property- property name in the entity use as a left-hand side of the operatoroperator- an operatorvalue- the corresponding, unparsed value, to the right-hand side of the operator- Returns:
- a filter filled with the object alias, property, inferred type, operator and parsed value
-
getFilter
public final Filter getFilter(String property, Filter.Operator operator, String value, SubqueryMode subqueryMode) - Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>
-
getFilter
Description copied from interface:FilteringDaoSimilar toFilteringDao.getFilter(String, Filter.Operator, String), but with a collection of values.- Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>
-
getFilter
public final Filter getFilter(String property, Filter.Operator operator, Collection<String> values, SubqueryMode subqueryMode) - Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>
-
getFilter
public final <T> Filter getFilter(String property, Class<T> propertyType, Filter.Operator operator, @Nullable T value) Description copied from interface:FilteringDaoObtain aFilterwith an already parsed value.- Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>- See Also:
-
getFilter
public final <T> Filter getFilter(String property, Class<T> propertyType, Filter.Operator operator, Collection<T> values) Description copied from interface:FilteringDaoObtain aFilterwith an already parsed collection of values.- Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>- See Also:
-
getFilter
public final Filter getFilter(List<FilteringDao.ConjunctSpec> conjuncts, @Nullable SubqueryMode subqueryMode) Description copied from interface:FilteringDaoBuild a filter requiring a SINGLE element of a to-many relation to satisfy EVERY given predicate.Ordinary conjunction cannot express this.
valueUri = X and categoryUri = Ybecomes two independent subqueries and asks "has some characteristic valued X, and has some characteristic categorised Y" — which is true of a dataset where those are different characteristics. This conjoins the predicates inside one subquery, so they must hold of the same element.Every predicate must be a subquery-filterable property on the same relation.
- Specified by:
getFilterin interfaceFilteringDao<O extends Identifiable>- Parameters:
conjuncts- predicates to conjoin; at least one. A single conjunct behaves exactly like the correspondinggetFilteroverload.subqueryMode-SubqueryMode.ANY(the default when null) orSubqueryMode.NONE.SubqueryMode.ALLis rejected for more than one conjunct: "every element satisfies A and B" negates to a disjunction, which a subquery carrying a conjunction cannot represent.
-
getSort
public final Sort getSort(String property, @Nullable Sort.Direction direction, Sort.NullMode nullMode) Description copied from interface:FilteringDao- Specified by:
getSortin interfaceFilteringDao<O extends Identifiable>- Parameters:
property- a property ofOto sort bydirection- a sorting direction, or null if the default direction appliesnullMode- behavior for null values when sorting- Returns:
- a
Sortobject that can be used, for example, onFilteringVoEnabledDao.loadValueObjects(Filters, Sort, int, int)
-
getFilterablePropertyMeta
protected final AbstractFilteringVoEnabledDao.FilterablePropertyMeta getFilterablePropertyMeta(String propertyName) -
resolveFilterablePropertyMeta
protected AbstractFilteringVoEnabledDao.FilterablePropertyMeta.FilterablePropertyMetaBuilder resolveFilterablePropertyMeta(String propertyName) throws IllegalArgumentException Obtain various meta-information used to infer what to use in aFilterorSort.This is used by
getFilter(String, Filter.Operator, String)andFilteringDao.getSort(String, Sort.Direction, Sort.NullMode).- Throws:
IllegalArgumentException- if no such propertyName exists inO- See Also:
-
resolveFilterablePropertyMeta
protected AbstractFilteringVoEnabledDao.FilterablePropertyMeta.FilterablePropertyMetaBuilder resolveFilterablePropertyMeta(@Nullable String objectAlias, Class<? extends Identifiable> clazz, String propertyName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-