Package ubic.gemma.rest.util.args
Class AbstractEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- java.lang.Object
-
- ubic.gemma.rest.util.args.AbstractEntityArgService<T,S>
-
- All Implemented Interfaces:
EntityArgService<T,S>
- Direct Known Subclasses:
CompositeSequenceArgService
,DatabaseEntryArgService
,DatasetArgService
,ExpressionAnalysisResultSetArgService
,GeneArgService
,PlatformArgService
,QuantitationTypeArgService
,TaxonArgService
public abstract class AbstractEntityArgService<T extends Identifiable,S extends FilteringService<T>> extends Object implements EntityArgService<T,S>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEntityArgService(S service)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T
checkEntity(AbstractEntityArg<?,T,S> entityArg, T entity)
Checks whether the given object is null, and throws an appropriate exception if necessary.protected AbstractEntityArg<?,T,S>
entityArgValueOf(Class<? extends AbstractEntityArg<?,T,S>> entityArgClass, String s)
Invoke either a staticvalueOf
method or a suitable constructor to instantiate the argument.protected Map<String,List<String>>
getArgsByPropertyName(AbstractEntityArrayArg<T,S> entitiesArg)
Given aAbstractEntityArrayArg
, construct a mapping of properties it refers to values those properties are allowed to take in a filter.Class<? extends T>
getElementClass()
List<T>
getEntities(AbstractEntityArg<?,T,S> entityArg)
Retrieve the entities represented by this argument.List<T>
getEntities(AbstractEntityArrayArg<T,S> entitiesArg)
Retrieve each entity represented by the array argument, raising aNotFoundException
if any of them is missing.T
getEntity(AbstractEntityArg<?,T,S> entityArg)
Retrieve the entity represented by this argument.Set<String>
getFilterableProperties()
List<Object>
getFilterablePropertyAllowedValues(String p)
Collection<org.springframework.security.access.ConfigAttribute>
getFilterablePropertyConfigAttributes(String p)
String
getFilterablePropertyDescription(String p)
boolean
getFilterablePropertyIsUsingSubquery(String p)
List<MessageSourceResolvable>
getFilterablePropertyResolvableAllowedValuesLabels(String p)
Class<?>
getFilterablePropertyType(String p)
<A> Filters
getFilters(AbstractEntityArg<A,T,S> entityArg)
Translate the provided entity argument into aFilters
.Filters
getFilters(AbstractEntityArrayArg<T,S> entitiesArg)
Translate the provided entity argument into aFilters
.Filters
getFilters(FilterArg<T> filterArg)
Obtain aFilters
from a filter argument.Sort
getSort(SortArg<T> sortArg)
Obtain aSort
from a sort argument.
-
-
-
Field Detail
-
service
protected final S extends FilteringService<T> service
-
-
Constructor Detail
-
AbstractEntityArgService
protected AbstractEntityArgService(S service)
-
-
Method Detail
-
getElementClass
public Class<? extends T> getElementClass()
- Specified by:
getElementClass
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
BaseReadOnlyService.getElementClass()
-
getFilterableProperties
public Set<String> getFilterableProperties()
- Specified by:
getFilterableProperties
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterableProperties()
-
getFilterablePropertyType
public Class<?> getFilterablePropertyType(String p)
- Specified by:
getFilterablePropertyType
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterablePropertyType(String)
-
getFilterablePropertyDescription
public String getFilterablePropertyDescription(String p)
- Specified by:
getFilterablePropertyDescription
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterablePropertyDescription(String)
-
getFilterablePropertyAllowedValues
public List<Object> getFilterablePropertyAllowedValues(String p)
- Specified by:
getFilterablePropertyAllowedValues
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterablePropertyAllowedValues(String)
-
getFilterablePropertyResolvableAllowedValuesLabels
public List<MessageSourceResolvable> getFilterablePropertyResolvableAllowedValuesLabels(String p)
- Specified by:
getFilterablePropertyResolvableAllowedValuesLabels
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterablePropertyResolvableAllowedValuesLabels(String)
-
getFilterablePropertyIsUsingSubquery
public boolean getFilterablePropertyIsUsingSubquery(String p)
- Specified by:
getFilterablePropertyIsUsingSubquery
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
-
getFilterablePropertyConfigAttributes
public Collection<org.springframework.security.access.ConfigAttribute> getFilterablePropertyConfigAttributes(String p)
- Specified by:
getFilterablePropertyConfigAttributes
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- See Also:
FilteringService.getFilterablePropertyConfigAttributes(String)
-
getEntity
@Nonnull public T getEntity(AbstractEntityArg<?,T,S> entityArg) throws javax.ws.rs.NotFoundException, javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Retrieve the entity represented by this argument.- Specified by:
getEntity
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.NotFoundException
- if the entity does not existjavax.ws.rs.BadRequestException
- if the argument is malformed
-
getEntities
public List<T> getEntities(AbstractEntityArg<?,T,S> entityArg) throws javax.ws.rs.NotFoundException, javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Retrieve the entities represented by this argument.Note that this will never return an empty array.
This is intended for cases where an argument could match more than one entity.
- Specified by:
getEntities
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.NotFoundException
- if no entity matching the argument existjavax.ws.rs.BadRequestException
- if the argument is malformed
-
getEntities
public List<T> getEntities(AbstractEntityArrayArg<T,S> entitiesArg) throws javax.ws.rs.NotFoundException, javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Retrieve each entity represented by the array argument, raising aNotFoundException
if any of them is missing.- Specified by:
getEntities
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.NotFoundException
- if any entity is missingjavax.ws.rs.BadRequestException
- if the argument is malformed
-
getFilters
public <A> Filters getFilters(AbstractEntityArg<A,T,S> entityArg) throws javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Translate the provided entity argument into aFilters
.This will generate clause in the form of
property = value
.- Specified by:
getFilters
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.BadRequestException
- if the argument is malformed
-
getFilters
public Filters getFilters(AbstractEntityArrayArg<T,S> entitiesArg) throws javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Translate the provided entity argument into aFilters
.This will generate clause in the form of
property in (values...)
.- Specified by:
getFilters
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.BadRequestException
- if the argument is malformed
-
getArgsByPropertyName
protected Map<String,List<String>> getArgsByPropertyName(AbstractEntityArrayArg<T,S> entitiesArg)
Given aAbstractEntityArrayArg
, construct a mapping of properties it refers to values those properties are allowed to take in a filter.
-
getFilters
public Filters getFilters(FilterArg<T> filterArg) throws javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Obtain aFilters
from a filter argument.- Specified by:
getFilters
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.BadRequestException
- if the argument is malformed
-
getSort
public Sort getSort(SortArg<T> sortArg) throws javax.ws.rs.BadRequestException
Description copied from interface:EntityArgService
Obtain aSort
from a sort argument.- Specified by:
getSort
in interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
- Throws:
javax.ws.rs.BadRequestException
- if the argument is malformed
-
checkEntity
protected T checkEntity(AbstractEntityArg<?,T,S> entityArg, @Nullable T entity) throws javax.ws.rs.NotFoundException
Checks whether the given object is null, and throws an appropriate exception if necessary.- Parameters:
entity
- the object that should be checked for being null.- Returns:
- the same object as given.
- Throws:
javax.ws.rs.NotFoundException
- if the given entity is null.
-
entityArgValueOf
protected AbstractEntityArg<?,T,S> entityArgValueOf(Class<? extends AbstractEntityArg<?,T,S>> entityArgClass, String s) throws javax.ws.rs.BadRequestException
Invoke either a staticvalueOf
method or a suitable constructor to instantiate the argument.- Throws:
javax.ws.rs.BadRequestException
-
-