public class EntityUtils extends Object
Constructor and Description |
---|
EntityUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
addGroupAndUserNameRestriction(boolean showOnlyEditable,
boolean showPublic)
Have to add 'and' to start of this if it's a later clause
Author: nicolas with fixes to generalize by paul, same code appears in the PhenotypeAssociationDaoImpl
|
static void |
addUserAndGroupParameters(SQLQuery queryObject,
SessionFactory sessionFactory)
Populates parameters in query created using addGroupAndUserNameRestriction(boolean, boolean).
|
static void |
createFile(File file) |
static void |
deleteFile(File file) |
static Field |
getDeclaredField(Class<?> cls,
String field)
Recursive version of
Class.getDeclaredField(String) that also checks in the superclass hierarchy. |
static Class |
getDeclaredFieldType(String property,
Class cls)
Checks if property of given name exists in the given class.
|
static <T extends Identifiable> |
getIdMap(Collection<T> entities)
Given a set of entities, create a map of their ids to the entities.
|
static <T extends Identifiable> |
getIds(Collection<T> entities) |
static Class<?> |
getImplClass(Class<?> type) |
static Object |
getImplementationForProxy(Object target)
Expert only.
|
static <S,T> Map<S,T> |
getNestedPropertyMap(Collection<T> entities,
String nestedProperty,
String propertyName)
Group entities by their property using a nested property.
|
static boolean[] |
getPermissions(gemma.gsec.acl.domain.AclObjectIdentity aoi)
Checks ACL related properties from the AclObjectIdentity.
|
static <T> T |
getProperty(Object entity,
String propertyName)
Get a property of an entity object via its getter.
|
static <S,T> Map<S,T> |
getPropertyMap(Collection<? extends T> entities,
String propertyName)
Group entities by their property.
|
static boolean |
isProxy(Object target) |
static <T,S> void |
populateMapSet(Map<T,Set<S>> map,
T key,
S hash)
Checks if the given map already contains a Set for the given key, and if it does, adds the given has code to it.
|
static void |
renameFile(File file,
File newFile) |
static Collection<Long> |
securityFilterIds(Class<? extends gemma.gsec.model.Securable> securedClass,
Collection<Long> ids,
boolean showOnlyEditable,
boolean showPublic,
Session sess)
Expert use only.
|
public static <T,S> void populateMapSet(Map<T,Set<S>> map, T key, S hash)
T
- the key type parameter of the mapS
- the type parameter of the setmap
- the map to be checkedkey
- the keyhash
- the hash to be added to the set at the given key of the mappublic static <T extends Identifiable> List<Long> getIds(Collection<T> entities)
entities
- entitiespublic static <T extends Identifiable> Map<Long,T> getIdMap(Collection<T> entities)
T
- the typeentities
- where id is called "id"public static <T> T getProperty(Object entity, String propertyName)
T
- type of the propertyentity
- the entitypropertyName
- name of the propertyPropertyUtils.getProperty(Object, String)
public static <S,T> Map<S,T> getPropertyMap(Collection<? extends T> entities, String propertyName)
T
- the typeentities
- entitiespropertyName
- property name (e.g. "id")getProperty(Object, String)
public static <S,T> Map<S,T> getNestedPropertyMap(Collection<T> entities, String nestedProperty, String propertyName)
T
- the typeentities
- entitiesnestedProperty
- nested propertypropertyName
- property name (e.g. "id")getProperty(Object, String)
public static Object getImplementationForProxy(Object target)
target
- The object to be un-proxied.public static boolean isProxy(Object target)
target
- targetpublic static Collection<Long> securityFilterIds(Class<? extends gemma.gsec.model.Securable> securedClass, Collection<Long> ids, boolean showOnlyEditable, boolean showPublic, Session sess)
sess
- sessionsecuredClass
- Securable typeids
- to be filteredshowPublic
- also show public items (won't work if showOnlyEditable is true)showOnlyEditable
- show only editablepublic static String addGroupAndUserNameRestriction(boolean showOnlyEditable, boolean showPublic)
showOnlyEditable
- only show those the user has access to editshowPublic
- also show public items (wont work if showOnlyEditable is true)public static void addUserAndGroupParameters(SQLQuery queryObject, SessionFactory sessionFactory)
queryObject
- the query object created using the sql query with group and username restrictions.sessionFactory
- session factory from the DAO that is using this method.public static boolean[] getPermissions(gemma.gsec.acl.domain.AclObjectIdentity aoi)
SecurityUtil
, but allows usage without an Acl object.aoi
- the acl object identity of an object whose permissions are to be checked.public static void createFile(File file) throws IOException
IOException
public static void deleteFile(File file)
public static Class getDeclaredFieldType(String property, Class cls) throws NoSuchFieldException
property
- the property to check for. If the string contains dot characters ('.'), only the part
before the first dot will be evaluated. Substring after the dot will be checked against the
type of the field retrieved from the substring before the dot.cls
- the class to check the property on.NoSuchFieldException
public static Field getDeclaredField(Class<?> cls, String field) throws NoSuchFieldException
Class.getDeclaredField(String)
that also checks in the superclass hierarchy.NoSuchFieldException
Class.getDeclaredField(String)
Copyright © 2005–2023 Pavlidis lab, Michael Smith Laboratories and Department of Psychiatry, University of British Columbia. All rights reserved.