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 protectedAbstractEntityArgService(S service)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TcheckEntity(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 staticvalueOfmethod 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 aNotFoundExceptionif any of them is missing.TgetEntity(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)StringgetFilterablePropertyDescription(String p)booleangetFilterablePropertyIsUsingSubquery(String p)List<MessageSourceResolvable>getFilterablePropertyResolvableAllowedValuesLabels(String p)Class<?>getFilterablePropertyType(String p)<A> FiltersgetFilters(AbstractEntityArg<A,T,S> entityArg)Translate the provided entity argument into aFilters.FiltersgetFilters(AbstractEntityArrayArg<T,S> entitiesArg)Translate the provided entity argument into aFilters.FiltersgetFilters(FilterArg<T> filterArg)Obtain aFiltersfrom a filter argument.SortgetSort(SortArg<T> sortArg)Obtain aSortfrom 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:
getElementClassin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
BaseReadOnlyService.getElementClass()
-
getFilterableProperties
public Set<String> getFilterableProperties()
- Specified by:
getFilterablePropertiesin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
FilteringService.getFilterableProperties()
-
getFilterablePropertyType
public Class<?> getFilterablePropertyType(String p)
- Specified by:
getFilterablePropertyTypein interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
FilteringService.getFilterablePropertyType(String)
-
getFilterablePropertyDescription
public String getFilterablePropertyDescription(String p)
- Specified by:
getFilterablePropertyDescriptionin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
FilteringService.getFilterablePropertyDescription(String)
-
getFilterablePropertyAllowedValues
public List<Object> getFilterablePropertyAllowedValues(String p)
- Specified by:
getFilterablePropertyAllowedValuesin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
FilteringService.getFilterablePropertyAllowedValues(String)
-
getFilterablePropertyResolvableAllowedValuesLabels
public List<MessageSourceResolvable> getFilterablePropertyResolvableAllowedValuesLabels(String p)
- Specified by:
getFilterablePropertyResolvableAllowedValuesLabelsin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>- See Also:
FilteringService.getFilterablePropertyResolvableAllowedValuesLabels(String)
-
getFilterablePropertyIsUsingSubquery
public boolean getFilterablePropertyIsUsingSubquery(String p)
- Specified by:
getFilterablePropertyIsUsingSubqueryin interfaceEntityArgService<T extends Identifiable,S extends FilteringService<T>>
-
getFilterablePropertyConfigAttributes
public Collection<org.springframework.security.access.ConfigAttribute> getFilterablePropertyConfigAttributes(String p)
- Specified by:
getFilterablePropertyConfigAttributesin 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:EntityArgServiceRetrieve the entity represented by this argument.- Specified by:
getEntityin 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:EntityArgServiceRetrieve 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:
getEntitiesin 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:EntityArgServiceRetrieve each entity represented by the array argument, raising aNotFoundExceptionif any of them is missing.- Specified by:
getEntitiesin 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:EntityArgServiceTranslate the provided entity argument into aFilters.This will generate clause in the form of
property = value.- Specified by:
getFiltersin 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:EntityArgServiceTranslate the provided entity argument into aFilters.This will generate clause in the form of
property in (values...).- Specified by:
getFiltersin 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:EntityArgServiceObtain aFiltersfrom a filter argument.- Specified by:
getFiltersin 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:EntityArgServiceObtain aSortfrom a sort argument.- Specified by:
getSortin 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 staticvalueOfmethod or a suitable constructor to instantiate the argument.- Throws:
javax.ws.rs.BadRequestException
-
-